Skip to content
Snippets Groups Projects
Commit cfd3a8ff authored by Lene Wasskog's avatar Lene Wasskog
Browse files

refactor: Use the same variables names from start to end, set altitude to 0

parent 1353d3fb
No related branches found
No related tags found
1 merge request!191Add map module and Open-Meteo support
...@@ -117,14 +117,14 @@ public class POIService { ...@@ -117,14 +117,14 @@ public class POIService {
LOGGER.error("Remember to check for roles as well, if necessary!"); LOGGER.error("Remember to check for roles as well, if necessary!");
PointOfInterestBean poiBean = SessionControllerGetter.getPointOfInterestBean(); PointOfInterestBean poiBean = SessionControllerGetter.getPointOfInterestBean();
Integer poiTypeId = poiMap.get("typeId") != null ? Integer.parseInt(poiMap.get("typeId").toString()) : null; Integer poiTypeId = poiMap.get("pointOfInterestTypeId") != null ? Integer.parseInt(poiMap.get("pointOfInterestTypeId").toString()) : null;
if(poiTypeId == null) { if(poiTypeId == null) {
return Response.status(Status.BAD_REQUEST).entity("Point of interest type is required").build(); return Response.status(Status.BAD_REQUEST).entity("pointOfInterestTypeId is required").build();
} }
String poiName = poiMap.get("name") != null ? poiMap.get("name").toString() : null; String poiName = poiMap.get("name") != null ? poiMap.get("name").toString() : null;
Double poiLongitude = poiMap.get("longitude") != null ? Double.valueOf(poiMap.get("longitude").toString()): null; Double poiLongitude = poiMap.get("longitude") != null ? Double.valueOf(poiMap.get("longitude").toString()): null;
Double poiLatitude = poiMap.get("latitude") != null ? Double.valueOf(poiMap.get("latitude").toString()): null; Double poiLatitude = poiMap.get("latitude") != null ? Double.valueOf(poiMap.get("latitude").toString()): null;
Double poiAltitude = poiMap.get("altitude") != null ? Double.valueOf(poiMap.get("altitude").toString()): null; Double poiAltitude = 0.0;
PointOfInterest poiToSave = PointOfInterestFactory.getPointOfInterest(poiTypeId); PointOfInterest poiToSave = PointOfInterestFactory.getPointOfInterest(poiTypeId);
poiToSave.setName(poiName); poiToSave.setName(poiName);
...@@ -149,7 +149,7 @@ public class POIService { ...@@ -149,7 +149,7 @@ public class POIService {
.build(); .build();
} else { } else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR) return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("Failed to create PointOfInterest") .entity("Failed to create PointOfInterest " + poiName)
.build(); .build();
} }
} }
......
...@@ -306,9 +306,9 @@ class MapModal { ...@@ -306,9 +306,9 @@ class MapModal {
confirmSelection(feature) { confirmSelection(feature) {
if (typeof this.callbackOnClose === 'function') { if (typeof this.callbackOnClose === 'function') {
const pointData = { const pointData = {
id: feature.properties.pointOfInterestId, pointOfInterestId: feature.properties.pointOfInterestId,
name: feature.properties.pointOfInterestName, name: feature.properties.pointOfInterestName,
typeId: feature.properties.pointOfInterestTypeId, pointOfInterestTypeId: feature.properties.pointOfInterestTypeId,
longitude: feature.geometry.coordinates[0], longitude: feature.geometry.coordinates[0],
latitude: feature.geometry.coordinates[1] latitude: feature.geometry.coordinates[1]
}; };
......
...@@ -108,21 +108,14 @@ ...@@ -108,21 +108,14 @@
} }
function callbackOnCloseLocationMap(poiData) { function callbackOnCloseLocationMap(poiData) {
if(!poiData.id) { if(!poiData.pointOfInterestId) {
persistNewLocation(poiData); persistNewLocation(poiData);
} else { } else {
selectPoi("locationPointOfInterestId", poiData.id); selectPoi("locationPointOfInterestId", poiData.pointOfInterestId);
} }
} }
function persistNewLocation(poiData) { function persistNewLocation(poiData) {
const params = {
'name': poiData.name,
'typeId': poiData.typeId,
'longitude': poiData.longitude,
'latitude': poiData.latitude,
'altitude': '0', // default value - populate using a service for getting altitude for coordinates?
}
fetch("/rest/poi", { fetch("/rest/poi", {
method: 'POST', method: 'POST',
headers: { headers: {
...@@ -130,7 +123,7 @@ ...@@ -130,7 +123,7 @@
'Accept': 'application/json', 'Accept': 'application/json',
'Authorization': '${user.userUuid!'NOT LOGGED IN?'}' 'Authorization': '${user.userUuid!'NOT LOGGED IN?'}'
}, },
body: JSON.stringify(params) body: JSON.stringify(poiData)
}) })
.then(response => response.json()) .then(response => response.json())
.then(poi => { .then(poi => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment