use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRCategUtils method getCategoryIDMap.
public static HashMap<MCRCategoryID, String> getCategoryIDMap(String json) {
HashMap<MCRCategoryID, String> categories = new HashMap<>();
JsonStreamParser jsonStreamParser = new JsonStreamParser(json);
if (jsonStreamParser.hasNext()) {
JsonArray saveObjArray = jsonStreamParser.next().getAsJsonArray();
for (JsonElement jsonElement : saveObjArray) {
// jsonObject.item.id.rootid
JsonObject root = jsonElement.getAsJsonObject();
String rootId = root.getAsJsonObject("item").getAsJsonObject("id").getAsJsonPrimitive("rootid").getAsString();
String state = root.getAsJsonPrimitive("state").getAsString();
JsonElement parentIdJSON = root.get("parentId");
if (parentIdJSON != null && parentIdJSON.isJsonPrimitive() && "_placeboid_".equals(parentIdJSON.getAsString())) {
state = "new";
}
categories.put(MCRCategoryID.rootID(rootId), state);
}
} else {
return null;
}
return categories;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRMetadataHistoryManager method objectIsHidden.
static boolean objectIsHidden(MCRObject obj) {
MCRCategoryID state = obj.getService().getState();
if (state == null) {
LogManager.getLogger().debug("{} is visible as it does not use a service state.", obj.getId());
return false;
}
boolean hidden = !"published".equals(state.getID());
LogManager.getLogger().debug("{} is hidden due to service state '{}': {}", obj.getId(), state, hidden);
return hidden;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID 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.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method exportAll.
/**
* Save all MCRClassifications.
*
* @param dirname
* the directory name to store all classifications
* @param style
* the name part of the stylesheet like <em>style</em>
* -classification.xsl
* @return false if an error was occured, else true
*/
@MCRCommand(syntax = "export all classifications to directory {0} with {1}", help = "The command store all classifications to the directory with name {0} with the stylesheet {1}-object.xsl. For {1} save is the default.", order = 70)
public static boolean exportAll(String dirname, String style) throws Exception {
List<MCRCategoryID> allClassIds = DAO.getRootCategoryIDs();
boolean ret = false;
for (MCRCategoryID id : allClassIds) {
ret = ret & export(id.getRootID(), dirname, style);
}
return ret;
}
use of org.mycore.datamodel.classifications2.MCRCategoryID in project mycore by MyCoRe-Org.
the class MCRClassification2Commands method checkAllClassifications.
@MCRCommand(syntax = "check all classifications", help = "checks if all redundant information are stored without conflicts", order = 140)
public static List<String> checkAllClassifications() {
List<MCRCategoryID> classifications = MCRCategoryDAOFactory.getInstance().getRootCategoryIDs();
List<String> commands = new ArrayList<>(classifications.size());
for (MCRCategoryID id : classifications) {
commands.add("check classification " + id.getRootID());
}
return commands;
}
Aggregations