Search in sources :

Example 6 with MCRJSONCategory

use of org.mycore.frontend.classeditor.json.MCRJSONCategory in project mycore by MyCoRe-Org.

the class CategoryDAOMock method createCategory.

private MCRJSONCategory createCategory(String rootID, String categID, MCRCategoryID parentID) {
    MCRCategoryID id = new MCRCategoryID(rootID, categID);
    Set<MCRLabel> labels = new HashSet<>();
    labels.add(new MCRLabel("de", id + "_text", id + "_descr"));
    labels.add(new MCRLabel("en", id + "_text", id + "_descr"));
    MCRJSONCategory newCategory = new MCRJSONCategory();
    newCategory.setId(id);
    newCategory.setLabels(labels);
    newCategory.setParentID(parentID);
    return newCategory;
}
Also used : MCRJSONCategory(org.mycore.frontend.classeditor.json.MCRJSONCategory) MCRCategoryID(org.mycore.datamodel.classifications2.MCRCategoryID) MCRLabel(org.mycore.datamodel.classifications2.MCRLabel) HashSet(java.util.HashSet)

Example 7 with MCRJSONCategory

use of org.mycore.frontend.classeditor.json.MCRJSONCategory in project mycore by MyCoRe-Org.

the class MCRClassificationEditorResource method getCategory.

private String getCategory(MCRCategoryID id) {
    if (!CATEGORY_DAO.exist(id)) {
        throw new WebApplicationException(Status.NOT_FOUND);
    }
    MCRCategory category = CATEGORY_DAO.getCategory(id, 1);
    if (!(category instanceof MCRJSONCategory)) {
        category = new MCRJSONCategory(category);
    }
    Gson gson = MCRJSONManager.instance().createGson();
    return gson.toJson(category);
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory) MCRJSONCategory(org.mycore.frontend.classeditor.json.MCRJSONCategory) WebApplicationException(javax.ws.rs.WebApplicationException) Gson(com.google.gson.Gson)

Example 8 with MCRJSONCategory

use of org.mycore.frontend.classeditor.json.MCRJSONCategory in project mycore by MyCoRe-Org.

the class MCRCategUtils method newCategory.

public static MCRCategory newCategory(MCRCategoryID id, Set<MCRLabel> labels, MCRCategoryID mcrCategoryID) {
    MCRJSONCategory category = new MCRJSONCategory();
    category.setId(id);
    category.setLabels(labels);
    category.setParentID(mcrCategoryID);
    return category;
}
Also used : MCRJSONCategory(org.mycore.frontend.classeditor.json.MCRJSONCategory)

Aggregations

MCRJSONCategory (org.mycore.frontend.classeditor.json.MCRJSONCategory)8 MCRCategory (org.mycore.datamodel.classifications2.MCRCategory)3 MCRCategoryID (org.mycore.datamodel.classifications2.MCRCategoryID)3 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonStreamParser (com.google.gson.JsonStreamParser)1 HashSet (java.util.HashSet)1 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1 PERMISSION_DELETE (org.mycore.access.MCRAccessManager.PERMISSION_DELETE)1 MCRLabel (org.mycore.datamodel.classifications2.MCRLabel)1 MCRLabelSetWrapper (org.mycore.frontend.classeditor.wrapper.MCRLabelSetWrapper)1 MCRRestrictedAccess (org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess)1