Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* SDM-5 SLA-log fra SDM4-importere følger ikke standarden

*  Tilføjet kopi register view, så kopi register service maps nu bliver oprettet automatisk
  • Loading branch information...
commit 20057d216274d90c82ba78af41793937b07202d7 1 parent 84eb53c
@kpntrifork kpntrifork authored
View
6 Changelog.md
@@ -15,4 +15,8 @@
* Opgrading til sdm4-core 4.3, der løser
NSPSUPPORT-126: ParserExecutor logger filers absolutte stier og md5-summer inden parser behandler dem
* Opgraderet til sdm-core 4.9 for at kunne resette transaction time
-* SDM-23: Reset transaction time før hver import
+* SDM-23: Reset transaction time før hver import
+
+## autorisationimporter 4.5
+* SDM-5 SLA-log fra SDM4-importere følger ikke standarden
+* Tilføjet kopi register view, så kopi register service maps nu bliver oprettet automatisk
View
4 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>dk.nsi.stamdata4</groupId>
<artifactId>sdm-parent</artifactId>
- <version>4.3</version>
+ <version>4.7</version>
</parent>
<artifactId>autorisationimporter</artifactId>
@@ -58,7 +58,7 @@
<dependency>
<groupId>dk.nsi.stamdata4</groupId>
<artifactId>sdm-core</artifactId>
- <version>4.9</version>
+ <version>4.10</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
View
13 src/main/java/dk/nsi/sdm4/autorisation/parser/AutorisationParser.java
@@ -69,7 +69,7 @@
private int maxAllowedReduction;
@Override
- public void process(File dataset) throws ParserException {
+ public void process(File dataset, String identifier) throws ParserException {
Preconditions.checkNotNull(dataset);
File[] files = dataset.listFiles();
@@ -80,9 +80,9 @@ public void process(File dataset) throws ParserException {
// Make sure we update transaction time
persister.resetTransactionTime();
-
- SLALogItem slaLogItem = slaLogger.createLogItem("AutorisationImporter", "All Files");
-
+ SLALogItem slaLogItem = slaLogger.createLogItem(getHome()+".process", "SDM4."+getHome()+".process");
+ slaLogItem.setMessageId(identifier);
+ slaLogItem.addCallParameter(Parser.SLA_INPUT_NAME, dataset.getAbsolutePath());
try {
// Make sure the file set has not been imported before.
// Check what the previous highest version is (the ValidFrom column).
@@ -101,16 +101,19 @@ public void process(File dataset) throws ParserException {
+ previousVersion + "', new_version='" + currentVersion + "'.");
}
+ int processed = 0;
for (File file : files) {
Autorisationsregisterudtraek autRegisterDataset = parse(file, currentVersion);
guardAgainsUnacceptableReduction(file, autRegisterDataset);
+ processed += autRegisterDataset.size();
persister.persistCompleteDataset(autRegisterDataset);
}
// Update the table for the STS.
jdbcTemplate.execute("TRUNCATE TABLE autreg");
jdbcTemplate.update("INSERT INTO autreg (cpr, given_name, surname, aut_id, edu_id) SELECT cpr, Fornavn, Efternavn, Autorisationsnummer, UddannelsesKode " + FROMCLAUSE_VALID_AUTORISATIONER);
-
+
+ slaLogItem.addCallParameter(Parser.SLA_RECORDS_PROCESSED_MAME, ""+processed);
slaLogItem.setCallResultOk();
slaLogItem.store();
} catch (Exception e) {
View
53 src/main/resources/db/migration/V20130529_1536__Autorisation_krsviews.sql
@@ -0,0 +1,53 @@
+-- -----------------------------------------------------
+-- Someone has to create the SKRS tables first time
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `SKRSViewMapping` (
+ `idSKRSViewMapping` BIGINT(15) NOT NULL AUTO_INCREMENT ,
+ `register` VARCHAR(255) NOT NULL ,
+ `datatype` VARCHAR(255) NOT NULL ,
+ `version` INT NOT NULL ,
+ `tableName` VARCHAR(255) NOT NULL ,
+ `createdDate` TIMESTAMP NOT NULL ,
+ PRIMARY KEY (`idSKRSViewMapping`) ,
+ INDEX `idx` (`register` ASC, `datatype` ASC, `version` ASC) ,
+ UNIQUE INDEX `unique` (`register` ASC, `datatype` ASC, `version` ASC) )
+ ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `SKRSColumns` (
+ `idSKRSColumns` BIGINT(15) NOT NULL AUTO_INCREMENT ,
+ `viewMap` BIGINT(15) NOT NULL ,
+ `isPID` TINYINT NOT NULL ,
+ `tableColumnName` VARCHAR(255) NOT NULL ,
+ `feedColumnName` VARCHAR(255) NULL ,
+ `feedPosition` INT NOT NULL ,
+ `dataType` INT NOT NULL ,
+ `maxLength` INT NULL ,
+ PRIMARY KEY (`idSKRSColumns`) ,
+ INDEX `viewMap_idx` (`viewMap` ASC) ,
+ UNIQUE INDEX `viewColumn` (`tableColumnName` ASC, `viewMap` ASC) ,
+ CONSTRAINT `viewMap`
+ FOREIGN KEY (`viewMap` )
+ REFERENCES `SKRSViewMapping` (`idSKRSViewMapping` )
+ ON DELETE CASCADE
+ ON UPDATE NO ACTION)
+ ENGINE = InnoDB;
+
+
+-- ---------------------------------------------------------------------------------------------------------------------
+-- Autorisation
+-- ---------------------------------------------------------------------------------------------------------------------
+-- Would have been nice if multiple statements where possible so all these subselects could go away
+-- ---------------------------------------------------------------------------------------------------------------------
+
+INSERT IGNORE INTO SKRSViewMapping (register, datatype, version, tableName, createdDate)
+ VALUES ('autorisationsregisteret', 'autorisation', 1, 'Autorisation', NOW());
+INSERT IGNORE INTO SKRSColumns (viewMap, isPID, tableColumnName, feedColumnName, feedPosition, dataType, maxLength) VALUES
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 1, 'AutorisationPID', NULL, 0, -5, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'Autorisationsnummer', 'autorisationsnummer', 1, 12, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'CPR', 'cpr', 2, 12, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'Fornavn', 'fornavn', 3, 12, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'Efternavn', 'efternavn', 4, 12, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'UddannelsesKode', 'uddannelseskode', 5, 4, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'ModifiedDate', NULL, 0, 93, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'ValidFrom', 'validFrom', 6, 93, NULL),
+((SELECT idSKRSViewMapping FROM SKRSViewMapping WHERE register='autorisationsregisteret' AND datatype='autorisation' AND version=1), 0, 'ValidTo', 'validTo', 7, 93, NULL);
View
4 src/test/java/dk/nsi/sdm4/autorisation/AutorisationImportTest.java
@@ -65,7 +65,7 @@
@Test
public void testCanImport() throws IOException, InterruptedException {
File dataset = createTestDataset("data/aut/valid/20090915AutDK.csv");
- parser.process(dataset);
+ parser.process(dataset, "id");
long cnt = jdbcTemplate.queryForLong("SELECT count(1) FROM Autorisation");
assertEquals(4, cnt);
Thread.sleep(1000);
@@ -76,7 +76,7 @@ public void testCanImport() throws IOException, InterruptedException {
// Import another file and check validTo is set correctly and modified date is updated
dataset = createTestDataset("data/aut/valid/20090918AutDK.csv");
- parser.process(dataset);
+ parser.process(dataset, "id");
cnt = jdbcTemplate.queryForLong("SELECT count(1) FROM Autorisation");
assertEquals(6, cnt);
cnt = jdbcTemplate.queryForLong("SELECT count(1) FROM Autorisation WHERE ValidTo>=?", new Timestamp(now.getTime()));
View
4 src/test/java/dk/nsi/sdm4/autorisation/parser/AutParserTest.java
@@ -121,7 +121,7 @@ public void doesNotAllowNumberOfAutorisationerToDecreaseMoreThanThreshold() thro
when(jdbcTemplate.queryForInt(any(String.class))).thenReturn(5); // der er to indgange i den fil vi importer om lidt
try {
- parser.process(validWith3Removed.getParentFile());
+ parser.process(validWith3Removed.getParentFile(), "id");
fail("Expected exception from parser because number of autorisationer decreased too much");
} catch (ParserException e) {
assertThat(e.getMessage(), containsString(validWith3Removed.getName()));
@@ -134,7 +134,7 @@ public void doesNotAllowNumberOfAutorisationerToDecreaseMoreThanThreshold() thro
@Test
public void doesNotAllowMoreThanOneInputFile() throws IOException {
try {
- parser.process(valid.getParentFile()); // valid indeholder 2 filer
+ parser.process(valid.getParentFile(), "id"); // valid indeholder 2 filer
fail("Expected exception from parser because number of files is not one");
} catch (ParserException e) {
assertThat(e.getMessage(), containsString("2")); // antal filer
Please sign in to comment.
Something went wrong with that request. Please try again.