use of org.mycore.datamodel.metadata.MCRMetaIFS in project mycore by MyCoRe-Org.
the class MCRMODSCommands method createDerivate.
private static MCRDerivate createDerivate(MCRObjectID documentID, File fileDir) throws MCRPersistenceException, IOException, MCRAccessException {
MCRDerivate derivate = new MCRDerivate();
derivate.setId(MCRObjectID.getNextFreeId(documentID.getProjectId(), "derivate"));
derivate.setLabel("data object from " + documentID);
String schema = CONFIG.getString("MCR.Metadata.Config.derivate", "datamodel-derivate.xml").replaceAll(".xml", ".xsd");
derivate.setSchema(schema);
MCRMetaLinkID linkId = new MCRMetaLinkID();
linkId.setSubTag("linkmeta");
linkId.setReference(documentID, null, null);
derivate.getDerivate().setLinkMeta(linkId);
MCRMetaIFS ifs = new MCRMetaIFS();
ifs.setSubTag("internal");
ifs.setSourcePath(fileDir.getAbsolutePath());
derivate.getDerivate().setInternals(ifs);
LOGGER.debug("Creating new derivate with ID {}", derivate.getId());
MCRMetadataManager.create(derivate);
setDefaultPermissions(derivate.getId());
return derivate;
}
Aggregations