Skip to content

Commit d28461c

Browse files
author
Open Lowcode SAS
committed
Close #131
1 parent 1763340 commit d28461c

File tree

2 files changed

+60
-17
lines changed

2 files changed

+60
-17
lines changed

src/org/openlowcode/design/data/properties/basic/ComputedDecimal.java

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ public class ComputedDecimal
4343
private int precision;
4444
private int scale;
4545
private String fieldlabel;
46+
private int priority;
4647

48+
4749
/**
48-
* creates a computed decimal field with a formatter
50+
* creates a computed decimal field with a formatter with default priority for display
4951
*
5052
* @param name name of the field (should be valid java attribute
5153
* name)
@@ -66,12 +68,40 @@ public ComputedDecimal(
6668
int scale,
6769
FormulaDefinitionElement formula,
6870
DecimalFormatter decimalformatter) {
71+
this(name,fieldlabel,precision,scale,formula,decimalformatter,100);
72+
}
73+
74+
/**
75+
* creates a computed decimal field with a formatter
76+
*
77+
* @param name name of the field (should be valid java attribute
78+
* name)
79+
* @param fieldlabel label in default language
80+
*
81+
* @param precision (digits to the right of decimal point (e.g. 533.33
82+
* has precision on 2)
83+
* @param scale total number of digits of the number (e.g. 533.33 is
84+
* 5 digits)
85+
* @param formula formula to calculate the field value
86+
* @param decimalformatter formatter for the field (if graphical display is
87+
* expected)
88+
* @param priority priority for the field display
89+
*/
90+
public ComputedDecimal(
91+
String name,
92+
String fieldlabel,
93+
int precision,
94+
int scale,
95+
FormulaDefinitionElement formula,
96+
DecimalFormatter decimalformatter,
97+
int priority) {
6998
super(name, "COMPUTEDDECIMAL");
7099
this.formula = formula;
71100
this.decimalformatter = decimalformatter;
72101
this.precision = precision;
73102
this.scale = scale;
74103
this.fieldlabel = fieldlabel;
104+
this.priority = priority;
75105
}
76106

77107
@Override
@@ -88,7 +118,7 @@ public void controlAfterParentDefinition() {
88118
this.setExtraAttributes(",\"" + fieldlabel.replace("\"", "\\\"") + "\"," + precision + "," + scale
89119
+ ",new Formula(" + StringFormatter.formatForJavaClass(parent.getName()) + ".getComputeddecimalfor"
90120
+ this.getInstancename().toLowerCase() + "Extractor()," + formula.generateFormulaElement() + "),"
91-
+ (decimalformatter != null ? decimalformatter.generateDefinition() : "null"));
121+
+ (decimalformatter != null ? decimalformatter.generateDefinition() : "null")+","+priority);
92122
alltriggers = new ArrayList<CalculatedFieldTriggerPath>();
93123
formula.setTriggersOnSourceFields(new CalculatedFieldTriggerPath(this));
94124

@@ -97,15 +127,14 @@ public void controlAfterParentDefinition() {
97127
/**
98128
* creates a computed decimal field without a formatter
99129
*
100-
* @param name name of the field (should be valid java attribute
101-
* name)
102-
* @param fieldlabel label in default language
130+
* @param name name of the field (should be valid java attribute name)
131+
* @param fieldlabel label in default language
103132
*
104-
* @param precision (digits to the right of decimal point (e.g. 533.33
105-
* has precision on 2)
106-
* @param scale total number of digits of the number (e.g. 533.33 is
107-
* 5 digits)
108-
* @param formula formula to calculate the field value
133+
* @param precision (digits to the right of decimal point (e.g. 533.33 has
134+
* precision on 2)
135+
* @param scale total number of digits of the number (e.g. 533.33 is 5
136+
* digits)
137+
* @param formula formula to calculate the field value
109138
*/
110139
public ComputedDecimal(String name, String fieldlabel, int precision, int scale, FormulaDefinitionElement formula) {
111140
this(name, fieldlabel, precision, scale, formula, null);

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
*
3636
* @param <E> parent data object
3737
*/
38-
public class ComputeddecimalDefinition<E extends DataObject<E>> extends DataObjectPropertyDefinition<E> {
38+
public class ComputeddecimalDefinition<E extends DataObject<E>>
39+
extends
40+
DataObjectPropertyDefinition<E> {
3941
private DecimalStoredField computedValue;
4042
private String label;
4143
private Formula<E> formula;
4244
private SDecimalFormatter formatter;
45+
private int priority;
4346

4447
public Formula<E> getFormula() {
4548
return this.formula;
@@ -58,15 +61,24 @@ public Formula<E> getFormula() {
5861
* digits after comma)
5962
* @param formula the formula to compute the decimal
6063
* @param formatter formatter of the decimal field
64+
* @param priority priority for the display field (between -1000 and 1000)
6165
*/
62-
public ComputeddecimalDefinition(DataObjectDefinition<E> parentobject, String name, String label, int precision,
63-
int scale, Formula<E> formula, SDecimalFormatter formatter) {
66+
public ComputeddecimalDefinition(
67+
DataObjectDefinition<E> parentobject,
68+
String name,
69+
String label,
70+
int precision,
71+
int scale,
72+
Formula<E> formula,
73+
SDecimalFormatter formatter,
74+
int priority) {
6475
super(parentobject, name);
6576
computedValue = new DecimalStoredField(this.getName().toUpperCase(), null, precision, scale);
6677
this.addFieldSchema(computedValue);
6778
this.label = label;
6879
this.formula = formula;
6980
this.formatter = formatter;
81+
this.priority = priority;
7082
}
7183

7284
@Override
@@ -85,17 +97,19 @@ public FieldSchemaForDisplay<E>[] setFieldSchemaToDisplay() {
8597
FieldSchemaForDisplay<E>[] returnvalue = new FieldSchemaForDisplay[1];
8698
if (formatter == null)
8799
returnvalue[0] = new FieldSchemaForDisplay<E>(label, "Calculated field for " + label, computedValue, false,
88-
false, 100, 20, this.parentobject);
100+
false, priority, 20, this.parentobject);
89101
if (formatter != null)
90102
returnvalue[0] = new FieldSchemaForDisplay<E>(label, "Calculated field for " + label, computedValue,
91-
formatter, false, false, 100, 20, this.parentobject);
103+
formatter, false, false, priority, 20, this.parentobject);
92104

93105
return returnvalue;
94106
}
95107

96108
@Override
97-
public FlatFileLoaderColumn<E> getFlatFileLoaderColumn(DataObjectDefinition<E> objectdefinition,
98-
String[] columnattributes, PropertyExtractor<E> propertyextractor,
109+
public FlatFileLoaderColumn<E> getFlatFileLoaderColumn(
110+
DataObjectDefinition<E> objectdefinition,
111+
String[] columnattributes,
112+
PropertyExtractor<E> propertyextractor,
99113
ChoiceValue<ApplocaleChoiceDefinition> locale) {
100114
throw new RuntimeException("Not yet implemented");
101115
}

0 commit comments

Comments
 (0)