Search in sources :

Example 1 with MapBuilder

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);
}
Also used : DAOModel(io.vertigo.studio.plugins.mda.task.model.DAOModel) MapBuilder(io.vertigo.util.MapBuilder)

Example 2 with MapBuilder

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);
}
Also used : PAOModel(io.vertigo.studio.plugins.mda.task.model.PAOModel) MapBuilder(io.vertigo.util.MapBuilder)

Example 3 with MapBuilder

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);
}
Also used : MapBuilder(io.vertigo.util.MapBuilder) MasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.java.model.masterdata.MasterDataDefinitionModel)

Example 4 with MapBuilder

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);
    });
}
Also used : AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Definition(io.vertigo.core.definition.Definition) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) MapBuilder(io.vertigo.util.MapBuilder) ListBuilder(io.vertigo.util.ListBuilder) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) MdaResult(io.vertigo.studio.mda.MdaResult)

Example 5 with MapBuilder

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);
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtStereotype(io.vertigo.dynamo.domain.metamodel.DtStereotype) MapBuilder(io.vertigo.util.MapBuilder) TSDtDefinitionModel(io.vertigo.studio.plugins.mda.domain.ts.model.TSDtDefinitionModel) HashMap(java.util.HashMap) FileGeneratorConfig(io.vertigo.studio.plugins.mda.FileGeneratorConfig) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) TSMasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.ts.model.TSMasterDataDefinitionModel) List(java.util.List) GeneratorPlugin(io.vertigo.studio.impl.mda.GeneratorPlugin) FileGenerator(io.vertigo.studio.plugins.mda.FileGenerator) MdaResultBuilder(io.vertigo.studio.mda.MdaResultBuilder) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) Entry(java.util.Map.Entry) DomainUtil(io.vertigo.studio.plugins.mda.util.DomainUtil) Optional(java.util.Optional) Named(javax.inject.Named) MasterDataManager(io.vertigo.studio.masterdata.MasterDataManager) Collections(java.util.Collections) MapBuilder(io.vertigo.util.MapBuilder) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) TSMasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.ts.model.TSMasterDataDefinitionModel)

Aggregations

MapBuilder (io.vertigo.util.MapBuilder)10 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 FileGeneratorConfig (io.vertigo.studio.plugins.mda.FileGeneratorConfig)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 Home (io.vertigo.app.Home)3 DtStereotype (io.vertigo.dynamo.domain.metamodel.DtStereotype)3 Assertion (io.vertigo.lang.Assertion)3 GeneratorPlugin (io.vertigo.studio.impl.mda.GeneratorPlugin)3 MasterDataManager (io.vertigo.studio.masterdata.MasterDataManager)3 MasterDataValues (io.vertigo.studio.masterdata.MasterDataValues)3 MdaResultBuilder (io.vertigo.studio.mda.MdaResultBuilder)3 FileGenerator (io.vertigo.studio.plugins.mda.FileGenerator)3 DomainUtil (io.vertigo.studio.plugins.mda.util.DomainUtil)3 Collections (java.util.Collections)3 Entry (java.util.Map.Entry)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3