/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/coveragefileupload/AddressSourceDAO.java
ViewVC logotype

Contents of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/coveragefileupload/AddressSourceDAO.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3022 - (show annotations) (download)
Tue Apr 26 17:37:56 2016 UTC (8 years ago) by torben
File size: 2321 byte(s)
Rename package
1 package dk.daoas.adressevedligehold.coveragefileupload;
2
3 import java.io.IOException;
4
5 import org.apache.commons.fileupload.FileItem;
6
7 import dk.daoas.adressevedligehold.coveragefileupload.AddressSourceEntry.EntryType;
8
9 public class AddressSourceDAO extends AbstractAddressSource {
10
11 final static String DAO = "DAO";
12
13
14 public AddressSourceDAO(FileItem file) throws Exception {
15 super(file);
16
17 }
18
19 @Override
20 public void validate() throws IOException {
21 super.validateWithHeader(17, ';');
22 }
23
24
25
26 @Override
27 public AddressSourceEntry getNextEntry() throws IOException {
28 String line = br.readLine();
29 if (line == null) // end of file
30 return null;
31
32 if (line.trim().equals(""))
33 return null;
34
35
36 AddressSourceEntry entry = new AddressSourceEntry( EntryType.TypeAddressRange);
37 entry.distributor = DAO;
38
39 String[] parts = line.split(";");
40 if (parts.length != 17) {
41 throw new IOException("Not enough fields in CSV file. Found " + parts.length + ", expected 17");
42 }
43
44 entry.gadeid = Integer.parseInt( parts[0] );
45 entry.vejnavn = parts[1];
46 //String stednavn = parts[2]; //Ikke brugt
47 //String david = parts[3]; //Ikke brugt
48 entry.postnr = Short.parseShort( parts[4] );
49 short net = Short.parseShort( parts[5] );
50 entry.rute = dirigeringsCache.getInstance( parts[6].toUpperCase() ); //Nogle Bruter i gl inputfil kan stå med lille b
51 entry.husnr = Short.parseShort( parts[7] );
52 entry.litra = parts[8];
53 entry.tilHusnr = Short.parseShort( parts[9] );
54 entry.tilLitra = parts[10];
55 //String sekvens = parts[11];
56 //String fraDato = parts[12];
57 //String tilDato = parts[13];
58 //short bane = Short.parseShort( parts[14] );
59 //String distributor = parts[15];
60 entry.koreliste = dirigeringsCache.getInstance( parts[16] );
61
62 switch (net) {
63 case 5:
64 entry.ugedage = EntryUgedage.LOR;
65 break;
66 case 6:
67 entry.ugedage = EntryUgedage.MAN_FRE;
68 break;
69 case 7:
70 entry.ugedage = EntryUgedage.SON;
71 break;
72 default:
73 throw new IOException("Ukendt net" + net);
74 }
75
76
77 lineCount++;
78
79 return entry;
80 }
81
82 @Override
83 public String getDistributor() {
84 return DAO;
85 }
86
87 @Override
88 public boolean calculateDistances() {
89 return true; //DAO skal beregne afstande
90 }
91
92 }

  ViewVC Help
Powered by ViewVC 1.1.20