Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NSPSUPPORT-137

- flyttet kommune -> region mapning ud i property fil, der kan overskrives eksternt
- tilføjet 6 ikke-regions kommuner og mappet dem til værdien 99 jvf aftale med Stig/Medcom
  • Loading branch information...
commit dd7ec1ea3f0df902305b68b34ed4c62adabc7685 1 parent 3faff98
bbg authored
View
147 nsp/cpr-ws/src/main/java/dk/nsi/stamdata/cpr/mapping/MunicipalityMapper.java
@@ -24,144 +24,43 @@
*/
package dk.nsi.stamdata.cpr.mapping;
-import java.util.Map;
+import java.util.Properties;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Ordering;
+import org.apache.commons.io.IOUtils;
+import java.io.IOException;
+import java.io.InputStream;
public class MunicipalityMapper
{
public String toCountyCode(String municipalityCode)
{
- String countyCode = municipalityToCounty.get(municipalityCode);
+ String countyCode = municipalityToCounty.getProperty(municipalityCode);
Preconditions.checkState(countyCode != null, "The municipality code '%s' is not associated with any county. There is an error in the registry or CPR-service.", municipalityCode);
return countyCode;
}
- private static final Map<String, String> municipalityToCounty;
+ private static Properties municipalityToCounty = new Properties();
static
{
- // Ordering the entries in a tree by name should be faster than
- // a hash map.
-
- municipalityToCounty = Maps.newTreeMap(Ordering.usingToString());
-
- // Region Hovedstaden
-
- municipalityToCounty.put("0101", "1084");
- municipalityToCounty.put("0147", "1084");
- municipalityToCounty.put("0151", "1084");
- municipalityToCounty.put("0153", "1084");
- municipalityToCounty.put("0155", "1084");
- municipalityToCounty.put("0157", "1084");
- municipalityToCounty.put("0159", "1084");
- municipalityToCounty.put("0161", "1084");
- municipalityToCounty.put("0163", "1084");
- municipalityToCounty.put("0165", "1084");
- municipalityToCounty.put("0167", "1084");
- municipalityToCounty.put("0169", "1084");
- municipalityToCounty.put("0173", "1084");
- municipalityToCounty.put("0175", "1084");
- municipalityToCounty.put("0230", "1084");
- municipalityToCounty.put("0183", "1084");
- municipalityToCounty.put("0185", "1084");
- municipalityToCounty.put("0187", "1084");
- municipalityToCounty.put("0201", "1084");
- municipalityToCounty.put("0190", "1084");
- municipalityToCounty.put("0210", "1084");
- municipalityToCounty.put("0250", "1084");
- municipalityToCounty.put("0260", "1084");
- municipalityToCounty.put("0270", "1084");
- municipalityToCounty.put("0217", "1084");
- municipalityToCounty.put("0219", "1084");
- municipalityToCounty.put("0223", "1084");
- municipalityToCounty.put("0240", "1084");
- municipalityToCounty.put("0400", "1084");
- municipalityToCounty.put("0411", "1084");
-
- // Region Sjælland
-
- municipalityToCounty.put("0350", "1085");
- municipalityToCounty.put("0253", "1085");
- municipalityToCounty.put("0259", "1085");
- municipalityToCounty.put("0265", "1085");
- municipalityToCounty.put("0269", "1085");
- municipalityToCounty.put("0306", "1085");
- municipalityToCounty.put("0320", "1085");
- municipalityToCounty.put("0316", "1085");
- municipalityToCounty.put("0326", "1085");
- municipalityToCounty.put("0329", "1085");
- municipalityToCounty.put("0330", "1085");
- municipalityToCounty.put("0340", "1085");
- municipalityToCounty.put("0360", "1085");
- municipalityToCounty.put("0376", "1085");
- municipalityToCounty.put("0370", "1085");
- municipalityToCounty.put("0336", "1085");
- municipalityToCounty.put("0390", "1085");
-
- // Region Syddanmark (1083)
-
- municipalityToCounty.put("0420", "1083");
- municipalityToCounty.put("0430", "1083");
- municipalityToCounty.put("0440", "1083");
- municipalityToCounty.put("0410", "1083");
- municipalityToCounty.put("0450", "1083");
- municipalityToCounty.put("0461", "1083");
- municipalityToCounty.put("0479", "1083");
- municipalityToCounty.put("0482", "1083");
- municipalityToCounty.put("0480", "1083");
- municipalityToCounty.put("0492", "1083");
- municipalityToCounty.put("0510", "1083");
- municipalityToCounty.put("0580", "1083");
- municipalityToCounty.put("0561", "1083");
- municipalityToCounty.put("0563", "1083");
- municipalityToCounty.put("0530", "1083");
- municipalityToCounty.put("0573", "1083");
- municipalityToCounty.put("0575", "1083");
- municipalityToCounty.put("0607", "1083");
- municipalityToCounty.put("0621", "1083");
- municipalityToCounty.put("0630", "1083");
- municipalityToCounty.put("0766", "1083");
- municipalityToCounty.put("0615", "1083");
- municipalityToCounty.put("0657", "1083");
- municipalityToCounty.put("0661", "1083");
- municipalityToCounty.put("0756", "1083");
- municipalityToCounty.put("0540", "1083");
- municipalityToCounty.put("0550", "1083");
-
-
- // Region Midtjylland (1082)
-
- municipalityToCounty.put("0665", "1082");
- municipalityToCounty.put("0760", "1082");
- municipalityToCounty.put("0671", "1082");
- municipalityToCounty.put("0706", "1082");
- municipalityToCounty.put("0707", "1082");
- municipalityToCounty.put("0710", "1082");
- municipalityToCounty.put("0727", "1082");
- municipalityToCounty.put("0730", "1082");
- municipalityToCounty.put("0741", "1082");
- municipalityToCounty.put("0740", "1082");
- municipalityToCounty.put("0746", "1082");
- municipalityToCounty.put("0751", "1082");
- municipalityToCounty.put("0779", "1082");
- municipalityToCounty.put("0791", "1082");
-
- // Region Nordjylland (1081)
-
- municipalityToCounty.put("0773", "1081");
- municipalityToCounty.put("0787", "1081");
- municipalityToCounty.put("0810", "1081");
- municipalityToCounty.put("0813", "1081");
- municipalityToCounty.put("0860", "1081");
- municipalityToCounty.put("0846", "1081");
- municipalityToCounty.put("0825", "1081");
- municipalityToCounty.put("0840", "1081");
- municipalityToCounty.put("0849", "1081");
- municipalityToCounty.put("0851", "1081");
- municipalityToCounty.put("0820", "1081");
+ ClassLoader classLoader = MunicipalityMapper.class.getClassLoader();
+ InputStream isInternal = classLoader.getResourceAsStream("municipalities-internal.properties");
+ InputStream isExternal = classLoader.getResourceAsStream("municipalities-external.properties");
+
+ try {
+ municipalityToCounty.load(isInternal);
+
+ // external file is optional, but will overwrite settings in the internal file
+ if (isExternal != null) {
+ municipalityToCounty.load(isExternal);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Problem loading one of the municipalities.properties file", e);
+ } finally {
+ IOUtils.closeQuietly(isExternal);
+ IOUtils.closeQuietly(isInternal);
+ }
}
}
View
117 nsp/cpr-ws/src/main/resources/municipalities-internal.properties
@@ -0,0 +1,117 @@
+# Region Hovedstaden
+0101=1084
+0147=1084
+0151=1084
+0153=1084
+0155=1084
+0157=1084
+0159=1084
+0161=1084
+0163=1084
+0165=1084
+0167=1084
+0169=1084
+0173=1084
+0175=1084
+0230=1084
+0183=1084
+0185=1084
+0187=1084
+0201=1084
+0190=1084
+0210=1084
+0250=1084
+0260=1084
+0270=1084
+0217=1084
+0219=1084
+0223=1084
+0240=1084
+0400=1084
+0411=1084
+
+# Region Sjælland
+0350=1085
+0253=1085
+0259=1085
+0265=1085
+0269=1085
+0306=1085
+0320=1085
+0316=1085
+0326=1085
+0329=1085
+0330=1085
+0340=1085
+0360=1085
+0376=1085
+0370=1085
+0336=1085
+0390=1085
+
+# Region Syddanmark
+0420=1083
+0430=1083
+0440=1083
+0410=1083
+0450=1083
+0461=1083
+0479=1083
+0482=1083
+0480=1083
+0492=1083
+0510=1083
+0580=1083
+0561=1083
+0563=1083
+0530=1083
+0573=1083
+0575=1083
+0607=1083
+0621=1083
+0630=1083
+0766=1083
+0615=1083
+0657=1083
+0661=1083
+0756=1083
+0540=1083
+0550=1083
+
+# Region Midtjylland
+0665=1082
+0760=1082
+0671=1082
+0706=1082
+0707=1082
+0710=1082
+0727=1082
+0730=1082
+0741=1082
+0740=1082
+0746=1082
+0751=1082
+0779=1082
+0791=1082
+
+# Region Nordjylland
+0773=1081
+0787=1081
+0810=1081
+0813=1081
+0860=1081
+0846=1081
+0825=1081
+0840=1081
+0849=1081
+0851=1081
+0820=1081
+
+# Udenfor regioner
+0890=99
+0912=99
+0955=99
+0956=99
+0957=99
+0958=99
+0961=99
Please sign in to comment.
Something went wrong with that request. Please try again.