Search in sources :

Example 1 with FileGeneratorConfig

use of io.vertigo.studio.plugins.mda.FileGeneratorConfig 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)

Example 2 with FileGeneratorConfig

use of io.vertigo.studio.plugins.mda.FileGeneratorConfig in project vertigo by KleeGroup.

the class TSGeneratorPlugin method generateDtResourcesTS.

/**
 * Génère les ressources JS pour les traductions.
 * @param fileGeneratorConfig Configuration du domaine.
 */
private static void generateDtResourcesTS(final String targetSubDir, final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder) {
    final Map<String, List<TSDtDefinitionModel>> packageMap = new HashMap<>();
    for (final TSDtDefinitionModel dtDefinitionModel : getTsDtDefinitionModels()) {
        final String packageName = dtDefinitionModel.getFunctionnalPackageName();
        packageMap.computeIfAbsent(packageName, o -> new ArrayList<>()).add(dtDefinitionModel);
    }
    final String simpleClassName = "DtDefinitions" + "Label";
    for (final Entry<String, List<TSDtDefinitionModel>> entry : packageMap.entrySet()) {
        final Map<String, Object> model = new MapBuilder<String, Object>().put("packageName", entry.getKey()).put("simpleClassName", simpleClassName).put("dtDefinitions", entry.getValue()).build();
        FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName(entry.getKey() + ".ts").withGenSubDir(targetSubDir).withPackageName(fileGeneratorConfig.getProjectPackageName() + ".ui." + entry.getKey() + ".i18n.generated").withTemplateName("domain/ts/template/propertiesTS.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) HashMap(java.util.HashMap) TSDtDefinitionModel(io.vertigo.studio.plugins.mda.domain.ts.model.TSDtDefinitionModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MapBuilder(io.vertigo.util.MapBuilder)

Example 3 with FileGeneratorConfig

use of io.vertigo.studio.plugins.mda.FileGeneratorConfig in project vertigo by KleeGroup.

the class SqlGeneratorPlugin method generateMasterDataInserts.

private void generateMasterDataInserts(final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder) {
    final MasterDataValues masterDataValues = masterDataManagerOpt.isPresent() ? masterDataManagerOpt.get().getValues() : new MasterDataValues();
    final List<SqlMasterDataDefinitionModel> sqlMasterDataDefinitionModels = Home.getApp().getDefinitionSpace().getAll(DtDefinition.class).stream().filter(dtDefinition -> dtDefinition.getStereotype() == DtStereotype.StaticMasterData).map(dtDefinition -> new SqlMasterDataDefinitionModel(dtDefinition, masterDataValues.getOrDefault(dtDefinition.getClassCanonicalName(), Collections.emptyMap()))).collect(Collectors.toList());
    final Map<String, Object> model = new MapBuilder<String, Object>().put("masterdatas", sqlMasterDataDefinitionModels).build();
    FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName("init_masterdata.sql").withGenSubDir(targetSubDir).withPackageName("").withTemplateName("domain/sql/template/init_masterdata.ftl").build().generateFile(mdaResultBuilder);
}
Also used : DtStereotype(io.vertigo.dynamo.domain.metamodel.DtStereotype) MapBuilder(io.vertigo.util.MapBuilder) HashMap(java.util.HashMap) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) GeneratorPlugin(io.vertigo.studio.impl.mda.GeneratorPlugin) FileGenerator(io.vertigo.studio.plugins.mda.FileGenerator) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) AssociationNNDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition) DomainUtil(io.vertigo.studio.plugins.mda.util.DomainUtil) Named(javax.inject.Named) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Collection(java.util.Collection) FileGeneratorConfig(io.vertigo.studio.plugins.mda.FileGeneratorConfig) Collectors(java.util.stream.Collectors) SqlDtDefinitionModel(io.vertigo.studio.plugins.mda.domain.sql.model.SqlDtDefinitionModel) SqlMasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.sql.model.SqlMasterDataDefinitionModel) List(java.util.List) StringUtil(io.vertigo.util.StringUtil) AssociationSimpleDefinition(io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition) MdaResultBuilder(io.vertigo.studio.mda.MdaResultBuilder) Entry(java.util.Map.Entry) Optional(java.util.Optional) SqlMethodModel(io.vertigo.studio.plugins.mda.domain.sql.model.SqlMethodModel) MasterDataManager(io.vertigo.studio.masterdata.MasterDataManager) Collections(java.util.Collections) MapBuilder(io.vertigo.util.MapBuilder) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) SqlMasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.sql.model.SqlMasterDataDefinitionModel)

Example 4 with FileGeneratorConfig

use of io.vertigo.studio.plugins.mda.FileGeneratorConfig in project vertigo by KleeGroup.

the class DomainGeneratorPlugin method generateJavaEnums.

private void generateJavaEnums(final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder) {
    final MasterDataValues masterDataValues = masterDataManagerOpt.isPresent() ? masterDataManagerOpt.get().getValues() : new MasterDataValues();
    Home.getApp().getDefinitionSpace().getAll(DtDefinition.class).stream().filter(dtDefinition -> dtDefinition.getStereotype() == DtStereotype.StaticMasterData).forEach(dtDefintion -> generateJavaEnum(fileGeneratorConfig, mdaResultBuilder, dtDefintion, masterDataValues.getOrDefault(dtDefintion.getClassCanonicalName(), Collections.emptyMap())));
}
Also used : MasterDataDefinitionModel(io.vertigo.studio.plugins.mda.domain.java.model.masterdata.MasterDataDefinitionModel) DtStereotype(io.vertigo.dynamo.domain.metamodel.DtStereotype) MapBuilder(io.vertigo.util.MapBuilder) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) MethodAnnotationsModel(io.vertigo.studio.plugins.mda.domain.java.model.MethodAnnotationsModel) GeneratorPlugin(io.vertigo.studio.impl.mda.GeneratorPlugin) FileGenerator(io.vertigo.studio.plugins.mda.FileGenerator) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) DomainUtil(io.vertigo.studio.plugins.mda.util.DomainUtil) Named(javax.inject.Named) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Collection(java.util.Collection) FileGeneratorConfig(io.vertigo.studio.plugins.mda.FileGeneratorConfig) Collectors(java.util.stream.Collectors) List(java.util.List) MdaResultBuilder(io.vertigo.studio.mda.MdaResultBuilder) Entry(java.util.Map.Entry) Optional(java.util.Optional) DtDefinitionModel(io.vertigo.studio.plugins.mda.domain.java.model.DtDefinitionModel) MasterDataManager(io.vertigo.studio.masterdata.MasterDataManager) Collections(java.util.Collections) MasterDataValue(io.vertigo.studio.masterdata.MasterDataValue) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues)

Example 5 with FileGeneratorConfig

use of io.vertigo.studio.plugins.mda.FileGeneratorConfig in project vertigo by KleeGroup.

the class DomainGeneratorPlugin method generateDtResources.

private static void generateDtResources(final String targetSubDir, final FileGeneratorConfig fileGeneratorConfig, final MdaResultBuilder mdaResultBuilder) {
    final String simpleClassName = "DtResources";
    final String resourcesTemplateName = "domain/java/template/resources.ftl";
    final String propertiesTemplateName = "domain/java/template/properties.ftl";
    // pour les .properties on force l'ISO-8859-1 comme la norme l'impose
    final FileGeneratorConfig propertiesFileConfig = new FileGeneratorConfig(fileGeneratorConfig.getTargetGenDir(), fileGeneratorConfig.getProjectPackageName(), "ISO-8859-1");
    /**
     * Génération des ressources afférentes au DT.
     */
    for (final Entry<String, Collection<DtDefinition>> entry : DomainUtil.getDtDefinitionCollectionMap().entrySet()) {
        final Collection<DtDefinition> dtDefinitions = entry.getValue();
        Assertion.checkNotNull(dtDefinitions);
        final String packageName = entry.getKey();
        final Map<String, Object> model = new MapBuilder<String, Object>().put("packageName", packageName).put("simpleClassName", simpleClassName).put("dtDefinitions", toModels(dtDefinitions)).build();
        FileGenerator.builder(fileGeneratorConfig).withModel(model).withFileName(simpleClassName + ".java").withGenSubDir(targetSubDir).withPackageName(packageName).withTemplateName(resourcesTemplateName).build().generateFile(mdaResultBuilder);
        FileGenerator.builder(propertiesFileConfig).withModel(model).withFileName(simpleClassName + ".properties").withGenSubDir(targetSubDir).withPackageName(packageName).withTemplateName(propertiesTemplateName).build().generateFile(mdaResultBuilder);
    }
}
Also used : FileGeneratorConfig(io.vertigo.studio.plugins.mda.FileGeneratorConfig) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Collection(java.util.Collection) MapBuilder(io.vertigo.util.MapBuilder)

Aggregations

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