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