CategoryTree
This commit is contained in:
@@ -42,7 +42,7 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
|
||||
static final String adamHost = "https://edam-q.bayer.com:2015";
|
||||
static final String mamHost = "https://service.media-assistant.animalhealth.bayer.com";
|
||||
static final int[] selection = { 71948, /*71048, 70778, 70746, 70142,*/ 70361, /*63924, 71263, 63201, 56942, 57641, 70745, 70440, 70340,
|
||||
static final int[] selection = { /*71948, 71048, 70778, 70746, 70142,*/ 70361, /*63924, 71263, 63201, 56942, 57641, 70745, 70440, 70340,
|
||||
70288, 71725*/ };
|
||||
|
||||
static final File entryLog = new File("C:\\Temp\\Migration AH\\entry.log");
|
||||
@@ -87,8 +87,22 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
log.info("GET entry " + id);
|
||||
|
||||
Entry entry = restTemplate.exchange(mamHost + "/rest/migration/entry/{id}", HttpMethod.GET, entity, Entry.class, id).getBody();
|
||||
|
||||
// postToAdam(entry);
|
||||
|
||||
// check exclusion criteria
|
||||
if (entry.stateId == 7) {
|
||||
log.info("Skipping entry " + entry.id + ": Status " + entry.stateId + "(LOCKED_BY_ADMIN)");
|
||||
continue;
|
||||
}
|
||||
else if (entry.stateId == 8) {
|
||||
log.info("Skipping entry " + entry.id + ": Status " + entry.stateId + "(ASSIGNED_TO_INDEXATION)");
|
||||
continue;
|
||||
}
|
||||
else if (entry.stateId == 10) {
|
||||
log.info("Skipping entry " + entry.id + ": Status " + entry.stateId + "(ARCHIVED)");
|
||||
continue;
|
||||
}
|
||||
|
||||
postToAdam(entry);
|
||||
}
|
||||
|
||||
// // delete all created records
|
||||
@@ -110,24 +124,32 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
record.addClassification("Country.Global");
|
||||
record.addClassification("Agencies.Bayer AH");
|
||||
record.addClassification("Usage.Restricted");
|
||||
|
||||
// status
|
||||
if (entry.stateId == 6) { // ACCEPTED
|
||||
record.addClassification("Status.Released");
|
||||
} else if (entry.stateId == 10) { // ARCHIVED
|
||||
record.addClassification("Status.Archived");
|
||||
} else {
|
||||
log.error("Skipping entry " + entry.id + ": No target status for stateId == " + entry.stateId);
|
||||
FileUtils.writeStringToFile(problemLog, entry.id + fieldSeparator + entryJson + lineSeparator, Charset.forName("utf-8"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
// business unit
|
||||
record.addClassification("BusinessUnit.CAP");
|
||||
|
||||
|
||||
// media type
|
||||
record.addClassification(Definitions.mediaTypes.get(entry.mediaType.id));
|
||||
|
||||
|
||||
|
||||
|
||||
// process table
|
||||
Set<String> keywords = new HashSet<String>();
|
||||
String status = "Status.Released";
|
||||
String businessUnit = "BusinessUnit.General";
|
||||
|
||||
for (int category : entry.categories) {
|
||||
|
||||
// TODO
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
record.addClassification(status);
|
||||
record.addClassification(businessUnit);
|
||||
|
||||
|
||||
|
||||
|
||||
// Fields
|
||||
record.addField("byr_Title", entry.name.get("en"));
|
||||
|
||||
@@ -152,19 +174,21 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
|
||||
// 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*")));
|
||||
keywords.addAll(Arrays.asList(entry.keyword.get("en").split("\\s*,\\s*")));
|
||||
}
|
||||
|
||||
if (keywords.size() > 0) {
|
||||
record.addField("byr_ah_keywords_tl", new ArrayList<String>(keywords));
|
||||
}
|
||||
|
||||
// License Information
|
||||
record.addField("byr_ah_licenseHolderList", Collections.singletonList(Definitions.defaultLicenseHolder));
|
||||
|
||||
// SR: If license holder is not "Bayer Animal Health GmbH" put on review list
|
||||
// if license holder is not "Bayer Animal Health GmbH" put on review list
|
||||
if (!entry.copyright.organization.get("id").equals("3740")) {
|
||||
log.warn("Entry " + entry.id + ": License Holder is not set to 'Bayer Animal Health GmbH' (organization 3740)");
|
||||
}
|
||||
|
||||
|
||||
record.addField("byr_ah_licenseAdditionalPermittedUse", Collections.singletonList(Definitions.defaultAdditionalPermittedUse));
|
||||
|
||||
String licenseDescription = "";
|
||||
@@ -172,9 +196,12 @@ public class MamMigrationSelective implements CommandLineRunner {
|
||||
licenseDescription += entry.copyright.use;
|
||||
record.addField("byr_ah_licenseComments", licenseDescription);
|
||||
|
||||
if (entry.gpc != null)
|
||||
record.addField("byr_ah_approvalNumber",entry.gpc.gpcNumber); // TODO
|
||||
// if (entry.gpc != null)
|
||||
// record.addField("byr_ah_approvalNumber",entry.gpc.gpcNumber);
|
||||
|
||||
|
||||
|
||||
// Create record
|
||||
HttpEntity<WriteRecord> httpEntity = new HttpEntity<WriteRecord>(record, adamHeaders);
|
||||
try {
|
||||
URI location = restTemplate.postForLocation(adamHost + "/records", httpEntity, WriteRecord.class);
|
||||
@@ -209,8 +236,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
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user