use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method replaceMarcRelator.
@Test
public void replaceMarcRelator() throws Exception {
MCRCategory marcrelator = loadClassificationResource("/marcrelator-test.xml");
DAO.addCategory(null, marcrelator);
startNewTransaction();
marcrelator = loadClassificationResource("/marcrelator-test2.xml");
DAO.replaceCategory(marcrelator);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryDAOImplTest method getRootCategories.
@Test
public void getRootCategories() {
addWorldClassification();
MCRCategoryID find = category.getId();
List<MCRCategory> classes = DAO.getRootCategories();
assertEquals("Result size does not match.", 1, classes.size());
assertEquals("Returned MCRCategoryID does not match.", find, classes.get(0).getId());
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRClassificationBrowser2 method addLabel.
/**
* Add label in current lang, otherwise default lang, optional with
* description
*/
private void addLabel(HttpServletRequest req, MCRCategory child, Element category) {
MCRLabel label = child.getCurrentLabel().orElseThrow(() -> new MCRException("Category " + child.getId() + " has no labels."));
category.addContent(new Element("label").setText(label.getText()));
// if true, add description
boolean descr = Boolean.valueOf(req.getParameter("adddescription"));
if (descr && (label.getDescription() != null)) {
category.addContent(new Element("description").setText(label.getDescription()));
}
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryListTypeAdapter method deserialize.
@Override
public MCRCategoryListWrapper deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
List<MCRCategory> categList = new ArrayList<>();
for (JsonElement categRef : json.getAsJsonArray()) {
JsonObject categRefJsonObject = categRef.getAsJsonObject();
MCRCategory categ = context.deserialize(categRefJsonObject, MCRJSONCategory.class);
categList.add(categ);
}
return new MCRCategoryListWrapper(categList);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRCategoryListTypeAdapter method categListToJsonArray.
private JsonElement categListToJsonArray(List<MCRCategory> categList, Map<MCRCategoryID, Boolean> linkMap) {
JsonArray categJsonArray = new JsonArray();
for (MCRCategory categ : categList) {
Boolean hasLink = linkMap.get(categ.getId());
JsonElement element = createCategRefJSONObj(categ, hasLink);
categJsonArray.add(element);
}
return categJsonArray;
}
Aggregations