use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class CategoryDAOMock method buildTestCategs.
private void buildTestCategs() {
MCRJSONCategory root_01 = createCategory("rootID_01", "", null);
MCRJSONCategory root_02 = createCategory("rootID_02", "", null);
MCRJSONCategory categ_01 = createCategory("rootID_01", "categ_01", null);
MCRJSONCategory categ_02 = createCategory("rootID_01", "categ_02", null);
List<MCRCategory> children = new ArrayList<>();
children.add(categ_01);
children.add(categ_02);
root_01.setChildren(children);
rootCategMap.put(root_01.getId(), root_01);
rootCategMap.put(root_02.getId(), root_02);
categMap.put(root_01.getId(), root_01);
categMap.put(root_02.getId(), root_02);
categMap.put(categ_01.getId(), categ_01);
categMap.put(categ_02.getId(), categ_02);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRClassificationEditorResourceTest method getRootCategories.
@Test
public void getRootCategories() throws Exception {
final String categoryJsonStr = target("classifications").request().get(String.class);
MCRCategoryListWrapper categListWrapper = MCRJSONManager.instance().createGson().fromJson(categoryJsonStr, MCRCategoryListWrapper.class);
List<MCRCategory> categList = categListWrapper.getList();
assertEquals("Wrong number of root categories.", 2, categList.size());
}
use of org.mycore.datamodel.classifications2.MCRCategory 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);
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method checkMissingParent.
private static void checkMissingParent(String classID, List<String> log) {
Session session = MCRHIBConnection.instance().getSession();
String sqlQuery = "select cat.categid from {h-schema}MCRCategory cat WHERE cat.classid='" + classID + "' and cat.level > 0 and cat.parentID is NULL";
@SuppressWarnings("unchecked") List<String> list = session.createNativeQuery(sqlQuery).getResultList();
for (String categIDString : list) {
log.add("parentID is null for category " + new MCRCategoryID(classID, categIDString));
}
}
use of org.mycore.datamodel.classifications2.MCRCategory in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method listCategory.
private static void listCategory(MCRCategory categ) {
int level = categ.getLevel();
StringBuilder sb = new StringBuilder(128);
for (int i = 0; i < level * 2; i++) {
sb.append(' ');
}
String space = sb.toString();
if (categ.isCategory()) {
LOGGER.info("{} ID : {}", space, categ.getId().getID());
}
for (MCRLabel label : categ.getLabels()) {
LOGGER.info("{} Label : ({}) {}", space, label.getLang(), label.getText());
}
List<MCRCategory> children = categ.getChildren();
for (MCRCategory child : children) {
listCategory(child);
}
}
Aggregations