@@ -3203,31 +3203,94 @@ else if(classeApiMethode.contains("PATCH")) {
32033203 tl (3 , "pgPool.withTransaction(" , i18nGlobale .getString (I18n .var_connexionSql ), " -> {" );
32043204 tl (4 , i18nGlobale .getString (I18n .var_requeteSite ), ".set" , i18nGlobale .getString (I18n .var_ConnexionSql ), "(" , i18nGlobale .getString (I18n .var_connexionSql ), ");" );
32053205 tl (4 , "vars" , classeNomSimple , "(" , i18nGlobale .getString (I18n .var_requeteSite ), ").onSuccess(a -> {" );
3206- tl (5 , "sql" , classeApiMethode , classeNomSimple , "(o, " , classeVarInheritClePrimaire , ").onSuccess(" , uncapitalizeClasseNomSimple , " -> {" );
3207- tl (6 , i18nGlobale .getString (I18n .var_definir ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ", true).onSuccess(c -> {" );
3208- tl (7 , i18nGlobale .getString (I18n .var_attribuer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(d -> {" );
3209- tl (8 , i18nGlobale .getString (I18n .var_indexer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(o2 -> {" );
3210- tl (9 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), " != null) {" );
3211- tl (10 , i18nGlobale .getString (I18n .var_requeteApi ), ".setNumPATCH(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumPATCH() + 1);" );
3212- tl (10 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumFound() == 1L && Optional.ofNullable(" , i18nGlobale .getString (I18n .var_requeteSite ), ".getJsonObject()).map(json -> json.size() > 0).orElse(false)) {" );
3213- tl (11 , "o" , classeSauvegarde ? "2" : "" , "." , i18nGlobale .getString (I18n .var_requeteApi ), classeNomSimple , "();" );
3214- tl (11 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getVars().size() > 0)" );
3215- tl (12 , "eventBus.publish(\" websocket" , classeNomSimple , "\" , JsonObject.mapFrom(" , i18nGlobale .getString (I18n .var_requeteApi ), ").toString());" );
3216- tl (10 , "}" );
3217- tl (9 , "}" );
3218- tl (9 , "promise1.complete(" , uncapitalizeClasseNomSimple , ");" );
3219- tl (8 , "}).onFailure(ex -> {" );
3220- tl (9 , "promise1.fail(ex);" );
3221- tl (8 , "});" );
3222- tl (7 , "}).onFailure(ex -> {" );
3223- tl (8 , "promise1.fail(ex);" );
3224- tl (7 , "});" );
3225- tl (6 , "}).onFailure(ex -> {" );
3226- tl (7 , "promise1.fail(ex);" );
3227- tl (6 , "});" );
3228- tl (5 , "}).onFailure(ex -> {" );
3229- tl (6 , "promise1.fail(ex);" );
3230- tl (5 , "});" );
3206+ if (activerContextBroker && classeFiware ) {
3207+ tl (5 , "JsonObject jsonObject = o.getSiteRequest_().getJsonObject();" );
3208+ tl (5 , "if(jsonObject.isEmpty()) {" );
3209+ tl (6 , "ngsildGetEntity(o).onSuccess(ngsildData -> {" );
3210+ tl (7 , "String setNgsildData = String.format(\" set%s\" ,StringUtils.capitalize(" , classeNomSimple , ".VAR_ngsildData));" );
3211+ tl (7 , "jsonObject.put(setNgsildData, ngsildData);" );
3212+ tl (7 , "sql" , classeApiMethode , classeNomSimple , "(o, " , classeVarInheritClePrimaire , ").onSuccess(" , uncapitalizeClasseNomSimple , " -> {" );
3213+ tl (8 , i18nGlobale .getString (I18n .var_definir ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ", true).onSuccess(c -> {" );
3214+ tl (9 , i18nGlobale .getString (I18n .var_attribuer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(d -> {" );
3215+ tl (10 , i18nGlobale .getString (I18n .var_indexer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(o2 -> {" );
3216+ tl (11 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), " != null) {" );
3217+ tl (12 , i18nGlobale .getString (I18n .var_requeteApi ), ".setNumPATCH(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumPATCH() + 1);" );
3218+ tl (12 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumFound() == 1L && Optional.ofNullable(" , i18nGlobale .getString (I18n .var_requeteSite ), ".getJsonObject()).map(json -> json.size() > 0).orElse(false)) {" );
3219+ tl (13 , "o" , classeSauvegarde ? "2" : "" , "." , i18nGlobale .getString (I18n .var_requeteApi ), classeNomSimple , "();" );
3220+ tl (13 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getVars().size() > 0)" );
3221+ tl (14 , "eventBus.publish(\" websocket" , classeNomSimple , "\" , JsonObject.mapFrom(" , i18nGlobale .getString (I18n .var_requeteApi ), ").toString());" );
3222+ tl (12 , "}" );
3223+ tl (11 , "}" );
3224+ tl (11 , "promise1.complete(" , uncapitalizeClasseNomSimple , ");" );
3225+ tl (10 , "}).onFailure(ex -> {" );
3226+ tl (11 , "promise1.fail(ex);" );
3227+ tl (10 , "});" );
3228+ tl (9 , "}).onFailure(ex -> {" );
3229+ tl (10 , "promise1.fail(ex);" );
3230+ tl (9 , "});" );
3231+ tl (8 , "}).onFailure(ex -> {" );
3232+ tl (9 , "promise1.fail(ex);" );
3233+ tl (8 , "});" );
3234+ tl (7 , "}).onFailure(ex -> {" );
3235+ tl (8 , "promise1.fail(ex);" );
3236+ tl (7 , "});" );
3237+ tl (6 , "}).onFailure(ex -> {" );
3238+ tl (7 , "promise1.fail(ex);" );
3239+ tl (6 , "});" );
3240+ tl (5 , "} else {" );
3241+ tl (6 , "sql" , classeApiMethode , classeNomSimple , "(o, " , classeVarInheritClePrimaire , ").onSuccess(" , uncapitalizeClasseNomSimple , " -> {" );
3242+ tl (7 , i18nGlobale .getString (I18n .var_definir ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ", true).onSuccess(c -> {" );
3243+ tl (8 , i18nGlobale .getString (I18n .var_attribuer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(d -> {" );
3244+ tl (9 , i18nGlobale .getString (I18n .var_indexer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(o2 -> {" );
3245+ tl (10 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), " != null) {" );
3246+ tl (11 , i18nGlobale .getString (I18n .var_requeteApi ), ".setNumPATCH(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumPATCH() + 1);" );
3247+ tl (11 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumFound() == 1L && Optional.ofNullable(" , i18nGlobale .getString (I18n .var_requeteSite ), ".getJsonObject()).map(json -> json.size() > 0).orElse(false)) {" );
3248+ tl (12 , "o" , classeSauvegarde ? "2" : "" , "." , i18nGlobale .getString (I18n .var_requeteApi ), classeNomSimple , "();" );
3249+ tl (12 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getVars().size() > 0)" );
3250+ tl (13 , "eventBus.publish(\" websocket" , classeNomSimple , "\" , JsonObject.mapFrom(" , i18nGlobale .getString (I18n .var_requeteApi ), ").toString());" );
3251+ tl (11 , "}" );
3252+ tl (10 , "}" );
3253+ tl (10 , "promise1.complete(" , uncapitalizeClasseNomSimple , ");" );
3254+ tl (9 , "}).onFailure(ex -> {" );
3255+ tl (10 , "promise1.fail(ex);" );
3256+ tl (9 , "});" );
3257+ tl (8 , "}).onFailure(ex -> {" );
3258+ tl (9 , "promise1.fail(ex);" );
3259+ tl (8 , "});" );
3260+ tl (7 , "}).onFailure(ex -> {" );
3261+ tl (8 , "promise1.fail(ex);" );
3262+ tl (7 , "});" );
3263+ tl (6 , "}).onFailure(ex -> {" );
3264+ tl (7 , "promise1.fail(ex);" );
3265+ tl (6 , "});" );
3266+ tl (5 , "}" );
3267+ } else {
3268+ tl (5 , "sql" , classeApiMethode , classeNomSimple , "(o, " , classeVarInheritClePrimaire , ").onSuccess(" , uncapitalizeClasseNomSimple , " -> {" );
3269+ tl (6 , i18nGlobale .getString (I18n .var_definir ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ", true).onSuccess(c -> {" );
3270+ tl (7 , i18nGlobale .getString (I18n .var_attribuer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(d -> {" );
3271+ tl (8 , i18nGlobale .getString (I18n .var_indexer ), classeNomSimple , "(" , uncapitalizeClasseNomSimple , ").onSuccess(o2 -> {" );
3272+ tl (9 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), " != null) {" );
3273+ tl (10 , i18nGlobale .getString (I18n .var_requeteApi ), ".setNumPATCH(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumPATCH() + 1);" );
3274+ tl (10 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getNumFound() == 1L && Optional.ofNullable(" , i18nGlobale .getString (I18n .var_requeteSite ), ".getJsonObject()).map(json -> json.size() > 0).orElse(false)) {" );
3275+ tl (11 , "o" , classeSauvegarde ? "2" : "" , "." , i18nGlobale .getString (I18n .var_requeteApi ), classeNomSimple , "();" );
3276+ tl (11 , "if(" , i18nGlobale .getString (I18n .var_requeteApi ), ".getVars().size() > 0)" );
3277+ tl (12 , "eventBus.publish(\" websocket" , classeNomSimple , "\" , JsonObject.mapFrom(" , i18nGlobale .getString (I18n .var_requeteApi ), ").toString());" );
3278+ tl (10 , "}" );
3279+ tl (9 , "}" );
3280+ tl (9 , "promise1.complete(" , uncapitalizeClasseNomSimple , ");" );
3281+ tl (8 , "}).onFailure(ex -> {" );
3282+ tl (9 , "promise1.fail(ex);" );
3283+ tl (8 , "});" );
3284+ tl (7 , "}).onFailure(ex -> {" );
3285+ tl (8 , "promise1.fail(ex);" );
3286+ tl (7 , "});" );
3287+ tl (6 , "}).onFailure(ex -> {" );
3288+ tl (7 , "promise1.fail(ex);" );
3289+ tl (6 , "});" );
3290+ tl (5 , "}).onFailure(ex -> {" );
3291+ tl (6 , "promise1.fail(ex);" );
3292+ tl (5 , "});" );
3293+ }
32313294 tl (4 , "}).onFailure(ex -> {" );
32323295 tl (5 , "promise1.fail(ex);" );
32333296 tl (4 , "});" );
@@ -3418,7 +3481,16 @@ else if(classeApiMethode.contains("PATCH")) {
34183481 tl (3 , "}));" );
34193482 tl (3 , "CompositeFuture.all(futures1).onSuccess(a -> {" );
34203483 tl (4 , "CompositeFuture.all(futures2).onSuccess(b -> {" );
3421- tl (5 , "promise.complete();" );
3484+ if (activerContextBroker && classeFiware ) {
3485+ tl (5 , "cbDeleteEntity(o).onSuccess(c -> {" );
3486+ tl (6 , "promise.complete();" );
3487+ tl (5 , "}).onFailure(ex -> {" );
3488+ tl (6 , "LOG.error(String.format(\" sql" , classeApiMethode , classeNomSimple , " " , i18nGlobale .getString (I18n .str_a_échoué ), ". \" ), ex);" );
3489+ tl (6 , "promise.fail(ex);" );
3490+ tl (5 , "});" );
3491+ } else {
3492+ tl (5 , "promise.complete();" );
3493+ }
34223494 tl (4 , "}).onFailure(ex -> {" );
34233495 tl (5 , "LOG.error(String.format(\" sql" , classeApiMethode , classeNomSimple , " " , i18nGlobale .getString (I18n .str_a_échoué ), ". \" ), ex);" );
34243496 tl (5 , "promise.fail(ex);" );
@@ -4427,13 +4499,15 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
44274499 tl (3 , "for (String var : vars) {" );
44284500 tl (4 , "String ngsiType = " , classeNomSimple , ".ngsiType(var);" );
44294501 tl (4 , "String displayName = Optional.ofNullable(" , classeNomSimple , ".displayName" , classeNomSimple , "(var)).orElse(var);" );
4430- tl (4 , "if (ngsiType != null && displayName != null && !var.equals(\" ngsildData\" )) {" );
4502+ tl (4 , "if (ngsiType != null && displayName != null && !var.equals(\" id \" ) && !var.equals( \" ngsildData\" )) {" );
44314503 tl (5 , "Object value = o.obtainForClass(var);" );
44324504 tl (5 , "if(value != null) {" );
4505+ tl (6 , "Object ngsildVal = " , classeNomSimple , ".ngsi" , classeNomSimple , "(var, o);" );
4506+ tl (6 , "String ngsildType = " , classeNomSimple , ".ngsiType(var);" );
44334507 tl (6 , "entityBody.put(displayName" );
44344508 tl (8 , ", new JsonObject()" );
4435- tl (8 , ".put(\" type\" , \" Property \" )" );
4436- tl (8 , ".put(\" value\" , value )" );
4509+ tl (8 , ".put(\" type\" , ngsildType )" );
4510+ tl (8 , ".put(\" value\" , ngsildVal )" );
44374511 tl (8 , ".put(\" observedAt\" , observedAtStr)" );
44384512 tl (8 , ");" );
44394513 tl (5 , "}" );
@@ -4471,9 +4545,9 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
44714545 tl (2 , "try {" );
44724546 tl (3 , "String entityName = o.getName();" );
44734547 tl (3 , "String entityType = " , classeNomSimple , ".CLASS_SIMPLE_NAME;" );
4474- tl (3 , "String entityId = o.getEntityId ();" );
4548+ tl (3 , "String entityId = o.getId ();" );
44754549 tl (3 , "String ngsildUri = String.format(\" /ngsi-ld/v1/entities/%s\" , urlEncode(entityId));" );
4476- tl (3 , "String ngsildContext = o.getNgsildContext( );" );
4550+ tl (3 , "String ngsildContext = config.getString(ComputateConfigKeys.CONTEXT_BROKER_CONTEXT );" );
44774551 tl (3 , "String link = String.format(\" <%s>; rel=\\ \" http://www.w3.org/ns/json-ld#context\\ \" ; type=\\ \" application/ld+json\\ \" \" , ngsildContext);" );
44784552 l ();
44794553 tl (3 , "webClient.get(" );
@@ -4511,7 +4585,7 @@ public void ecrireGenApiServiceImpl3(String classeLangueNom) throws Exception {
45114585 tl (3 , "webClient.delete(" );
45124586 tl (5 , "config.getInteger(ComputateConfigKeys.CONTEXT_BROKER_PORT)" );
45134587 tl (5 , ", config.getString(ComputateConfigKeys.CONTEXT_BROKER_HOST_NAME)" );
4514- tl (5 , ", String.format(\" /ngsi-ld/v1/entities/%s\" , urlEncode(o.getEntityId ()))" );
4588+ tl (5 , ", String.format(\" /ngsi-ld/v1/entities/%s\" , urlEncode(o.getId ()))" );
45154589 tl (5 , ")" );
45164590 tl (5 , ".ssl(config.getBoolean(ComputateConfigKeys.CONTEXT_BROKER_SSL))" );
45174591 tl (5 , ".putHeader(\" Content-Type\" , \" application/ld+json\" )" );
0 commit comments