@Override protected String probeSession(CoreSession session) { // finds if there are documents in 'deleted' lifecycle state List<Map<String, Serializable>> deletedMaps = session.queryProjection(QUERY_DELETED, 1, 0); // limit 1 if (!deletedMaps.isEmpty()) { return MIGRATION_STATE_LIFECYCLE; } else { return MIGRATION_STATE_PROPERTY; } }
@Override protected String probeSession(CoreSession session) { // finds if there are any taggings List<Map<String, Serializable>> taggingMaps = session.queryProjection(QUERY_TAGGING, 1, 0); // limit 1 if (!taggingMaps.isEmpty()) { return MIGRATION_STATE_RELATIONS; } else { return MIGRATION_STATE_FACETS; } }
@Override public void run() { PartialList<Map<String, Serializable>> workflows = session.queryProjection(WORKFLOWS_QUERY, limit, 0); numberOfCleanedUpWorkflows = workflows.size(); for (Map<String, Serializable> workflow : workflows) { String routeDocId = workflow.get(ECM_UUID).toString(); final String associatedTaskQuery = String.format(TASKS_QUERY, routeDocId); session.queryProjection(associatedTaskQuery, 0, 0) .stream() .map(task -> new IdRef(task.get(ECM_UUID).toString())) .forEach(session::removeDocument); session.removeDocument(new IdRef(routeDocId)); } }
@Override protected void migrateSession(CoreSession session) { List<Map<String, Serializable>> taggingMaps = session.queryProjection(QUERY_TAGGING, -1, 0); List<Map<String, Serializable>> tagMaps = session.queryProjection(tagSql, -1, 0);
protected boolean hasContent(DocumentModel document, String query) throws IOException { try (SessionWrapper wrapper = ctx.getSession(document)) { // Limit result set to 1 as we just want to know if there's at least one child return wrapper.getSession() .queryProjection(String.format(query, NXQL.escapeString(document.getId())), 1, 0) .size() > 0; } }
@Override protected void migrateSession(CoreSession session) { List<Map<String, Serializable>> deletedMaps = session.queryProjection(QUERY_DELETED, -1, 0);
@Override public void write(JsonGenerator jg, DocumentModel document) throws IOException { if (!document.isFolder()) { jg.writeBooleanField(NAME, false); return; } try (SessionWrapper wrapper = ctx.getSession(document)) { String fetchFolderishChildQuery = "SELECT * FROM Document WHERE ecm:mixinType = 'Folderish'" + " AND ecm:mixinType != 'HiddenInNavigation' AND ecm:isTrashed = 0" + " AND ecm:parentId = " + NXQL.escapeString(document.getId()); // Limit result set to 1 as we just want to know if there's at least one Folderish child boolean hasChildren = !wrapper.getSession().queryProjection(fetchFolderishChildQuery, 1, 0).isEmpty(); jg.writeBooleanField(NAME, hasChildren); } }