/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/fileupload/AddressSourceFD.java
ViewVC logotype

Contents of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/fileupload/AddressSourceFD.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2954 - (show annotations) (download)
Tue Feb 16 13:15:25 2016 UTC (8 years, 3 months ago) by torben
File size: 2132 byte(s)
When done - schedule a incremental distance calculation
1 package dk.daoas.adressevedligehold.fileupload;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import org.apache.commons.fileupload.FileItem;
7
8 import com.google.common.base.Splitter;
9
10 import dk.daoas.adressevedligehold.fileupload.AddressSourceEntry.EntryType;
11
12 public class AddressSourceFD extends AbstractAddressSource {
13
14
15 String filenameFirst2;
16
17 public AddressSourceFD(FileItem file) throws Exception {
18 super(file);
19
20 filenameFirst2 = file.getName().substring(0, 2).toUpperCase();
21 }
22
23 @Override
24 public void validate() throws IOException {
25 super.validateWithHeader(9, ';');
26 }
27
28
29
30 @Override
31 public AddressSourceEntry getNextEntry() throws IOException {
32 String line = br.readLine();
33 if (line == null) // end of file
34 return null;
35
36 if (line.trim().equals(""))
37 return null;
38
39
40 AddressSourceEntry entry = new AddressSourceEntry( EntryType.TypeSingleAddress);
41 entry.distributor = "FD";
42
43 List<String> parts = Splitter.on(';').splitToList(line);
44
45 if (parts.size() != 9) {
46 throw new IOException("Not enough fields in line " + line);
47 }
48
49 entry.postnr = Short.parseShort( parts.get(0) );
50 entry.vejnavn = parts.get(1);
51 entry.husnr = Short.parseShort( parts.get(2) );
52 entry.litra = parts.get(3);
53 entry.vejkode = Short.parseShort( parts.get(4) );
54 entry.kommunekode = Short.parseShort( parts.get(5) );
55 entry.gadeid = Integer.parseInt( parts.get(6) );
56 entry.rute = dirigeringsCache.getInstance( parts.get(7) );
57 entry.koreliste = dirigeringsCache.getInstance( parts.get(8) );
58
59 switch(filenameFirst2) {
60 case "HV":
61 entry.ugedage = EntryUgedage.MAN_FRE;
62 break;
63 case "LO":
64 entry.ugedage = EntryUgedage.LOR;
65 break;
66 case "SO":
67 entry.ugedage = EntryUgedage.SON;
68 break;
69 default:
70 throw new IOException("Ukendt ugedage " + filenameFirst2);
71 }
72
73
74 lineCount++;
75
76 return entry;
77 }
78
79 @Override
80 public String getDistributor() {
81 return "FD";
82 }
83
84 @Override
85 public boolean calculateDistances() {
86 return false; //FD skal IKKE beregne afstande
87 }
88
89 }

  ViewVC Help
Powered by ViewVC 1.1.20