55
66package org .geoserver .geofence .services ;
77
8+ import java .util .ArrayList ;
9+ import java .util .HashMap ;
10+ import java .util .Map ;
811import org .geoserver .geofence .core .model .LayerDetails ;
912import org .geoserver .geofence .core .model .Rule ;
1013import org .geoserver .geofence .core .model .RuleLimits ;
1316import org .geoserver .geofence .services .dto .ShortRule ;
1417import org .geoserver .geofence .services .exception .BadRequestServiceEx ;
1518import org .geoserver .geofence .services .exception .NotFoundServiceEx ;
16-
19+ import org .javatuples .Quartet ;
20+ import org .javatuples .Triplet ;
1721import java .util .List ;
1822import java .util .Set ;
1923
@@ -33,6 +37,23 @@ public interface RuleAdminService
3337
3438 long insert (Rule rule , InsertPosition position );
3539
40+ /**
41+ * @param rules to be inserted
42+ * @return map of inserted rules along with their ids.
43+ */
44+ default List <Long > insert (List <Quartet <Rule ,RuleLimits ,LayerDetails ,InsertPosition >> rules ) {
45+ List <Long > ids = new ArrayList <>();
46+ for (Quartet <Rule ,RuleLimits ,LayerDetails ,InsertPosition > rule : rules ) {
47+ long id = insert (rule .getValue0 (),rule .getValue3 ());
48+ RuleLimits limits =rule .getValue1 ();
49+ if (limits !=null ) setLimits (id ,limits );
50+ LayerDetails details =rule .getValue2 ();
51+ if (details !=null ) setDetails (id ,details );
52+ ids .add (id );
53+ }
54+ return ids ;
55+ }
56+
3657 long update (Rule rule ) throws NotFoundServiceEx ;
3758
3859 /**
@@ -134,7 +155,7 @@ public interface RuleAdminService
134155 * @throws BadRequestServiceEx if a wildcard type is used in filter
135156 */
136157 ShortRule getRule (RuleFilter filter ) throws BadRequestServiceEx ;
137-
158+
138159 /**
139160 * Return the Rules according to the filter.
140161 * Rules will be enriched with all their joined data, so this method may be heavy to execute.
0 commit comments