Skip to content

Commit 2ae96a0

Browse files
authored
Merge pull request #18 from mendix/run/4620-upgrade-to-10.21
[RUN-4620][RUN-4565] Upgrade project to 10.21.0
2 parents 5802ef5 + 384b11e commit 2ae96a0

38 files changed

+735
-647
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.classpath
55
.mendix-cache
66
.project
7+
.vscode
78

89
/.gradle/
910
/.mendix-cache
@@ -34,3 +35,4 @@ src/ObjectHandling/modeler-merge-marker
3435
src/ObjectHandling/project-settings.user.json
3536
src/ObjectHandling/theme-cache
3637
src/ObjectHandling/userlib
38+
src/ObjectHandling/vendorlib

build.gradle

+10-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import com.github.jk1.license.render.*
88

99
plugins {
1010
id 'java'
11-
id 'com.mendix.gradle.publish-module-plugin' version '1.20'
11+
id 'com.mendix.gradle.publish-module-plugin' version '1.21'
1212
id 'net.researchgate.release' version '2.8.1'
1313
id 'com.github.jk1.dependency-license-report' version '2.0'
1414
}
1515

16-
sourceCompatibility = '11'
16+
sourceCompatibility = '21'
1717
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1818

1919
project.ext {
20-
mendixPublicApiVersion = '9.18.0'
20+
mendixPublicApiVersion = '10.21.0'
2121
}
2222

2323
def mprDir = "$projectDir/src/ObjectHandling"
@@ -29,11 +29,12 @@ mxMarketplace {
2929
moduleLicense = 'Apache V2'
3030
appDirectory = "src/ObjectHandling"
3131
versionPathPrefix = "_Docs/version " // the path prefix within the module to the version folder
32-
createMigrationFile = true
33-
includeFiles = ["$mprDir/License.txt", "$mprDir/SiemensMendixObjectHandling__4.0.3__READMEOSS.html"]
32+
includeFiles = ["$mprDir/License.txt", "$mprDir/SiemensMendixObjectHandling__5.0.0__READMEOSS.html"]
33+
syncJavaDependenciesBeforeBuild = true
3434
}
3535

3636
def userLibDir = "$mprDir/userlib"
37+
def vendorLibDir = "$mprDir/vendorlib"
3738

3839
repositories {
3940
maven {
@@ -59,16 +60,13 @@ dependencies {
5960
[group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.0.3']
6061
)
6162

62-
compileOnly([group: 'com.mendix', name: 'public-api', version: "$mendixPublicApiVersion"])
63+
testImplementation fileTree(vendorLibDir) { include '*.jar' }
6364

64-
implementation(
65-
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'],
66-
[group: 'org.apache.commons', name: 'commons-text', version: '1.10.0']
67-
)
65+
compileOnly([group: 'com.mendix', name: 'public-api', version: "$mendixPublicApiVersion"])
6866
}
6967

7068
tasks.withType(JavaCompile) {
71-
options.compilerArgs << "-Xlint:deprecation"
69+
options.deprecation = true
7270
}
7371

7472
sourceSets {
@@ -101,6 +99,7 @@ task copyAllToUserlib(type: Copy) {
10199

102100
clean {
103101
delete "$userLibDir"
102+
delete "$vendorLibDir"
104103
}
105104

106105
tasks.named('mxBuild') {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=4.0.4-SNAPSHOT
1+
version=5.0.0-SNAPSHOT

marketplace/release-notes/5.0.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
We upgraded the Object Handling module to Mendix version 10.21.0

src/ObjectHandling/ObjectHandling.mpr

-8 MB
Binary file not shown.

src/ObjectHandling/SiemensMendixObjectHandling__4.0.3__READMEOSS.html renamed to src/ObjectHandling/SiemensMendixObjectHandling__5.0.0__READMEOSS.html

+1-1
Large diffs are not rendered by default.

src/ObjectHandling/javasource/objecthandling/ORM.java

+39-41
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.mendix.systemwideinterfaces.core.IMendixObject;
2121
import com.mendix.systemwideinterfaces.core.IMendixObject.ObjectState;
2222
import com.mendix.systemwideinterfaces.core.IMendixObjectMember;
23-
import com.mendix.systemwideinterfaces.core.IMendixObjectMember.MemberState;
2423
import com.mendix.systemwideinterfaces.core.meta.IMetaAssociation;
2524
import com.mendix.systemwideinterfaces.core.meta.IMetaAssociation.AssociationType;
2625
import com.mendix.systemwideinterfaces.core.meta.IMetaEnumValue;
@@ -40,7 +39,7 @@ public static Long getGUID(IMendixObject item)
4039
public static String getOriginalValueAsString(IContext context, IMendixObject item,
4140
String member)
4241
{
43-
return String.valueOf(item.getMember(context, member).getOriginalValue(context));
42+
return String.valueOf(item.getMember(member).getOriginalValue(context));
4443
}
4544

4645
public static boolean objectHasChanged(IMendixObject anyobject) {
@@ -62,7 +61,7 @@ public static boolean memberHasChanged(IContext context, IMendixObject item, Str
6261
throw new IllegalArgumentException("The provided object is empty");
6362
if (!item.hasMember(member))
6463
throw new IllegalArgumentException("Unknown member: " + member);
65-
return item.getMember(context, member).getState() == MemberState.CHANGED || item.getState() != ObjectState.NORMAL;
64+
return item.getMember(member).isChanged() || item.getState() != ObjectState.NORMAL;
6665
}
6766

6867
public static void deepClone(IContext c, IMendixObject source, IMendixObject target, String membersToSkip, String membersToKeep, String reverseAssociations, String excludeEntities, String excludeModules) throws CoreException
@@ -97,16 +96,16 @@ private static void duplicate(IContext ctx, IMendixObject src, IMendixObject tar
9796
if (m instanceof MendixObjectReference && !keep && m.getValue(ctx) != null) {
9897
IMendixObject o = Core.retrieveId(ctx, ((MendixObjectReference) m).getValue(ctx));
9998
IMendixIdentifier refObj = getCloneOfObject(ctx, o, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
100-
tar.setValue(ctx, key, refObj);
99+
tar.setValue(ctx, key, refObj);
101100
}
102101

103102
else if (m instanceof MendixObjectReferenceSet && !keep && m.getValue(ctx) != null) {
104103
MendixObjectReferenceSet rs = (MendixObjectReferenceSet) m;
105104
List<IMendixIdentifier> res = new ArrayList<IMendixIdentifier>();
106105
for(IMendixIdentifier item : rs.getValue(ctx)) {
107106
IMendixObject o = Core.retrieveId(ctx, item);
108-
IMendixIdentifier refObj = getCloneOfObject(ctx, o, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
109-
res.add(refObj);
107+
IMendixIdentifier refObj = getCloneOfObject(ctx, o, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
108+
res.add(refObj);
110109
}
111110
tar.setValue(ctx, key, res);
112111
}
@@ -123,31 +122,31 @@ else if (m instanceof MendixAutoNumber) //skip autonumbers! Ticket 14893
123122
}
124123

125124
private static IMendixIdentifier getCloneOfObject(IContext ctx, IMendixObject src,
126-
List<String> toskip, List<String> tokeep, List<String> revAssoc,
127-
List<String> skipEntities, List<String> skipModules,
128-
Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
125+
List<String> toskip, List<String> tokeep, List<String> revAssoc,
126+
List<String> skipEntities, List<String> skipModules,
127+
Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
129128
{
130-
String objType = src.getMetaObject().getName();
131-
String modName = src.getMetaObject().getModuleName();
132-
133-
// if object is already being cloned, return ref to clone
134-
if (mappedObjects.containsKey(src.getId())) {
135-
return mappedObjects.get(src.getId());
136-
// if object should be skipped based on module or entity, return source object
137-
} else if (skipEntities.contains(objType) || skipModules.contains(modName)) {
138-
return src.getId();
139-
// if not already being cloned, create clone
140-
} else {
141-
IMendixObject clone = Core.instantiate(ctx, src.getType());
142-
duplicate(ctx, src, clone, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
143-
return clone.getId();
144-
}
129+
String objType = src.getMetaObject().getName();
130+
String modName = src.getMetaObject().getModuleName();
131+
132+
// if object is already being cloned, return ref to clone
133+
if (mappedObjects.containsKey(src.getId())) {
134+
return mappedObjects.get(src.getId());
135+
// if object should be skipped based on module or entity, return source object
136+
} else if (skipEntities.contains(objType) || skipModules.contains(modName)) {
137+
return src.getId();
138+
// if not already being cloned, create clone
139+
} else {
140+
IMendixObject clone = Core.instantiate(ctx, src.getType());
141+
duplicate(ctx, src, clone, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
142+
return clone.getId();
143+
}
145144
}
146145

147146
private static void duplicateReverseAssociations(IContext ctx, IMendixObject src, IMendixObject tar,
148-
List<String> toskip, List<String> tokeep, List<String> revAssocs,
149-
List<String> skipEntities, List<String> skipModules,
150-
Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
147+
List<String> toskip, List<String> tokeep, List<String> revAssocs,
148+
List<String> skipEntities, List<String> skipModules,
149+
Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
151150
{
152151
for(String fullAssocName : revAssocs) {
153152
String[] parts = fullAssocName.split("/");
@@ -158,29 +157,28 @@ private static void duplicateReverseAssociations(IContext ctx, IMendixObject src
158157
String assocname = parts.length == 3 ? parts[1] : parts[0]; //support length 3 for backward compatibility
159158

160159
IMetaAssociation massoc = src.getMetaObject().getDeclaredMetaAssociationChild(assocname);
161-
160+
162161
if (massoc != null) {
163162
IMetaObject relationParent = massoc.getParent();
164163
// if the parent is in the exclude list, we can't clone the parent, and setting the
165164
// references to the newly cloned target object will screw up the source data.
166165
if (skipEntities.contains(relationParent.getName()) || skipModules.contains(relationParent.getModuleName())){
167-
throw new IllegalArgumentException("A reverse reference has been specified that starts at an entity in the exclude list, this is not possible to clone: '" + fullAssocName + "'");
168-
}
169-
170-
//MWE: what to do with reverse reference sets? -> to avoid spam creating objects on
171-
//reverse references, do not support referenceset (todo: we could keep a map of converted guids and reuse that!)
166+
throw new IllegalArgumentException("A reverse reference has been specified that starts at an entity in the exclude list, this is not possible to clone: '" + fullAssocName + "'");
167+
}
168+
169+
//MWE: what to do with reverse reference sets? -> to avoid spam creating objects on
170+
//reverse references, do not support referenceset (todo: we could keep a map of converted guids and reuse that!)
172171
if (massoc.getType() == AssociationType.REFERENCESET) {
173172
throw new IllegalArgumentException("It is not possible to clone reverse referencesets: '" + fullAssocName + "'");
174173
}
175174

176-
List<IMendixObject> objs = Core.retrieveXPathQuery(ctx, String.format("//%s[%s='%s']",
177-
relationParent.getName(), assocname, String.valueOf(src.getId().toLong())));
175+
List<IMendixObject> objs = Core.createXPathQuery(String.format("//%s[%s='%s']",
176+
relationParent.getName(), assocname, String.valueOf(src.getId().toLong()))).execute(ctx);
178177

179178
for(IMendixObject obj : objs) {
180-
@SuppressWarnings("unused") // object is unused on purpose
181-
IMendixIdentifier refObj = getCloneOfObject(ctx, obj, toskip, tokeep, revAssocs, skipEntities, skipModules, mappedObjects);
182-
// setting reference explicitly is not necessary, this has been done in the
183-
// duplicate() call.
179+
@SuppressWarnings("unused") // object is unused on purpose
180+
IMendixIdentifier refObj = getCloneOfObject(ctx, obj, toskip, tokeep, revAssocs, skipEntities, skipModules, mappedObjects);
181+
// setting reference explicitly is not necessary, this has been done in the duplicate() call.
184182
}
185183
}
186184
}
@@ -196,7 +194,7 @@ public static String getValueOfPath(IContext context, IMendixObject substitute,
196194
{
197195
String[] path = fullpath.split("/");
198196
if (path.length == 1) {
199-
IMendixObjectMember<?> member = substitute.getMember(context, path[0]);
197+
IMendixObjectMember<?> member = substitute.getMember(path[0]);
200198

201199
//special case, see ticket 9135, format datetime.
202200
if (member instanceof MendixDateTime) {
@@ -224,7 +222,7 @@ else if (path.length == 0)
224222
throw new Exception("communitycommons.ORM.getValueOfPath: Unexpected end of path.");
225223

226224
else {
227-
IMendixObjectMember<?> member = substitute.getMember(context, path[0]);
225+
IMendixObjectMember<?> member = substitute.getMember(path[0]);
228226
if (member instanceof MendixObjectReference) {
229227
MendixObjectReference ref = (MendixObjectReference) member;
230228
IMendixIdentifier id = ref.getValue(context);

src/ObjectHandling/javasource/objecthandling/XPath.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.mendix.core.Core;
3131
import com.mendix.core.CoreException;
32+
import com.mendix.datastorage.XPathQuery;
3233
import com.mendix.systemwideinterfaces.core.IContext;
3334
import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
3435
import com.mendix.systemwideinterfaces.core.IMendixObject;
@@ -350,13 +351,17 @@ private void assertEmptyStack() throws IllegalStateException {
350351
public long count() throws CoreException {
351352
assertEmptyStack();
352353

353-
return Core.retrieveXPathQueryAggregate(context, "count(" + getXPath() + ")");
354+
return Core.createXPathQuery("count(" + getXPath() + ")").executeAggregateLong(context);
354355
}
355356

356357
public IMendixObject firstMendixObject() throws CoreException {
357358
assertEmptyStack();
358359

359-
List<IMendixObject> result = Core.retrieveXPathQuery(context, getXPath(), 1, offset, sorting);
360+
XPathQuery query = (XPathQuery) Core.createXPathQuery(getXPath()).setAmount(1).setOffset(offset);
361+
for (Map.Entry<String, String> sort : sorting.entrySet())
362+
query.addSort(sort.getKey(), sort.getValue() == "asc");
363+
List<IMendixObject> result = query.execute(context);
364+
360365
if (result.isEmpty())
361366
return null;
362367
return result.get(0);
@@ -541,7 +546,10 @@ public T firstOrWait(long timeoutMSecs) throws CoreException, InterruptedExcepti
541546
public List<IMendixObject> allMendixObjects() throws CoreException {
542547
assertEmptyStack();
543548

544-
return Core.retrieveXPathQuery(context, getXPath(), limit, offset, sorting);
549+
XPathQuery query = (XPathQuery) Core.createXPathQuery(getXPath()).setAmount(limit).setOffset(offset);
550+
for (Map.Entry<String, String> sort : sorting.entrySet())
551+
query.addSort(sort.getKey(), sort.getValue() == "asc");
552+
return query.execute(context);
545553
}
546554

547555
public List<T> all() throws CoreException {

src/ObjectHandling/javasource/objecthandling/actions/EndTransaction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
package objecthandling.actions;
1111

1212
import com.mendix.systemwideinterfaces.core.IContext;
13-
import com.mendix.webui.CustomJavaAction;
13+
import com.mendix.systemwideinterfaces.core.UserAction;
1414

1515
/**
1616
* Ends the current transaction.
1717
*/
18-
public class EndTransaction extends CustomJavaAction<java.lang.Boolean>
18+
public class EndTransaction extends UserAction<java.lang.Boolean>
1919
{
2020
public EndTransaction(IContext context)
2121
{

src/ObjectHandling/javasource/objecthandling/actions/StartTransaction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
package objecthandling.actions;
1111

1212
import com.mendix.systemwideinterfaces.core.IContext;
13-
import com.mendix.webui.CustomJavaAction;
13+
import com.mendix.systemwideinterfaces.core.UserAction;
1414

1515
/**
1616
* Starts a new transaction.
1717
*/
18-
public class StartTransaction extends CustomJavaAction<java.lang.Boolean>
18+
public class StartTransaction extends UserAction<java.lang.Boolean>
1919
{
2020
public StartTransaction(IContext context)
2121
{

0 commit comments

Comments
 (0)