use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method checkEmptyLabels.
private static void checkEmptyLabels(String classID, List<String> log) {
Session session = MCRHIBConnection.instance().getSession();
String sqlQuery = "select cat.categid from {h-schema}MCRCategory cat left outer join {h-schema}MCRCategoryLabels label on cat.internalid = label.category where cat.classid='" + classID + "' and (label.text is null or trim(label.text) = '')";
@SuppressWarnings("unchecked") List<String> list = session.createNativeQuery(sqlQuery).getResultList();
for (String categIDString : list) {
log.add("EMPTY lables for category " + new MCRCategoryID(classID, categIDString));
}
}
use of org.mycore.datamodel.classifications2.MCRCategoryID 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);
}
}
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRRoleManager method isAssignedToRole.
static boolean isAssignedToRole(MCRUser user, String roleID) {
MCRCategoryID categoryID = MCRCategoryID.fromString(roleID);
MCRCategLinkReference linkReference = getLinkID(user);
return CATEG_LINK_SERVICE.isInCategory(linkReference, categoryID);
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRRoleServlet method chooseCategory.
private static void chooseCategory(HttpServletRequest request) {
MCRCategoryID categoryID;
String categID = getProperty(request, "categID");
if (categID != null) {
categoryID = MCRCategoryID.fromString(categID);
} else {
String rootID = getProperty(request, "classID");
categoryID = (rootID == null) ? MCRUser2Constants.ROLE_CLASSID : MCRCategoryID.rootID(rootID);
}
Element rootElement = getRootElement(request);
rootElement.setAttribute("classID", categoryID.getRootID());
if (!categoryID.isRootID()) {
rootElement.setAttribute("categID", categoryID.getID());
}
request.setAttribute(LAYOUT_ELEMENT_KEY, new Document(rootElement));
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRSolrClassificationUtil method rebuildIndex.
/**
* Reindex the whole classification system.
*/
public static void rebuildIndex() {
LOGGER.info("rebuild classification index...");
// categories
MCRCategoryDAO categoryDAO = MCRCategoryDAOFactory.getInstance();
List<MCRCategoryID> rootCategoryIDs = categoryDAO.getRootCategoryIDs();
for (MCRCategoryID rootID : rootCategoryIDs) {
LOGGER.info("rebuild classification '{}'...", rootID);
MCRCategory rootCategory = categoryDAO.getCategory(rootID, -1);
List<MCRCategory> categoryList = getDescendants(rootCategory);
categoryList.add(rootCategory);
List<SolrInputDocument> solrDocumentList = toSolrDocument(categoryList);
bulkIndex(solrDocumentList);
}
// links
MCRCategLinkService linkService = MCRCategLinkServiceFactory.getInstance();
Collection<String> linkTypes = linkService.getTypes();
for (String linkType : linkTypes) {
LOGGER.info("rebuild '{}' links...", linkType);
bulkIndex(linkService.getLinks(linkType).stream().map(link -> new MCRSolrCategoryLink(link.getCategory().getId(), link.getObjectReference())).map(MCRSolrCategoryLink::toSolrDocument).collect(Collectors.toList()));
}
}
Aggregations