branch feature/3452 updated (f72b535 -> 314c55b)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3452 in repository topia. See http://git.nuiton.org/topia.git from f72b535 For each entity of the model, generate a indexes.ddl file (refs #3452) new 314c55b Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) 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 314c55b3f8b666b25ad2757e72842f50b991fc0e Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 12:44:06 2015 +0200 Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) Summary of changes: .../templates/EntityHibernateMappingGenerator.java | 17 ++++++--- .../topia/templates/IndexesDdlGenerator.java | 21 +++++++---- .../topia/templates/TopiaTemplateHelper.java | 42 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 12 deletions(-) -- 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/3452 in repository topia. See http://git.nuiton.org/topia.git commit 314c55b3f8b666b25ad2757e72842f50b991fc0e Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 12:44:06 2015 +0200 Improve (see #3674) and fix (see #3675) (when using dbName on reverse attribute) the name of generated index (refs #3452) --- .../templates/EntityHibernateMappingGenerator.java | 17 ++++++--- .../topia/templates/IndexesDdlGenerator.java | 21 +++++++---- .../topia/templates/TopiaTemplateHelper.java | 42 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java index 573f270..eff80cb 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java @@ -269,25 +269,32 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { // add database-object to create and drop index String tableName; - String indexName = "idx_" + clazz.getName() + "_" + attribute.getName(); String propertyName; - if (GeneratorUtil.isNMultiplicity(attribute.getReverseMaxMultiplicity())) { // many to many tableName = templateHelper.getManyToManyTableName(attribute); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } else { // one to many tableName =templateHelper.getDbName(attribute.getClassifier()); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } // add schema if exist (http://nuiton.org/issues/2052) String schema = topiaTagValues.getDbSchemaNameTagValue(clazz, model); - if (StringUtils.isNotEmpty(schema)) { + boolean withSchema = StringUtils.isNotEmpty(schema); + + String indexName = "idx"; + if (withSchema) { + indexName += '_' + schema; + } + indexName += '_' + tableName+ '_' + propertyName ; + indexName = indexName.toLowerCase(); + + if (withSchema) { tableName = schema + "." + tableName; } /*{ <database-object> diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java index 17e2289..97a0370 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/IndexesDdlGenerator.java @@ -68,6 +68,8 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { topiaTagValues = templateHelper.getTopiaTagValues(); } + ObjectModelPackage aPackage = model.getPackage(input); + for (ObjectModelAttribute attribute : input.getAttributes()) { if (!attribute.isNavigable() || attribute.hasAssociationClass() || @@ -81,8 +83,6 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { continue; } - ObjectModelPackage aPackage = model.getPackage(input); - boolean indexForeignKeys = topiaTagValues.getIndexForeignKeysTagValue(attribute, aPackage, model); @@ -95,25 +95,32 @@ public class IndexesDdlGenerator extends ObjectModelGenerator { // add database-object to create and drop index String tableName; - String indexName = "idx_" + input.getName() + "_" + attribute.getName(); String propertyName; - if (GeneratorUtil.isNMultiplicity(attribute.getReverseMaxMultiplicity())) { // many to many tableName = templateHelper.getManyToManyTableName(attribute); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } else { // one to many tableName =templateHelper.getDbName(attribute.getClassifier()); - propertyName = templateHelper.getDbName(attribute.getReverseAttribute()); + propertyName = templateHelper.getReverseDbNameOnReverseAttribute(attribute); } // add schema if exist (http://nuiton.org/issues/2052) String schema = topiaTagValues.getDbSchemaNameTagValue(input, model); - if (StringUtils.isNotEmpty(schema)) { + boolean withSchema = StringUtils.isNotEmpty(schema); + + String indexName = "idx"; + if (withSchema) { + indexName += '_' + schema; + } + indexName += '_' + tableName+ '_' + propertyName ; + indexName = indexName.toLowerCase(); + + if (withSchema) { tableName = schema + "." + tableName; } /*{ 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 1d0020d..38e7fd6 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 @@ -266,6 +266,48 @@ public class TopiaTemplateHelper { } /** + * Obtain the reverse db name of a reverse attribute. + * + * <strong>Note that the reverse attribute can't be null here.</strong> + * <ul> + * <li>Try first to get the reverse db Name from the ReverseDbname tag-value</li> + * <li>If not found, try then the ReverseDbname tag-value on the same attribute but from this other side of the relation</li> + * <li>If not found, try then just get the name of the reverse attribute name</li> + * </ul> + * @param attr the attribute to seek + * @return the value of the reverse db name on the revser attribute + * @since 2.9.5.2 + * @deprecated Eugene should deal with this + */ + @Deprecated + public String getReverseDbNameOnReverseAttribute(ObjectModelAttribute attr) { + + ObjectModelAttribute reverseAttribute = attr.getReverseAttribute(); + + if (reverseAttribute == null) { + throw new IllegalArgumentException("The reverse attribute can't be null, but was on " + attr); + } + + String result = topiaTagValues.findDirectTagValue(TopiaTagValues.TAG_REVERSE_DB_NAME, reverseAttribute); + if (StringUtils.isEmpty(result)) { + + // Try to get it from the other site of the relation + ObjectModelAttribute reverseAttribute2 = reverseAttribute.getClassifier().getAttribute(attr.getName()); + result = topiaTagValues.findDirectTagValue(TopiaTagValues.TAG_REVERSE_DB_NAME, reverseAttribute2); + + } + + if (StringUtils.isEmpty(result)) { + + result = GeneratorUtil.toLowerCaseFirstLetter(reverseAttribute.getName()); + + } + + return result; + + } + + /** * Renvoie le nom BD de l'élement passé en paramètre. Elle se base sur le * tag associé si il existe, sinon sur le nom de l'élément * -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm