Skip to content

Commit 300c5f4

Browse files
committed
Fix unindexing by solrId and db based imports
1 parent d88aad8 commit 300c5f4

File tree

1 file changed

+73
-68
lines changed

1 file changed

+73
-68
lines changed

src/main/java/org/computate/frFR/java/EcrireApiClasse.java

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,89 +2832,94 @@ else if(StringUtils.containsAny(classeApiMethode, i18nGlobale.getString(I18n.var
28322832
tl(5, i18nGlobale.getString(I18n.var_connexionSql), ".preparedQuery(sqlQuery)");
28332833
tl(7, ".execute(Tuple.tuple(Arrays.asList(", classeVarId, "))");
28342834
tl(7, ").onSuccess(", i18nGlobale.getString(I18n.var_resultat), " -> {");
2835-
tl(6, "try {");
2836-
tl(7, "if(", i18nGlobale.getString(I18n.var_resultat), ".size() >= 1) {");
2837-
tl(8, classeNomSimple, " o = new ", classeNomSimple, "();");
2838-
tl(8, "o.set", i18nGlobale.getString(I18n.var_RequeteSite), "_(", i18nGlobale.getString(I18n.var_requeteSite), ");");
2839-
tl(8, "for(Row definition : ", i18nGlobale.getString(I18n.var_resultat), ".value()) {");
2840-
tl(9, "for(Integer i = 0; i < definition.size(); i++) {");
2841-
tl(10, "try {");
2842-
tl(11, "String columnName = definition.getColumnName(i);");
2843-
tl(11, "Object columnValue = definition.getValue(i);");
2844-
tl(11, "o.", i18nGlobale.getString(I18n.var_definir), i18nGlobale.getString(I18n.var_PourClasse), "(columnName, columnValue);");
2845-
tl(10, "} catch(Exception e) {");
2846-
tl(11, "LOG.error(String.format(\"", i18nGlobale.getString(I18n.var_definir), classeNomSimple, " ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), e);");
2835+
tl(6, i18nGlobale.getString(I18n.var_connexionSql), ".close().onSuccess(a -> {");
2836+
tl(7, "try {");
2837+
tl(8, "if(", i18nGlobale.getString(I18n.var_resultat), ".size() >= 1) {");
2838+
tl(9, classeNomSimple, " o = new ", classeNomSimple, "();");
2839+
tl(9, "o.set", i18nGlobale.getString(I18n.var_RequeteSite), "_(", i18nGlobale.getString(I18n.var_requeteSite), ");");
2840+
tl(9, "for(Row definition : ", i18nGlobale.getString(I18n.var_resultat), ".value()) {");
2841+
tl(10, "for(Integer i = 0; i < definition.size(); i++) {");
2842+
tl(11, "try {");
2843+
tl(12, "String columnName = definition.getColumnName(i);");
2844+
tl(12, "Object columnValue = definition.getValue(i);");
2845+
tl(12, "o.", i18nGlobale.getString(I18n.var_definir), i18nGlobale.getString(I18n.var_PourClasse), "(columnName, columnValue);");
2846+
tl(11, "} catch(Exception e) {");
2847+
tl(12, "LOG.error(String.format(\"", i18nGlobale.getString(I18n.var_definir), classeNomSimple, " ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), e);");
2848+
tl(11, "}");
28472849
tl(10, "}");
28482850
tl(9, "}");
2849-
tl(8, "}");
2850-
tl(8, classeNomSimple, " o2 = new ", classeNomSimple, "();");
2851-
tl(8, "o2.set", i18nGlobale.getString(I18n.var_RequeteSite), "_(", i18nGlobale.getString(I18n.var_requeteSite), ");");
2852-
tl(8, "JsonObject body2 = new JsonObject();");
2853-
tl(8, "for(String f : body.fieldNames()) {");
2854-
tl(9, "Object bodyVal = body.getValue(f);");
2855-
tl(9, "if(bodyVal instanceof JsonArray) {");
2856-
tl(10, "JsonArray bodyVals = (JsonArray)bodyVal;");
2857-
tl(10, "Object valsObj = o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f);");
2858-
tl(10, "Collection<?> vals = valsObj instanceof JsonArray ? ((JsonArray)valsObj).getList() : (Collection<?>)valsObj;");
2859-
tl(10, "if(bodyVals.size() == vals.size()) {");
2860-
tl(11, "Boolean match = true;");
2861-
tl(11, "for(Object val : vals) {");
2862-
tl(12, "if(val != null) {");
2863-
tl(13, "if(!bodyVals.contains(val.toString())) {");
2851+
tl(9, classeNomSimple, " o2 = new ", classeNomSimple, "();");
2852+
tl(9, "o2.set", i18nGlobale.getString(I18n.var_RequeteSite), "_(", i18nGlobale.getString(I18n.var_requeteSite), ");");
2853+
tl(9, "JsonObject body2 = new JsonObject();");
2854+
tl(9, "for(String f : body.fieldNames()) {");
2855+
tl(10, "Object bodyVal = body.getValue(f);");
2856+
tl(10, "if(bodyVal instanceof JsonArray) {");
2857+
tl(11, "JsonArray bodyVals = (JsonArray)bodyVal;");
2858+
tl(11, "Object valsObj = o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f);");
2859+
tl(11, "Collection<?> vals = valsObj instanceof JsonArray ? ((JsonArray)valsObj).getList() : (Collection<?>)valsObj;");
2860+
tl(11, "if(bodyVals.size() == vals.size()) {");
2861+
tl(12, "Boolean match = true;");
2862+
tl(12, "for(Object val : vals) {");
2863+
tl(13, "if(val != null) {");
2864+
tl(14, "if(!bodyVals.contains(val.toString())) {");
2865+
tl(15, "match = false;");
2866+
tl(15, "break;");
2867+
tl(14, "}");
2868+
tl(13, "} else {");
28642869
tl(14, "match = false;");
28652870
tl(14, "break;");
28662871
tl(13, "}");
2867-
tl(12, "} else {");
2868-
tl(13, "match = false;");
2869-
tl(13, "break;");
28702872
tl(12, "}");
2873+
tl(12, "vals.clear();");
2874+
tl(12, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
2875+
tl(11, "} else {");
2876+
tl(12, "vals.clear();");
2877+
tl(12, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
28712878
tl(11, "}");
2872-
tl(11, "vals.clear();");
2873-
tl(11, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
28742879
tl(10, "} else {");
2875-
tl(11, "vals.clear();");
2876-
tl(11, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
2880+
tl(11, "o2.", i18nGlobale.getString(I18n.var_definir), i18nGlobale.getString(I18n.var_PourClasse), "(f, bodyVal);");
2881+
tl(11, "o2.", i18nGlobale.getString(I18n.var_attribuer), i18nGlobale.getString(I18n.var_PourClasse), "(f, bodyVal);");
2882+
tl(11, "if(!StringUtils.containsAny(f, \"", classeVarId, "\", \"", i18nGlobale.getString(I18n.var_cree), "\", \"set", i18nGlobale.getString(I18n.var_Cree), "\") && !Objects.equals(o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f), o2.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f)))");
2883+
tl(12, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
28772884
tl(10, "}");
2878-
tl(9, "} else {");
2879-
tl(10, "o2.", i18nGlobale.getString(I18n.var_definir), i18nGlobale.getString(I18n.var_PourClasse), "(f, bodyVal);");
2880-
tl(10, "o2.", i18nGlobale.getString(I18n.var_attribuer), i18nGlobale.getString(I18n.var_PourClasse), "(f, bodyVal);");
2881-
tl(10, "if(!StringUtils.containsAny(f, \"", classeVarId, "\", \"", i18nGlobale.getString(I18n.var_cree), "\", \"set", i18nGlobale.getString(I18n.var_Cree), "\") && !Objects.equals(o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f), o2.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f)))");
2882-
tl(9, "body2.put(\"set\" + StringUtils.capitalize(f), bodyVal);");
28832885
tl(9, "}");
2884-
tl(8, "}");
2885-
tl(8, "for(String f : Optional.ofNullable(o.get", i18nGlobale.getString(I18n.var_Sauvegardes), "()).orElse(new ArrayList<>())) {");
2886-
tl(9, "if(!body.fieldNames().contains(f)) {");
2887-
tl(10, "if(!StringUtils.containsAny(f, \"", classeVarId, "\", \"", i18nGlobale.getString(I18n.var_cree), "\", \"set", i18nGlobale.getString(I18n.var_Cree), "\") && !Objects.equals(o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f), o2.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f)))");
2888-
tl(11, "body2.putNull(\"set\" + StringUtils.capitalize(f));");
2886+
tl(9, "for(String f : Optional.ofNullable(o.get", i18nGlobale.getString(I18n.var_Sauvegardes), "()).orElse(new ArrayList<>())) {");
2887+
tl(10, "if(!body.fieldNames().contains(f)) {");
2888+
tl(11, "if(!StringUtils.containsAny(f, \"", classeVarId, "\", \"", i18nGlobale.getString(I18n.var_cree), "\", \"set", i18nGlobale.getString(I18n.var_Cree), "\") && !Objects.equals(o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f), o2.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(f)))");
2889+
tl(12, "body2.putNull(\"set\" + StringUtils.capitalize(f));");
2890+
tl(10, "}");
28892891
tl(9, "}");
2890-
tl(8, "}");
2891-
tl(8, "if(", i18nGlobale.getString(I18n.var_resultat), ".size() >= 1) {");
2892-
tl(9, i18nGlobale.getString(I18n.var_requeteApi), ".setOriginal(o);");
2893-
tl(9, i18nGlobale.getString(I18n.var_requeteApi), ".setId(o.get", StringUtils.capitalize(classeVarId), "());");
2892+
tl(9, "if(", i18nGlobale.getString(I18n.var_resultat), ".size() >= 1) {");
2893+
tl(10, i18nGlobale.getString(I18n.var_requeteApi), ".setOriginal(o);");
2894+
tl(10, i18nGlobale.getString(I18n.var_requeteApi), ".setId(o.get", StringUtils.capitalize(classeVarId), "());");
28942895
if(classeModele)
2895-
tl(9, i18nGlobale.getString(I18n.var_requeteApi), ".set", classeVarClePrimaireCapitalise, "(o.get", StringUtils.capitalize(classeVarClePrimaire), "());");
2896+
tl(10, i18nGlobale.getString(I18n.var_requeteApi), ".set", classeVarClePrimaireCapitalise, "(o.get", StringUtils.capitalize(classeVarClePrimaire), "());");
2897+
tl(9, "}");
2898+
tl(9, i18nGlobale.getString(I18n.var_requeteSite), ".set", i18nGlobale.getString(I18n.var_ObjetJson), "(body2);");
2899+
tl(9, "patch", classeNomSimple, "Future(", (classeModele ? "o" : "o2"), ", ", classeApiMethode.equals("PUTImport"), ").onSuccess(b -> {");
2900+
tl(10, "LOG.debug(\"Import ", classeNomSimple, " {} ", i18nGlobale.getString(I18n.str_a_réussi), ", ", i18nGlobale.getString(I18n.var_modifie), " ", classeNomSimple, ". \", body.getValue(", classeNomSimple, ".VAR_", classeVarId, "));");
2901+
tl(10, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.succeededFuture());");
2902+
tl(9, "}).onFailure(ex -> {");
2903+
tl(10, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
2904+
tl(10, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
2905+
tl(9, "});");
2906+
tl(8, "} else {");
2907+
tl(9, "post", classeNomSimple, "Future(", i18nGlobale.getString(I18n.var_requeteSite), ", ", classeApiMethode.equals("PUTImport"), ").onSuccess(b -> {");
2908+
tl(10, "LOG.debug(\"Import ", classeNomSimple, " {} ", i18nGlobale.getString(I18n.str_a_réussi), ", ", i18nGlobale.getString(I18n.str_créé_nouveau), " ", classeNomSimple, ". \", body.getValue(", classeNomSimple, ".VAR_", classeVarId, "));");
2909+
tl(10, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.succeededFuture());");
2910+
tl(9, "}).onFailure(ex -> {");
2911+
tl(10, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
2912+
tl(10, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
2913+
tl(9, "});");
28962914
tl(8, "}");
2897-
tl(8, i18nGlobale.getString(I18n.var_requeteSite), ".set", i18nGlobale.getString(I18n.var_ObjetJson), "(body2);");
2898-
tl(8, "patch", classeNomSimple, "Future(", (classeModele ? "o" : "o2"), ", ", classeApiMethode.equals("PUTImport"), ").onSuccess(b -> {");
2899-
tl(9, "LOG.debug(\"Import ", classeNomSimple, " {} ", i18nGlobale.getString(I18n.str_a_réussi), ", ", i18nGlobale.getString(I18n.var_modifie), " ", classeNomSimple, ". \", body.getValue(", classeNomSimple, ".VAR_", classeVarId, "));");
2900-
tl(9, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.succeededFuture());");
2901-
tl(8, "}).onFailure(ex -> {");
2902-
tl(9, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
2903-
tl(9, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
2904-
tl(8, "});");
2905-
tl(7, "} else {");
2906-
tl(8, "post", classeNomSimple, "Future(", i18nGlobale.getString(I18n.var_requeteSite), ", ", classeApiMethode.equals("PUTImport"), ").onSuccess(b -> {");
2907-
tl(9, "LOG.debug(\"Import ", classeNomSimple, " {} ", i18nGlobale.getString(I18n.str_a_réussi), ", ", i18nGlobale.getString(I18n.str_créé_nouveau), " ", classeNomSimple, ". \", body.getValue(", classeNomSimple, ".VAR_", classeVarId, "));");
2908-
tl(9, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.succeededFuture());");
2909-
tl(8, "}).onFailure(ex -> {");
2910-
tl(9, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
2911-
tl(9, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
2912-
tl(8, "});");
2915+
tl(7, "} catch(Exception ex) {");
2916+
tl(8, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
2917+
tl(8, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
29132918
tl(7, "}");
2914-
tl(6, "} catch(Exception ex) {");
2919+
tl(6, "}).onFailure(ex -> {");
29152920
tl(7, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
29162921
tl(7, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
2917-
tl(6, "}");
2922+
tl(6, "});");
29182923
tl(5, "}).onFailure(ex -> {");
29192924
tl(6, "LOG.error(String.format(\"", classeApiOperationIdMethode, "Future ", i18nGlobale.getString(I18n.str_a_échoué), ". \"), ex);");
29202925
tl(6, i18nGlobale.getString(I18n.var_gestionnaireEvenements), ".handle(Future.failedFuture(ex));");
@@ -4752,7 +4757,7 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
47524757
tl(4, "JsonObject json = new JsonObject();");
47534758
tl(4, "JsonObject delete = new JsonObject();");
47544759
tl(4, "json.put(\"delete\", delete);");
4755-
tl(4, "String query = String.format(\"filter(%s):%s)\", ", classeNomSimple, ".VAR_", solrId, ", o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(", classeNomSimple, ".VAR_", solrId, "));");
4760+
tl(4, "String query = String.format(\"filter(%s:%s)\", ", classeNomSimple, ".VAR_", solrId, ", o.", i18nGlobale.getString(I18n.var_obtenir), i18nGlobale.getString(I18n.var_PourClasse), "(", classeNomSimple, ".VAR_", solrId, "));");
47564761
tl(4, "delete.put(\"query\", query);");
47574762
tl(4, "String solrUsername = ", i18nGlobale.getString(I18n.var_requeteSite), ".getConfig().getString(", classePartsConfigCles.nomSimple(classeLangueNom), ".SOLR_USERNAME);");
47584763
tl(4, "String solrPassword = ", i18nGlobale.getString(I18n.var_requeteSite), ".getConfig().getString(", classePartsConfigCles.nomSimple(classeLangueNom), ".SOLR_PASSWORD);");

0 commit comments

Comments
 (0)