diff --git a/src/main/java/no/nibio/vips/logic/controller/servlet/PointOfInterestController.java b/src/main/java/no/nibio/vips/logic/controller/servlet/PointOfInterestController.java index 9f2d923e257ecf34d61b674b402bedac9f633291..e1a80dd79fe9824855b0c45213a5447d4cdb9556 100755 --- a/src/main/java/no/nibio/vips/logic/controller/servlet/PointOfInterestController.java +++ b/src/main/java/no/nibio/vips/logic/controller/servlet/PointOfInterestController.java @@ -298,6 +298,8 @@ public class PointOfInterestController extends HttpServlet { { weatherStation.setIsForecastLocation(Boolean.TRUE); } + + weatherStation.setIsPrivate(formValidation.getFormField("isPrivate").getWebValue() != null); Double altitude = 0.0; Point p2d = formValidation.getFormField("location").getValueAsPointWGS84(); @@ -657,6 +659,8 @@ public class PointOfInterestController extends HttpServlet { { poi.setIsForecastLocation(Boolean.FALSE); } + + poi.setIsPrivate(formValidation.getFormField("isPrivate").getWebValue() != null); Double altitude = 0.0; Point p2d = formValidation.getFormField("location").getValueAsPointWGS84(); diff --git a/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java b/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java index 33aaf8a0e4d5dcbe88baf9394b921bed4de517c0..1994194e6297c20f3c8f1ca459f539f0283955d7 100755 --- a/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java +++ b/src/main/java/no/nibio/vips/logic/entity/PointOfInterest.java @@ -91,8 +91,17 @@ public class PointOfInterest implements Serializable, Comparable { private Boolean isForecastLocation; private Integer pointOfInterestTypeId; private Date lastEditedTime; + private Boolean isPrivate; - + @Column(name = "is_private") + public Boolean getIsPrivate() { + return isPrivate; + } + + public void setIsPrivate(Boolean isPrivate) { + this.isPrivate = isPrivate; + } + // For attaching ad-hoc properties // e.g. Worst warning for map private Map<String, Object> properties; diff --git a/src/main/resources/db/migration/V21__Add_POI_Property_IsPrivate.sql b/src/main/resources/db/migration/V21__Add_POI_Property_IsPrivate.sql new file mode 100644 index 0000000000000000000000000000000000000000..abc442d80985e6130b570ac1d5471843d7509148 --- /dev/null +++ b/src/main/resources/db/migration/V21__Add_POI_Property_IsPrivate.sql @@ -0,0 +1,12 @@ +-- Adding this property when adding support for private POIs/weather datasources in VIPS +ALTER TABLE point_of_interest +ADD COLUMN is_private BOOLEAN DEFAULT FALSE; + +-- Set all POIS not owned by a superuser or admin to is_private = TRUE +UPDATE point_of_interest +SET is_private=TRUE +WHERE user_id NOT IN +( + SELECT DISTINCT user_id FROM user_vips_logic_role + WHERE vips_logic_role_id IN (1,2) +); \ No newline at end of file diff --git a/src/main/webapp/formdefinitions/poiForm.json b/src/main/webapp/formdefinitions/poiForm.json index 6aa6e956f28c279cad1d247f5e35be0069ed9921..83a8b2f07cdc65cf3f1e72e061d7bb177ea0ab3c 100755 --- a/src/main/webapp/formdefinitions/poiForm.json +++ b/src/main/webapp/formdefinitions/poiForm.json @@ -86,6 +86,11 @@ "name" : "isForecastLocation", "dataType" : "STRING", "required" : false + }, + { + "name" : "isPrivate", + "dataType" : "STRING", + "required" : false } ] } diff --git a/src/main/webapp/formdefinitions/weatherStationForm.json b/src/main/webapp/formdefinitions/weatherStationForm.json index c4540a5267b1559eafb1ea817be29cd8f613bc6b..3b0af8f3afed9554273194d7592f241735cbd4c0 100755 --- a/src/main/webapp/formdefinitions/weatherStationForm.json +++ b/src/main/webapp/formdefinitions/weatherStationForm.json @@ -87,6 +87,11 @@ "dataType" : "STRING", "fieldType" : "MULTIPLE_MAP", "required" : false + }, + { + "name" : "isPrivate", + "dataType" : "STRING", + "required" : false } ] diff --git a/src/main/webapp/templates/poiForm.ftl b/src/main/webapp/templates/poiForm.ftl index 58fe8f499d7c016a75595b1ddc7100efed9f3be0..7e7287849cd1f53bb998f4eacb0da65abe7f648c 100755 --- a/src/main/webapp/templates/poiForm.ftl +++ b/src/main/webapp/templates/poiForm.ftl @@ -81,6 +81,14 @@ <input type="text" class="form-control" name="name" placeholder="${i18nBundle.name}" value="${(poi.name)!""}" onblur="validateField(this); checkPoiNameAvailability(this);"/> <span class="help-block" id="${formId}_name_validation"></span> </div> + <div class="form-group"> + <div class="checkbox"> + <label> + <input type="checkbox" name="isPrivate"<#if poi.isPrivate?has_content && poi.isPrivate == true> checked="checked"<#else></#if>/> + </label> + ${i18nBundle.isPrivate} + </div> + </div> <div class="form-group"> <label for="pointOfInterestTypeId">${i18nBundle.pointOfInterestType}</label> <select class="form-control" name="pointOfInterestTypeId" onblur="validateField(this);"> diff --git a/src/main/webapp/templates/weatherstationForm.ftl b/src/main/webapp/templates/weatherstationForm.ftl index cb0a0afd4225804dbd7e48e967bb728f792b50d9..07089514dc6edd1e353b7987412894b487a08845 100755 --- a/src/main/webapp/templates/weatherstationForm.ftl +++ b/src/main/webapp/templates/weatherstationForm.ftl @@ -71,6 +71,14 @@ </label> </div> </div> + <div class="form-group"> + <div class="checkbox"> + <label> + <input type="checkbox" name="isPrivate"<#if weatherStation.isPrivate?has_content && weatherStation.isPrivate == true> checked="checked"<#else></#if>/> + </label> + ${i18nBundle.isPrivate} + </div> + </div> <div class="form-group"> <label for="location">${i18nBundle.location} (<a href="http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS_84" target="new">WGS84</a>: ${i18nBundle.longitude},${i18nBundle.latitude})</label> <input type="text" class="form-control" id="location" name="location" placeholder="${i18nBundle.location}" value="${(weatherStation.longitude?c)!""},${(weatherStation.latitude?c)!""}" onblur="validateField(this);" onchange="if(validateField(this)){updateMarkerPosition();}" />