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