Skip to content

Commit c1a7652

Browse files
committed
Adding a default location for smart data models
1 parent f5a661e commit c1a7652

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5553,15 +5553,15 @@ else if(entiteIndexe
55535553

55545554
wNgsiMethode.tl(2, "case VAR_", entiteVar, ":");
55555555
if("Point".equals(entiteNomSimple)) {
5556-
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"Point\").put(\"coordinates\", new JsonArray().add(Double.valueOf(o.get", entiteVarCapitalise, "().getX())).add(Double.valueOf(o.get", entiteVarCapitalise, "().getY()))).toString();");
5556+
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"Point\").put(\"coordinates\", new JsonArray().add(Double.valueOf(o.get", entiteVarCapitalise, "().getX())).add(Double.valueOf(o.get", entiteVarCapitalise, "().getY())));");
55575557
} else if("Path".equals(entiteNomSimple)) {
55585558
wNgsiMethode.tl(3, "JsonArray pointsArray", entiteVarCapitalise, " = new JsonArray();");
55595559
wNgsiMethode.tl(3, "o.get", entiteVarCapitalise, "().getPoints().stream().map(point -> new JsonArray().add(Double.valueOf(point.getX())).add(Double.valueOf(point.getY()))).collect(Collectors.toList()).forEach(pointArray -> pointsArray", entiteVarCapitalise, ".add(pointArray));");
5560-
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"LineString\").put(\"coordinates\", pointsArray", entiteVarCapitalise, ").toString();");
5560+
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"LineString\").put(\"coordinates\", pointsArray", entiteVarCapitalise, ");");
55615561
} else if("Polygon".equals(entiteNomSimple)) {
55625562
wNgsiMethode.tl(3, "JsonArray pointsArray", entiteVarCapitalise, " = new JsonArray();");
55635563
wNgsiMethode.tl(3, "o.get", entiteVarCapitalise, "().getPoints().stream().map(point -> new JsonArray().add(Double.valueOf(point.getX())).add(Double.valueOf(point.getY()))).collect(Collectors.toList()).forEach(pointArray -> pointsArray", entiteVarCapitalise, ".add(pointArray));");
5564-
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"LineString\").put(\"coordinates\", pointsArray", entiteVarCapitalise, ").toString();");
5564+
wNgsiMethode.tl(3, "return new JsonObject().put(\"type\", \"LineString\").put(\"coordinates\", pointsArray", entiteVarCapitalise, ");");
55655565
} else {
55665566
wNgsiMethode.tl(3, "return o.get", entiteVarCapitalise, "();");
55675567
}

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,12 +1919,10 @@ public void pageCodeClasseJava(String langueNom, JsonObject langueConfig) throws
19191919
if(classePageSuperNomSimple != null)
19201920
tl(1, "@Override");
19211921
tl(1, "protected void _DEFAULT_MAP_LOCATION(", classePartsCouverture.nomSimple(langueNom), "<JsonObject> ", langueConfig.getString(I18n.var_cVar), ") {");
1922-
tl(2, "String pointStr = Optional.ofNullable(", langueConfig.getString(I18n.var_requeteSite), "_.get", langueConfig.getString(I18n.var_Requete), "Vars().get(VAR_DEFAULT_MAP_LOCATION)).orElse(", langueConfig.getString(I18n.var_requeteSite), "_.getConfig().getString(", classePartsConfigCles.nomSimple(langueNom), ".DEFAULT_MAP_LOCATION));");
1923-
tl(2, "if(pointStr != null) {");
1924-
tl(3, "String[] parts = pointStr.replace(\"[\", \"\").replace(\"]\", \"\").replace(\"\\\"\", \"\").split(\",\");");
1925-
tl(3, "JsonObject point = new JsonObject().put(\"lat\", Double.parseDouble(parts[0])).put(\"lon\", Double.parseDouble(parts[1]));");
1926-
tl(3, langueConfig.getString(I18n.var_cVar), ".o(point);");
1927-
tl(2, "}");
1922+
if(classeVarEmplacement != null) {
1923+
tl(2, "Point point = ", classeNomSimple, ".staticSet", StringUtils.capitalize(classeVarEmplacement), "(", langueConfig.getString(I18n.var_requeteSite), "_, Optional.ofNullable(", langueConfig.getString(I18n.var_requeteSite), "_.get", langueConfig.getString(I18n.var_Requete), "Vars().get(VAR_DEFAULT_MAP_LOCATION)).orElse(", langueConfig.getString(I18n.var_requeteSite), "_.getConfig().getString(", classePartsConfigCles.nomSimple(langueNom), ".DEFAULT_MAP_LOCATION)));");
1924+
tl(2, "w.o(new JsonObject().put(\"type\", \"Point\").put(\"coordinates\", new JsonArray().add(Double.valueOf(point.getX())).add(Double.valueOf(point.getY()))));");
1925+
}
19281926
tl(1, "}");
19291927
l();
19301928
if(classePageSuperNomSimple != null)
@@ -2884,7 +2882,7 @@ public void ecrirePageHeadJinja(String langueNom, JsonObject i18nPage, Boolean e
28842882

28852883
// tl(3, "document.querySelector('#site-calendar-box').accordion({ collapsible: true, active: false });");
28862884
l("{% if DEFAULT_MAP_LOCATION is defined %}");
2887-
tl(3, "window.DEFAULT_MAP_LOCATION = { lat: {{ DEFAULT_MAP_LOCATION.lat }}, lon: {{ DEFAULT_MAP_LOCATION.lon }} };");
2885+
tl(3, "window.DEFAULT_MAP_LOCATION = { type: 'Point', coordinates: [ {{ DEFAULT_MAP_LOCATION.coordinates[0] }}, {{ DEFAULT_MAP_LOCATION.coordinates[1] }} ]};");
28882886
l("{% endif %}");
28892887
l("{% if DEFAULT_MAP_ZOOM is defined %}");
28902888
tl(3, "window.DEFAULT_MAP_ZOOM = {{ DEFAULT_MAP_ZOOM }};");
@@ -3833,11 +3831,11 @@ else if(entiteAttribuer) {
38333831
auteurPageJs.tl(3, "}).addTo(window.map", classeNomSimple, ");");
38343832
auteurPageJs.l();
38353833
auteurPageJs.tl(3, "if(window['DEFAULT_MAP_LOCATION'] && window['DEFAULT_MAP_ZOOM'])");
3836-
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView([window['DEFAULT_MAP_LOCATION']['lat'], window['DEFAULT_MAP_LOCATION']['lon']], window['DEFAULT_MAP_ZOOM']);");
3834+
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView([window['DEFAULT_MAP_LOCATION']['coordinates'][1], window['DEFAULT_MAP_LOCATION']['coordinates'][0]], window['DEFAULT_MAP_ZOOM']);");
38373835
auteurPageJs.tl(3, "else if(window['DEFAULT_MAP_ZOOM'])");
38383836
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView(null, window['DEFAULT_MAP_ZOOM']);");
38393837
auteurPageJs.tl(3, "else if(window['DEFAULT_MAP_LOCATION'])");
3840-
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView([window['DEFAULT_MAP_LOCATION']['lat'], window['DEFAULT_MAP_LOCATION']['lon']]);");
3838+
auteurPageJs.tl(4, "window.map", classeNomSimple, ".setView([window['DEFAULT_MAP_LOCATION']['coordinates'][1], window['DEFAULT_MAP_LOCATION']['coordinates'][0]]);");
38413839
auteurPageJs.l();
38423840
auteurPageJs.tl(3, "layout['margin'] = { r: 0, t: 0, b: 0, l: 0 };");
38433841
auteurPageJs.tl(3, "window.geoJSON", classeNomSimple, " = L.geoJSON().addTo(window.map", classeNomSimple, ");");

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6417,7 +6417,11 @@ else if("location".equals(fieldName))
64176417
wSmartDataModel.l(" * HtmCell: ", cell, "");
64186418
wSmartDataModel.l(" * Facet: true");
64196419
wSmartDataModel.l(" **/");
6420-
wSmartDataModel.l(" protected void _", fieldName, "(Wrap<", javaType, "> w) {}");
6420+
wSmartDataModel.l(" protected void _", fieldName, "(Wrap<", javaType, "> w) {");
6421+
if("location".equals(fieldName)) {
6422+
wSmartDataModel.l(" w.o(staticSetLocation(siteRequest_, siteRequest_.getConfig().getString(ComputateConfigKeys.DEFAULT_MAP_LOCATION)));");
6423+
}
6424+
wSmartDataModel.l(" }");
64216425
}
64226426
cell++;
64236427
// if(cell > 3) {

0 commit comments

Comments
 (0)