Skip to content

Commit 62a70d9

Browse files
committed
Adding entityId, entityShortId, objectTitle, objectId fields to SmartDataModels
1 parent f3d5ff2 commit 62a70d9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

+47
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;
@@ -5559,7 +5560,53 @@ else if("location".equals(fieldName))
55595560
wSmartDataModel.l();
55605561
}
55615562
}
5563+
5564+
wSmartDataModel.l("");
5565+
wSmartDataModel.l(" /**");
5566+
wSmartDataModel.l(" * {@inheritDoc}");
5567+
wSmartDataModel.l(" * DocValues: true");
5568+
wSmartDataModel.l(" * Persist: true");
5569+
wSmartDataModel.l(" * DisplayName: entity ID");
5570+
wSmartDataModel.l(" * Description: A unique ID for this Smart Data Model");
5571+
wSmartDataModel.l(" * HtmRow: 3");
5572+
wSmartDataModel.l(" * HtmCell: 1");
5573+
wSmartDataModel.l(" * Facet: true");
5574+
wSmartDataModel.l(" */");
5575+
wSmartDataModel.l(" protected void _entityId(Wrap<String> w) {");
5576+
if(properties.fieldNames().contains("name")) {
5577+
wSmartDataModel.l(" w.o(String.format(\"urn:ngsi-ld:%s:%s\", CLASS_SIMPLE_NAME, toId(name)));");
5578+
}
5579+
wSmartDataModel.l(" }");
5580+
wSmartDataModel.l("");
5581+
wSmartDataModel.l(" /**");
5582+
wSmartDataModel.l(" * {@inheritDoc}");
5583+
wSmartDataModel.l(" * DisplayName: short entity ID");
5584+
wSmartDataModel.l(" * Description: A short ID for this Smart Data Model");
5585+
wSmartDataModel.l(" * Facet: true");
5586+
wSmartDataModel.l(" */");
5587+
wSmartDataModel.l(" protected void _entityShortId(Wrap<String> w) {");
5588+
wSmartDataModel.l(" if(entityId != null) {");
5589+
wSmartDataModel.l(" w.o(StringUtils.substringAfter(entityId, String.format(\"urn:ngsi-ld:%s:\", CLASS_SIMPLE_NAME)));");
5590+
wSmartDataModel.l(" }");
5591+
wSmartDataModel.l(" }");
5592+
wSmartDataModel.l("");
5593+
wSmartDataModel.l(" @Override");
5594+
wSmartDataModel.l(" protected void _objectTitle(Wrap<String> w) {");
5595+
wSmartDataModel.l(" StringBuilder b = new StringBuilder();");
5596+
wSmartDataModel.l(" b.append(Optional.ofNullable(entityShortId).map(s -> String.format(\"%s - %s\", ", classeNomSimple, "_NameAdjectiveSingular_enUS, s)).orElse(pk.toString()));");
5597+
wSmartDataModel.l(" w.o(b.toString().trim());");
5598+
wSmartDataModel.l(" }");
5599+
wSmartDataModel.l("");
5600+
wSmartDataModel.l(" @Override");
5601+
wSmartDataModel.l(" protected void _objectId(Wrap<String> w) {");
5602+
wSmartDataModel.l(" if(objectTitle != null) {");
5603+
wSmartDataModel.l(" w.o(toId(objectTitle));");
5604+
wSmartDataModel.l(" } else if(id != null){");
5605+
wSmartDataModel.l(" w.o(id.toString());");
5606+
wSmartDataModel.l(" }");
5607+
wSmartDataModel.l(" }");
55625608
wSmartDataModel.l("}");
5609+
55635610
wSmartDataModel.l();
55645611
System.out.println(wSmartDataModel);
55655612
}

0 commit comments

Comments
 (0)