Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create new pull request #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,48 @@ 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

`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

`property.columnType?contains("TIMESTAMP")`

`property.columnType?cap_first`

#### Update docker image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {

Expand Down Expand Up @@ -76,22 +88,35 @@ public static Map<String, Object> addAuthoringData(GeneratorContext context) {
*/
public static void addCommonDataModelElements(ProjectConfiguration conf, Map<String, Object> 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<String, Object> model, String bPackage,
public static void importPrimaryKeyIfComposed(ProjectConfiguration conf, Map<String, Object> model, String bPackage,
DomainModelElement dme) {
if (dme.getPrimaryKey().isComposed()) {
model.put(IMPORT_PRIMARY_KEY_PROPERTY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void doBeforeProcessDataModelGroup(GeneratorContext context, Map<String,
@Override
public void visitDomainModelElement(ProjectConfiguration pConf, Collection<DomainModelElement> dmElementCollection,
Map<String, Object> propertiesMap, String dmgName, DomainModelElement dmElement, String basePackage) {
dmElement.getPrimaryKey().setGenerationType(pConf.getGlobalGenerationType());
fillEntityControllerJs(pConf, propertiesMap, dmElement);
fillEntityDeleteDialogControllerJs(pConf, propertiesMap, dmElement);
fillEntityDeleteDialogHtml(pConf, propertiesMap, dmElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DomainModelElement> dmElementCollection,
public void visitDomainModelElement(ProjectConfiguration confg, Collection<DomainModelElement> dmElementCollection,
Map<String, Object> 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<String, Object> model, String dmgName, String basePackage,
Expand All @@ -96,12 +83,4 @@ private void fillPrimaryKey(ProjectConfiguration pConf, Map<String, Object> mode
+ pConf.getDomainLayerName() + "/" + dmElement.getPrimaryKey().getType() + ".java");
}
}

private static void importPrimaryKey(ProjectConfiguration pConf, Map<String, Object> model, String basePackage,
DomainModelElement dmElement) {
if (dmElement.getPrimaryKey().isComposed()) {
model.put("importPrimaryKey", formatToImportStatement(basePackage, pConf.getDomainLayerName(),
dmElement.getPrimaryKey().getType()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class RepositoryLayerTask extends AbstractAngularSpringLayerTask {
public void visitDomainModelElement(ProjectConfiguration pConf, Collection<DomainModelElement> dmElementCollection,
Map<String, Object> 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 + "/"
Expand Down

This file was deleted.

Loading