Skip to content

Commit

Permalink
Added the original object in PUTImport PATCH to fix websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Jan 9, 2024
1 parent 28d25a6 commit 10a86a8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/org/computate/frFR/java/EcrireApiClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ else if(classeApiMethode.contains("PATCH")) {
tl(tBase + 8, "if(", classeLangueConfig.getString(ConfigCles.var_requeteApi), ".getNumFound() == 1L)");
tl(tBase + 9, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setOriginal(", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ".first());");
if(classeModele)
tl(tBase + 8, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setPk(Optional.ofNullable(", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ".first()).map(o2 -> o2.getPk()).orElse(null));");
tl(tBase + 8, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setPk(Optional.ofNullable(", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ".first()).map(o2 -> o2.get", StringUtils.capitalize(classeVarClePrimaire), "()).orElse(null));");
tl(tBase + 8, "eventBus.publish(\"websocket", classeNomSimple, "\", JsonObject.mapFrom(", classeLangueConfig.getString(ConfigCles.var_requeteApi), ").toString());");
l();
tl(tBase + 8, classeLangueConfig.getString(ConfigCles.var_liste), classeApiMethode, classeNomSimple, "(", classeLangueConfig.getString(ConfigCles.var_requeteApi), ", ", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ").onSuccess(e -> {");
Expand Down Expand Up @@ -2354,7 +2354,7 @@ else if(StringUtils.contains(classeApiMethode, "PATCH")) {
tl(7, "if(", classeLangueConfig.getString(ConfigCles.var_requeteApi), ".getNumFound() == 1L)");
tl(8, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setOriginal(o);");
if(classeModele)
tl(7, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setPk(Optional.ofNullable(", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ".first()).map(o2 -> o2.getPk()).orElse(null));");
tl(7, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setPk(Optional.ofNullable(", classeLangueConfig.getString(ConfigCles.var_liste), classeNomSimple, ".first()).map(o2 -> o2.get", StringUtils.capitalize(classeVarClePrimaire), "()).orElse(null));");
// tl(7, "eventBus.publish(\"websocket", classeNomSimple, "\", JsonObject.mapFrom(", classeLangueConfig.getString(ConfigCles.var_requeteApi), ").toString());");
tl(7, classeApiOperationIdMethode, "Future(o, false).onSuccess(o2 -> {");
tl(8, classeLangueConfig.getString(ConfigCles.var_gestionnaireEvenements), ".handle(Future.succeededFuture(ServiceResponse.completedWithJson(Buffer.buffer(new JsonObject().encodePrettily()))));");
Expand Down Expand Up @@ -2462,6 +2462,11 @@ else if(StringUtils.containsAny(classeApiMethode, classeLangueConfig.getString(C
tl(8, "}");
tl(7, "}");
tl(7, "if(body2.size() > 0) {");
tl(8, "if(", classeLangueConfig.getString(ConfigCles.var_listeRecherche), ".size() == 1) {");
tl(9, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setOriginal(o);");
if(classeModele)
tl(9, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setPk(o.get", StringUtils.capitalize(classeVarClePrimaire), "());");
tl(8, "}");
tl(8, classeLangueConfig.getString(ConfigCles.var_requeteSite), ".set", classeLangueConfig.getString(ConfigCles.var_ObjetJson), "(body2);");
tl(8, "patch", classeNomSimple, "Future(", (classeModele ? "o" : "o2"), ", ", classeApiMethode.equals("PUTImport"), ").onSuccess(b -> {");
tl(9, "LOG.debug(\"Import ", classeNomSimple, " {} ", classeLangueConfig.getString(ConfigCles.str_a_réussi), ", ", classeLangueConfig.getString(ConfigCles.var_modifie), " ", classeNomSimple, ". \", body.getValue(", classeNomSimple, ".VAR_", classeModele ? classeVarClePrimaire : classeVarCleUnique, "));");
Expand Down Expand Up @@ -3920,7 +3925,7 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
tl(6, "query.put(\"softCommit\", softCommit);");
tl(5, "if(commitWithin != null)");
tl(6, "query.put(\"commitWithin\", commitWithin);");
tl(5, "query.put(\"q\", \"*:*\").put(\"fq\", new JsonArray().add(\"pk:\" + o.getPk())).put(\"var\", new JsonArray().add(\"refresh:false\"));");
tl(5, "query.put(\"q\", \"*:*\").put(\"fq\", new JsonArray().add(\"pk:\" + o.get", StringUtils.capitalize(classeVarClePrimaire), "())).put(\"var\", new JsonArray().add(\"refresh:false\"));");
tl(5, "params.put(\"query\", query);");
tl(5, "JsonObject context = new JsonObject().put(\"params\", params).put(\"user\", ", classeLangueConfig.getString(ConfigCles.var_requeteSite), ".getUserPrincipal());");
tl(5, "JsonObject json = new JsonObject().put(\"context\", context);");
Expand Down

0 comments on commit 10a86a8

Please sign in to comment.