use of org.mycore.datamodel.classifications2.MCRCategory 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.MCRCategory in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method loadFromURL.
@MCRCommand(syntax = "load classification from url {0}", help = "The command adds a new classification from URL {0} to the system.", order = 15)
public static void loadFromURL(String fileURL) throws SAXParseException, MalformedURLException, URISyntaxException {
Document xml = MCRXMLParserFactory.getParser().parseXML(new MCRURLContent(new URL(fileURL)));
MCRCategory category = MCRXMLTransformer.getCategory(xml);
DAO.addCategory(null, category);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRUserTestCase method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
MCRCategory groupsCategory = MCRCategoryDAOImplTest.loadClassificationResource("/mcr-roles.xml");
MCRCategoryDAO DAO = MCRCategoryDAOFactory.getInstance();
DAO.addCategory(null, groupsCategory);
}
use of org.mycore.datamodel.classifications2.MCRCategory 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()));
}
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRRoleManager method getExternalRole.
/**
* Factory for external roles
* @param name a valid {@link MCRCategoryID}
* @return MCRRole instance or null if category does not exist
*/
public static MCRRole getExternalRole(String name) {
MCRCategoryID categoryID = MCRCategoryID.fromString(name);
if (categoryID.isRootID()) {
LOGGER.debug("External role may not be a rootCategory: {}", categoryID);
return null;
}
MCRCategory category = DAO.getCategory(categoryID, 0);
if (category == null) {
LOGGER.debug("Category does not exist: {}", categoryID);
return null;
}
return new MCRRole(name, category.getLabels());
}
Aggregations