Skip to content

Commit 8ae9f83

Browse files
committedFeb 14, 2024
Adding entityId, entityShortId, objectTitle, objectId fields to SmartDataModels
1 parent f3d5ff2 commit 8ae9f83

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed
 

‎src/main/java/org/computate/frFR/java/IndexerClasse.java

+49-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import org.apache.solr.common.SolrDocumentList;
7676
import org.apache.solr.common.SolrInputDocument;
7777
import org.apache.solr.common.SolrInputField;
78+
import org.computate.search.wrap.Wrap;
7879
import org.slf4j.Logger;
7980
import org.slf4j.LoggerFactory;
8081
import org.yaml.snakeyaml.Yaml;
@@ -5439,6 +5440,7 @@ else if(langueConfig.getString(ConfigCles.var_PUTFusion).equals(classeApiMethode
54395440
wSmartDataModel.l("import io.vertx.core.json.JsonObject;");
54405441
wSmartDataModel.l("import io.vertx.pgclient.data.Path;");
54415442
wSmartDataModel.l("import io.vertx.pgclient.data.Point;");
5443+
wSmartDataModel.l("import io.vertx.pgclient.data.Polygon;");
54425444
wSmartDataModel.l();
54435445
wSmartDataModel.l("/**");
54445446
wSmartDataModel.l(" * SmartDataModel: ", classeSmartDataModel, " - ", classeSmartDataSubModule, " - ", classeSmartDataDomain);
@@ -5484,7 +5486,7 @@ else if(langueConfig.getString(ConfigCles.var_PUTFusion).equals(classeApiMethode
54845486
String description = field.getString("description");
54855487
String javaType = "JsonObject";
54865488
if("areaServed".equals(fieldName))
5487-
javaType = "Path";
5489+
javaType = "Polygon";
54885490
else if("location".equals(fieldName))
54895491
javaType = "Point";
54905492
else if("string".equals(jsonType))
@@ -5559,7 +5561,53 @@ else if("location".equals(fieldName))
55595561
wSmartDataModel.l();
55605562
}
55615563
}
5564+
5565+
wSmartDataModel.l("");
5566+
wSmartDataModel.l(" /**");
5567+
wSmartDataModel.l(" * {@inheritDoc}");
5568+
wSmartDataModel.l(" * DocValues: true");
5569+
wSmartDataModel.l(" * Persist: true");
5570+
wSmartDataModel.l(" * DisplayName: entity ID");
5571+
wSmartDataModel.l(" * Description: A unique ID for this Smart Data Model");
5572+
wSmartDataModel.l(" * HtmRow: 3");
5573+
wSmartDataModel.l(" * HtmCell: 1");
5574+
wSmartDataModel.l(" * Facet: true");
5575+
wSmartDataModel.l(" */");
5576+
wSmartDataModel.l(" protected void _entityId(Wrap<String> w) {");
5577+
if(properties.fieldNames().contains("name")) {
5578+
wSmartDataModel.l(" w.o(String.format(\"urn:ngsi-ld:%s:%s\", CLASS_SIMPLE_NAME, toId(name)));");
5579+
}
5580+
wSmartDataModel.l(" }");
5581+
wSmartDataModel.l("");
5582+
wSmartDataModel.l(" /**");
5583+
wSmartDataModel.l(" * {@inheritDoc}");
5584+
wSmartDataModel.l(" * DisplayName: short entity ID");
5585+
wSmartDataModel.l(" * Description: A short ID for this Smart Data Model");
5586+
wSmartDataModel.l(" * Facet: true");
5587+
wSmartDataModel.l(" */");
5588+
wSmartDataModel.l(" protected void _entityShortId(Wrap<String> w) {");
5589+
wSmartDataModel.l(" if(entityId != null) {");
5590+
wSmartDataModel.l(" w.o(StringUtils.substringAfter(entityId, String.format(\"urn:ngsi-ld:%s:\", CLASS_SIMPLE_NAME)));");
5591+
wSmartDataModel.l(" }");
5592+
wSmartDataModel.l(" }");
5593+
wSmartDataModel.l("");
5594+
wSmartDataModel.l(" @Override");
5595+
wSmartDataModel.l(" protected void _objectTitle(Wrap<String> w) {");
5596+
wSmartDataModel.l(" StringBuilder b = new StringBuilder();");
5597+
wSmartDataModel.l(" b.append(Optional.ofNullable(entityShortId).map(s -> String.format(\"%s - %s\", ", classeNomSimple, "_NameAdjectiveSingular_enUS, s)).orElse(pk.toString()));");
5598+
wSmartDataModel.l(" w.o(b.toString().trim());");
5599+
wSmartDataModel.l(" }");
5600+
wSmartDataModel.l("");
5601+
wSmartDataModel.l(" @Override");
5602+
wSmartDataModel.l(" protected void _objectId(Wrap<String> w) {");
5603+
wSmartDataModel.l(" if(objectTitle != null) {");
5604+
wSmartDataModel.l(" w.o(toId(objectTitle));");
5605+
wSmartDataModel.l(" } else if(id != null){");
5606+
wSmartDataModel.l(" w.o(id.toString());");
5607+
wSmartDataModel.l(" }");
5608+
wSmartDataModel.l(" }");
55625609
wSmartDataModel.l("}");
5610+
55635611
wSmartDataModel.l();
55645612
System.out.println(wSmartDataModel);
55655613
}

0 commit comments

Comments
 (0)