Skip to content

Commit

Permalink
Update after comments
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Bouquet <[email protected]>
  • Loading branch information
bqth29 committed Apr 24, 2024
1 parent 78bdf58 commit 093121e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ private CsaProfileCracUtils() {

}

public static Map<String, Set<PropertyBag>> groupPropertyBagsBy(PropertyBags propertyBags, String groupBy) {
public static Map<String, Set<PropertyBag>> groupPropertyBags(PropertyBags propertyBags, String groupingPoperty) {
Map<String, Set<PropertyBag>> mappedPropertyBags = new HashMap<>();
for (PropertyBag propertyBag : propertyBags) {
String propValue = propertyBag.getId(groupBy);
String propValue = propertyBag.getId(groupingPoperty);
Set<PropertyBag> propPropertyBags = mappedPropertyBags.computeIfAbsent(propValue, k -> new HashSet<>());
propPropertyBags.add(propertyBag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public CsaProfileCnecCreator(Crac crac, Network network, PropertyBags assessedEl
this.crac = crac;
this.network = network;
this.assessedElementsPropertyBags = assessedElementsPropertyBags;
this.assessedElementsWithContingenciesPropertyBags = CsaProfileCracUtils.groupPropertyBagsBy(assessedElementsWithContingenciesPropertyBags, CsaProfileConstants.REQUEST_ASSESSED_ELEMENT);
this.currentLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBagsBy(currentLimitsPropertyBags, CsaProfileConstants.REQUEST_CURRENT_LIMIT);
this.voltageLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBagsBy(voltageLimitsPropertyBags, CsaProfileConstants.REQUEST_VOLTAGE_LIMIT);
this.angleLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBagsBy(angleLimitsPropertyBags, CsaProfileConstants.REQUEST_VOLTAGE_ANGLE_LIMIT);
this.assessedElementsWithContingenciesPropertyBags = CsaProfileCracUtils.groupPropertyBags(assessedElementsWithContingenciesPropertyBags, CsaProfileConstants.REQUEST_ASSESSED_ELEMENT);
this.currentLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBags(currentLimitsPropertyBags, CsaProfileConstants.REQUEST_CURRENT_LIMIT);
this.voltageLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBags(voltageLimitsPropertyBags, CsaProfileConstants.REQUEST_VOLTAGE_LIMIT);
this.angleLimitsPropertyBags = CsaProfileCracUtils.groupPropertyBags(angleLimitsPropertyBags, CsaProfileConstants.REQUEST_VOLTAGE_ANGLE_LIMIT);
this.cracCreationContext = cracCreationContext;
this.defaultMonitoredSides = defaultMonitoredSides;
this.regionEic = regionEic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CsaProfileContingencyCreator(Crac crac, Network network, PropertyBags con
this.crac = crac;
this.network = network;
this.contingenciesPropertyBags = contingenciesPropertyBags;
this.contingencyEquipmentsPropertyBags = CsaProfileCracUtils.groupPropertyBagsBy(contingencyEquipmentsPropertyBags, CsaProfileConstants.REQUEST_CONTINGENCY);
this.contingencyEquipmentsPropertyBags = CsaProfileCracUtils.groupPropertyBags(contingencyEquipmentsPropertyBags, CsaProfileConstants.REQUEST_CONTINGENCY);
this.cracCreationContext = cracCreationContext;
this.createAndAddContingencies();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public CsaProfileRemedialActionsCreator(Crac crac, Network network, CsaProfileCr
this.elementaryActionsHelper = elementaryActionsHelper;
this.networkActionCreator = new NetworkActionCreator(this.crac, network);
this.pstRangeActionCreator = new PstRangeActionCreator(this.crac, network);
Map<String, Set<PropertyBag>> linkedAeWithRa = CsaProfileCracUtils.groupPropertyBagsBy(assessedElementWithRemedialActions, CsaProfileConstants.REQUEST_REMEDIAL_ACTION);
Map<String, Set<PropertyBag>> linkedCoWithRa = CsaProfileCracUtils.groupPropertyBagsBy(contingencyWithRemedialActions, CsaProfileConstants.REQUEST_REMEDIAL_ACTION);
Map<String, Set<PropertyBag>> linkedAeWithRa = CsaProfileCracUtils.groupPropertyBags(assessedElementWithRemedialActions, CsaProfileConstants.REQUEST_REMEDIAL_ACTION);
Map<String, Set<PropertyBag>> linkedCoWithRa = CsaProfileCracUtils.groupPropertyBags(contingencyWithRemedialActions, CsaProfileConstants.REQUEST_REMEDIAL_ACTION);
createRemedialActions(false, spsMaxTimeToImplementThreshold, assessedElementPropertyBags, linkedAeWithRa, linkedCoWithRa, cnecCreationContexts);
createRemedialActions(true, spsMaxTimeToImplementThreshold, assessedElementPropertyBags, linkedAeWithRa, linkedCoWithRa, cnecCreationContexts);
// standaloneRaIdsImplicatedIntoAGroup contain ids of Ra's depending on a group whether the group is imported or not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public ElementaryActionsHelper(PropertyBags gridStateAlterationRemedialActionPro
this.gridStateAlterationCollectionPropertyBags = gridStateAlterationCollectionPropertyBags;
this.assessedElementWithRemedialActionPropertyBags = assessedElementWithRemedialActionPropertyBags;

this.remedialActionDependenciesByGroup = CsaProfileCracUtils.groupPropertyBagsBy(remedialActionDependenciesPropertyBags, CsaProfileConstants.DEPENDING_REMEDIAL_ACTION_GROUP);
this.remedialActionDependenciesByGroup = CsaProfileCracUtils.groupPropertyBags(remedialActionDependenciesPropertyBags, CsaProfileConstants.DEPENDING_REMEDIAL_ACTION_GROUP);

this.linkedContingencyWithRAs = CsaProfileCracUtils.groupPropertyBagsBy(contingencyWithRemedialActionsPropertyBags, CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedStaticPropertyRanges = CsaProfileCracUtils.groupPropertyBagsBy(staticPropertyRangesPropertyBags, CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION); // the id here is the id of the subclass of gridStateAlteration (tapPositionAction, RotatingMachine, ..)
this.linkedContingencyWithRAs = CsaProfileCracUtils.groupPropertyBags(contingencyWithRemedialActionsPropertyBags, CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedStaticPropertyRanges = CsaProfileCracUtils.groupPropertyBags(staticPropertyRangesPropertyBags, CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION); // the id here is the id of the subclass of gridStateAlteration (tapPositionAction, RotatingMachine, ..)

this.linkedTopologyActions = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(topologyActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedRotatingMachineActions = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(rotatingMachineActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedShuntCompensatorModification = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(shuntCompensatorModificationPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedTapPositionActions = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(tapPositionActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedTopologyActions = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(topologyActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedRotatingMachineActions = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(rotatingMachineActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedShuntCompensatorModification = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(shuntCompensatorModificationPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);
this.linkedTapPositionActions = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(tapPositionActionsPropertyBags, false), CsaProfileConstants.GRID_STATE_ALTERATION_REMEDIAL_ACTION);

this.linkedTopologyActionsAuto = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(topologyActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedRotatingMachineActionsAuto = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(rotatingMachineActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedShuntCompensatorModificationAuto = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(shuntCompensatorModificationPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedTapPositionActionsAuto = CsaProfileCracUtils.groupPropertyBagsBy(filterElementaryActions(tapPositionActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedTopologyActionsAuto = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(topologyActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedRotatingMachineActionsAuto = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(rotatingMachineActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedShuntCompensatorModificationAuto = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(shuntCompensatorModificationPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);
this.linkedTapPositionActionsAuto = CsaProfileCracUtils.groupPropertyBags(filterElementaryActions(tapPositionActionsPropertyBags, true), CsaProfileConstants.GRID_STATE_ALTERATION_COLLECTION);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void testGetLinkedPropertyBags() {

sourcesPb.addAll(Arrays.asList(sourcePb1, sourcePb2, sourcePb3));

Map<String, Set<PropertyBag>> map = CsaProfileCracUtils.groupPropertyBagsBy(sourcesPb, "sourceProperty2");
Map<String, Set<PropertyBag>> map = CsaProfileCracUtils.groupPropertyBags(sourcesPb, "sourceProperty2");
Set<PropertyBag> result = map.get(destPb.getId("destProperty3"));
assertNotNull(result);
assertEquals(1, result.size());
Expand Down

0 comments on commit 093121e

Please sign in to comment.