use of org.mycore.datamodel.classifications2.MCRCategLinkReference in project mycore by MyCoRe-Org.
the class MCRRoleManager method storeRoleAssignments.
/**
* Stores role membership information of the user
*
* @param user the user
*/
static void storeRoleAssignments(MCRUser user) {
MCRCategLinkReference ref = getLinkID(user);
LinkedList<MCRCategoryID> categories = new LinkedList<>();
for (String roleID : user.getSystemRoleIDs()) {
MCRCategoryID categID = new MCRCategoryID(MCRUser2Constants.ROLE_CLASSID.getRootID(), roleID);
categories.add(categID);
}
for (String roleID : user.getExternalRoleIDs()) {
MCRCategoryID categID = MCRCategoryID.fromString(roleID);
categories.add(categID);
}
LOGGER.info("Assigning {} to these roles: {}", user.getUserID(), categories);
CATEG_LINK_SERVICE.setLinks(ref, categories);
}
use of org.mycore.datamodel.classifications2.MCRCategLinkReference in project mycore by MyCoRe-Org.
the class MCRCategLinkServiceImplTest method isInCategory.
@Test
public void isInCategory() {
MCRCategoryImpl germany = (MCRCategoryImpl) category.getChildren().get(0).getChildren().get(0);
MCRCategoryImpl europe = (MCRCategoryImpl) category.getChildren().get(0);
MCRCategoryImpl asia = (MCRCategoryImpl) category.getChildren().get(1);
MCRCategLinkReference jena = new MCRCategLinkReference("Jena", "city");
addTestLinks();
startNewTransaction();
assertTrue("Jena should be in Germany", SERVICE.isInCategory(jena, germany.getId()));
assertTrue("Jena should be in Europe", SERVICE.isInCategory(jena, europe.getId()));
assertFalse("Jena should not be in Asia", SERVICE.isInCategory(jena, asia.getId()));
}
use of org.mycore.datamodel.classifications2.MCRCategLinkReference in project mycore by MyCoRe-Org.
the class MCRClassificationUtils method isInCollection.
public static boolean isInCollection(String mcrId, String collection) {
MCRObjectID mcrObjectID = MCRObjectID.getInstance(mcrId);
MCRCategoryID collectionID = new MCRCategoryID(MCRConstants.COLLECTION_CLASS_ID.getRootID(), collection);
MCRCategLinkReference reference = new MCRCategLinkReference(mcrObjectID);
return LINK_SERVICE.isInCategory(reference, collectionID);
}
use of org.mycore.datamodel.classifications2.MCRCategLinkReference in project mycore by MyCoRe-Org.
the class MCRCreatorRuleStrategy method objectStatusIsSubmitted.
private static boolean objectStatusIsSubmitted(MCRObjectID mcrObjectID) {
MCRCategLinkReference reference = new MCRCategLinkReference(mcrObjectID);
boolean isSubmitted = false;
if (SUBMITTED_CATEGORY == null) {
return false;
}
String[] submittedCategoriesSplitted = SUBMITTED_CATEGORY.split(",");
for (String submittedCategoryID : submittedCategoriesSplitted) {
String categoryId = submittedCategoryID.trim();
MCRCategoryID submittedCategory = MCRCategoryID.fromString(categoryId);
if (LINK_SERVICE.isInCategory(reference, submittedCategory)) {
isSubmitted = true;
}
}
return isSubmitted;
}
use of org.mycore.datamodel.classifications2.MCRCategLinkReference in project mycore by MyCoRe-Org.
the class MCRFileMetaEventHandler method handleDerivateCreated.
@Override
protected void handleDerivateCreated(MCREvent evt, MCRDerivate der) {
MCRObjectID derivateID = der.getId();
MCRObjectDerivate objectDerivate = der.getDerivate();
List<MCRFileMetadata> fileMetadata = objectDerivate.getFileMetadata();
for (MCRFileMetadata metadata : fileMetadata) {
Collection<MCRCategoryID> categories = metadata.getCategories();
if (!categories.isEmpty()) {
MCRPath path = MCRPath.getPath(derivateID.toString(), metadata.getName());
MCRCategLinkReference linkReference = new MCRCategLinkReference(path);
CATEGLINK_SERVICE.setLinks(linkReference, categories);
}
}
}
Aggregations