branch feature/3768 created (now 7e270b8)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3768 in repository topia. See http://git.nuiton.org/topia.git at 7e270b8 Use LinkedHashSet collection implementation type when unique and orderBy but not ordered This branch includes the following new commits: new 7e270b8 Use LinkedHashSet collection implementation type when unique and orderBy but not ordered The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 7e270b826e265cd47a7d5906c0a346d64b781ea0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 25 15:00:08 2015 +0200 Use LinkedHashSet collection implementation type when unique and orderBy but not ordered -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/3768 in repository topia. See http://git.nuiton.org/topia.git commit 7e270b826e265cd47a7d5906c0a346d64b781ea0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 25 15:00:08 2015 +0200 Use LinkedHashSet collection implementation type when unique and orderBy but not ordered --- .../nuiton/topia/templates/EntityTransformer.java | 8 ++---- .../topia/templates/TopiaTemplateHelper.java | 33 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java index f35c7e4..bea9385 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java @@ -739,10 +739,8 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } else { // List, Set or Collection ? - String collectionInterface = - JavaGeneratorUtil.getCollectionType(attribute).getName(); - String collectionImpl = - JavaGeneratorUtil.getCollectionInstanceType(attribute).getName(); + String collectionInterface = templateHelper.getCollectionType(attribute).getName(); + String collectionImpl = templateHelper.getCollectionInstanceType(attribute).getName(); addImport(outputInterface, collectionInterface); addImport(outputAbstract, collectionInterface); @@ -1855,7 +1853,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { protected String getCollectionType(ObjectModelAttribute attribute) { String result = null; if (!associationClass && GeneratorUtil.isNMultiplicity(attribute)) { - result = JavaGeneratorUtil.getCollectionType(attribute).getName(); + result = templateHelper.getCollectionType(attribute).getName(); } return result; } diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java index 24821ed..ec57837 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java @@ -661,9 +661,9 @@ public class TopiaTemplateHelper { for (ObjectModelAttribute attr : aClass.getAttributes()) { fqns.add(attr.getType()); if (GeneratorUtil.isNMultiplicity(attr)) { - String collectionType = JavaGeneratorUtil.getCollectionType(attr).getName(); + String collectionType = getCollectionType(attr).getName(); fqns.add(collectionType); - String collectionObject = JavaGeneratorUtil.getCollectionInstanceType(attr).getName(); + String collectionObject = getCollectionInstanceType(attr).getName(); fqns.add(collectionObject); } } @@ -681,9 +681,9 @@ public class TopiaTemplateHelper { } fqns.add(attr.getType()); if (GeneratorUtil.isNMultiplicity(attr)) { - String collectionType = JavaGeneratorUtil.getCollectionType(attr).getName(); + String collectionType = getCollectionType(attr).getName(); fqns.add(collectionType); - String collectionObject = JavaGeneratorUtil.getCollectionInstanceType(attr).getName(); + String collectionObject = getCollectionInstanceType(attr).getName(); fqns.add(collectionObject); } } @@ -925,6 +925,31 @@ public class TopiaTemplateHelper { return value; } + public Class<?> getCollectionType(ObjectModelAttribute attribute) { + + Class<?> collectionType = JavaGeneratorUtil.getCollectionType(attribute); + return collectionType; + + } + public Class<?> getCollectionInstanceType(ObjectModelAttribute attribute) { + + boolean unique = EugeneStereoTypes.hasUniqueStereotype(attribute); + boolean ordered = EugeneStereoTypes.hasOrderedStereotype(attribute); + boolean orderBy = topiaTagValues.getOrderByTagValue(attribute) != null; + + Class<?> result; + + if (unique && orderBy && !ordered) { + // Special case, we want to keep the order coming from database + // This does not mean we keep order while saving a such relation + result = LinkedHashSet.class; + } else { + result = JavaGeneratorUtil.getCollectionInstanceType(attribute); + } + return result; + + } + protected <T extends TagValueDefinitionProvider> T getTagValueDefinitionProvider(Class<T> providerType) { TagValueDefinitionProviderManagerExtension extension = model.getExtension( -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm