From 9dbfb791fc458bfac51d8993d5e620cf8405755a Mon Sep 17 00:00:00 2001 From: Open Lowcode SAS Date: Fri, 12 Feb 2021 09:16:07 +0100 Subject: [PATCH] Close #278 --- .../properties/Hasmultidimensionalchild.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/org/openlowcode/server/data/properties/Hasmultidimensionalchild.java b/src/org/openlowcode/server/data/properties/Hasmultidimensionalchild.java index b4af0bca..27a16235 100644 --- a/src/org/openlowcode/server/data/properties/Hasmultidimensionalchild.java +++ b/src/org/openlowcode/server/data/properties/Hasmultidimensionalchild.java @@ -174,14 +174,24 @@ public void repair(E object, ChoiceValue deleteifinvali // gets previous children F[] previouschildren = this.casteddefinition.getChildren(object.getId()); HashMap childrenbykey = new HashMap(); - + + // Creates a list of duplicates to be removed, newest children are stored here to be removed later + + ArrayList duplicatechildren = new ArrayList(); + // get MultiDimensionHelper MultidimensionchildHelper 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 @@ -202,6 +212,8 @@ public void repair(E object, ChoiceValue deleteifinvali compulsorychildren.put(key, thisobject); } + + // detects optionals and invalids ArrayList optionalsandinvalids = new ArrayList(); @@ -250,6 +262,19 @@ public void repair(E object, ChoiceValue deleteifinvali unconsolidatedinvalids.add(invalid); } } + // process duplicates, consolidates value + + for (int i=0;i found object to consolidate the duplicate into "); + } + } + // Complete optionals with missing primary values for (int i = 0; i < optionals.size(); i++) {