Skip to content

Commit c6748dc

Browse files
author
Open Lowcode SAS
committed
Partial implementation of #119
Kept in the main branch as it has no side effect, but not usable yet
1 parent a2308cc commit c6748dc

File tree

8 files changed

+595
-0
lines changed

8 files changed

+595
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.design.data.properties.basic;
12+
import java.io.IOException;
13+
import java.util.ArrayList;
14+
15+
import org.openlowcode.design.data.DataObjectDefinition;
16+
import org.openlowcode.design.data.Property;
17+
import org.openlowcode.design.data.SimpleChoiceCategory;
18+
import org.openlowcode.design.generation.SourceGenerator;
19+
import org.openlowcode.design.generation.StringFormatter;
20+
import org.openlowcode.design.module.Module;
21+
22+
/**
23+
* A data object with a subtype can:<ul>
24+
* <li>have specific rule per subtype</li>
25+
* <li>have a companion object for a group of subtypes, adding fields and properties</li>
26+
* <li></li></ul>
27+
*
28+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
29+
* SAS</a>
30+
*
31+
* @param <E>
32+
*/
33+
public class Subtype<E extends DataObjectDefinition>
34+
extends
35+
Property<Subtype<E>> {
36+
37+
private SimpleChoiceCategory subtypes;
38+
private UniqueIdentified uniqueidentified;
39+
40+
public Subtype(SimpleChoiceCategory subtypes) {
41+
super("SUBTYPE");
42+
if (subtypes==null) throw new RuntimeException("Subtypes cannot be null");
43+
this.subtypes=subtypes;
44+
this.addChoiceCategoryHelper("LISTOFSUBTYPES", subtypes);
45+
}
46+
47+
48+
49+
@Override
50+
public void controlAfterParentDefinition() {
51+
uniqueidentified = (UniqueIdentified) parent.getPropertyByName("UNIQUEIDENTIFIED");
52+
this.addDependentProperty(uniqueidentified);
53+
}
54+
55+
56+
57+
public SimpleChoiceCategory getSubTypes() {
58+
return this.subtypes;
59+
}
60+
61+
@Override
62+
public String[] getPropertyInitMethod() {
63+
// TODO Auto-generated method stub
64+
return null;
65+
}
66+
67+
@Override
68+
public String[] getPropertyExtractMethod() {
69+
// TODO Auto-generated method stub
70+
return null;
71+
}
72+
73+
@Override
74+
public String[] getPropertyDeepCopyStatement() {
75+
// TODO Auto-generated method stub
76+
return null;
77+
}
78+
79+
@Override
80+
public ArrayList<DataObjectDefinition> getExternalObjectDependence() {
81+
// TODO Auto-generated method stub
82+
return null;
83+
}
84+
85+
@Override
86+
public void setFinalSettings() {
87+
// TODO Auto-generated method stub
88+
89+
}
90+
91+
@Override
92+
public String getJavaType() {
93+
// TODO Auto-generated method stub
94+
return null;
95+
}
96+
97+
@Override
98+
public void writeDependentClass(SourceGenerator sg, Module module) throws IOException {
99+
sg.wl("import " + subtypes.getParentModule().getPath() + ".data.choice."
100+
+ StringFormatter.formatForJavaClass(subtypes.getName()) + "ChoiceDefinition;");
101+
102+
}
103+
104+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.design.data.properties.basic;
12+
13+
import java.io.IOException;
14+
import java.util.ArrayList;
15+
16+
import org.openlowcode.design.data.ChoiceCategory;
17+
import org.openlowcode.design.data.ChoiceValue;
18+
import org.openlowcode.design.data.DataObjectDefinition;
19+
import org.openlowcode.design.data.Property;
20+
import org.openlowcode.design.data.PropertyGenerics;
21+
import org.openlowcode.design.data.SimpleChoiceCategory;
22+
import org.openlowcode.design.generation.SourceGenerator;
23+
import org.openlowcode.design.generation.StringFormatter;
24+
import org.openlowcode.design.module.Module;
25+
26+
/**
27+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
28+
* SAS</a>
29+
*
30+
* @param <E>
31+
*/
32+
public class SubtypeCompanion<E extends DataObjectDefinition>
33+
extends
34+
Property<SubtypeCompanion<E>> {
35+
36+
Subtype<?> subtypeformainobject;
37+
DataObjectDefinition mainobjet;
38+
private DataObjectDefinition mainobject;
39+
private ChoiceValue[] typesforcompanion;
40+
private SimpleChoiceCategory subtypecategory;
41+
private ChoiceCategory types;
42+
private StoredObject storedobject;
43+
44+
public SubtypeCompanion(DataObjectDefinition mainobject, ChoiceValue[] typesforcompanion) {
45+
super("SUBTYPECOMPANION");
46+
if (mainobject == null)
47+
throw new RuntimeException("Main object is not defined");
48+
subtypeformainobject = (Subtype<?>) mainobject.getPropertyByName("SUBTYPE");
49+
this.mainobject = mainobject;
50+
this.typesforcompanion = typesforcompanion;
51+
if (typesforcompanion == null)
52+
throw new RuntimeException("SubtypeCompanion property for object " + mainobject.getName()
53+
+ " does not have a type for companion choice (null array)");
54+
if (typesforcompanion.length == 0)
55+
throw new RuntimeException("SubtypeCompanion property for object " + mainobject.getName()
56+
+ " does not have a type for companion choice (zero element array)");
57+
types = typesforcompanion[0].getParent();
58+
this.addChoiceCategoryHelper("LISTOFSUBTYPES", types);
59+
60+
}
61+
62+
@Override
63+
public void controlAfterParentDefinition() {
64+
this.storedobject = (StoredObject) parent.getPropertyByName("STOREDOBJECT");
65+
if (this.storedobject == null)
66+
throw new RuntimeException("Subtypecompanion is dependent on storedobject");
67+
this.addDependentProperty(storedobject);
68+
this.addPropertyGenerics(new PropertyGenerics("MAINOBJECT", mainobject, new UniqueIdentified()));
69+
}
70+
71+
@Override
72+
public String[] getPropertyInitMethod() {
73+
// TODO Auto-generated method stub
74+
return null;
75+
}
76+
77+
@Override
78+
public String[] getPropertyExtractMethod() {
79+
// TODO Auto-generated method stub
80+
return null;
81+
}
82+
83+
@Override
84+
public String[] getPropertyDeepCopyStatement() {
85+
// TODO Auto-generated method stub
86+
return null;
87+
}
88+
89+
@Override
90+
public ArrayList<DataObjectDefinition> getExternalObjectDependence() {
91+
// TODO Auto-generated method stub
92+
return null;
93+
}
94+
95+
@Override
96+
public void setFinalSettings() {
97+
if (this.getParent().getPropertyByName("UNIQUEIDENTIFIED") != null)
98+
throw new RuntimeException("Object " + this.getParent().getName()
99+
+ " has both subtype companion and unique identified, this is not possible");
100+
subtypeformainobject = (Subtype<?>) mainobject.getPropertyByName("SUBTYPE");
101+
if (subtypeformainobject == null)
102+
throw new RuntimeException(
103+
"Main object " + this.mainobject.getName() + " does not have the property SUBTYPE, so object "
104+
+ this.getParent().getName() + " cannot reference it as a main object for subtype");
105+
subtypecategory = subtypeformainobject.getSubTypes();
106+
for (int i = 0; i < typesforcompanion.length; i++) {
107+
ChoiceValue thissubtype = typesforcompanion[i];
108+
109+
if (!subtypecategory.isKeyPresent(thissubtype.getName()))
110+
throw new RuntimeException("Subtype " + thissubtype + " for companion object "
111+
+ this.getParent().getName() + " is not part of the category for main object "
112+
+ subtypeformainobject.getParent().getName());
113+
}
114+
115+
}
116+
117+
@Override
118+
public String getJavaType() {
119+
// TODO Auto-generated method stub
120+
return null;
121+
}
122+
123+
@Override
124+
public void writeDependentClass(SourceGenerator sg, Module module) throws IOException {
125+
126+
sg.wl("import " + types.getParentModule().getPath() + ".data.choice."
127+
+ StringFormatter.formatForJavaClass(types.getName()) + "ChoiceDefinition;");
128+
129+
}
130+
131+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.server.data.properties;
12+
13+
import org.openlowcode.module.designer.data.Propertydef;
14+
import org.openlowcode.server.data.DataObject;
15+
import org.openlowcode.server.data.DataObjectPayload;
16+
import org.openlowcode.server.data.DataObjectProperty;
17+
import org.openlowcode.server.data.DataObjectPropertyDefinition;
18+
import org.openlowcode.server.data.SimpleFieldChoiceDefinition;
19+
20+
/**
21+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
22+
* SAS</a>
23+
*
24+
* @param <E>
25+
* @param <F>
26+
*/
27+
public class Subtype<E extends DataObject<E> & UniqueidentifiedInterface<E>, F extends SimpleFieldChoiceDefinition<F>>
28+
extends
29+
DataObjectProperty<E> {
30+
31+
private Uniqueidentified<E> uniqueidentified;
32+
33+
public Subtype(DataObjectPropertyDefinition<E> definition, DataObjectPayload parentpayload) {
34+
super(definition, parentpayload);
35+
}
36+
37+
public void setDependentPropertyUniqueidentified(Uniqueidentified<E> uniqueidentified) {
38+
this.uniqueidentified = uniqueidentified;
39+
40+
}
41+
42+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.server.data.properties;
12+
13+
import java.util.ArrayList;
14+
15+
import org.openlowcode.module.designer.data.Propertydef;
16+
import org.openlowcode.module.system.data.choice.ApplocaleChoiceDefinition;
17+
import org.openlowcode.server.data.ChoiceValue;
18+
import org.openlowcode.server.data.DataObject;
19+
import org.openlowcode.server.data.DataObjectDefinition;
20+
import org.openlowcode.server.data.DataObjectElement;
21+
import org.openlowcode.server.data.DataObjectElementDefinition;
22+
import org.openlowcode.server.data.DataObjectPayload;
23+
import org.openlowcode.server.data.DataObjectPropertyDefinition;
24+
import org.openlowcode.server.data.PropertyExtractor;
25+
import org.openlowcode.server.data.SimpleFieldChoiceDefinition;
26+
import org.openlowcode.server.data.loader.FlatFileLoaderColumn;
27+
import org.openlowcode.server.data.specificstorage.ExternalFieldSchema;
28+
import org.openlowcode.server.data.storage.QueryCondition;
29+
30+
/**
31+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
32+
* SAS</a>
33+
*
34+
* @param <E>
35+
* @param <F>
36+
*/
37+
public class SubtypeDefinition<E extends DataObject<E> & UniqueidentifiedInterface<E>,F extends SimpleFieldChoiceDefinition<F>>
38+
extends
39+
DataObjectPropertyDefinition<E> {
40+
private SimpleFieldChoiceDefinition<F> subtypes;
41+
private UniqueidentifiedDefinition<E> uniqueidentified;
42+
public SubtypeDefinition(DataObjectDefinition<E> parentobject, SimpleFieldChoiceDefinition<F> subtypes) {
43+
super(parentobject, "SUBTYPE");
44+
this.subtypes = subtypes;
45+
}
46+
47+
@Override
48+
public ArrayList<ExternalFieldSchema<?>> generateExternalSchema() {
49+
// TODO Auto-generated method stub
50+
return null;
51+
}
52+
53+
@Override
54+
public QueryCondition getUniversalQueryCondition(String alias) {
55+
// TODO Auto-generated method stub
56+
return null;
57+
}
58+
59+
@Override
60+
public FieldSchemaForDisplay[] setFieldSchemaToDisplay() {
61+
// TODO Auto-generated method stub
62+
return null;
63+
}
64+
65+
@Override
66+
public FlatFileLoaderColumn<E> getFlatFileLoaderColumn(
67+
DataObjectDefinition<E> objectdefinition,
68+
String[] columnattributes,
69+
PropertyExtractor<E> propertyextractor,
70+
ChoiceValue<ApplocaleChoiceDefinition> locale) {
71+
// TODO Auto-generated method stub
72+
return null;
73+
}
74+
75+
@Override
76+
public String[] getLoaderFieldList() {
77+
// TODO Auto-generated method stub
78+
return null;
79+
}
80+
81+
@Override
82+
public String[] getLoaderFieldSample(String name) {
83+
// TODO Auto-generated method stub
84+
return null;
85+
}
86+
87+
@Override
88+
public DataObjectElement<DataObjectElementDefinition<?, E>, E> initiateFieldInstance(
89+
DataObjectPayload parentpayload) {
90+
// TODO Auto-generated method stub
91+
return null;
92+
}
93+
94+
public void setDependentDefinitionUniqueidentified(UniqueidentifiedDefinition<E> uniqueidentified) {
95+
this.uniqueidentified=uniqueidentified;
96+
97+
}
98+
99+
}

0 commit comments

Comments
 (0)