Skip to content

Commit 6b681e1

Browse files
author
Open Lowcode SAS
committed
Close #267
1 parent d33aebc commit 6b681e1

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public boolean allowothervalues() {
8282
}
8383

8484
@Override
85-
public F getDefaultValueForOtherData() {
85+
public F getDefaultValueForOtherData(F current) {
8686
return defaultforotherdata;
8787
}
8888
@Override

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

+25-16
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,16 @@ public String getAndPrint(E object) {
301301
public abstract boolean allowothervalues();
302302

303303
/**
304+
* @param current the current value
304305
* @return the value to consolidate other values in. Example, if you want to
305306
* have always time data from a 5 years time window, you may have a
306307
* value 'Before' that will consolidate values from previous year when
307-
* you get previous year data
308+
* you get previous year data. Return null in order not to consolidate
309+
* the data
310+
* @since 1.11.4
308311
*/
309-
public abstract F getDefaultValueForOtherData();
312+
313+
public abstract F getDefaultValueForOtherData(F current);
310314

311315
/**
312316
* This method checks if the current value can be kept or an alternative should
@@ -348,7 +352,7 @@ public boolean replaceWithDefaultValue(E object) {
348352
}
349353

350354
}
351-
F alternative = getDefaultValueForOtherData();
355+
F alternative = getDefaultValueForOtherData(get(object));
352356
if (alternative != null) {
353357
logger.finer(" ---> Found alternative " + alternative);
354358
set(object, alternative);
@@ -592,15 +596,18 @@ public boolean isValid(E optionalorinvalid) {
592596
if (this.allowothervalues())
593597
return true;
594598
F value = getter.apply(optionalorinvalid);
595-
if (value==null) return false;
599+
if (value == null)
600+
return false;
596601
F[] mandatoryvalues = this.getMandatoryValues();
597602
F[] optionalvalues = this.getOptionalValues();
598-
if (mandatoryvalues!=null) for (int i = 0; i < mandatoryvalues.length; i++)
599-
if (value.equals(mandatoryvalues[i]))
600-
return true;
601-
if (optionalvalues!=null) for (int i = 0; i < optionalvalues.length; i++)
602-
if (value.equals(optionalvalues[i]))
603-
return true;
603+
if (mandatoryvalues != null)
604+
for (int i = 0; i < mandatoryvalues.length; i++)
605+
if (value.equals(mandatoryvalues[i]))
606+
return true;
607+
if (optionalvalues != null)
608+
for (int i = 0; i < optionalvalues.length; i++)
609+
if (value.equals(optionalvalues[i]))
610+
return true;
604611
return false;
605612
}
606613

@@ -613,12 +620,14 @@ public boolean isTextValid(
613620
return true;
614621
F[] mandatoryvalues = this.getMandatoryValues();
615622
F[] optionalvalues = this.getOptionalValues();
616-
if (mandatoryvalues!=null) for (int i = 0; i < mandatoryvalues.length; i++)
617-
if (payload.equals(mandatoryvalues[i]))
618-
return true;
619-
if (optionalvalues!=null) for (int i = 0; i < optionalvalues.length; i++)
620-
if (payload.equals(optionalvalues[i]))
621-
return true;
623+
if (mandatoryvalues != null)
624+
for (int i = 0; i < mandatoryvalues.length; i++)
625+
if (payload.equals(mandatoryvalues[i]))
626+
return true;
627+
if (optionalvalues != null)
628+
for (int i = 0; i < optionalvalues.length; i++)
629+
if (payload.equals(optionalvalues[i]))
630+
return true;
622631
return false;
623632
}
624633

0 commit comments

Comments
 (0)