use of io.vertigo.util.MapBuilder in project vertigo by KleeGroup.
the class TaskGeneratorPlugin method generateDao.
/**
* Génération d'un DAO c'est à dire des taches afférentes à un objet.
*/
private static void generateDao(final String targetSubDir, final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder, final DtDefinition dtDefinition, final Collection<TaskDefinition> taskDefinitions) {
final DAOModel daoModel = new DAOModel(fileGeneratorConfig, dtDefinition, taskDefinitions);
final Map<String, Object> model = new MapBuilder<String, Object>().put("dao", daoModel).build();
FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName(daoModel.getClassSimpleName() + ".java").withGenSubDir(targetSubDir).withPackageName(daoModel.getPackageName()).withTemplateName("task/template/dao.ftl").build().generateFile(mdaResultBuilder);
}
use of io.vertigo.util.MapBuilder in project vertigo by KleeGroup.
the class TaskGeneratorPlugin method generatePao.
/**
* Génération d'un PAO c'est à dire des taches afférentes à un package.
*/
private static void generatePao(final String targetSubDir, final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder, final Collection<TaskDefinition> taskDefinitionCollection, final String packageName) {
final PAOModel paoModel = new PAOModel(fileGeneratorConfig, taskDefinitionCollection, packageName);
final Map<String, Object> model = new MapBuilder<String, Object>().put("pao", paoModel).build();
FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName(paoModel.getClassSimpleName() + ".java").withGenSubDir(targetSubDir).withPackageName(paoModel.getPackageName()).withTemplateName("task/template/pao.ftl").build().generateFile(mdaResultBuilder);
}
use of io.vertigo.util.MapBuilder in project vertigo by KleeGroup.
the class DomainGeneratorPlugin method generateJavaEnum.
private void generateJavaEnum(final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder, final DtDefinition dtDefinition, final Map<String, MasterDataValue> values) {
final MasterDataDefinitionModel masterDataDefinitionModel = new MasterDataDefinitionModel(dtDefinition, values);
final Map<String, Object> model = new MapBuilder<String, Object>().put("entity", masterDataDefinitionModel).build();
FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName(masterDataDefinitionModel.getClassSimpleName() + "Enum.java").withGenSubDir(targetSubDir).withPackageName(dtDefinition.getPackageName()).withTemplateName("domain/java/template/masterdata_enum.ftl").build().generateFile(mdaResultBuilder);
}
use of io.vertigo.util.MapBuilder in project vertigo by KleeGroup.
the class Studio method start.
/**
* Start method of the server
*/
public void start() {
Spark.exception(Exception.class, (e, request, response) -> {
response.status(500);
LOGGER.error("studio : error on render ", e);
response.body(e.getMessage());
});
Spark.get("/studio", (request, response) -> {
final MdaResult mdaResult = null;
return display(response, mdaResult);
});
Spark.get("/grammar", (request, response) -> {
final MdaResult mdaResult = null;
return grammar(response, mdaResult);
});
Spark.get("/studio/definitions/:definitionName", (request, response) -> {
final String defintionName = request.params(":definitionName");
final Map<String, Object> model = new MapBuilder<String, Object>().put("definition", getDefinition(defintionName)).build();
return render(response, "template/definition.ftl", model);
});
Spark.get("/generate", (request, response) -> {
final MdaResult mdaResult = generate();
return display(response, mdaResult);
});
Spark.get("/clean", (request, response) -> {
final MdaResult mdaResult = clean();
return display(response, mdaResult);
});
Spark.get("/graph", (request, response) -> {
final ListBuilder<Vertex> verticlesBuilder = new ListBuilder<>();
final ListBuilder<Definition> edgesBuilders = new ListBuilder<>();
edgesBuilders.addAll(app.getDefinitionSpace().getAll(DtDefinition.class));
for (final AssociationNNDefinition associationDefinition1 : app.getDefinitionSpace().getAll(AssociationNNDefinition.class)) {
verticlesBuilder.add(new Vertex(associationDefinition1.getAssociationNodeA().getDtDefinition(), associationDefinition1.getAssociationNodeB().getDtDefinition()));
}
for (final AssociationSimpleDefinition associationDefinition2 : app.getDefinitionSpace().getAll(AssociationSimpleDefinition.class)) {
verticlesBuilder.add(new Vertex(associationDefinition2.getAssociationNodeA().getDtDefinition(), associationDefinition2.getAssociationNodeB().getDtDefinition()));
}
// for (final Domain domain : app.getDefinitionSpace().getAll(Domain.class)) {
// // verticlesBuilder.add(new Vertex(domain.getFormatter(), domain));
// for (final DefinitionReference<ConstraintDefinition> constraintDefinitionRef : domain.getConstraintDefinitionRefs()) {
// verticlesBuilder.add(new Vertex(constraintDefinitionRef.get(), domain));
// }
// }
// edgesBuilders.addAll(app.getDefinitionSpace().getAll(ConstraintDefinition.class));
// edgesBuilders.addAll(app.getDefinitionSpace().getAll(Domain.class));
final Map<String, Object> model = new MapBuilder<String, Object>().put("edges", edgesBuilders.build()).put("verticles", verticlesBuilder.build()).build();
return render(response, "template/graph.ftl", model);
});
}
use of io.vertigo.util.MapBuilder in project vertigo by KleeGroup.
the class TSGeneratorPlugin method generateTsMasterData.
private void generateTsMasterData(final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder) {
final MasterDataValues masterDataValues = masterDataManagerOpt.isPresent() ? masterDataManagerOpt.get().getValues() : new MasterDataValues();
final List<TSMasterDataDefinitionModel> tsMasterDataDefinitionModels = Home.getApp().getDefinitionSpace().getAll(DtDefinition.class).stream().filter(dtDefinition -> dtDefinition.getStereotype() == DtStereotype.StaticMasterData).map(dtDefinition -> new TSMasterDataDefinitionModel(dtDefinition, masterDataValues.getOrDefault(dtDefinition.getClassCanonicalName(), Collections.emptyMap()))).collect(Collectors.toList());
final Map<String, Object> model = new MapBuilder<String, Object>().put("masterdatas", tsMasterDataDefinitionModels).build();
FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName("masterdata.ts").withGenSubDir(targetSubDir).withPackageName("").withTemplateName("domain/ts/template/ts_masterdata.ftl").build().generateFile(mdaResultBuilder);
}
Aggregations