-
Notifications
You must be signed in to change notification settings - Fork 15
Multitple representation with multiple files EARK SIP
Miguel Guimarães edited this page May 14, 2021
·
2 revisions
// 1) instantiate E-ARK SIP object
SIP sip = new EARKSIP("Multiple-Representation-With-Multiple-Files-EARK-SIP");
sip.addCreatorSoftwareAgent("RODA Commons IP", "2.0.0");
// 1.1) set optional human-readable description
sip.setDescription("An example of E-ARK SIP creation using commons-ip library for Webinar #11");
// 1.2) add descriptive metadata (SIP level)
IPDescriptiveMetadata metadataDescriptiveDC = new IPDescriptiveMetadata(
new IPFile(Paths.get("src/main/resources/webinar/metadata_descriptive_dc.xml")),
new MetadataType(MetadataType.MetadataTypeEnum.DC), null);
sip.addDescriptiveMetadata(metadataDescriptiveDC);
// 1.3) add preservation metadata (SIP level)
IPMetadata metadataPreservation = new IPMetadata(
new IPFile(Paths.get("src/main/resources/webinar/metadata_preservation_premis.xml")));
sip.addPreservationMetadata(metadataPreservation);
// 1.4) add other metadata (SIP level)
IPFile metadataOtherFile = new IPFile(Paths.get("src/main/resources/webinar/metadata_other.txt"));
IPMetadata metadataOther = new IPMetadata(metadataOtherFile);
sip.addOtherMetadata(metadataOther);
// 1.5) add xml schema (SIP level)
sip.addSchema(new IPFile(Paths.get("src/main/resources/webinar/schema.xsd")));
// 1.6) add documentation (SIP level)
sip.addDocumentation(new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf")));
// 1.7) add an agent (SIP level)
IPAgent agent = new IPAgent("Example of agent Name", "OTHER", "OTHER ROLE", METSEnums.CreatorType.INDIVIDUAL,
"OTHER TYPE", "", IPAgentNoteTypeEnum.SOFTWARE_VERSION);
sip.addAgent(agent);
// Representation 1
IPRepresentation representation1 = new IPRepresentation("representation 1");
sip.addRepresentation(representation1);
// Add file to representation 1
IPFile representation1File1 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation1File1.setRenameTo("File1.pdf");
representation1.addFile(representation1File1);
// Add file to representation 1
IPFile representation1File2 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation1File2.setRenameTo("File2.pdf");
representation1.addFile(representation1File2);
// Representation 2
IPRepresentation representation2 = new IPRepresentation("representation 2");
sip.addRepresentation(representation2);
// Add file to representation 2
// called 'abc' which has a folder inside called 'def'
IPFile representation2File1 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation2File1.setRelativeFolders(Arrays.asList("abc", "def"));
representation2File1.setRenameTo("File3.pdf");
representation2.addFile(representation2File1);
// Add file to representation 2
IPFile representation2File2 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation2File2.setRenameTo("File4.pdf");
representation2.addFile(representation2File2);
// Representation 3
IPRepresentation representation3 = new IPRepresentation("representation 3");
sip.addRepresentation(representation3);
// Add file to representation 3
IPFile representation3File1 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation3File1.setRelativeFolders(Arrays.asList("xyz", "ghi"));
representation3File1.setRenameTo("File5.pdf");
representation3.addFile(representation3File1);
// Add file to representation 3
IPFile representation3File2 = new IPFile(Paths.get("src/main/resources/webinar/documentation.pdf"));
representation3File2.setRenameTo("File6.pdf");
representation3.addFile(representation3File2);
// Final Step - Build
Path build = sip.build(webinarFolder);
return build.toAbsolutePath().toString();