--- dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceFD.java 2016/01/28 16:12:28 2868 +++ dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/coveragefileupload/AddressSourceFD.java 2016/04/26 17:37:56 3022 @@ -1,16 +1,13 @@ -package dk.daoas.adressevedligehold; +package dk.daoas.adressevedligehold.coveragefileupload; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; import java.util.List; import org.apache.commons.fileupload.FileItem; import com.google.common.base.Splitter; -import dk.daoas.adressevedligehold.AddressSourceEntry.EntryType; +import dk.daoas.adressevedligehold.coveragefileupload.AddressSourceEntry.EntryType; public class AddressSourceFD extends AbstractAddressSource { @@ -25,40 +22,10 @@ @Override public void validate() throws IOException { - try { - is = file.getInputStream(); - isr = new InputStreamReader(is, Charset.forName("ISO-8859-1") ); - br = new BufferedReader(isr); - - String line = br.readLine(); - - if (line == null) { - throw new IOException("Can't read 1st line - is file empty?"); - } - - String[] parts = line.split(";"); - if (parts.length != 9) { - throw new IOException("Not enough fields in CSV file. Found " + parts.length + ", expected 9"); - } - - - - } catch (Exception e) { - try { - br.close(); - isr.close(); - is.close(); - } catch (Exception e2) { - System.out.println("Error cleaning up resources"); - } - - throw e; // Re-throw - - } + super.validateWithHeader(9, ';'); } - //TODO: Skal csv parsning klares med Apache Commons CSV ? @Override public AddressSourceEntry getNextEntry() throws IOException { @@ -69,7 +36,6 @@ if (line.trim().equals("")) return null; - //System.out.println(line); AddressSourceEntry entry = new AddressSourceEntry( EntryType.TypeSingleAddress); entry.distributor = "FD"; @@ -114,5 +80,10 @@ public String getDistributor() { return "FD"; } + + @Override + public boolean calculateDistances() { + return false; //FD skal IKKE beregne afstande + } }