Search in sources :

Example 1 with SqlMasterDataDefinitionModel

use of io.vertigo.studio.plugins.mda.domain.sql.model.SqlMasterDataDefinitionModel 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)

Aggregations

Home (io.vertigo.app.Home)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 DtStereotype (io.vertigo.dynamo.domain.metamodel.DtStereotype)1 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)1 AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)1 Assertion (io.vertigo.lang.Assertion)1 GeneratorPlugin (io.vertigo.studio.impl.mda.GeneratorPlugin)1 MasterDataManager (io.vertigo.studio.masterdata.MasterDataManager)1 MasterDataValues (io.vertigo.studio.masterdata.MasterDataValues)1 MdaResultBuilder (io.vertigo.studio.mda.MdaResultBuilder)1 FileGenerator (io.vertigo.studio.plugins.mda.FileGenerator)1 FileGeneratorConfig (io.vertigo.studio.plugins.mda.FileGeneratorConfig)1 SqlDtDefinitionModel (io.vertigo.studio.plugins.mda.domain.sql.model.SqlDtDefinitionModel)1 SqlMasterDataDefinitionModel (io.vertigo.studio.plugins.mda.domain.sql.model.SqlMasterDataDefinitionModel)1 SqlMethodModel (io.vertigo.studio.plugins.mda.domain.sql.model.SqlMethodModel)1 DomainUtil (io.vertigo.studio.plugins.mda.util.DomainUtil)1 MapBuilder (io.vertigo.util.MapBuilder)1 StringUtil (io.vertigo.util.StringUtil)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1