Skip to content

Commit

Permalink
Store a list of plan item definitions in the stage, consistent with h…
Browse files Browse the repository at this point in the history
…ow in a process the flow elements are stored
  • Loading branch information
jbarrez committed Jul 14, 2023
1 parent ae08d49 commit 121910f
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

/**
* @author Joram Barrez
*/
Expand All @@ -31,10 +33,18 @@ public class Stage extends PlanFragment implements HasExitCriteria {
protected String validateFormFields;
protected Integer displayOrder;
protected String includeInStageOverview;
protected List<PlanItemDefinition> planItemDefinitionList = new ArrayList<>();
protected Map<String, PlanItemDefinition> planItemDefinitionMap = new LinkedHashMap<>();

public void addPlanItemDefinition(PlanItemDefinition planItemDefinition) {
planItemDefinitionMap.put(planItemDefinition.getId(), planItemDefinition);
planItemDefinitionList.add(planItemDefinition);
addPlanItemDefinitionToMap(planItemDefinition);
}

protected void addPlanItemDefinitionToMap(PlanItemDefinition planItemDefinition) {
if (planItemDefinition != null && StringUtils.isNotEmpty(planItemDefinition.getId())) {
planItemDefinitionMap.put(planItemDefinition.getId(), planItemDefinition);
}
}

public PlanItemDefinition findPlanItemDefinitionInStageOrUpwards(String planItemDefinitionId) {
Expand Down Expand Up @@ -95,7 +105,7 @@ private <T extends PlanItemDefinition> void internalFindPlanItemDefinitionsOfTyp
}

public List<PlanItemDefinition> getPlanItemDefinitions() {
return new ArrayList<>(planItemDefinitionMap.values());
return planItemDefinitionList;
}

public Map<String, PlanItemDefinition> getPlanItemDefinitionMap() {
Expand Down

0 comments on commit 121910f

Please sign in to comment.