Skip to content

Commit

Permalink
Fixing bugs with templates
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Nov 12, 2024
1 parent 25a3d14 commit 80e5cf3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
26 changes: 15 additions & 11 deletions src/main/java/org/computate/frFR/java/EcrireApiClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public void ecrireGenApiServiceImpl1(String classeLangueNom) throws Exception {
// classePageTemplates //
/////////////////////////

if(classePageTemplates != null && entiteDefinir) {
if(classePageAvecTemplate && entiteDefinir) {
wPageTemplates.tl(3, "page.persistForClass(", classeNomSimple, ".VAR_", entiteVar, ", ", classeNomSimple, ".staticSet", entiteVarCapitalise, "(", i18nGlobale.getString(I18n.var_requeteSite), "2, (String)", i18nGlobale.getString(I18n.var_resultat), ".get(", classeNomSimple, ".VAR_", entiteVar, ")));");
}

Expand Down Expand Up @@ -4000,12 +4000,16 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
s(wFacets);
if(classeVarCleUnique != null) {
l();
tl(3, "String id = ", i18nGlobale.getString(I18n.var_requeteService), ".getParams().getJsonObject(\"path\").getString(\"id\");");
tl(3, "if(", classeVarCleUnique, " != null && NumberUtils.isCreatable(", classeVarCleUnique, ")) {");
tl(4, i18nGlobale.getString(I18n.var_listeRecherche), ".fq(\"(", classeVarClePrimaire, "_docvalues_long:\" + SearchTool.escapeQueryChars(id) + \" OR ", classeVarId, "_docvalues_string:\" + SearchTool.escapeQueryChars(id) + \")\");");
tl(3, "} else if(", classeVarCleUnique, " != null) {");
tl(4, i18nGlobale.getString(I18n.var_listeRecherche), ".fq(\"", classeVarId, "_docvalues_string:\" + SearchTool.escapeQueryChars(id));");
tl(3, "}");
tl(3, "String ", classeVarId, " = ", i18nGlobale.getString(I18n.var_requeteService), ".getParams().getJsonObject(\"path\").getString(\"", classeVarId, "\");");
if(classeModele) {
tl(3, "if(", classeVarCleUnique, " != null && NumberUtils.isCreatable(", classeVarCleUnique, ")) {");
tl(4, i18nGlobale.getString(I18n.var_listeRecherche), ".fq(\"(", classeVarClePrimaire, "_docvalues_long:\" + SearchTool.escapeQueryChars(", classeVarId, ") + \" OR ", classeVarId, "_docvalues_string:\" + SearchTool.escapeQueryChars(", classeVarId, ") + \")\");");
tl(3, "} else if(", classeVarCleUnique, " != null) {");
tl(4, i18nGlobale.getString(I18n.var_listeRecherche), ".fq(\"", classeVarId, "_docvalues_string:\" + SearchTool.escapeQueryChars(", classeVarId, "));");
tl(3, "}");
} else {
tl(3, i18nGlobale.getString(I18n.var_listeRecherche), ".fq(\"", classeVarId, "_docvalues_string:\" + SearchTool.escapeQueryChars(", classeVarId, "));");
}
}
if(classeAuth && (classeRoleSession || classeRoleUtilisateur)) {
l();
Expand Down Expand Up @@ -4548,10 +4552,10 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
tl(1, "}");
}

/////////////////////////
// classePageTemplates //
/////////////////////////
if(classePageTemplates != null) {
//////////////////////
// genererCorpsPage //
//////////////////////
if(classePageAvecTemplate) {
l();
tl(1, "@Override");
tl(1, "public Future<JsonObject> ", i18nGlobale.getString(I18n.var_genererCorpsPage), "(ComputateSiteRequest ", i18nGlobale.getString(I18n.var_requeteSite), ", Map<String, Object> ctx, String resourceUri, String templateUri, String ", i18nGlobale.getString(I18n.var_classeNomSimple), ") {");
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/computate/frFR/java/EcrireGenClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ public class EcrireGenClasse extends EcrireClasse {
* Var.enUS: classModel
*/
protected Boolean classeModele;
protected String classePageTemplates;

protected Boolean classeApi;
protected String classeApiUri;
protected String classeApiUriPageRecherche;
protected String classeApiUriPageEdition;
protected String classeApiTag;

/**
Expand Down Expand Up @@ -2155,6 +2155,7 @@ public void genCodeClasseDebut(String langueNom, JsonObject langueConfig) throws
classeNomVar = classeDoc.getString("classeNomVar" + "_" + langueNom2 + "_stored_string");
classeApiUri = classeDoc.getString("classeApiUri" + "_" + langueNom2 + "_stored_string");
classeApiUriPageRecherche = classeDoc.getString("classeApiUri" + langueConfig.getString(I18n.var_PageRecherche) + "_" + langueNom2 + "_stored_string");
classeApiUriPageEdition = classeDoc.getString("classeApiUri" + langueConfig.getString(I18n.var_PageEdition) + "_" + langueNom2 + "_stored_string");
classeAdjectif = classeDoc.getString("classeAdjectif" + "_" + langueNom2 + "_stored_string");
classeAdjectifPluriel = classeDoc.getString("classeAdjectifPluriel" + "_" + langueNom2 + "_stored_string");
classeAdjectifVar = classeDoc.getString("classeAdjectifVar" + "_" + langueNom2 + "_stored_string");
Expand Down Expand Up @@ -2243,6 +2244,8 @@ public void genCodeClasseDebut(String langueNom, JsonObject langueConfig) throws
tl(1, "public static final String ", classeNomSimple, "_", langueConfig.getString(I18n.var_ApiUri), "_", langueNom2, " = ", q(classeApiUri), ";");
if(classeApiUriPageRecherche != null)
tl(1, "public static final String ", classeNomSimple, "_", langueConfig.getString(I18n.var_ApiUri), langueConfig.getString(I18n.var_PageRecherche), "_", langueNom2, " = ", q(classeApiUriPageRecherche), ";");
if(classeApiUriPageEdition != null)
tl(1, "public static final String ", classeNomSimple, "_", langueConfig.getString(I18n.var_ApiUri), langueConfig.getString(I18n.var_PageEdition), "_", langueNom2, " = ", q(classeApiUriPageEdition), ";");

if(classeDeNom != null)
tl(1, "public static final String ", classeNomSimple, "_", langueConfig.getString(I18n.var_DeNom), "_", langueNom2, " = ", q(classeDeNom), ";");
Expand Down Expand Up @@ -2270,10 +2273,12 @@ public void genCodeClasseDebut(String langueNom, JsonObject langueConfig) throws
String classePageUriMethode = classeDoc.getString("classeApiUri" + classePageMethode + "_" + langueNom2 + "_stored_string");
if(classePageUriMethode != null) {
if(classePageUriMethode != null) {
tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_Uri", " = ", q(classePageUriMethode), ";");
tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_OpenApiUri", " = ", q(classePageUriMethode), ";");
tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_StringFormatUri", " = ", q(classePageUriMethode.replaceAll("\\{[^\\}]+\\}", "%s")), ";");
tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_StringFormatUrl", " = ", q("%s" + classePageUriMethode.replaceAll("\\{[^\\}]+\\}", "%s")), ";");
}
if(classePageUriMethode != null) {
tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_ImageUri", " = ", q("/png", classePageUriMethode, "-999.png"), ";");
// tl(1, "public static final String ", classePageMethode, "_", langueNom2, "_ImageUri", " = ", q("/png", classePageUriMethode, "-999.png"), ";");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,7 @@ public void pageCodeClasseJava(String langueNom, JsonObject langueConfig) throws
if(classePageSimple) {
tl(2, langueConfig.getString(I18n.var_cVar), ".o(new ", classeApiClasseNomSimple, "());");
} else {
tl(2, "if(", varResultat, "Count == 1 && Optional.ofNullable(", langueConfig.getString(I18n.var_requeteSite), "_.get", langueConfig.getString(I18n.var_RequeteService), "().getParams().getJsonObject(\"path\")).map(o -> o.getString(\"id\")).orElse(null) != null)");
tl(2, "if(", varResultat, "Count == 1 && Optional.ofNullable(", langueConfig.getString(I18n.var_requeteSite), "_.get", langueConfig.getString(I18n.var_RequeteService), "().getParams().getJsonObject(\"path\")).map(o -> o.getString(\"", classeVarId, "\")).orElse(null) != null)");
tl(3, langueConfig.getString(I18n.var_cVar), ".o(", langueConfig.getString(I18n.var_listeRecherche), classeApiClasseNomSimple, "_.get(0));");
}
tl(1, "}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public void ecrireGenClasse(JsonObject doc, String langueNom) throws Exception {
classeNomSimpleSuperGenerique = doc.getString("classeNomSimpleSuperGenerique_" + langueNom + "_stored_string");
classeNomCanoniqueSuperGenerique = doc.getString("classeNomCanoniqueSuperGenerique_" + langueNom + "_stored_string");
classePageTemplate = doc.getString("classePageTemplate_" + langueNom + "_stored_string");
classePageAvecTemplate = doc.getBoolean("classePageAvecTemplate_stored_boolean");
classeGenPageTemplate = doc.getString("classeGenPageTemplate_" + langueNom + "_stored_string");
classePageSuperTemplate = doc.getString("classePageSuperTemplate_" + langueNom + "_stored_string");
classePageNomSimple = doc.getString("classePageNomSimple_" + langueNom + "_stored_string");
Expand Down Expand Up @@ -314,7 +315,6 @@ public void ecrireGenClasse(JsonObject doc, String langueNom) throws Exception {
classeRoleSession = (Boolean)doc.getBoolean("classeRoleSession_stored_boolean");
classeRoleUtilisateur = (Boolean)doc.getBoolean("classeRoleUtilisateur_stored_boolean");
classeRoleChacun = (Boolean)doc.getBoolean("classeRoleChacun_stored_boolean");
classePageTemplates = doc.getString("classePageTemplates_" + langueNom + "_stored_string");

classeSessionEcrire = (Boolean)doc.getBoolean("classeSessionEcrire_stored_boolean");
classeUtilisateurEcrire = (Boolean)doc.getBoolean("classeUtilisateurEcrire_stored_boolean");
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/computate/frFR/java/IndexerClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2268,8 +2268,6 @@ else if(!StringUtils.contains(classeNomCanoniqueSuper, ".") && StringUtils.isNot
Boolean classePageSimple = indexerStockerSolr(classeDoc, "classePageSimple", regexTrouve("^" + i18nGlobale.getString(I18n.var_PageSimple) + ": \\s*(true)$", classeCommentaire));
Boolean classeSauvegarde = indexerStockerSolr(classeDoc, "classeSauvegarde", regexTrouve("^" + i18nGlobale.getString(I18n.var_Sauvegarde) + ":\\s*(true)$", classeCommentaire) || classeModele || classeFiware);
indexerStockerSolr(langueNomGlobale, classeDoc, "classePageTemplate", regexLangue(langueNomGlobale, "^" + i18nGlobale.getString(I18n.var_PageTemplate), classeCommentaire));
indexerStockerSolr(langueNomGlobale, classeDoc, "classePageTemplates", regexLangue(langueNomGlobale, "^" + i18nGlobale.getString(I18n.var_PageTemplates), classeCommentaire));
indexerStockerSolr(langueNomGlobale, classeDoc, "classePageTemplatesUtilisateur", regexLangue(langueNomGlobale, "^" + i18nGlobale.getString(I18n.var_PageTemplatesUtilisateur), classeCommentaire));
String classeApiClasseNomSimple = regexLangue(langueNomGlobale, "^" + i18nGlobale.getString(I18n.var_ApiClasse), classeCommentaire, classeNomSimple);

if(classeApiClasseNomSimple != null) {
Expand Down Expand Up @@ -5790,7 +5788,8 @@ else if(StringUtils.contains(classeApiMethode, i18nGlobale.getString(I18n.var_Pa
indexerStockerSolr(langueNomGlobale, classeDoc, String.format("classeGen%sCheminJinja", classeApiMethode), String.format("%s/%s", templateChemin, classeGenPageTemplate));
} else {
String classePageNomFichier = String.format("%s%s.htm", classeNomSimple, classeApiMethode);
classePageTemplateMethode = apiMethode.getString(i18nGlobale.getString(I18n.var_PageTemplate), String.format("%s/%s", StringUtils.substringBeforeLast(classeApiUriMethode.substring(1), "/"), classePageNomFichier));
// classePageTemplateMethode = apiMethode.getString(i18nGlobale.getString(I18n.var_PageTemplate), String.format("%s/%s", StringUtils.substringBeforeLast(classeApiUriMethode.substring(1), "/"), classePageNomFichier));
classePageTemplateMethode = "%s.htm";
}

indexerStockerSolr(langueNomGlobale, classeDoc, String.format("classe%sTemplate", classeApiMethode), classePageTemplateMethode);
Expand Down

0 comments on commit 80e5cf3

Please sign in to comment.