Skip to content

Commit 51f7302

Browse files
author
Open Lowcode SAS
committed
Close #232
1 parent 5b7af65 commit 51f7302

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/org/openlowcode/server/data/properties/Hasmultidimensionalchild.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ F, E>> void postprocStoredobjectInsert(
108108
*/
109109
public void addlines(E object, F[] newlines) {
110110
MultidimensionchildHelper<F, E> helper = this.casteddefinition.getHelper();
111-
111+
helper.setContext(object);
112112
// get existing children
113113
F[] previouschildren = this.casteddefinition.getChildren(object.getId());
114114
// check if new line templates collide with existing, delete the ones that exist
@@ -120,13 +120,17 @@ public void addlines(E object, F[] newlines) {
120120
}
121121
ArrayList<F> allobjectstoinsert = new ArrayList<F>();
122122
for (int i = 0; i < newlines.length; i++) {
123-
ArrayList<F> missingforthisoptional = helper.getOtherPrimaryelements(newlines[i], childrenbykey);
123+
F thisline = newlines[i];
124+
boolean invalid = helper.isInvalid(thisline);
125+
if (!invalid) {
126+
ArrayList<F> missingforthisoptional = helper.getOtherPrimaryelements(thisline, childrenbykey);
124127
for (int j = 0; j < missingforthisoptional.size(); j++) {
125128
F thismissing = missingforthisoptional.get(j);
126129
allobjectstoinsert.add(thismissing);
127130
childrenbykey.put(helper.generateKeyForObject(thismissing), thismissing);
128131

129132
}
133+
}
130134
}
131135

132136
for (int i = 0; i < allobjectstoinsert.size(); i++)

src/org/openlowcode/server/data/properties/multichild/MultichildValueHelper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,13 @@ public boolean isValid(E optionalorinvalid) {
592592
if (this.allowothervalues())
593593
return true;
594594
F value = getter.apply(optionalorinvalid);
595+
if (value==null) return false;
595596
F[] mandatoryvalues = this.getMandatoryValues();
596597
F[] optionalvalues = this.getOptionalValues();
597-
for (int i = 0; i < mandatoryvalues.length; i++)
598+
if (mandatoryvalues!=null) for (int i = 0; i < mandatoryvalues.length; i++)
598599
if (value.equals(mandatoryvalues[i]))
599600
return true;
600-
for (int i = 0; i < optionalvalues.length; i++)
601+
if (optionalvalues!=null) for (int i = 0; i < optionalvalues.length; i++)
601602
if (value.equals(optionalvalues[i]))
602603
return true;
603604
return false;
@@ -612,10 +613,10 @@ public boolean isTextValid(
612613
return true;
613614
F[] mandatoryvalues = this.getMandatoryValues();
614615
F[] optionalvalues = this.getOptionalValues();
615-
for (int i = 0; i < mandatoryvalues.length; i++)
616+
if (mandatoryvalues!=null) for (int i = 0; i < mandatoryvalues.length; i++)
616617
if (payload.equals(mandatoryvalues[i]))
617618
return true;
618-
for (int i = 0; i < optionalvalues.length; i++)
619+
if (optionalvalues!=null) for (int i = 0; i < optionalvalues.length; i++)
619620
if (payload.equals(optionalvalues[i]))
620621
return true;
621622
return false;

0 commit comments

Comments
 (0)