Skip to content

Commit

Permalink
refactoring Repository generator
Browse files Browse the repository at this point in the history
refactoring the repository generator
  • Loading branch information
danimaniarqsoft committed Nov 16, 2017
1 parent 3148b72 commit e02e2b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 87 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand All @@ -63,18 +61,12 @@ public class RestResourceLayerTask extends AbstractAngularSpringLayerTask {
@Override
public void visitDomainModelElement(ProjectConfiguration pConf, Collection<DomainModelElement> dmElementCollection,
Map<String, Object> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,20 +59,28 @@ public class ServiceLayerTask extends AbstractAngularSpringLayerTask {
@Override
public void visitDomainModelElement(ProjectConfiguration pConf, Collection<DomainModelElement> dmElementCollection,
Map<String, Object> 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<String, Object> 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<String, Object> 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");
}
}

0 comments on commit e02e2b3

Please sign in to comment.