Definitions
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
package com.bayer.edam.migration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.bayer.edam.migration.adam.WriteRecord.Classification;
|
||||||
|
import com.bayer.edam.migration.adam.WriteRecord.Field;
|
||||||
|
import com.bayer.edam.migration.adam.WriteRecord.LocalizedValue;
|
||||||
|
|
||||||
|
public class Definitions {
|
||||||
|
|
||||||
|
public static final Map<String, Classification> classifications;
|
||||||
|
public static final Map<String, String> fieldIDs;
|
||||||
|
|
||||||
|
static {
|
||||||
|
classifications = new HashMap<String, Classification>();
|
||||||
|
|
||||||
|
classifications.put("Global", new Classification("dff7666b-326b-4e1c-912c-a7b4006c8500", 1));
|
||||||
|
classifications.put("Bayer AH", new Classification("8de5ef0e-3c6d-451c-b82b-a7b4006c954c", 1));
|
||||||
|
classifications.put("CAP", new Classification("306e050a-dd58-46ad-93a7-a73100a2547f", 1));
|
||||||
|
classifications.put("MediaType.Other", new Classification("7c13e620-7eb0-4c12-9dfb-a7b4008f19b1", 1));
|
||||||
|
classifications.put("Draft", new Classification("dfee7cb7-fffc-41cb-9ee9-a68a00d4f0c3", 1));
|
||||||
|
classifications.put("Unrestricted", new Classification("6b95a635-40e9-4782-ad5f-a73100a2bb94", 1));
|
||||||
|
|
||||||
|
fieldIDs = new HashMap<String, String>();
|
||||||
|
fieldIDs.put("byr_Title", "31f337fa-add6-4e25-a672-a68a00d4ff3b");
|
||||||
|
fieldIDs.put("byr_ah_projectLead", "5400d446-9d95-4158-ac06-a6dd00d06a12");
|
||||||
|
fieldIDs.put("byr_ah_licenseHolderList", "de3f83cb50e747228bfea731010bc27c");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field createSingleValueField(String name, String value) {
|
||||||
|
String id = fieldIDs.get(name);
|
||||||
|
Field newField = new Field(id);
|
||||||
|
newField.localizedValues.add(new LocalizedValue("Happy Doggy"));
|
||||||
|
return newField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Field createMultiValueField(String name, List<String> values) {
|
||||||
|
String id = fieldIDs.get(name);
|
||||||
|
Field newField = new Field(id);
|
||||||
|
newField.localizedValues.add(new LocalizedValue(values));
|
||||||
|
return newField;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.bayer.edam.migration;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -18,7 +19,6 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.http.client.BufferingClientHttpRequestFactory;
|
import org.springframework.http.client.BufferingClientHttpRequestFactory;
|
||||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@@ -79,6 +79,16 @@ public class MamMigrationSelective implements CommandLineRunner {
|
|||||||
log.info("Migrating entry " + entry.id);
|
log.info("Migrating entry " + entry.id);
|
||||||
|
|
||||||
WriteRecord newRecord = new WriteRecord();
|
WriteRecord newRecord = new WriteRecord();
|
||||||
|
newRecord.addClassification("Global");
|
||||||
|
newRecord.addClassification("Bayer AH");
|
||||||
|
newRecord.addClassification("CAP");
|
||||||
|
newRecord.addClassification("MediaType.Other");
|
||||||
|
newRecord.addClassification("Draft");
|
||||||
|
newRecord.addClassification("Unrestricted");
|
||||||
|
|
||||||
|
newRecord.addField("byr_Title", "Happy Doggy!");
|
||||||
|
newRecord.addField("byr_ah_projectLead", Collections.singletonList("21cfce6116484269a351a71300e1fed0"));
|
||||||
|
newRecord.addField("byr_ah_licenseHolderList", Collections.singletonList("4b82f989fae54a309e17a7470073c36b"));
|
||||||
|
|
||||||
HttpEntity<WriteRecord> httpEntity = new HttpEntity<WriteRecord>(newRecord, adamHeaders);
|
HttpEntity<WriteRecord> httpEntity = new HttpEntity<WriteRecord>(newRecord, adamHeaders);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.bayer.edam.migration.adam;
|
package com.bayer.edam.migration.adam;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bayer.edam.migration.Definitions;
|
||||||
|
|
||||||
public class WriteRecord {
|
public class WriteRecord {
|
||||||
|
|
||||||
|
|
||||||
public static class Classification {
|
public static class Classification {
|
||||||
public String id;
|
public String id;
|
||||||
public Integer sortIndex;
|
public Integer sortIndex;
|
||||||
@@ -42,37 +42,37 @@ public class WriteRecord {
|
|||||||
public Field(String id) {
|
public Field(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Field() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Fields {
|
public static class Fields {
|
||||||
public List<Field> addOrUpdate = new ArrayList<Field>();
|
public List<Field> addOrUpdate = new ArrayList<Field>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String contentType = "Record";
|
public String contentType = "Record";
|
||||||
public Classifications classifications = new Classifications();
|
public Classifications classifications = new Classifications();
|
||||||
public Fields fields = new Fields();
|
public Fields fields = new Fields();
|
||||||
|
|
||||||
public WriteRecord() {
|
public void add(Classification classification) {
|
||||||
// XXX some default values
|
classifications.addOrUpdate.add(classification);
|
||||||
classifications.addOrUpdate.add(new Classification("dff7666b-326b-4e1c-912c-a7b4006c8500", 1)); // Global
|
}
|
||||||
classifications.addOrUpdate.add(new Classification("8de5ef0e-3c6d-451c-b82b-a7b4006c954c", 1)); // Bayer AH
|
|
||||||
classifications.addOrUpdate.add(new Classification("306e050a-dd58-46ad-93a7-a73100a2547f", 1)); // CAP
|
public void add(Field field) {
|
||||||
classifications.addOrUpdate.add(new Classification("7c13e620-7eb0-4c12-9dfb-a7b4008f19b1", 1)); // Other
|
|
||||||
classifications.addOrUpdate.add(new Classification("dfee7cb7-fffc-41cb-9ee9-a68a00d4f0c3", 1)); // Draft
|
|
||||||
classifications.addOrUpdate.add(new Classification("6b95a635-40e9-4782-ad5f-a73100a2bb94", 1)); // Unrestricted
|
|
||||||
|
|
||||||
Field field = new Field("31f337fa-add6-4e25-a672-a68a00d4ff3b"); // Title
|
|
||||||
field.localizedValues.add(new LocalizedValue("Happy Doggy"));
|
|
||||||
fields.addOrUpdate.add(field);
|
|
||||||
|
|
||||||
field = new Field("5400d446-9d95-4158-ac06-a6dd00d06a12"); // Project Lead
|
|
||||||
field.localizedValues.add(new LocalizedValue(Collections.singletonList("21cfce6116484269a351a71300e1fed0")));
|
|
||||||
fields.addOrUpdate.add(field);
|
|
||||||
|
|
||||||
field = new Field("de3f83cb50e747228bfea731010bc27c"); // License Holder
|
|
||||||
field.localizedValues.add(new LocalizedValue(Collections.singletonList("4b82f989fae54a309e17a7470073c36b")));
|
|
||||||
fields.addOrUpdate.add(field);
|
fields.addOrUpdate.add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addClassification(String name) {
|
||||||
|
add(Definitions.classifications.get(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addField(String name, String value) {
|
||||||
|
fields.addOrUpdate.add(Definitions.createSingleValueField(name, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addField(String name, List<String> values) {
|
||||||
|
fields.addOrUpdate.add(Definitions.createMultiValueField(name, values));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user