@@ -486,7 +486,7 @@ public void create(LocationGroup group) {
486
486
CWMS_LOC_PACKAGE .call_CREATE_LOC_GROUP2 (dslContext .configuration (), categoryId ,
487
487
group .getId (), group .getDescription (), group .getOfficeId (), group .getSharedLocAliasId (),
488
488
group .getSharedRefLocationId ());
489
- assignLocs (group , office );
489
+ assignLocs (dslContext , group , office );
490
490
});
491
491
}
492
492
@@ -522,19 +522,28 @@ public void unassignAllLocs(LocationGroup group, String office) {
522
522
}
523
523
524
524
public void assignLocs (LocationGroup group , String office ) {
525
+ connection (dsl , conn -> {
526
+ DSLContext dslContext = getDslContext (conn , office );
527
+ assignLocs (dslContext ,group , office );
528
+ });
529
+ }
530
+
531
+ /**
532
+ * Used when an appropriate context already exists to avoid opening a second connection.
533
+ * @param dslContext a dslContext that is assumed to be fully prepared for use in this operation
534
+ * @param group
535
+ * @param office
536
+ */
537
+ public void assignLocs (DSLContext dslContext , LocationGroup group , String office ) {
525
538
List <AssignedLocation > assignedLocations = group .getAssignedLocations ();
526
539
if (assignedLocations != null ) {
527
540
List <LOC_ALIAS_TYPE3 > collect = assignedLocations .stream ()
528
541
.map (LocationGroupDao ::convertToLocAliasType )
529
542
.collect (toList ());
530
543
LOC_ALIAS_ARRAY3 assignedLocs = new LOC_ALIAS_ARRAY3 (collect );
531
-
532
- LocationCategory cat = group .getLocationCategory ();
533
- connection (dsl , conn -> {
534
- DSLContext dslContext = getDslContext (conn , office );
544
+ LocationCategory cat = group .getLocationCategory ();
535
545
CWMS_LOC_PACKAGE .call_ASSIGN_LOC_GROUPS3 (dslContext .configuration (),
536
546
cat .getId (), group .getId (), assignedLocs , office );
537
- });
538
547
}
539
548
}
540
549
}
0 commit comments