diff --git a/src/main/java/org/computate/frFR/java/EcrireGenClasse.java b/src/main/java/org/computate/frFR/java/EcrireGenClasse.java index a7d07d3e..64dc11a6 100644 --- a/src/main/java/org/computate/frFR/java/EcrireGenClasse.java +++ b/src/main/java/org/computate/frFR/java/EcrireGenClasse.java @@ -43,6 +43,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.translate.AggregateTranslator; import org.apache.commons.text.translate.CharSequenceTranslator; @@ -1995,56 +1996,6 @@ public void genCodeClasseDebut(String langueNom, YAMLConfiguration langueConfig) } s(" {\n"); - if(classeSmartDataModel != null) { - File smartDataModelSpecFile = new File(System.getenv("HOME"), String.format(".local/src/smart-data-models/%s/dataModel.%s/%s/model.yaml", classeSmartDataDomain, classeSmartDataSubModule, classeSmartDataModel)); - if(smartDataModelSpecFile.exists()) { - Yaml yaml = new Yaml(); - Map map = yaml.load(FileUtils.readFileToString(smartDataModelSpecFile, StandardCharsets.UTF_8)); - JsonObject spec = new JsonObject(map); - JsonObject properties = spec.getJsonObject(classeSmartDataModel).getJsonObject("properties"); - l(); - tl(1, "/* FIWARE SmartDataModel fields: */"); - - Integer row = 3; - Integer cell = 1; - for(String fieldName : properties.fieldNames()) { - JsonObject field = properties.getJsonObject(fieldName); - String jsonType = field.getString("type"); - String description = field.getString("description"); - String javaType = "JsonObject"; - if("string".equals(jsonType)) - javaType = "String"; - else if("boolean".equals(jsonType)) - javaType = "Boolean"; - else if("integer".equals(jsonType)) - javaType = "Integer"; - else if("number".equals(jsonType)) - javaType = "BigDecimal"; - l("//"); - l("// /**"); - l("// * {@inheritDoc}"); - l("// * DocValues: true"); - l("// * Persist: true"); - l("// * DisplayName: ", StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(fieldName), " ").toLowerCase()); - if(description != null) - l("// * Description: ", description.replace("\r\n", " ").replace("\n", " ")); - l("// * HtmRow: ", row); - l("// * HtmCell: ", cell); - l("// * Facet: true"); - l("// */"); - l("// protected void _", fieldName, "(Wrap<", javaType, "> w) {"); - l("// }"); - cell++; - if(cell > 3) { - row++; - cell = 1; - } - } - - l(); - } - } - if(activerLog) { tl(1, "protected static final Logger LOG = LoggerFactory.getLogger(", classeNomSimple, ".class);"); } @@ -6344,7 +6295,7 @@ public void genCodeClasseFin(String langueNom, YAMLConfiguration langueConfig) t o = auteurGenClasseDebut; if(ecrireCommentaire) { - l("/**\t"); + l("/**"); ecrireCommentairePart(classeCommentaireLangue, 0); String hackathonMission = classeDoc.getString("hackathonMissionGen_stored_string"); String hackathonColumn = classeDoc.getString("hackathonColumnGen_stored_string"); @@ -6365,7 +6316,7 @@ public void genCodeClasseFin(String langueNom, YAMLConfiguration langueConfig) t JsonObject langueConfigJson = new JsonObject(jsonWriter.writeValueAsString(obj)); // Todo ecrireClasseCommentaire(langueConfigJson, siteNom, langueNom); - l(" **/"); + l(" **/"); } auteurGenClasse.s(auteurGenClasseDebut); @@ -6464,6 +6415,97 @@ public void ecrireClasseCommentaire(JsonObject langueConfig, String siteNom, Str classe.put("Description", b.toString()); } + try { + if(classeSmartDataModel != null) { + File smartDataModelSpecFile = new File(System.getenv("HOME"), String.format(".local/src/smart-data-models/%s/dataModel.%s/%s/model.yaml", classeSmartDataDomain, classeSmartDataSubModule, classeSmartDataModel)); + if(smartDataModelSpecFile.exists()) { + Yaml yaml = new Yaml(); + Map map = yaml.load(FileUtils.readFileToString(smartDataModelSpecFile, StandardCharsets.UTF_8)); + JsonObject spec = new JsonObject(map); + JsonObject properties = spec.getJsonObject(classeSmartDataModel).getJsonObject("properties"); + l(); + tl(0, " *

FIWARE SmartDataModel fields:

"); + + l(" * {@literal /}{@literal **}
"); + l(" * {@literal * SmartDataModel: ", classeSmartDataModel, " - ", classeSmartDataSubModule, " - ", classeSmartDataDomain, "}
"); + l(" * {@literal * Fiware: true}
"); + l(" * {@literal * SqlOrder: 1}
"); + l(" * {@literal * Api: true}
"); + l(" * {@literal * Page: true}
"); + l(" * {@literal * SuperPage.enUS: BaseModelPage}
"); + l(" * {@literal * Indexed: true}
"); + l(" * {@literal * Order: 1}
"); + l(" * {@literal * Description: }
"); + l(" * {@literal * ApiTag.enUS: ", classeNomSimple, "}
"); + l(" * {@literal * ApiUri.enUS: /api/", classeNomSimple, "}
"); + l(" *
"); + l(" * {@literal * ApiMethod.enUS: Search}
"); + l(" * {@literal * ApiMethod: GET}
"); + l(" * {@literal * ApiMethod: PATCH}
"); + l(" * {@literal * ApiMethod: POST}
"); + l(" * {@literal * ApiMethod: PUTImport}
"); + l(" *
"); + l(" * {@literal * ApiMethod.enUS: SearchPage}
"); + l(" * {@literal * Page.SearchPage.enUS: ", classeNomSimple, "Page}
"); + l(" * {@literal * ApiUri.SearchPage.enUS: /", classeNomSimple, "}
"); + l(" *
"); + l(" * {@literal * Role.enUS: SiteAdmin}
"); + l(" *
"); + l(" * {@literal * AName.enUS: a ", classeNomSimple, "}
"); + l(" * {@literal * Color: 2017-shaded-spruce}
"); + l(" * {@literal * IconGroup: duotone}
"); + l(" * {@literal * IconName: map-location-dot}
"); + l(" * {@literal * Rows: 100}
"); + l(" * {@literal **}{@literal /}
"); + l(" * {@literal public class ", classeNomSimple, " extends ", classeNomSimple, "Gen} {
"); + + Integer row = 3; + Integer cell = 1; + for(String fieldName : properties.fieldNames()) { + if(!fieldName.equals("id")) { + JsonObject field = properties.getJsonObject(fieldName); + String jsonType = field.getString("type"); + String description = field.getString("description"); + String javaType = "JsonObject"; + if("string".equals(jsonType)) + javaType = "String"; + else if("boolean".equals(jsonType)) + javaType = "Boolean"; + else if("integer".equals(jsonType)) + javaType = "Integer"; + else if("number".equals(jsonType)) + javaType = "BigDecimal"; + else if("location".equals(fieldName)) + javaType = "Path"; + l(" *
"); + l(" * {@literal /**}
"); + l(" * {@literal * {@inheritDoc}}
"); + l(" * {@literal * DocValues: true}
"); + l(" * {@literal * Persist: true}
"); + l(" * {@literal * DisplayName: ", StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(fieldName), " ").toLowerCase(), "}
"); + if(description != null) + l(" * {@literal * Description: ", description.replace("\r\n", " ").replace("\n", " "), "}
"); + l(" * {@literal * HtmRow: ", row, "}
"); + l(" * {@literal * HtmCell: ", cell, "}
"); + l(" * {@literal * Facet: true}
"); + l(" * {@literal **}{@literal /}
"); + l(" * {@literal protected void _", fieldName, "(Wrap<", javaType, "> w)} {}
"); + cell++; + if(cell > 3) { + row++; + cell = 1; + } + } + } + l(" * }
"); + + l(); + } + } + } catch(Exception ex) { + ExceptionUtils.rethrow(ex); + } + ecrireClasseCommentaireChamp(langueNom, classeRef, "01_commentaire", "commentaire", wClasseDescription , true , classeNomSimpleGen @@ -6716,9 +6758,9 @@ public void ecrireClasseCommentaire(JsonObject langueConfig, String siteNom, Str }); if(o != null) { - tl(0, "
    "); - s(0, b.toString()); - tl(0, "
"); + tl(0, " *
    "); + s(b.toString()); + tl(0, " *
"); } classe.put("Todo", b.toString()); @@ -6732,9 +6774,9 @@ public void ecrireClasseCommentaire(JsonObject langueConfig, String siteNom, Str b.insert(0, s); }); if(o != null) { - tl(0, "
    "); - s(0, b.toString()); - tl(0, "
"); + tl(0, " *
    "); + s(b.toString()); + tl(0, " *
"); } classe.put("Suggere", b.toString());