From afb541c6edc0be757293566d8cd92ca67ce67a20 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Pichardo Date: Wed, 15 Nov 2017 22:20:13 -0600 Subject: [PATCH 1/4] updatin README updating README --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e8fe5c5..92e1d83 100644 --- a/README.md +++ b/README.md @@ -52,17 +52,17 @@ Para hacer los pasos anteriores con un unico comando: #### Entity-Properties -`property.name`: the name of the property in camelCase format -`property.qualifiedName`: the qualifiedName in java world -`property.columnType`: the type of the property in the datamodel representation -`property.blob`: true if the property is blob, false otherwise -`property.time`: true if the property is time, false otherwise -`property.clob`: true if the property is clob, false otherwise -`property.bigDecimal`: true if the property is bigDecimal, false otherwise -`property.localDate`: true if the property is localDate, false otherwise -`property.instant`: true if the property is instant, false otherwise -`property.zoneDateTime`: true if the property is zoneDateTime, false otherwise - +`property.name`: the name of the property in camelCase format +`property.qualifiedName`: the qualifiedName in java world +`property.columnType`: the type of the property in the datamodel representation +`property.blob`: true if the property is blob, false otherwise +`property.time`: true if the property is time, false otherwise +`property.clob`: true if the property is clob, false otherwise +`property.bigDecimal`: true if the property is bigDecimal, false otherwise +`property.localDate`: true if the property is localDate, false otherwise +`property.instant`: true if the property is instant, false otherwise +`property.zoneDateTime`: true if the property is zoneDateTime, false otherwise + ### template quick reference From 087265c0acf1f31a0b5f0593a91629be34083206 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Pichardo Date: Wed, 15 Nov 2017 22:23:56 -0600 Subject: [PATCH 2/4] README README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 92e1d83..79b97aa 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,19 @@ Para hacer los pasos anteriores con un unico comando: #### Entity `entity`: Name of the entity + `entityHyphenNotation`: hyphen notation of the entity + `entityHyphenNotationPlural`: hyphen notation in plural format of the entity + `entityCamelCase`: entity in camel-case notation + `entityCamelCasePlural`: entity in camel-case plural format + `hasBlobProperties`: true if the entity has blob properties, false otherwise + `hasTimeProperties`: true if the entity has time properties, false otherwise + `hasLocalDate`: true if the entity has LocalDate properties, false otherwise #### Entity-Properties From 3148b726f02daa0a035afdee054eb5a85a918537 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Pichardo Date: Thu, 16 Nov 2017 01:55:11 -0600 Subject: [PATCH 3/4] refactoring the overall engine refactoring engine service --- README.md | 10 +++ .../engine/service/layers/LayerUtils.java | 79 ++++++++++++------- .../angularspring/AngularLayerTask.java | 1 - .../layers/angularspring/ModelLayerTask.java | 31 ++------ .../angularspring/RepositoryLayerTask.java | 3 +- 5 files changed, 69 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 79b97aa..c519037 100644 --- a/README.md +++ b/README.md @@ -60,20 +60,30 @@ Para hacer los pasos anteriores con un unico comando: #### Entity-Properties `property.name`: the name of the property in camelCase format + `property.qualifiedName`: the qualifiedName in java world + `property.columnType`: the type of the property in the datamodel representation + `property.blob`: true if the property is blob, false otherwise + `property.time`: true if the property is time, false otherwise + `property.clob`: true if the property is clob, false otherwise + `property.bigDecimal`: true if the property is bigDecimal, false otherwise + `property.localDate`: true if the property is localDate, false otherwise + `property.instant`: true if the property is instant, false otherwise + `property.zoneDateTime`: true if the property is zoneDateTime, false otherwise ### template quick reference `property.columnType?contains("TIMESTAMP")` + `property.columnType?cap_first` #### Update docker image diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/LayerUtils.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/LayerUtils.java index 20902f7..ce49ada 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/LayerUtils.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/LayerUtils.java @@ -5,11 +5,11 @@ import java.util.HashMap; import java.util.Map; -import java.util.Optional; import mx.infotec.dads.kukulkan.engine.domain.core.DomainModelElement; import mx.infotec.dads.kukulkan.engine.domain.core.GeneratorContext; import mx.infotec.dads.kukulkan.engine.domain.core.ProjectConfiguration; +import mx.infotec.dads.kukulkan.util.NameConventions; /** * LayerUtils @@ -19,30 +19,42 @@ */ public class LayerUtils { + public static final String URL_NAME_PROPERTY = "urlName"; + public static final String IMPORT_REPOSITORY_PROPERTY = "importRepository"; + public static final String IMPORT_SERVICE_PROPERTY = "importService"; /** * Authoring Properties */ - private static final String YEAR_PROPERTY = "year"; - private static final String AUTHOR_PROPERTY = "author"; - private static final String IS_MONGO_PROPERTY = "isMongoDB"; - private static final String PROJECT_NAME_PROPERTY = "projectName"; - private static final String DATA_MODEL_GROUP_PROPERTY = "dataModelGroup"; + public static final String YEAR_PROPERTY = "year"; + public static final String AUTHOR_PROPERTY = "author"; + public static final String IS_MONGO_PROPERTY = "isMongoDB"; + public static final String PROJECT_NAME_PROPERTY = "projectName"; + public static final String DATA_MODEL_GROUP_PROPERTY = "dataModelGroup"; /** * Common Properties per Element */ - private static final String ID_PROPERTY = "id"; - private static final String ENTITY_PROPERTY = "entity"; - private static final String ENTITY_CAMEL_CASE_PROPERTY = "entityCamelCase"; - private static final String ENTITY_CAMEL_CASE_PLURAL_PROPERTY = "entityCamelCasePlural"; - private static final String ENTITY_HYPHEN_NOTATION_PLURAL_PROPERTY = "entityHyphenNotationPlural"; - private static final String ENTITY_HYPHEN_NOTATION_PROPERTY = "entityHyphenNotation"; - private static final String IMPORT_PRIMARY_KEY_PROPERTY = "importPrimaryKey"; - private static final String IMPORT_MODEL_PROPERTY = "importModel"; - private static final String PRIMARY_KEY_PROPERTY = "primaryKey"; - private static final String PROPERTIES_PROPERTY = "properties"; - private static final String HAS_BLOB_PROPERTIES_PROPERTY = "hasBlobProperties"; - private static final String HAS_LOCAL_DATE_PROPERTY = "hasLocalDate"; - private static final String HAS_TIME_PROPERTIES_PROPERTY = "hasTimeProperties"; + public static final String HAS_BLOB_PROPERTIES_PROPERTY = "hasBlobProperties"; + public static final String HAS_LOCAL_DATE_PROPERTY = "hasLocalDate"; + public static final String HAS_TIME_PROPERTIES_PROPERTY = "hasTimeProperties"; + public static final String HAS_BIG_DECIMAL_PROPERTY = "hasBigDecimal"; + public static final String HAS_ZONE_DATE_TIME_PROPERTY = "hasZoneDateTime"; + public static final String HAS_INSTANT_PROPERTY = "hasInstant"; + public static final String HAS_CONSTRAINTS_PROPERTY = "hasConstraints"; + public static final String TABLE_NAME_PROPERTY = "tableName"; + public static final String PACKAGE_PROPERTY = "package"; + public static final String PACKAGE_SIMPLE_FORMAT_PROPERTY = "packageSimpleFormat"; + public static final String PACKAGE_IMPL_PROPERTY = "packageImpl"; + public static final String IMPORTS_PROPERTY = "imports"; + public static final String IMPORT_PRIMARY_KEY_PROPERTY = "importPrimaryKey"; + public static final String IMPORT_MODEL_PROPERTY = "importModel"; + public static final String ENTITY_PROPERTY = "entity"; + public static final String ENTITY_CAMEL_CASE_PROPERTY = "entityCamelCase"; + public static final String ENTITY_CAMEL_CASE_PLURAL_PROPERTY = "entityCamelCasePlural"; + public static final String ENTITY_HYPHEN_NOTATION_PLURAL_PROPERTY = "entityHyphenNotationPlural"; + public static final String ENTITY_HYPHEN_NOTATION_PROPERTY = "entityHyphenNotation"; + public static final String ID_PROPERTY = "id"; + public static final String PRIMARY_KEY_PROPERTY = "primaryKey"; + public static final String PROPERTIES_PROPERTY = "properties"; private LayerUtils() { @@ -76,22 +88,35 @@ public static Map addAuthoringData(GeneratorContext context) { */ public static void addCommonDataModelElements(ProjectConfiguration conf, Map map, String bPackage, DomainModelElement dme) { + map.put(HAS_TIME_PROPERTIES_PROPERTY, dme.isHasTimeProperties()); + map.put(HAS_LOCAL_DATE_PROPERTY, dme.isHasLocalDate()); + map.put(HAS_BLOB_PROPERTIES_PROPERTY, dme.isHasBlobProperties()); + map.put(HAS_CONSTRAINTS_PROPERTY, dme.isHasConstraints()); + map.put(HAS_INSTANT_PROPERTY, dme.isHasInstant()); + map.put(HAS_ZONE_DATE_TIME_PROPERTY, dme.isHasZoneDateTime()); + map.put(HAS_BIG_DECIMAL_PROPERTY, dme.isHasBigDecimal()); + map.put(URL_NAME_PROPERTY, dme.getCamelCaseFormat()); + map.put(TABLE_NAME_PROPERTY, dme.getTableName()); + map.put(PACKAGE_PROPERTY, null);// must be provided in individual files + map.put(IMPORTS_PROPERTY, dme.getImports()); + map.put(IMPORT_SERVICE_PROPERTY, + formatToImportStatement(bPackage, conf.getServiceLayerName(), dme.getName() + NameConventions.SERVICE)); + map.put(IMPORT_REPOSITORY_PROPERTY, + formatToImportStatement(bPackage, conf.getDaoLayerName(), dme.getName() + NameConventions.DAO)); map.put(IMPORT_MODEL_PROPERTY, formatToImportStatement(bPackage, conf.getDomainLayerName(), dme.getName())); + importPrimaryKeyIfComposed(conf, map, bPackage, dme); map.put(ENTITY_CAMEL_CASE_PROPERTY, dme.getCamelCaseFormat()); map.put(ENTITY_PROPERTY, dme.getName()); - map.put(ID_PROPERTY, dme.getPrimaryKey().getType()); - addPrimaryKeyIfComposed(conf, map, bPackage, dme); - map.put(PROPERTIES_PROPERTY, dme.getProperties()); - map.put(PRIMARY_KEY_PROPERTY, dme.getPrimaryKey()); map.put(ENTITY_HYPHEN_NOTATION_PROPERTY, camelCaseToHyphens(dme.getCamelCaseFormat())); map.put(ENTITY_HYPHEN_NOTATION_PLURAL_PROPERTY, camelCaseToHyphens(dme.getCamelCasePluralFormat())); map.put(ENTITY_CAMEL_CASE_PLURAL_PROPERTY, dme.getCamelCasePluralFormat()); - map.put(HAS_TIME_PROPERTIES_PROPERTY, dme.isHasTimeProperties()); - map.put(HAS_LOCAL_DATE_PROPERTY, dme.isHasLocalDate()); - map.put(HAS_BLOB_PROPERTIES_PROPERTY, dme.isHasBlobProperties()); + map.put(ID_PROPERTY, dme.getPrimaryKey().getType()); + dme.getPrimaryKey().setGenerationType(conf.getGlobalGenerationType()); + map.put(PRIMARY_KEY_PROPERTY, dme.getPrimaryKey()); + map.put(PROPERTIES_PROPERTY, dme.getProperties()); } - public static void addPrimaryKeyIfComposed(ProjectConfiguration conf, Map model, String bPackage, + public static void importPrimaryKeyIfComposed(ProjectConfiguration conf, Map model, String bPackage, DomainModelElement dme) { if (dme.getPrimaryKey().isComposed()) { model.put(IMPORT_PRIMARY_KEY_PROPERTY, diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/AngularLayerTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/AngularLayerTask.java index 1596e28..7092d8f 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/AngularLayerTask.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/AngularLayerTask.java @@ -66,7 +66,6 @@ public void doBeforeProcessDataModelGroup(GeneratorContext context, Map dmElementCollection, Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { - dmElement.getPrimaryKey().setGenerationType(pConf.getGlobalGenerationType()); fillEntityControllerJs(pConf, propertiesMap, dmElement); fillEntityDeleteDialogControllerJs(pConf, propertiesMap, dmElement); fillEntityDeleteDialogHtml(pConf, propertiesMap, dmElement); diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ModelLayerTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ModelLayerTask.java index 3e9c8f3..c0e645f 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ModelLayerTask.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ModelLayerTask.java @@ -23,7 +23,7 @@ */ package mx.infotec.dads.kukulkan.engine.service.layers.angularspring; -import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToImportStatement; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_PROPERTY; import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToPackageStatement; import java.util.Collection; @@ -54,25 +54,12 @@ public class ModelLayerTask extends AbstractAngularSpringLayerTask { private static final Logger LOGGER = LoggerFactory.getLogger(ModelLayerTask.class); @Override - public void visitDomainModelElement(ProjectConfiguration pConf, Collection dmElementCollection, + public void visitDomainModelElement(ProjectConfiguration confg, Collection dmElementCollection, Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { LOGGER.debug("visitDomainModelElement for {}", basePackage); - propertiesMap.put("id", dmElement.getPrimaryKey().getType()); - propertiesMap.put("tableName", dmElement.getTableName()); - propertiesMap.put("entity", dmElement.getName()); - propertiesMap.put("hasConstraints", dmElement.isHasConstraints()); - propertiesMap.put("hasInstant", dmElement.isHasInstant()); - propertiesMap.put("hasLocalDate", dmElement.isHasLocalDate()); - propertiesMap.put("hasZoneDateTime", dmElement.isHasZoneDateTime()); - propertiesMap.put("hasBigDecimal", dmElement.isHasBigDecimal()); - importPrimaryKey(pConf, propertiesMap, basePackage, dmElement); - propertiesMap.put("package", formatToPackageStatement(false, basePackage, pConf.getDomainLayerName())); - propertiesMap.put("properties", dmElement.getProperties()); - dmElement.getPrimaryKey().setGenerationType(pConf.getGlobalGenerationType()); - propertiesMap.put("primaryKey", dmElement.getPrimaryKey()); - propertiesMap.put("imports", dmElement.getImports()); - fillModel(pConf, propertiesMap, dmgName, basePackage, dmElement); - fillPrimaryKey(pConf, propertiesMap, dmgName, basePackage, dmElement); + propertiesMap.put(PACKAGE_PROPERTY, formatToPackageStatement(false, basePackage, confg.getDomainLayerName())); + fillModel(confg, propertiesMap, dmgName, basePackage, dmElement); + fillPrimaryKey(confg, propertiesMap, dmgName, basePackage, dmElement); } private void fillModel(ProjectConfiguration pConf, Map model, String dmgName, String basePackage, @@ -96,12 +83,4 @@ private void fillPrimaryKey(ProjectConfiguration pConf, Map mode + pConf.getDomainLayerName() + "/" + dmElement.getPrimaryKey().getType() + ".java"); } } - - private static void importPrimaryKey(ProjectConfiguration pConf, Map model, String basePackage, - DomainModelElement dmElement) { - if (dmElement.getPrimaryKey().isComposed()) { - model.put("importPrimaryKey", formatToImportStatement(basePackage, pConf.getDomainLayerName(), - dmElement.getPrimaryKey().getType())); - } - } } diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTask.java index cc8971b..1d4f89e 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTask.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTask.java @@ -23,6 +23,7 @@ */ package mx.infotec.dads.kukulkan.engine.service.layers.angularspring; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_PROPERTY; import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToPackageStatement; import java.util.Collection; @@ -58,7 +59,7 @@ public class RepositoryLayerTask extends AbstractAngularSpringLayerTask { public void visitDomainModelElement(ProjectConfiguration pConf, Collection dmElementCollection, Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { LOGGER.debug("repositoryLayerTask for dommain"); - propertiesMap.put("package", formatToPackageStatement(basePackage, pConf.getDaoLayerName())); + propertiesMap.put(PACKAGE_PROPERTY, formatToPackageStatement(basePackage, pConf.getDaoLayerName())); templateService.fillModel(dmElement, pConf.getId(), LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/repository.ftl", propertiesMap, BasePathEnum.SRC_MAIN_JAVA, basePackage.replace('.', '/') + "/" + dmgName + "/" From e02e2b33f66143bdc823a9e3368478ccd3af035f Mon Sep 17 00:00:00 2001 From: Daniel Cortes Pichardo Date: Thu, 16 Nov 2017 01:55:42 -0600 Subject: [PATCH 4/4] refactoring Repository generator refactoring the repository generator --- .../RepositoryLayerTestTask.java | 60 ------------------- .../angularspring/RestResourceLayerTask.java | 24 +++----- .../angularspring/ServiceLayerTask.java | 31 ++++++---- 3 files changed, 28 insertions(+), 87 deletions(-) delete mode 100644 src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTestTask.java diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTestTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTestTask.java deleted file mode 100644 index 1c0ef13..0000000 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RepositoryLayerTestTask.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * The MIT License (MIT) - * Copyright (c) 2016 Daniel Cortes Pichardo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package mx.infotec.dads.kukulkan.engine.service.layers.angularspring; - -import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToPackageStatement; - -import java.util.Collection; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; - -import mx.infotec.dads.kukulkan.engine.domain.core.DomainModelElement; -import mx.infotec.dads.kukulkan.engine.domain.core.ProjectConfiguration; -import mx.infotec.dads.kukulkan.engine.service.layers.springrest.util.LayerConstants; -import mx.infotec.dads.kukulkan.templating.service.TemplateService; -import mx.infotec.dads.kukulkan.util.BasePathEnum; - -/** - * Repository Layer Test Task - * - * @author Daniel Cortes Pichardo - * - */ -public class RepositoryLayerTestTask extends AbstractAngularSpringLayerTask { - - @Autowired - private TemplateService templateService; - - @Override - public void visitDomainModelElement(ProjectConfiguration pConf, Collection dmElementCollection, - Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { - propertiesMap.put("package", formatToPackageStatement(basePackage, pConf.getDaoLayerName())); - templateService.fillModel(dmElement, pConf.getId(), - LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/repository.ftl", propertiesMap, - BasePathEnum.SRC_TEST_JAVA, basePackage.replace('.', '/') + "/" + dmgName + "/" - + pConf.getDaoLayerName() + "/" + dmElement.getName() + "Repository.java"); - } - -} diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RestResourceLayerTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RestResourceLayerTask.java index 685a778..7465a67 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RestResourceLayerTask.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/RestResourceLayerTask.java @@ -23,8 +23,11 @@ */ package mx.infotec.dads.kukulkan.engine.service.layers.angularspring; -import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToImportStatement; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_PROPERTY; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_SIMPLE_FORMAT_PROPERTY; import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToPackageStatement; +import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.replaceDotBySlash; +import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.replaceSlashByDot; import java.util.Collection; import java.util.Map; @@ -36,14 +39,9 @@ import mx.infotec.dads.kukulkan.engine.domain.core.DomainModelElement; import mx.infotec.dads.kukulkan.engine.domain.core.ProjectConfiguration; -import mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils; import mx.infotec.dads.kukulkan.engine.service.layers.springrest.util.LayerConstants; import mx.infotec.dads.kukulkan.templating.service.TemplateService; import mx.infotec.dads.kukulkan.util.BasePathEnum; -import mx.infotec.dads.kukulkan.util.InflectorProcessor; - -import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.addCommonDataModelElements; -import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.*; import mx.infotec.dads.kukulkan.util.NameConventions; /** @@ -63,18 +61,12 @@ public class RestResourceLayerTask extends AbstractAngularSpringLayerTask { @Override public void visitDomainModelElement(ProjectConfiguration pConf, Collection dmElementCollection, Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { + LOGGER.debug("visitDomainModelElement {} ", basePackage); String webLayerDotFormat = replaceSlashByDot(pConf.getWebLayerName()); String webLayerSlashFormat = replaceDotBySlash(pConf.getWebLayerName()); - propertiesMap.put("package", formatToPackageStatement(basePackage, webLayerDotFormat)); - propertiesMap.put("packageSimpleFormat", formatToPackageStatement(true, basePackage, webLayerDotFormat)); - propertiesMap.put("importRepository", formatToImportStatement(basePackage, pConf.getDaoLayerName(), - dmElement.getName() + NameConventions.DAO)); - propertiesMap.put("importService", formatToImportStatement(basePackage, pConf.getServiceLayerName(), - dmElement.getName() + NameConventions.SERVICE)); - propertiesMap.put("entityCamelCasePlural", - InflectorProcessor.getInstance().pluralize(dmElement.getCamelCaseFormat())); - propertiesMap.put("urlName", dmElement.getCamelCaseFormat()); - propertiesMap.put("primaryKey", dmElement.getPrimaryKey()); + propertiesMap.put(PACKAGE_PROPERTY, formatToPackageStatement(basePackage, webLayerDotFormat)); + propertiesMap.put(PACKAGE_SIMPLE_FORMAT_PROPERTY, + formatToPackageStatement(true, basePackage, webLayerDotFormat)); templateService.fillModel(dmElement, pConf.getId(), LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/restResource.ftl", propertiesMap, BasePathEnum.SRC_MAIN_JAVA, basePackage.replace('.', '/') + "/" + dmgName + "/" + webLayerSlashFormat diff --git a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ServiceLayerTask.java b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ServiceLayerTask.java index 2ada2df..68cf8a0 100644 --- a/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ServiceLayerTask.java +++ b/src/main/java/mx/infotec/dads/kukulkan/engine/service/layers/angularspring/ServiceLayerTask.java @@ -23,7 +23,8 @@ */ package mx.infotec.dads.kukulkan.engine.service.layers.angularspring; -import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToImportStatement; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_IMPL_PROPERTY; +import static mx.infotec.dads.kukulkan.engine.service.layers.LayerUtils.PACKAGE_PROPERTY; import static mx.infotec.dads.kukulkan.util.JavaFileNameParser.formatToPackageStatement; import java.util.Collection; @@ -58,20 +59,28 @@ public class ServiceLayerTask extends AbstractAngularSpringLayerTask { @Override public void visitDomainModelElement(ProjectConfiguration pConf, Collection dmElementCollection, Map propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) { - propertiesMap.put("package", formatToPackageStatement(basePackage, pConf.getServiceLayerName())); - propertiesMap.put("packageImpl", formatToPackageStatement(basePackage, pConf.getServiceLayerName(), "impl")); - propertiesMap.put("importRepository", formatToImportStatement(basePackage, pConf.getDaoLayerName(), - dmElement.getName() + NameConventions.DAO)); - propertiesMap.put("importService", formatToImportStatement(basePackage, pConf.getServiceLayerName(), - dmElement.getName() + NameConventions.SERVICE)); - templateService.fillModel(dmElement, pConf.getId(), - LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/service.ftl", propertiesMap, BasePathEnum.SRC_MAIN_JAVA, - basePackage.replace('.', '/') + "/" + dmgName + "/" + pConf.getServiceLayerName() + "/" - + dmElement.getName() + NameConventions.SERVICE + ".java"); + LOGGER.debug("visitDomainModelElement: {} ", basePackage); + propertiesMap.put(PACKAGE_PROPERTY, formatToPackageStatement(basePackage, pConf.getServiceLayerName())); + propertiesMap.put(PACKAGE_IMPL_PROPERTY, + formatToPackageStatement(basePackage, pConf.getServiceLayerName(), "impl")); + fillServiceModel(pConf, propertiesMap, dmgName, dmElement, basePackage); + fillServiceImplModel(pConf, propertiesMap, dmgName, dmElement, basePackage); + } + + public void fillServiceImplModel(ProjectConfiguration pConf, Map propertiesMap, String dmgName, + DomainModelElement dmElement, String basePackage) { templateService.fillModel(dmElement, pConf.getId(), LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/serviceImpl.ftl", propertiesMap, BasePathEnum.SRC_MAIN_JAVA, basePackage.replace('.', '/') + "/" + dmgName + "/" + pConf.getServiceLayerName() + "/impl/" + dmElement.getName() + NameConventions.SERVICE_IMPLEMENTS + ".java"); } + + public void fillServiceModel(ProjectConfiguration pConf, Map propertiesMap, String dmgName, + DomainModelElement dmElement, String basePackage) { + templateService.fillModel(dmElement, pConf.getId(), + LayerConstants.REST_SPRING_JPA_BACK_END_URL + "/service.ftl", propertiesMap, BasePathEnum.SRC_MAIN_JAVA, + basePackage.replace('.', '/') + "/" + dmgName + "/" + pConf.getServiceLayerName() + "/" + + dmElement.getName() + NameConventions.SERVICE + ".java"); + } }