Skip to content

Commit e79e5ae

Browse files
authored
Merge pull request #159 from mendix/run/4308-optionally-skip-1-to-1-assocs-in-cloneobject
[RUN-4308] Add overload to ORM.cloneObject that can be used to skip 1-on-1 associations
2 parents 1873923 + 253c1b7 commit e79e5ae

File tree

2 files changed

+11
-1
lines changed
  • marketplace/release-notes
  • src/CommunityCommons/javasource/communitycommons

2 files changed

+11
-1
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- The StringFromFile Java action now removes BOM from strings. (Ticket #242904)
22
- We have upgraded the Guava dependency to 33.4.7. This also removes the dependency on the jsr305 version 3.0.2 dependency, which causes some code quality scanning tools to report issues.
33
- We have added a warning about possible deadlocks to the commitInSeparateDatabaseTransaction Java action.
4-
- We added the objectHasChangedMemberValue and memberHasChangedValue Java actions. These actions can be used to check if an object or member has a changed value that is different from the original value.
4+
- We added the objectHasChangedMemberValue and memberHasChangedValue Java actions. These actions can be used to check if an object or member has a changed value that is different from the original value.
5+
- We added the ORM.cloneObject(IContext, IMendixObject, IMendixObject, Boolean, Boolean) method. This is an overload for the ORM.cloneObject with an extra Boolean parameter 'skipIsBoth' that can be used to skip 1-on-1 associations.

src/CommunityCommons/javasource/communitycommons/ORM.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ private static boolean isFileDocument(IMendixObject object) {
276276

277277
public static Boolean cloneObject(IContext c, IMendixObject source,
278278
IMendixObject target, Boolean withAssociations) {
279+
return cloneObject(c, source, target, withAssociations, false);
280+
}
281+
282+
public static Boolean cloneObject(IContext c, IMendixObject source,
283+
IMendixObject target, Boolean withAssociations, Boolean skipIsBoth) {
279284
Map<String, ? extends IMendixObjectMember<?>> members = source.getMembers(c);
280285

281286
for (var entry : members.entrySet()) {
@@ -290,6 +295,10 @@ public static Boolean cloneObject(IContext c, IMendixObject source,
290295
continue;
291296
}
292297
if (withAssociations || ((!(m instanceof MendixObjectReference) && !(m instanceof MendixObjectReferenceSet) && !(m instanceof MendixAutoNumber)))) {
298+
if (skipIsBoth && (
299+
(m instanceof MendixObjectReference && ((MendixObjectReference) m).isBoth()) ||
300+
(m instanceof MendixObjectReferenceSet && ((MendixObjectReferenceSet) m).isBoth())))
301+
continue;
293302
target.setValue(c, entry.getKey(), m.getValue(c));
294303
}
295304
}

0 commit comments

Comments
 (0)