Search in sources :

Example 1 with MdaResultBuilder

use of io.vertigo.studio.mda.MdaResultBuilder in project vertigo by KleeGroup.

the class MdaManagerImpl method clean.

@Override
public MdaResult clean() {
    final File directory = new File(fileGeneratorConfig.getTargetGenDir());
    Assertion.checkArgument(directory.exists(), "targetGenDir must exist");
    Assertion.checkArgument(directory.isDirectory(), "targetGenDir must be a directory");
    // ---
    // We want to final clean the directory
    final MdaResultBuilder mdaResultBuilder = MdaResult.builder();
    deleteFiles(directory, mdaResultBuilder);
    return mdaResultBuilder.build();
}
Also used : MdaResultBuilder(io.vertigo.studio.mda.MdaResultBuilder) File(java.io.File)

Example 2 with MdaResultBuilder

use of io.vertigo.studio.mda.MdaResultBuilder 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 3 with MdaResultBuilder

use of io.vertigo.studio.mda.MdaResultBuilder 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 4 with MdaResultBuilder

use of io.vertigo.studio.mda.MdaResultBuilder 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 5 with MdaResultBuilder

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

Aggregations

MdaResultBuilder (io.vertigo.studio.mda.MdaResultBuilder)5 Home (io.vertigo.app.Home)4 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)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 FileGenerator (io.vertigo.studio.plugins.mda.FileGenerator)4 FileGeneratorConfig (io.vertigo.studio.plugins.mda.FileGeneratorConfig)4 DomainUtil (io.vertigo.studio.plugins.mda.util.DomainUtil)4 MapBuilder (io.vertigo.util.MapBuilder)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