Search in sources :

Example 91 with MCRCategory

use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.

the class MCRCategoryMapper method getMappingRule.

protected String getMappingRule(MCRCategoryID categoryID) {
    MCRCategory category = DAO.getCategory(categoryID, 0);
    // "x-mapper" was used in previous versions of mycore
    MCRLabel label = category.getLabel("x-mapping").orElse(category.getLabel("x-mapper").orElseThrow(() -> new MCRException("Category " + category + " does not hav a label for 'x-mapping'.")));
    return label.getText();
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory) MCRException(org.mycore.common.MCRException) MCRLabel(org.mycore.datamodel.classifications2.MCRLabel)

Example 92 with MCRCategory

use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.

the class MCRClassificationUtils method asDocument.

/**
 * Returns the classification as a jdom document. Returns null if the
 * classification does not exists.
 *
 * @param classId the classification root id
 * @return the classification as jdom document
 */
public static Document asDocument(String classId) {
    MCRCategoryID categoryId = MCRCategoryID.rootID(classId);
    MCRCategory classification = MCRCategoryDAOFactory.getInstance().getRootCategory(categoryId, -1);
    if (classification == null) {
        return null;
    }
    return MCRCategoryTransformer.getMetaDataDocument(classification, true);
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory) MCRCategoryID(org.mycore.datamodel.classifications2.MCRCategoryID)

Example 93 with MCRCategory

use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.

the class MCRStringTransformer method printCatgory.

private static void printCatgory(MCRCategory category, StringBuilder sb) {
    for (int i = 0; i < category.getLevel(); i++) {
        sb.append(' ');
    }
    sb.append(category.getId());
    sb.append('[');
    printLabels(category.getLabels(), sb);
    sb.append(']');
    sb.append('\n');
    for (MCRCategory child : category.getChildren()) {
        printCatgory(child, sb);
    }
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory)

Example 94 with MCRCategory

use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.

the class MCRSolrCategoryDAO method setLabels.

@Override
public MCRCategory setLabels(MCRCategoryID id, Set<MCRLabel> labels) {
    MCRCategory category = super.setLabels(id, labels);
    MCRSolrClassificationUtil.reindex(category);
    return category;
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory)

Example 95 with MCRCategory

use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.

the class MCRSolrCategoryDAO method setLabel.

@Override
public MCRCategory setLabel(MCRCategoryID id, MCRLabel label) {
    MCRCategory category = super.setLabel(id, label);
    MCRSolrClassificationUtil.reindex(category);
    return category;
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory)

Aggregations

MCRCategory (org.mycore.datamodel.classifications2.MCRCategory)87 MCRCategoryID (org.mycore.datamodel.classifications2.MCRCategoryID)36 Test (org.junit.Test)24 MCRLabel (org.mycore.datamodel.classifications2.MCRLabel)17 MCRCategoryDAO (org.mycore.datamodel.classifications2.MCRCategoryDAO)10 ArrayList (java.util.ArrayList)9 Document (org.jdom2.Document)9 Element (org.jdom2.Element)8 MCRException (org.mycore.common.MCRException)8 IOException (java.io.IOException)6 EntityManager (javax.persistence.EntityManager)6 URI (java.net.URI)5 Collection (java.util.Collection)5 HashMap (java.util.HashMap)5 LogManager (org.apache.logging.log4j.LogManager)5 Logger (org.apache.logging.log4j.Logger)5 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)5 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4