use of org.mycore.mets.model.files.FileSec in project mycore by MyCoRe-Org.
the class MCRMETSDefaultGenerator method createMets.
private Mets createMets() throws IOException {
Mets mets = new Mets();
String owner = getOwner();
// add dmdsec
DmdSec dmdSec = new DmdSec("dmd_" + owner);
// add amdsec
AmdSec amdSec = new AmdSec("amd_" + owner);
// file sec
FileSec fileSec = new FileSec();
for (MCRMetsFileUse fileUse : MCRMetsFileUse.values()) {
FileGrp fileGrp = new FileGrp(fileUse.toString());
fileSec.addFileGrp(fileGrp);
}
// physical structure
PhysicalStructMap physicalStructMap = new PhysicalStructMap();
PhysicalDiv physicalDiv = new PhysicalDiv("phys_" + owner, "physSequence");
physicalStructMap.setDivContainer(physicalDiv);
// logical structure
MCRILogicalStructMapTypeProvider typeProvider = getTypeProvider();
LogicalStructMap logicalStructMap = new LogicalStructMap();
LogicalDiv logicalDiv = new LogicalDiv("log_" + owner, typeProvider.getType(MCRObjectID.getInstance(owner)), owner, amdSec.getId(), dmdSec.getId());
logicalDiv.setDmdId(dmdSec.getId());
logicalStructMap.setDivContainer(logicalDiv);
// struct Link
StructLink structLink = new StructLink();
// create internal structure
structureMets(getDerivatePath(), getIgnorePaths(), fileSec, physicalDiv, logicalDiv, structLink, 0);
hrefIdMap.clear();
// add to mets
mets.addDmdSec(dmdSec);
mets.addAmdSec(amdSec);
mets.setFileSec(fileSec);
mets.addStructMap(physicalStructMap);
mets.addStructMap(logicalStructMap);
mets.setStructLink(structLink);
return mets;
}
use of org.mycore.mets.model.files.FileSec in project mycore by MyCoRe-Org.
the class MCRMETSHierarchyGenerator method createFileSection.
/**
* Creates the file section.
*
* @return generated file secion.
*/
protected FileSec createFileSection() throws IOException {
FileSec fileSec = new FileSec();
List<MCRPath> filePaths = MCRMetsSave.listFiles(getDerivatePath(), getIgnorePaths());
List<FileGrp> fileGrps = MCRMetsSave.buildFileGroups(filePaths);
fileGrps.forEach(fileSec::addFileGrp);
for (MCRPath file : filePaths) {
String contentType = MCRContentTypes.probeContentType(file);
FileRef ref = new FileRef(file, contentType);
this.files.add(ref);
}
for (FileRef ref : this.files) {
MCRMetsFileUse use = MCRMetsFileUse.get(ref.path);
FileGrp fileGrp = fileGrps.stream().filter(grp -> grp.getUse().equals(use.toString())).findFirst().orElse(null);
if (fileGrp == null) {
LOGGER.warn("Unable to add file '" + ref.toId() + "' because cannot find corresponding group " + " with @USE='" + use.toString() + "'. Ignore file and continue.");
continue;
}
addFile(ref.toId(), fileGrp, ref.getPath(), ref.getContentType());
}
return fileSec;
}
Aggregations