Skip to content

Commit bd4d0f6

Browse files
author
Open Lowcode SAS
committed
Close #105
1 parent 0249cc9 commit bd4d0f6

File tree

6 files changed

+102
-29
lines changed

6 files changed

+102
-29
lines changed

src/org/openlowcode/client/graphic/widget/CBusinessField.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ public void setActive(boolean active) {
163163
int preferedrowheight,
164164
String actionkeyforupdate);
165165

166+
166167
/**
168+
* @param pageactionmanager action manager
167169
* @param preferedrowheight prefered height for row (note: not used for big
168170
* decimal, not implemented for other fields
169171
* @param actionkeyforupdate update action key
@@ -177,7 +179,7 @@ public void setActive(boolean active) {
177179
* only one field display). if wrong, title is the
178180
* current column title (good for several fields
179181
* displays
180-
* @return
182+
* @return a table column to be used in grid classical layout
181183
*/
182184
public abstract TableColumn<CObjectGridLine<String>, ?> getTableColumnForGrid(
183185
PageActionManager pageactionmanager,

src/org/openlowcode/client/graphic/widget/CTextField.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ public void pingValue() {
10571057

10581058
}
10591059

1060+
10601061
@Override
10611062
public TableColumn<CObjectGridLine<String>, ?> getTableColumnForGrid(
10621063
PageActionManager pageactionmanager,

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class LinkObject<E extends DataObjectDefinition, F extends DataObjectDefi
6060
private boolean hasfieldshown = false;
6161
private int priorityforleft;
6262
private int priorityforright;
63+
private boolean setidsmodifiable = false;
6364

6465
/**
6566
* @param priorityforleft
@@ -83,6 +84,15 @@ public UniqueIdentified getUniqueIdentified() {
8384
private WidgetDisplayPriority displaypriorityfromleft;
8485
private WidgetDisplayPriority displaypriorityfromright;
8586

87+
/**
88+
* makes the ids of left and right object modifiable from client client. This
89+
* can be a security risk, with the possibility for data to be tampered if
90+
* someone uses a non-standard client
91+
*/
92+
public void setIdsmodifiable() {
93+
this.setidsmodifiable = true;
94+
}
95+
8696
/**
8797
* @return
8898
*/
@@ -152,7 +162,38 @@ public LinkObject(
152162
String labelfromright,
153163
WidgetDisplayPriority displaypriorityfromleft,
154164
WidgetDisplayPriority displaypriorityfromright) {
165+
this(leftobjectforlink, rightobjectforlink, labelfromleft, labelfromright, displaypriorityfromleft,
166+
displaypriorityfromright, false);
167+
}
168+
169+
/**
170+
* creates a link object with specified label from left object, and label from
171+
* right object for the link (e.g. for a wedding link between a man and a woman,
172+
* you could display 'husband' and 'wife' as specific label). Priority for the
173+
* widgets on left and right objects is also specified
174+
*
175+
* @param leftobjectforlink the left object of the link
176+
* @param rightobjectforlink the right object of the link
177+
* @param labelfromleft label of the link table seen from left object
178+
* @param labelfromright label of the link table seen from right
179+
* object
180+
* @param displaypriorityfromleft priority display from the left object
181+
* @param displaypriorityfromright priority display from the right object
182+
* @param setidsmodifiable put true if ids should be modifiable from
183+
* client. This can be a security risk, with the
184+
* possibility for data to be tampered if
185+
* someone uses a non-standard client
186+
*/
187+
public LinkObject(
188+
E leftobjectforlink,
189+
F rightobjectforlink,
190+
String labelfromleft,
191+
String labelfromright,
192+
WidgetDisplayPriority displaypriorityfromleft,
193+
WidgetDisplayPriority displaypriorityfromright,
194+
boolean setidsmodifiable) {
155195
this(leftobjectforlink, rightobjectforlink, labelfromleft, labelfromright);
196+
this.setidsmodifiable = setidsmodifiable;
156197
this.displaypriorityfromleft = displaypriorityfromleft;
157198
this.displaypriorityfromright = displaypriorityfromright;
158199
if (this.displaypriorityfromleft != null)
@@ -333,8 +374,11 @@ public void controlAfterParentDefinition() {
333374

334375
// -- process arguments
335376
if (this.hasfieldshown) {
336-
this.setExtraAttributes("," + this.priorityforleft + "," + this.priorityforright);
377+
this.setExtraAttributes("," + this.priorityforleft + "," + this.priorityforright+","+this.setidsmodifiable);
378+
} else {
379+
this.setExtraAttributes(","+this.setidsmodifiable);
337380
}
381+
338382

339383
}
340384

src/org/openlowcode/server/data/DataObjectPropertyDefinition.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ public static class FieldSchemaForDisplay<E extends DataObject<E>> {
401401
private boolean richtext = false;
402402
private FieldChoiceDefinition choiceforstring;
403403
private DataObjectDefinition<E> objectdefinition;
404-
404+
405+
406+
405407
/**
406408
* defines this text as richtext
407409
*/

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

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@
4343
* @param <F> object at left of link
4444
* @param <G> object at right of link
4545
*/
46-
public class LinkobjectDefinition<E extends DataObject<E> & LinkobjectInterface<E, F, G>, F extends DataObject<F> & UniqueidentifiedInterface<F>, G extends DataObject<G> & UniqueidentifiedInterface<G>>
47-
extends DataObjectPropertyDefinition<E> {
46+
public class LinkobjectDefinition<
47+
E extends DataObject<E> & LinkobjectInterface<E, F, G>,
48+
F extends DataObject<F> & UniqueidentifiedInterface<F>,
49+
G extends DataObject<G> & UniqueidentifiedInterface<G>>
50+
extends
51+
DataObjectPropertyDefinition<E> {
4852
private DataObjectDefinition<F> leftobjectdefinition;
4953
private DataObjectDefinition<G> rightobjectdefinition;
5054
private StringStoredField leftid;
@@ -65,6 +69,7 @@ public class LinkobjectDefinition<E extends DataObject<E> & LinkobjectInterface<
6569
private boolean showfieldsforrightobject;
6670
private int minpriorityforleftobjectfields;
6771
private int minpriorityforrightobjectfields;
72+
private boolean makesidmodifiable = false;
6873
private static Logger logger = Logger.getLogger(LinkobjectDefinition.class.getName());
6974

7075
/**
@@ -165,11 +170,18 @@ public boolean isReplaceifmorethanonefromleft() {
165170
* shown on the link
166171
* @param showrightfieldswithpriority if set, right fields above the priority
167172
* are shown on the link
173+
* @param makesidmodifiable if true, the ids of links can be sent to a
174+
* client before having been persisted. This may be
175+
* a security risk that the data is tampered on the
176+
* client side
168177
*/
169-
public LinkobjectDefinition(DataObjectDefinition<E> parentobject, DataObjectDefinition<F> leftobjectdefinition,
170-
DataObjectDefinition<G> rightobjectdefinition, int showleftfieldswithpriority,
171-
int showrightfieldswithpriority) {
172-
this(parentobject, leftobjectdefinition, rightobjectdefinition);
178+
public LinkobjectDefinition(
179+
DataObjectDefinition<E> parentobject,
180+
DataObjectDefinition<F> leftobjectdefinition,
181+
DataObjectDefinition<G> rightobjectdefinition,
182+
int showleftfieldswithpriority,
183+
int showrightfieldswithpriority,boolean makesidmodifiable) {
184+
this(parentobject, leftobjectdefinition, rightobjectdefinition,makesidmodifiable);
173185
if (showleftfieldswithpriority < 1000) {
174186
this.showfieldsforleftobject = true;
175187
this.minpriorityforleftobjectfields = showleftfieldswithpriority;
@@ -189,9 +201,16 @@ public LinkobjectDefinition(DataObjectDefinition<E> parentobject, DataObjectDefi
189201
* @param parentobject parent object definition
190202
* @param leftobjectdefinition definition of the left object for link
191203
* @param rightobjectdefinition definition of the right object for link
204+
* @param makesidmodifiable if true, the ids of links can be sent to a
205+
* client before having been persisted. This may be
206+
* a security risk that the data is tampered on the
207+
* client side
192208
*/
193-
public LinkobjectDefinition(DataObjectDefinition<E> parentobject, DataObjectDefinition<F> leftobjectdefinition,
194-
DataObjectDefinition<G> rightobjectdefinition) {
209+
public LinkobjectDefinition(
210+
DataObjectDefinition<E> parentobject,
211+
DataObjectDefinition<F> leftobjectdefinition,
212+
DataObjectDefinition<G> rightobjectdefinition,
213+
boolean makesidmodifiable) {
195214
super(parentobject, "LINKOBJECT");
196215
this.leftobjectdefinition = leftobjectdefinition;
197216
this.rightobjectdefinition = rightobjectdefinition;
@@ -217,6 +236,7 @@ public LinkobjectDefinition(DataObjectDefinition<E> parentobject, DataObjectDefi
217236
this.replaceifmorethanonefromleft = false;
218237
this.showfieldsforleftobject = false;
219238
this.showfieldsforrightobject = false;
239+
this.makesidmodifiable=makesidmodifiable;
220240
}
221241

222242
/**
@@ -287,7 +307,9 @@ public UniqueidentifiedDefinition<G> getRightuniqueidentifieddefinition() {
287307

288308
/**
289309
* sets the dependent property unique identified for the link object
290-
* @param uniqueidentifieddefinition unique identified property for the left object
310+
*
311+
* @param uniqueidentifieddefinition unique identified property for the left
312+
* object
291313
*/
292314
public void setDependentDefinitionUniqueidentified(UniqueidentifiedDefinition<E> uniqueidentifieddefinition) {
293315
this.uniqueidentifieddefinition = uniqueidentifieddefinition;
@@ -327,8 +349,8 @@ public ArrayList<ExternalFieldSchema<?>> generateExternalSchema() {
327349
}
328350
// get named property for left object
329351
if (leftobjectdefinition.hasProperty("NUMBERED")) {
330-
NumberedDefinition<F> numbereddefinition = (NumberedDefinition<F>) leftobjectdefinition
331-
.getProperty("NUMBERED");
352+
NumberedDefinition<
353+
F> numbereddefinition = (NumberedDefinition<F>) leftobjectdefinition.getProperty("NUMBERED");
332354
boolean orderedasnumber = false;
333355
int numberoffset = 0;
334356
if (numbereddefinition.getAutonumberingRule() != null)
@@ -355,8 +377,8 @@ public ArrayList<ExternalFieldSchema<?>> generateExternalSchema() {
355377
// get state property for left object
356378

357379
if (leftobjectdefinition.hasProperty("LIFECYCLE")) {
358-
LifecycleDefinition<?, ?> lifecycle = (LifecycleDefinition<?, ?>) (leftobjectdefinition
359-
.getProperty("LIFECYCLE"));
380+
LifecycleDefinition<
381+
?, ?> lifecycle = (LifecycleDefinition<?, ?>) (leftobjectdefinition.getProperty("LIFECYCLE"));
360382
ExternalFieldSchema<?> leftexternalfield = leftobjectdefinition.generateExternalField(
361383
this.getName() + "LEFTSTATE", "Left state", "this is a stupid comment", "LIFECYCLE", "STATE",
362384
lifecycle.getLifecycleHelper(), leftjoincondition, this.displayprofilehideleftobjectfields, 500,
@@ -408,8 +430,8 @@ public ArrayList<ExternalFieldSchema<?>> generateExternalSchema() {
408430
// adds an external field is the target object is named -- currently, there is
409431
// an error
410432
@SuppressWarnings("unchecked")
411-
NumberedDefinition<F> numbereddefinition = (NumberedDefinition<F>) rightobjectdefinition
412-
.getProperty("NUMBERED");
433+
NumberedDefinition<
434+
F> numbereddefinition = (NumberedDefinition<F>) rightobjectdefinition.getProperty("NUMBERED");
413435
boolean orderedasnumber = false;
414436
int numberoffset = 0;
415437
if (numbereddefinition.getAutonumberingRule() != null)
@@ -436,8 +458,8 @@ public ArrayList<ExternalFieldSchema<?>> generateExternalSchema() {
436458
externalfieldlist.add(rightexternalfield);
437459
}
438460
if (rightobjectdefinition.hasProperty("LIFECYCLE")) {
439-
LifecycleDefinition<?, ?> lifecycle = (LifecycleDefinition<?, ?>) (rightobjectdefinition
440-
.getProperty("LIFECYCLE"));
461+
LifecycleDefinition<
462+
?, ?> lifecycle = (LifecycleDefinition<?, ?>) (rightobjectdefinition.getProperty("LIFECYCLE"));
441463
ExternalFieldSchema<?> rightexternalfield = rightobjectdefinition.generateExternalField(
442464
this.getName() + "RIGHTSTATE", "Right object state", "this is a stupid comment", "LIFECYCLE",
443465
"STATE", lifecycle.getLifecycleHelper(), rightjoincondition,
@@ -473,11 +495,11 @@ public FieldSchemaForDisplay<E>[] setFieldSchemaToDisplay() {
473495
@SuppressWarnings("unchecked")
474496
FieldSchemaForDisplay<E>[] returnvalue = new FieldSchemaForDisplay[2];
475497
returnvalue[0] = new FieldSchemaForDisplay<E>("Left id",
476-
"the technical id generated by the system for the left object of the part", leftid, false, true, -200,
477-
16, this.parentobject);
498+
"the technical id generated by the system for the left object of the part", leftid, false, true,
499+
!makesidmodifiable, -200, 16, this.parentobject);
478500
returnvalue[1] = new FieldSchemaForDisplay<E>("Right id",
479-
"the technical id generated by the system for the right object of the part", rightid, false, true, -200,
480-
16, this.parentobject);
501+
"the technical id generated by the system for the right object of the part", rightid, false, true,
502+
!makesidmodifiable, -200, 16, this.parentobject);
481503

482504
return returnvalue;
483505
}
@@ -495,8 +517,10 @@ public QueryCondition getUniversalQueryCondition(String alias) {
495517
}
496518

497519
@Override
498-
public FlatFileLoaderColumn<E> getFlatFileLoaderColumn(DataObjectDefinition<E> objectdefinition,
499-
String[] columnattributes, PropertyExtractor<E> propertyextractor,
520+
public FlatFileLoaderColumn<E> getFlatFileLoaderColumn(
521+
DataObjectDefinition<E> objectdefinition,
522+
String[] columnattributes,
523+
PropertyExtractor<E> propertyextractor,
500524
ChoiceValue<ApplocaleChoiceDefinition> locale) {
501525
throw new RuntimeException("Not yet implemented");
502526
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public <E extends DataObject<E> & LinkobjectInterface<E, F, G>, F extends DataOb
8888
TableAlias alias, DataObjectId<F> idvalue, DataObjectDefinition<E> parentobjectdefinition,
8989
DataObjectDefinition<F> leftobjectdefinition, DataObjectDefinition<G> rightobjectdefinition) {
9090
LinkobjectDefinition<E, F, G> definition = new LinkobjectDefinition<E, F, G>(parentobjectdefinition,
91-
leftobjectdefinition, rightobjectdefinition);
91+
leftobjectdefinition, rightobjectdefinition, false);
9292
@SuppressWarnings("unchecked")
9393
StoredFieldSchema<String> id = (StoredFieldSchema<String>) definition.getDefinition().lookupOnName("LFID");
9494
if (alias == null)
@@ -112,7 +112,7 @@ public <E extends DataObject<E> & LinkobjectInterface<E, F, G>, F extends DataOb
112112
TableAlias alias, DataObjectId<G> idvalue, DataObjectDefinition<E> parentobjectdefinition,
113113
DataObjectDefinition<F> leftobjectdefinition, DataObjectDefinition<G> rightobjectdefinition) {
114114
LinkobjectDefinition<E, F, G> definition = new LinkobjectDefinition<E, F, G>(parentobjectdefinition,
115-
leftobjectdefinition, rightobjectdefinition);
115+
leftobjectdefinition, rightobjectdefinition, false);
116116
@SuppressWarnings("unchecked")
117117
StoredFieldSchema<String> id = (StoredFieldSchema<String>) definition.getDefinition().lookupOnName("RGID");
118118
if (alias == null)
@@ -627,7 +627,7 @@ public <E extends DataObject<E> & UniqueidentifiedInterface<E>, F extends DataOb
627627
aliaslist.add(additionalcondition.getAliases()[i]);
628628

629629
LinkobjectDefinition<F, E, G> definition = new LinkobjectDefinition<F, E, G>(linkobjectdefinition,
630-
leftobjectdefinition, rightobjectdefinition);
630+
leftobjectdefinition, rightobjectdefinition, false);
631631
QueryCondition rightidcondition = linkobjectdefinition.extendquery(aliaslist, linkalias,
632632
getRightidQueryCondition(linkalias, rightid, linkobjectdefinition, leftobjectdefinition,
633633
rightobjectdefinition));

0 commit comments

Comments
 (0)