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;
}
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);
}
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);
}
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())));
}
Aggregations