diff --git a/src/main/java/no/nibio/vips/logic/modules/barkbeetle/BarkbeetleController.java b/src/main/java/no/nibio/vips/logic/modules/barkbeetle/BarkbeetleController.java
index 784bda6e3e45de560e050f099c72ae941f9e4c14..4e9ac249ad1c88240987e9cbd69c4751ac5790a8 100644
--- a/src/main/java/no/nibio/vips/logic/modules/barkbeetle/BarkbeetleController.java
+++ b/src/main/java/no/nibio/vips/logic/modules/barkbeetle/BarkbeetleController.java
@@ -136,6 +136,10 @@ public class BarkbeetleController extends HttpServlet {
trapsite.setCountyName(formValidation.getFormField("countyName").getWebValue());
trapsite.setMunicipalityNo(formValidation.getFormField("municipalityNo").isEmpty() ? null : formValidation.getFormField("municipalityNo").getValueAsInteger());
trapsite.setMunicipalityName(formValidation.getFormField("municipalityName").getWebValue());
+ trapsite.setCounty2012No(formValidation.getFormField("county2012No").isEmpty() ? null : formValidation.getFormField("countyNo").getValueAsInteger());
+ trapsite.setCounty2012Name(formValidation.getFormField("county2012Name").getWebValue());
+ trapsite.setMunicipality2012No(formValidation.getFormField("municipality2012No").isEmpty() ? null : formValidation.getFormField("municipalityNo").getValueAsInteger());
+ trapsite.setMunicipality2012Name(formValidation.getFormField("municipality2012Name").getWebValue());
trapsite.setPropertyNo(formValidation.getFormField("propertyNo").isEmpty() ? null : formValidation.getFormField("propertyNo").getValueAsInteger());
trapsite.setPropertySectionNo(formValidation.getFormField("propertySectionNo").isEmpty() ? null : formValidation.getFormField("propertySectionNo").getValueAsInteger());
trapsite.setOwnerName(formValidation.getFormField("ownerName").getWebValue());
diff --git a/src/main/java/no/nibio/vips/logic/modules/barkbeetle/SeasonTrapsite.java b/src/main/java/no/nibio/vips/logic/modules/barkbeetle/SeasonTrapsite.java
index fca1de2c5f183955bfc62829ab92c7b3aafaf96d..60522a7185919dbff3050400bb1b84bb9552f191 100644
--- a/src/main/java/no/nibio/vips/logic/modules/barkbeetle/SeasonTrapsite.java
+++ b/src/main/java/no/nibio/vips/logic/modules/barkbeetle/SeasonTrapsite.java
@@ -116,6 +116,14 @@ public class SeasonTrapsite implements Serializable, Comparable {
private Integer municipalityNo;
@Column(name = "municipality_name")
private String municipalityName;
+ @Column(name = "county2012_no")
+ private Integer county2012No;
+ @Column(name = "county2012_name")
+ private String county2012Name;
+ @Column(name = "municipality2012_no")
+ private Integer municipality2012No;
+ @Column(name = "municipality2012_name")
+ private String municipality2012Name;
@Column(name = "property_no")
private Integer propertyNo;
@Column(name = "property_section_no")
@@ -498,5 +506,37 @@ public class SeasonTrapsite implements Serializable, Comparable {
return 0;
}
+
+ public Integer getCounty2012No() {
+ return county2012No;
+ }
+
+ public void setCounty2012No(Integer county2012No) {
+ this.county2012No = county2012No;
+ }
+
+ public String getCounty2012Name() {
+ return county2012Name;
+ }
+
+ public void setCounty2012Name(String county2012Name) {
+ this.county2012Name = county2012Name;
+ }
+
+ public Integer getMunicipality2012No() {
+ return municipality2012No;
+ }
+
+ public void setMunicipality2012No(Integer municipality2012No) {
+ this.municipality2012No = municipality2012No;
+ }
+
+ public String getMunicipality2012Name() {
+ return municipality2012Name;
+ }
+
+ public void setMunicipality2012Name(String municipality2012Name) {
+ this.municipality2012Name = municipality2012Name;
+ }
}
diff --git a/src/main/webapp/formdefinitions/modules/barkbeetle/seasonTrapsiteForm.json b/src/main/webapp/formdefinitions/modules/barkbeetle/seasonTrapsiteForm.json
index 7f13872e3072244f48249122810e29ad438c2ed6..f108339f3e1a66b73c74e85fa22399957367dc74 100644
--- a/src/main/webapp/formdefinitions/modules/barkbeetle/seasonTrapsiteForm.json
+++ b/src/main/webapp/formdefinitions/modules/barkbeetle/seasonTrapsiteForm.json
@@ -92,6 +92,26 @@
"dataType" : "STRING",
"required" : false
},
+{
+ "name" : "county2012No",
+ "dataType" : "INTEGER",
+ "required" : false
+ },
+ {
+ "name" : "county2012Name",
+ "dataType" : "STRING",
+ "required" : false
+ },
+ {
+ "name" : "municipality2012No",
+ "dataType" : "INTEGER",
+ "required" : false
+ },
+ {
+ "name" : "municipality2012Name",
+ "dataType" : "STRING",
+ "required" : false
+ },
{
"name" : "propertyNo",
"dataType" : "INTEGER",
diff --git a/src/main/webapp/templates/modules/barkbeetle/barkbeetleSeasonTrapsiteForm.ftl b/src/main/webapp/templates/modules/barkbeetle/barkbeetleSeasonTrapsiteForm.ftl
index 0250619842e1404f21a7014abed9bb0aa1c4a829..f4ff0f831d465a5eaca0483dfc3e3ea8865247a8 100644
--- a/src/main/webapp/templates/modules/barkbeetle/barkbeetleSeasonTrapsiteForm.ftl
+++ b/src/main/webapp/templates/modules/barkbeetle/barkbeetleSeasonTrapsiteForm.ftl
@@ -71,7 +71,7 @@
});
// Get County and municipality
- fetch("/corsproxy/https://proxy1.nibio.no/municipality_cache_ws/kommuneListe/N2000/4326/2019?lon=" + lon + "&lat=" + lat)
+ fetch("/corsproxy/https://proxy1.nibio.no/municipality_cache_ws/kommuneListe/N2000/4326/?lon=" + lon + "&lat=" + lat)
.then(response => response.json())
.then(municInfo =>{
if(municInfo.length == 0)
@@ -91,6 +91,28 @@
}
}
)
+ .catch( error => console.info(error));
+
+ // Get County and municipality from before 2012
+ fetch("/corsproxy/https://proxy1.nibio.no/municipality_cache_ws/kommuneListe/N2000/4326/2019?lon=" + lon + "&lat=" + lat)
+ .then(response => response.json())
+ .then(municInfo =>{
+ if(municInfo.length == 0)
+ {
+ theForm["county2012No"].value = 0;
+ theForm["county2012Name"].value = "Utlandet";
+ theForm["municipality2012No"].value = 0;
+ theForm["municipality2012Name"].value = "Utlandet";
+ }
+ else
+ {
+ theForm["county2012No"].value=municInfo[0]["fylkenr"];
+ theForm["county2012Name"].value=municInfo[0]["fylkenavn"];
+ theForm["municipality2012No"].value=municInfo[0]["komnr"];
+ theForm["municipality2012Name"].value=municInfo[0]["komnavn"];
+ }
+ }
+ )
.catch( error => console.info(error));;
}
@@ -146,9 +168,9 @@
og <a href="/images/modules/barkbeetle/Montering_av_barkbillefelle.pdf">Monteringsanvisning
Beka-felle</a>
</p>
- <p>Merk at fylkesnr, fylkesnavn, kommunenr og kommunenavn som genereres er
+ <!--p>Merk at fylkesnr, fylkesnavn, kommunenr og kommunenavn som genereres er
fra før sammenslåinger (2012). Registrant sørger bare for riktig plassering i kart.
- </p>
+ </p-->
<p>
<#if seasonTrapsite.seasonTrapsiteId?has_content>
<a href="/barkbeetle?action=registerData&seasonTrapsiteId=${seasonTrapsite.seasonTrapsiteId}" class="btn btn-default" role="button">Registrer fangstdata</a>
@@ -201,6 +223,10 @@
<input type="text" class="form-control" id="gisGeom" name="gisGeom" placeholder="Lokalitet" value="${(seasonTrapsite.longitude?c)!""},${(seasonTrapsite.latitude?c)!""}" onblur="validateField(this);" onchange="if(validateField(this)){handleLocationChanged(this);updateMarkerPosition();}" />
<span class="help-block" id="${formId}_gisGeom_validation"></span>
</div>
+ <input type="hidden" name="county2012No" value="${(seasonTrapsite.county2012No)!""}"/>
+ <input type="hidden" name="county2012Name" value="${(seasonTrapsite.county2012Name)!""}"/>
+ <input type="hidden" name="municipality2012No" value="${(seasonTrapsite.municipality2012No)!""}"/>
+ <input type="hidden" name="municipality2012Name" value="${(seasonTrapsite.municipality2012Name)!""}"/>
<div class="form-group">
<label for="altitude">Høyde over havet (m)</label>
<input type="number" class="form-control" name="altitude" step="0.1" placeholder="Høyde over havet" value="${(seasonTrapsite.altitude?c)!""}" onblur="validateField(this);" <#if !userIsAdmin>readonly</#if>/>