Skip to content

Commit

Permalink
No more magic string API addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Nov 9, 2023
1 parent 08864f7 commit 90706dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/computate/frFR/java/ConfigCles.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class ConfigCles {
public static final String var_ACTIVER_SUPPRIME = "var_ACTIVER_SUPPRIME";
public static final String var_ACTIVER_UTILISATEUR_CLE = "var_ACTIVER_UTILISATEUR_CLE";
public static final String var_ACTIVER_VERTX = "var_ACTIVER_VERTX";
public static final String var_CLASSE_API_ADDRESSE = "var_CLASSE_API_ADDRESSE";
public static final String var_addresse = "var_addresse";
public static final String var_Adjectif = "var_Adjectif";
public static final String var_AdjectifPluriel = "var_AdjectifPluriel";
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/computate/frFR/java/EcrireApiClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void ecrireGenApiService(String classeLangueNom) throws Exception {
tl(8, "protected WebClient ", classeLangueConfig.getString(ConfigCles.var_clientWeb), ";");

auteurGenApiService.tl(1, "static void ", classeLangueConfig.getString(ConfigCles.var_enregistrer), "Service(EventBus eventBus, JsonObject config, WorkerExecutor ", classeLangueConfig.getString(ConfigCles.var_executeurTravailleur), ", PgPool pgPool, KafkaProducer<String, String> kafkaProducer, WebClient ", classeLangueConfig.getString(ConfigCles.var_clientWeb), activerOpenIdConnect ? ", OAuth2Auth oauth2AuthenticationProvider, AuthorizationProvider authorizationProvider" : "", classePage ? ", HandlebarsTemplateEngine templateEngine" : "", ", Vertx vertx) {");
auteurGenApiService.tl(2, "new ServiceBinder(vertx).setAddress(", q(siteNom, "-", classeLangueNom, "-", classeNomSimple), ").register(", classeNomSimpleGenApiService, ".class, new ", classeNomSimpleApiServiceImpl, "(eventBus, config, ", classeLangueConfig.getString(ConfigCles.var_executeurTravailleur), ", pgPool, kafkaProducer, ", classeLangueConfig.getString(ConfigCles.var_clientWeb), activerOpenIdConnect ? ", oauth2AuthenticationProvider, authorizationProvider" : "", classePage ? ", templateEngine" : "", "));");
auteurGenApiService.tl(2, "new ServiceBinder(vertx).setAddress(", classeNomSimple, ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ").register(", classeNomSimpleGenApiService, ".class, new ", classeNomSimpleApiServiceImpl, "(eventBus, config, ", classeLangueConfig.getString(ConfigCles.var_executeurTravailleur), ", pgPool, kafkaProducer, ", classeLangueConfig.getString(ConfigCles.var_clientWeb), activerOpenIdConnect ? ", oauth2AuthenticationProvider, authorizationProvider" : "", classePage ? ", templateEngine" : "", "));");
auteurGenApiService.tl(1, "}");
auteurGenApiService.l();
for(String classeApiMethode : classeApiMethodes) {
Expand Down Expand Up @@ -1779,7 +1779,7 @@ public void ecrireGenApiServiceImpl2(String classeLangueNom) throws Exception {
if(StringUtils.containsAny(classeApiMethode, "POST", "PUT", "PATCH"))
tl(2, "LOG.debug(String.format(\"", classeApiOperationIdMethode, " ", classeLangueConfig.getString(ConfigCles.str_a_démarré), ". \"));");

tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, \"", siteNom, "-", classeLangueNom, "-", classePartsUtilisateurSite.nomSimple(classeLangueNom), "\", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
if(
StringUtils.containsAny(classeApiMethode, "POST", "PUT", "PATCH")
&& !(classeRoleSession || classeRoleUtilisateur || classeRoleChacun)
Expand Down Expand Up @@ -1905,7 +1905,7 @@ public void ecrireGenApiServiceImpl2(String classeLangueNom) throws Exception {
tl(6, "params.put(\"query\", query);");
tl(6, "JsonObject context = new JsonObject().put(\"params\", params).put(\"user\", ", classeLangueConfig.getString(ConfigCles.var_requeteSite), ".getUserPrincipal());");
tl(6, "JsonObject json = new JsonObject().put(\"context\", context);");
tl(6, "eventBus.request(\"", siteNom, "-", classeLangueNom, "-", classeNomSimple, "\", json, new DeliveryOptions().addHeader(\"action\", \"", classeApiOperationIdMethode, "Future\")).onSuccess(a -> {");
tl(6, "eventBus.request(", classeNomSimple, ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", json, new DeliveryOptions().addHeader(\"action\", \"", classeApiOperationIdMethode, "Future\")).onSuccess(a -> {");
tl(7, "JsonObject responseMessage = (JsonObject)a.body();");
tl(7, "JsonObject responseBody = new JsonObject(Buffer.buffer(JsonUtil.BASE64_DECODER.decode(responseMessage.getString(\"payload\"))));");
if(classeModele)
Expand Down Expand Up @@ -2253,7 +2253,7 @@ else if(classeApiMethode.equals(classeLangueConfig.getString(ConfigCles.var_PUTF
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);");
tl(5, "eventBus.request(\"", siteNom, "-", classeLangueNom, "-", classeNomSimple, "\", json, new DeliveryOptions().addHeader(\"action\", \"", classeApiOperationIdMethode, "Future\")).onSuccess(a -> {");
tl(5, "eventBus.request(", classeNomSimple, ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", json, new DeliveryOptions().addHeader(\"action\", \"", classeApiOperationIdMethode, "Future\")).onSuccess(a -> {");
tl(6, "promise1.complete();");
tl(5, "}).onFailure(ex -> {");
tl(6, "LOG.error(String.format(\"", classeLangueConfig.getString(ConfigCles.var_liste), classeApiMethode, classeNomSimple, " ", classeLangueConfig.getString(ConfigCles.str_a_échoué), ". \"), ex);");
Expand Down Expand Up @@ -2283,7 +2283,7 @@ else if(classeApiMethode.equals(classeLangueConfig.getString(ConfigCles.var_PUTF
l();
tl(1, "@Override");
tl(1, "public void ", classeApiOperationIdMethode, "Future(" , StringUtils.equals(classeApiTypeMediaRequeteMethode, "application/json") ? "JsonObject" : "String", " body, ServiceRequest ", classeLangueConfig.getString(ConfigCles.var_requeteService), ", Handler<AsyncResult<ServiceResponse>> ", classeLangueConfig.getString(ConfigCles.var_gestionnaireEvenements), ") {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, \"", siteNom, "-", classeLangueNom, "-", classePartsUtilisateurSite.nomSimple(classeLangueNom), "\", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(3, classePartsRequeteApi.nomSimple(classeLangueNom), " ", classeLangueConfig.getString(ConfigCles.var_requeteApi), " = new ", classePartsRequeteApi.nomSimple(classeLangueNom), "();");
tl(3, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setRows(1L);");
tl(3, classeLangueConfig.getString(ConfigCles.var_requeteApi), ".setNumFound(1L);");
Expand Down Expand Up @@ -2333,7 +2333,7 @@ else if(StringUtils.contains(classeApiMethode, "PATCH")) {
l();
tl(1, "@Override");
tl(1, "public void ", classeApiOperationIdMethode, "Future(" , StringUtils.equals(classeApiTypeMediaRequeteMethode, "application/json") ? "JsonObject" : "String", " body, ServiceRequest ", classeLangueConfig.getString(ConfigCles.var_requeteService), ", Handler<AsyncResult<ServiceResponse>> ", classeLangueConfig.getString(ConfigCles.var_gestionnaireEvenements), ") {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, \"", siteNom, "-", classeLangueNom, "-", classePartsUtilisateurSite.nomSimple(classeLangueNom), "\", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(3, "try {");
tl(4, classeLangueConfig.getString(ConfigCles.var_requeteSite), ".setJsonObject(body);");
tl(4, classeLangueConfig.getString(ConfigCles.var_requeteService), ".getParams().getJsonObject(\"query\").put(\"rows\", 1);");
Expand Down Expand Up @@ -2385,7 +2385,7 @@ else if(StringUtils.containsAny(classeApiMethode, classeLangueConfig.getString(C
l();
tl(1, "@Override");
tl(1, "public void ", classeApiOperationIdMethode, "Future(" , StringUtils.equals(classeApiTypeMediaRequeteMethode, "application/json") ? "JsonObject" : "String", " body, ServiceRequest ", classeLangueConfig.getString(ConfigCles.var_requeteService), ", Handler<AsyncResult<ServiceResponse>> ", classeLangueConfig.getString(ConfigCles.var_gestionnaireEvenements), ") {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, \"", siteNom, "-", classeLangueNom, "-", classePartsUtilisateurSite.nomSimple(classeLangueNom), "\", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(2, classeLangueConfig.getString(ConfigCles.var_utilisateur), "(", classeLangueConfig.getString(ConfigCles.var_requeteService), ", ", classePartsRequeteSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".class, ", classePartsUtilisateurSite.nomSimple(classeLangueNom), ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", \"post", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\", \"patch", classePartsUtilisateurSite.nomSimple(classeLangueNom), "Future\").onSuccess(", classeLangueConfig.getString(ConfigCles.var_requeteSite), " -> {");
tl(3, "try {");
if(StringUtils.equals(classeApiTypeMediaRequeteMethode, "application/json")) {
tl(4, classePartsRequeteApi.nomSimple(classeLangueNom), " ", classeLangueConfig.getString(ConfigCles.var_requeteApi), " = new ", classePartsRequeteApi.nomSimple(classeLangueNom), "();");
Expand Down Expand Up @@ -3917,7 +3917,7 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
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);");
tl(5, "eventBus.request(\"", siteNom, "-", classeLangueNom, "-", classeNomSimple, "\", json, new DeliveryOptions().addHeader(\"action\", \"patch", classeNomSimple, "Future\")).onSuccess(c -> {");
tl(5, "eventBus.request(", classeNomSimple, ".", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), ", json, new DeliveryOptions().addHeader(\"action\", \"patch", classeNomSimple, "Future\")).onSuccess(c -> {");
tl(6, "JsonObject responseMessage = (JsonObject)c.body();");
tl(6, "Integer statusCode = responseMessage.getInteger(\"statusCode\");");
tl(6, "if(statusCode.equals(200))");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/computate/frFR/java/EcrireGenClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -6016,6 +6016,7 @@ public void genCodeClasseFin(String langueNom, YAMLConfiguration langueConfig) t

l();
tl(1, "public static final String ", langueConfig.getString(ConfigCles.var_CLASSE_NOM_SIMPLE), " = \"", classeNomSimple, "\";");
tl(1, "public static final String ", classeLangueConfig.getString(ConfigCles.var_CLASSE_API_ADDRESSE), " = \"", siteNom, "-", classeLangueNom, "-", classeNomSimple, "\";");
s(wVarsStatic);

if(classeIndexe) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/computate/i18n/i18n_enUS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ var_ACTIVER_SESSION_ID: "ENABLE_SESSION_ID"
var_ACTIVER_SUPPRIME: "ENABLE_DELETED"
var_ACTIVER_UTILISATEUR_CLE: "ENABLE_USER_KEY"
var_ACTIVER_VERTX: "ENABLE_VERTX"
var_CLASSE_API_ADDRESSE: "CLASS_API_ADDRESS"
var_addresse: "address"
var_a_démarré: "started"
var_Adjectif: "Adjective"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/computate/i18n/i18n_frFR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var_ACTIVER_SESSION_ID: "ACTIVER_SESSION_ID"
var_ACTIVER_SUPPRIME: "ACTIVER_SUPPRIMER"
var_ACTIVER_UTILISATEUR_CLE: "ACTIVER_UTILISATEUR_CLE"
var_ACTIVER_VERTX: "ACTIVER_VERTX"
var_CLASSE_API_ADDRESSE: "CLASSE_API_ADDRESSE"
var_addresse: "addresse"
var_Adjectif: "Adjectif"
var_AdjectifPluriel: "AdjectifPluriel"
Expand Down

0 comments on commit 90706dd

Please sign in to comment.