Skip to content

Commit

Permalink
Close #278
Browse files Browse the repository at this point in the history
  • Loading branch information
Open Lowcode SAS committed Feb 12, 2021
1 parent c2b0976 commit 9dbfb79
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,24 @@ public void repair(E object, ChoiceValue<BooleanChoiceDefinition> deleteifinvali
// gets previous children
F[] previouschildren = this.casteddefinition.getChildren(object.getId());
HashMap<String, F> childrenbykey = new HashMap<String, F>();


// Creates a list of duplicates to be removed, newest children are stored here to be removed later

ArrayList<F> duplicatechildren = new ArrayList<F>();

// get MultiDimensionHelper
MultidimensionchildHelper<F, E> multidimensionalchildhelper = this.casteddefinition.getHelper();
multidimensionalchildhelper.setContext(object);
for (int i = 0; i < previouschildren.length; i++) {
F thischild = previouschildren[i];
String key = multidimensionalchildhelper.generateKeyForObject(thischild);
if (childrenbykey.containsKey(key)) {
duplicatechildren.add(thischild);

}
else {
childrenbykey.put(key, thischild);
}
}

// check missing mandatory
Expand All @@ -202,6 +212,8 @@ public void repair(E object, ChoiceValue<BooleanChoiceDefinition> deleteifinvali
compulsorychildren.put(key, thisobject);
}



// detects optionals and invalids

ArrayList<F> optionalsandinvalids = new ArrayList<F>();
Expand Down Expand Up @@ -250,6 +262,19 @@ public void repair(E object, ChoiceValue<BooleanChoiceDefinition> deleteifinvali
unconsolidatedinvalids.add(invalid);
}
}
// process duplicates, consolidates value

for (int i=0;i<duplicatechildren.size();i++) {
F thisduplicate = duplicatechildren.get(i);
String keyforduplicate = multidimensionalchildhelper.generateKeyForObject(thisduplicate);
if (childrenbykey.get(keyforduplicate) != null) {
F childtoconsolidateinto = childrenbykey.get(keyforduplicate);
multidimensionalchildhelper.getConsolidator().accept(childtoconsolidateinto, thisduplicate);
allobjectstodelete.add(thisduplicate);
logger.finer(" -> found object to consolidate the duplicate into ");
}
}

// Complete optionals with missing primary values

for (int i = 0; i < optionals.size(); i++) {
Expand Down

0 comments on commit 9dbfb79

Please sign in to comment.