default values and forced indexing
This commit is contained in:
@@ -32,6 +32,12 @@
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.univocity</groupId>
|
||||
<artifactId>univocity-parsers</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -6,4 +6,23 @@
|
||||
- "comment" mit in description?
|
||||
- MAM-Status "ARCHIVED" --> eDAM.Archived?
|
||||
- Was ist mit Status != ACCEPTED or ARCHIVED?
|
||||
- Regelung Cutover: Kein Upload mehr ab KW42 (16.10.)
|
||||
- Regelung Cutover: Kein Upload mehr ab KW42 (16.10.)
|
||||
- Wenn License Holder nicht gesetzt, trotzdem BAH GmbH? (bspw. 00070763)
|
||||
|
||||
|
||||
CREATE TABLE House (ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, date DATE NOT NULL, description VARCHAR(255));
|
||||
--CREATE TABLE Room (ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, qm INTEGER NOT NULL, HouseID INTEGER NOT NULL, FOREIGN KEY(HouseID) REFERENCES House (ID));
|
||||
INSERT INTO House (date, description) VALUES ('2017-09-18', 'Das blaue Haus');
|
||||
INSERT INTO House (date, description) VALUES ('2017-09-15', 'Das grüne Haus');
|
||||
CALL CSVWRITE ('C:/Temp/Migration AH/house.csv', 'SELECT * FROM House','charset=UTF-8');
|
||||
DROP TABLE House;
|
||||
CREATE TABLE House (
|
||||
ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
|
||||
date DATE NOT NULL,
|
||||
description VARCHAR(255))
|
||||
AS SELECT
|
||||
ID,
|
||||
date,
|
||||
description
|
||||
FROM CSVREAD('C:/Temp/Migration AH/house.csv', null, 'charset=UTF-8');
|
||||
SELECT * FROM House;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Definitions {
|
||||
public static final String defaultLanguage = "c2bd4f9bbb954bcb80c31e924c9c26dc"; //"00000000000000000000000000000000";
|
||||
public static final String defaultProjectLead = "21cfce6116484269a351a71300e1fed0";
|
||||
public static final String defaultLicenseHolder = "4b82f989fae54a309e17a7470073c36b"; // Bayer Animal Health GmbH
|
||||
public static final String defaultAdditionalPermittedUse = "e22aa8a5-c0d9-4e3b-8469-a731010bc1fd"; // N/A
|
||||
|
||||
static {
|
||||
classifications = new HashMap<String, Classification>();
|
||||
@@ -43,6 +44,7 @@ public class Definitions {
|
||||
fieldIDs.put("byr_ah_description", "f9e40f87-493e-4f17-b129-a6dd00d063b2"); // Additional Information
|
||||
fieldIDs.put("byr_ah_projectLead", "5400d446-9d95-4158-ac06-a6dd00d06a12");
|
||||
fieldIDs.put("byr_ah_licenseHolderList", "de3f83cb50e747228bfea731010bc27c");
|
||||
fieldIDs.put("byr_ah_licenseAdditionalPermittedUse", "5c9d43a0-bf70-4fb5-8ad4-a731010bc1ef");
|
||||
fieldIDs.put("byr_creationDate", "403fea1c-c154-4e3b-a941-a68a00d4fcc3");
|
||||
fieldIDs.put("byr_ah_keywords_tl", "6d582cfaa5b94101ab1fa6fd007e2fcd");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -21,7 +23,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.BufferingClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.HttpStatusCodeException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.bayer.edam.migration.adam.Token;
|
||||
@@ -35,9 +37,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
private static final Logger log = LoggerFactory.getLogger(MamMigrationSelective.class);
|
||||
|
||||
static String adamHost = "https://edam-q.bayer.com:2015";
|
||||
static int[] selection = { 71948 }; // { 71048, 70778, 70746
|
||||
// ,70142,70361,63924,71263,63201,56942,57641,70745,70440,70340,70288,71725 */
|
||||
// };
|
||||
static int[] selection = { 71948, 71048,70778/*,70746,70142,70361,63924,71263,63201,56942,57641,70745,70440,70340,70288,71725*/};
|
||||
|
||||
@Value("${mam.auth}")
|
||||
private String mamAuth;
|
||||
@@ -51,6 +51,8 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
|
||||
private static SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
|
||||
private static SimpleDateFormat stringDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
private List<String> locations = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void run(String... strings) throws Exception {
|
||||
@@ -74,9 +76,16 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
.getBody();
|
||||
|
||||
// log.info(entry.toFullString());
|
||||
|
||||
|
||||
postToAdam(entry);
|
||||
}
|
||||
|
||||
// delete all created records
|
||||
// for (String location : locations) {
|
||||
// ResponseEntity<String> response = restTemplate.exchange(adamHost + location, HttpMethod.DELETE,
|
||||
// adamHeadersEntity, String.class);
|
||||
// log.info("Deleted " + location + ": " + response.toString());
|
||||
// }
|
||||
|
||||
invalidateAdamToken();
|
||||
}
|
||||
@@ -110,6 +119,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
record.addField("byr_Title", entry.name.get("en"));
|
||||
record.addField("byr_ah_projectLead", Collections.singletonList(Definitions.defaultProjectLead));
|
||||
record.addField("byr_ah_licenseHolderList", Collections.singletonList(Definitions.defaultLicenseHolder));
|
||||
record.addField("byr_ah_licenseAdditionalPermittedUse", Collections.singletonList(Definitions.defaultAdditionalPermittedUse));
|
||||
|
||||
// Description / Additional Information
|
||||
String description = entry.description.get("en");
|
||||
@@ -130,20 +140,21 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
// TODO
|
||||
|
||||
// Keywords
|
||||
List<String> keywords = Arrays.asList(entry.keyword.get("en").split("\\s*,\\s*"));
|
||||
record.addField("byr_ah_keywords_tl", keywords);
|
||||
if (entry.keyword.get("en") != null && entry.keyword.get("en").length() > 0) {
|
||||
Set<String> keywords = new HashSet<String>(Arrays.asList(entry.keyword.get("en").split("\\s*,\\s*")));
|
||||
record.addField("byr_ah_keywords_tl", new ArrayList<String>(keywords));
|
||||
}
|
||||
|
||||
HttpEntity<WriteRecord> httpEntity = new HttpEntity<WriteRecord>(record, adamHeaders);
|
||||
try {
|
||||
URI location = restTemplate.postForLocation(adamHost + "/records", httpEntity, WriteRecord.class);
|
||||
log.info("Location: " + location);
|
||||
|
||||
ResponseEntity<String> response = restTemplate.exchange(adamHost + location, HttpMethod.DELETE,
|
||||
adamHeadersEntity, String.class);
|
||||
log.info("Deleted record: " + response.toString());
|
||||
} catch (HttpClientErrorException hcee) {
|
||||
log.error(hcee.getStatusCode().toString());
|
||||
log.error(hcee.getResponseBodyAsString());
|
||||
log.info("Created " + location);
|
||||
|
||||
locations.add(location.toString());
|
||||
|
||||
} catch (HttpStatusCodeException hsce) {
|
||||
log.error(hsce.getStatusCode().toString());
|
||||
log.error(hsce.getResponseBodyAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +175,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
headers.add("Accept", "application/hal+json");
|
||||
headers.add("Content-Type", "application/json");
|
||||
headers.add("Authorization", "Basic " + adamAuth);
|
||||
headers.add("set-immediateSearchIndexUpdate", "true"); // see https://edam.bayer.com:2015/docs/resources/record#example-records-direct-push
|
||||
HttpEntity<String> entity = new HttpEntity<String>("", headers);
|
||||
Token token = restTemplate.exchange(adamHost + "/auth", HttpMethod.GET, entity, Token.class).getBody();
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package com.bayer.edam.migration;
|
||||
package com.bayer.edam.migration.attic;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -22,6 +22,7 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.bayer.edam.migration.LoggingRequestInterceptor;
|
||||
import com.bayer.edam.migration.adam.ReadRecord;
|
||||
import com.bayer.edam.migration.adam.Token;
|
||||
import com.bayer.edam.migration.adam.WriteRecord;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package com.bayer.edam.migration;
|
||||
package com.bayer.edam.migration.attic;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -13,6 +13,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.bayer.edam.migration.MamMigrationSelective;
|
||||
import com.bayer.edam.migration.adam.Token;
|
||||
|
||||
//@SpringBootApplication
|
||||
Reference in New Issue
Block a user