Skip to content

Commit

Permalink
MCR-3051 allow to configure classifications for MODS import
Browse files Browse the repository at this point in the history
  • Loading branch information
yagee-de committed Feb 23, 2024
1 parent 46839d8 commit 33a347d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mycore-mods/src/main/java/org/mycore/mods/MCRMODSCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.xml.MCRXMLHelper;
import org.mycore.datamodel.common.MCRActiveLinkException;
import org.mycore.datamodel.classifications2.MCRCategoryID;
import org.mycore.datamodel.metadata.MCRDerivate;
import org.mycore.datamodel.metadata.MCRMetaClassification;
import org.mycore.datamodel.metadata.MCRMetaIFS;
import org.mycore.datamodel.metadata.MCRMetaLinkID;
import org.mycore.datamodel.metadata.MCRMetadataManager;
Expand Down Expand Up @@ -157,6 +159,8 @@ private static MCRObjectID saveAsMyCoReObject(String projectID, Element modsRoot
throws MCRActiveLinkException, MCRPersistenceException, MCRAccessException {
MCRObject mcrObject = MCRMODSWrapper.wrapMODSDocument(modsRoot, projectID);
mcrObject.setId(MCRObjectID.getNextFreeId(mcrObject.getId().getBase()));
MCRConfiguration2.getString("MCR.MODS.Import.Object.State")
.ifPresent(mcrObject.getService()::setState);
MCRMetadataManager.create(mcrObject);
return mcrObject.getId();
}
Expand Down Expand Up @@ -195,6 +199,14 @@ private static MCRDerivate createDerivate(MCRObjectID documentID, File fileDir)
firstRegularFile.ifPresent(ifs::setMainDoc);
derivate.getDerivate().setInternals(ifs);
}
MCRConfiguration2.getString("MCR.MODS.Import.Derivate.Categories")
.map(MCRConfiguration2::splitValue)
.ifPresent(s -> {
s.map(MCRCategoryID::fromString)
.forEach(categId -> derivate.getDerivate().getClassifications()
.add(new MCRMetaClassification("classification", 0, null,
categId)));
});

LOGGER.debug("Creating new derivate with ID {}", derivate.getId());
MCRMetadataManager.create(derivate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,7 @@ MCR.ContentTransformer.migrate-extension-display.Stylesheet=xsl/migrate-extensio
# if somebody wants to index all children of a mods object without checking if their metadata is changed,
# then the following property can be set to true
MCR.MODS.LinksEventHandler.IndexAllChildren=false

#Import commands
MCR.MODS.Import.Derivate.Categories=derivate_types:content
MCR.MODS.Import.Object.State=submitted

0 comments on commit 33a347d

Please sign in to comment.