From 8ae9f83d33610458a752e180d90827358b23cd55 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 13 Feb 2024 19:37:21 -0700 Subject: [PATCH] Adding entityId, entityShortId, objectTitle, objectId fields to SmartDataModels --- .../computate/frFR/java/IndexerClasse.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/computate/frFR/java/IndexerClasse.java b/src/main/java/org/computate/frFR/java/IndexerClasse.java index b59ca169..2a812603 100644 --- a/src/main/java/org/computate/frFR/java/IndexerClasse.java +++ b/src/main/java/org/computate/frFR/java/IndexerClasse.java @@ -75,6 +75,7 @@ import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputField; +import org.computate.search.wrap.Wrap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Yaml; @@ -5439,6 +5440,7 @@ else if(langueConfig.getString(ConfigCles.var_PUTFusion).equals(classeApiMethode wSmartDataModel.l("import io.vertx.core.json.JsonObject;"); wSmartDataModel.l("import io.vertx.pgclient.data.Path;"); wSmartDataModel.l("import io.vertx.pgclient.data.Point;"); + wSmartDataModel.l("import io.vertx.pgclient.data.Polygon;"); wSmartDataModel.l(); wSmartDataModel.l("/**"); wSmartDataModel.l(" * SmartDataModel: ", classeSmartDataModel, " - ", classeSmartDataSubModule, " - ", classeSmartDataDomain); @@ -5484,7 +5486,7 @@ else if(langueConfig.getString(ConfigCles.var_PUTFusion).equals(classeApiMethode String description = field.getString("description"); String javaType = "JsonObject"; if("areaServed".equals(fieldName)) - javaType = "Path"; + javaType = "Polygon"; else if("location".equals(fieldName)) javaType = "Point"; else if("string".equals(jsonType)) @@ -5559,7 +5561,53 @@ else if("location".equals(fieldName)) wSmartDataModel.l(); } } + + wSmartDataModel.l(""); + wSmartDataModel.l(" /**"); + wSmartDataModel.l(" * {@inheritDoc}"); + wSmartDataModel.l(" * DocValues: true"); + wSmartDataModel.l(" * Persist: true"); + wSmartDataModel.l(" * DisplayName: entity ID"); + wSmartDataModel.l(" * Description: A unique ID for this Smart Data Model"); + wSmartDataModel.l(" * HtmRow: 3"); + wSmartDataModel.l(" * HtmCell: 1"); + wSmartDataModel.l(" * Facet: true"); + wSmartDataModel.l(" */"); + wSmartDataModel.l(" protected void _entityId(Wrap w) {"); + if(properties.fieldNames().contains("name")) { + wSmartDataModel.l(" w.o(String.format(\"urn:ngsi-ld:%s:%s\", CLASS_SIMPLE_NAME, toId(name)));"); + } + wSmartDataModel.l(" }"); + wSmartDataModel.l(""); + wSmartDataModel.l(" /**"); + wSmartDataModel.l(" * {@inheritDoc}"); + wSmartDataModel.l(" * DisplayName: short entity ID"); + wSmartDataModel.l(" * Description: A short ID for this Smart Data Model"); + wSmartDataModel.l(" * Facet: true"); + wSmartDataModel.l(" */"); + wSmartDataModel.l(" protected void _entityShortId(Wrap w) {"); + wSmartDataModel.l(" if(entityId != null) {"); + wSmartDataModel.l(" w.o(StringUtils.substringAfter(entityId, String.format(\"urn:ngsi-ld:%s:\", CLASS_SIMPLE_NAME)));"); + wSmartDataModel.l(" }"); + wSmartDataModel.l(" }"); + wSmartDataModel.l(""); + wSmartDataModel.l(" @Override"); + wSmartDataModel.l(" protected void _objectTitle(Wrap w) {"); + wSmartDataModel.l(" StringBuilder b = new StringBuilder();"); + wSmartDataModel.l(" b.append(Optional.ofNullable(entityShortId).map(s -> String.format(\"%s - %s\", ", classeNomSimple, "_NameAdjectiveSingular_enUS, s)).orElse(pk.toString()));"); + wSmartDataModel.l(" w.o(b.toString().trim());"); + wSmartDataModel.l(" }"); + wSmartDataModel.l(""); + wSmartDataModel.l(" @Override"); + wSmartDataModel.l(" protected void _objectId(Wrap w) {"); + wSmartDataModel.l(" if(objectTitle != null) {"); + wSmartDataModel.l(" w.o(toId(objectTitle));"); + wSmartDataModel.l(" } else if(id != null){"); + wSmartDataModel.l(" w.o(id.toString());"); + wSmartDataModel.l(" }"); + wSmartDataModel.l(" }"); wSmartDataModel.l("}"); + wSmartDataModel.l(); System.out.println(wSmartDataModel); }