Search in sources :

Example 1 with MasterDataValues

use of io.vertigo.studio.masterdata.MasterDataValues in project vertigo by KleeGroup.

the class MasterDataManagerImpl method getValues.

@Override
public MasterDataValues getValues() {
    final MasterDataValues result = new MasterDataValues();
    for (final MasterDataValueProviderPlugin masterDataValueProviderPlugin : masterDataValueProviderPlugins) {
        final MasterDataValues masterDataValues = masterDataValueProviderPlugin.getValues();
        // we aggregate the results of all files
        masterDataValues.entrySet().stream().forEach(entry -> {
            result.computeIfPresent(entry.getKey(), (key, value) -> {
                entry.getValue().entrySet().stream().peek(newEntry -> Assertion.checkState(!value.containsKey(newEntry.getKey()), "Value with name '{0}' for MasterData '{1}' is declared in two files", newEntry.getKey(), entry.getKey())).forEach(newEntry -> value.put(newEntry.getKey(), newEntry.getValue()));
                return value;
            });
            result.computeIfAbsent(entry.getKey(), key -> entry.getValue());
        });
    }
    return result;
}
Also used : Inject(javax.inject.Inject) List(java.util.List) Assertion(io.vertigo.lang.Assertion) MasterDataManager(io.vertigo.studio.masterdata.MasterDataManager) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues) MasterDataValues(io.vertigo.studio.masterdata.MasterDataValues)

Example 2 with MasterDataValues

use of io.vertigo.studio.masterdata.MasterDataValues 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 MasterDataValues

use of io.vertigo.studio.masterdata.MasterDataValues 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 MasterDataValues

use of io.vertigo.studio.masterdata.MasterDataValues 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

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