use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRRoleServlet method getRoleElements.
private Collection<Element> getRoleElements() {
ArrayList<Element> list = new ArrayList<>(roleCategories.size());
for (MCRCategoryID categID : roleCategories) {
Element role = new Element("role");
role.setAttribute("categID", categID.toString());
MCRCategory category = categoryDao.getCategory(categID, 0);
if (category == null) {
continue;
}
role.setAttribute("label", category.getCurrentLabel().map(MCRLabel::getText).orElse(categID.getID()));
list.add(role);
}
return list;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRUserManager method setRoles.
private static MCRUser setRoles(MCRUser mcrUser) {
Collection<MCRCategoryID> roleIDs = MCRRoleManager.getRoleIDs(mcrUser);
mcrUser.getSystemRoleIDs().clear();
mcrUser.getExternalRoleIDs().clear();
for (MCRCategoryID roleID : roleIDs) {
if (roleID.getRootID().equals(MCRUser2Constants.ROLE_CLASSID.getRootID())) {
mcrUser.getSystemRoleIDs().add(roleID.getID());
} else {
mcrUser.getExternalRoleIDs().add(roleID.toString());
}
}
return mcrUser;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRRoleManager method deleteRole.
/**
* Deletes a role from the system.
* If the role is currently not stored in the classification system this method does nothing.
* This method will fail if any objects (e.g. users) are linked to it.
*/
public static void deleteRole(String roleID) {
MCRRole role = MCRRoleManager.getRole(roleID);
if (role == null) {
// unknown role
return;
}
MCRCategoryID categoryID = null;
if (role.isSystemRole()) {
categoryID = new MCRCategoryID(MCRUser2Constants.ROLE_CLASSID.getRootID(), role.getName());
} else {
categoryID = MCRCategoryID.fromString(role.getName());
}
DAO.deleteCategory(categoryID);
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRCategLinkServiceImplTest method getAllCategIDs.
private static Collection<MCRCategoryID> getAllCategIDs(MCRCategory category) {
HashSet<MCRCategoryID> ids = new HashSet<>();
ids.add(category.getId());
for (MCRCategory cat : category.getChildren()) {
ids.addAll(getAllCategIDs(cat));
}
return ids;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method newCategory.
private MCRCategoryImpl newCategory(MCRCategoryID id, String description) {
MCRCategoryImpl newCateg = new MCRCategoryImpl();
newCateg.setId(id);
Set<MCRLabel> labels = new HashSet<>();
labels.add(new MCRLabel("en", id.toString(), description));
newCateg.setLabels(labels);
return newCateg;
}
Aggregations