Permalink
Browse files

First shot of bemyndigelse importer

  • Loading branch information...
1 parent 6a17b44 commit 383ad7af4d2052351fe89fdb56c07aac94235514 Kjeld Froberg committed Mar 26, 2012
@@ -0,0 +1,38 @@
+package com.trifork.stamdata.specs;
+
+import static com.trifork.stamdata.persistence.RecordSpecification.field;
+
+import com.trifork.stamdata.persistence.RecordSpecification;
+
+public final class BemyndigelseRecordSpecs
+{
+ protected BemyndigelseRecordSpecs() {}
+
+ public static final RecordSpecification START_RECORD_SPEC = RecordSpecification.createSpecification("DummyTable", "DummyKey",
+ field("PostType", 2).numerical().doNotPersist(),
+ field("Dato", 8),
+ field("Timestamp", 20),
+ field("Version", 6),
+ field("SnitfladeId", 8));
+
+ public static final RecordSpecification END_RECORD_SPEC = RecordSpecification.createSpecification("DummyTable", "DummyKey",
+ field("PostType", 2).numerical().doNotPersist(),
+ field("AntalPost", 8).numerical());
+
+ public static final RecordSpecification ENTRY_RECORD_SPEC = RecordSpecification.createSpecification("Bemyndigelse", "kode",
+ field("PostType", 2).numerical().doNotPersist(),
+ field("CPRnr", 10),
+ field("bemyndigende_cpr", 10),
+ field("bemyndigede_cpr", 10),
+ field("bemyndigede_cvr", 8),
+ field("system", 255),
+ field("arbejdsfunktion", 255),
+ field("rettighed", 255),
+ field("status", 255),
+ field("godkendelsesdato", 8),
+
+ field("CreatedDate", 8),
+ field("ModifiedDate", 8),
+ field("ValidFrom", 8),
+ field("ValidTo", 8));
+}
@@ -0,0 +1,72 @@
+package com.trifork.stamdata.importer.jobs.bemyndigelse;
+
+import static com.trifork.stamdata.Preconditions.checkNotNull;
+
+import java.io.File;
+
+import javax.inject.Inject;
+
+import com.trifork.stamdata.importer.config.KeyValueStore;
+import com.trifork.stamdata.importer.parsers.Parser;
+import com.trifork.stamdata.importer.parsers.annotations.ParserInformation;
+import com.trifork.stamdata.importer.parsers.exceptions.OutOfSequenceException;
+import com.trifork.stamdata.importer.parsers.exceptions.ParserException;
+import com.trifork.stamdata.persistence.RecordPersister;
+import com.trifork.stamdata.specs.SikredeRecordSpecs;
+
+@ParserInformation(id = "bemyndigelse", name = "Bemyndigelse")
+public class BemyndigelseParser implements Parser {
+
+
+ private static final String SEQUENCE_KEY = "SEQUENCE_KEY";
+ private static final String RECORD_TYPE_START = "00";
+ private static final String RECORD_TYPE_ENTRY = "10";
+ private static final String RECORD_TYPE_END = "99";
+ private final KeyValueStore keyValueStore;
+
+ @Inject
+ BemyndigelseParser(KeyValueStore keyValueStore) {
+ this.keyValueStore = keyValueStore;
+ }
+
+ @Override
+ public void process(File dataSet, RecordPersister persister) throws OutOfSequenceException, ParserException,
+ Exception {
+
+ File file = checkRequiredFiles(dataSet);
+
+
+ }
+
+ private File checkRequiredFiles(File dir) {
+
+ checkNotNull(dir);
+
+ for (File file : dir.listFiles()) {
+
+ String fileName = file.getName();
+
+ if (fileName.matches("TODO")) {
+ return file;
+ }
+ }
+
+// String newSequenceNum = file.getName(); // ....
+
+ // TODO Check sequence of filename
+ String previousSequenceNum = keyValueStore.get(SEQUENCE_KEY);
+
+ if (previousSequenceNum == null) {
+ // log
+ } else {
+
+ // Check that the file sequence does not have "holes".
+
+ }
+
+ // keyValueStore.put(SEQUENCE_KEY, newSequenceNum);
+
+ throw new ParserException("File not found"); // TODO: Make subclass
+ }
+
+}

0 comments on commit 383ad7a

Please sign in to comment.