use of org.mycore.datamodel.classifications2.MCRCategory 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.MCRCategory 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.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method replaceCategoryWithItself.
@Test
public void replaceCategoryWithItself() {
addWorldClassification();
MCRCategory europe = category.getChildren().get(0);
MCRCategory germany = europe.getChildren().get(0);
DAO.replaceCategory(germany);
startNewTransaction();
getRootCategoryFromSession();
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method getCategoriesByLabel.
@Test
public void getCategoriesByLabel() {
addWorldClassification();
MCRCategory find = category.getChildren().get(0).getChildren().get(0);
MCRCategory dontFind = category.getChildren().get(1);
MCRLabel label = find.getLabels().iterator().next();
List<MCRCategory> results = DAO.getCategoriesByLabel(category.getId(), label.getLang(), label.getText());
assertFalse("No search results found", results.isEmpty());
assertTrue("Could not find Category: " + find.getId(), results.get(0).getLabels().contains(label));
assertTrue("No search result expected.", DAO.getCategoriesByLabel(dontFind.getId(), label.getLang(), label.getText()).isEmpty());
results = DAO.getCategoriesByLabel(label.getLang(), label.getText());
assertFalse("No search results found", results.isEmpty());
assertTrue("Could not find Category: " + find.getId(), results.get(0).getLabels().contains(label));
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method moveCategoryInParent.
@Test
public void moveCategoryInParent() throws SQLException {
addWorldClassification();
MCRCategory moveNode = category.getChildren().get(1);
DAO.moveCategory(moveNode.getId(), moveNode.getParent().getId(), 0);
startNewTransaction();
MCRCategoryImpl rootNode = getRootCategoryFromSession();
checkLeftRightLevelValue(rootNode, 0, 0);
MCRCategory movedNode = rootNode.getChildren().get(0);
assertEquals("Did not expect this category on position 0.", moveNode.getId(), movedNode.getId());
}
Aggregations