Source:
private void setIdsToRemoveWithNewExtensions(IStorageUtilityIndexed<Case> caseStorage, Vector<String> owners) { internalCaseDAG = new DAG<>(); Vector<CaseIndex> indexHolder = new Vector<>(); for (IStorageIterator<Case> i = caseStorage.iterate(); i.hasMore(); ) { Case c = i.nextRecord(); boolean owned = true; if (owners != null) { owned = owners.contains(c.getUserId()); } for (CaseIndex index : c.getIndices()) { CaseIndex toReplace = null; boolean skip = false; for (CaseIndex existing : indexHolder) { if (existing.getTarget().equals(index.getTarget())) { if (existing.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION) && !index.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION)) { toReplace = existing; } else { skip = true; } break; } } if (toReplace != null) { indexHolder.removeElement(toReplace); } if (!skip) { indexHolder.addElement(index); } } int nodeStatus = 0; if (owned) { nodeStatus |= STATUS_OWNED; } if (!c.isClosed()) { nodeStatus |= STATUS_OPEN; } if (owned && !c.isClosed()) { nodeStatus |= STATUS_RELEVANT; } internalCaseDAG.addNode(c.getCaseId(), new int[]{nodeStatus, c.getID()}); for (CaseIndex index : indexHolder) { internalCaseDAG.setEdge(c.getCaseId(), index.getTarget(), index.getRelationship()); } indexHolder.removeAllElements(); } invalidEdgesWereRemoved = removeInvalidEdges(); propagateRelevance(internalCaseDAG); propagateAvailabile(internalCaseDAG); propagateLive(internalCaseDAG); for (Enumeration iterator = internalCaseDAG.getNodes(); iterator.hasMoreElements(); ) { int[] node = (int[])iterator.nextElement(); if (!caseStatusIs(node[0], STATUS_ALIVE)) { idsToRemove.addElement(new Integer(node[1])); } } }

Target:
private void setIdsToRemoveWithNewExtensions(IStorageUtilityIndexed<Case> caseStorage, Vector<String> owners) { internalCaseDAG = new DAG<String, int[], String>(); Vector<CaseIndex> indexHolder = new Vector<CaseIndex>(); for (IStorageIterator<Case> i = caseStorage.iterate(); i.hasMore(); ) { Case c = i.nextRecord(); boolean owned = true; if (owners != null) { owned = owners.contains(c.getUserId()); } for (CaseIndex index : c.getIndices()) { CaseIndex toReplace = null; boolean skip = false; for (CaseIndex existing : indexHolder) { if (existing.getTarget().equals(index.getTarget())) { if (existing.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION) && !index.getRelationship().equals(CaseIndex.RELATIONSHIP_EXTENSION)) { toReplace = existing; } else { skip = true; } break; } } if (toReplace != null) { indexHolder.removeElement(toReplace); } if (!skip) { indexHolder.addElement(index); } } int nodeStatus = 0; if (owned) { nodeStatus |= STATUS_OWNED; } if (!c.isClosed()) { nodeStatus |= STATUS_OPEN; } if (owned && !c.isClosed()) { nodeStatus |= STATUS_RELEVANT; } internalCaseDAG.addNode(c.getCaseId(), new int[]{nodeStatus, c.getID()}); for (CaseIndex index : indexHolder) { internalCaseDAG.setEdge(c.getCaseId(), index.getTarget(), index.getRelationship()); } indexHolder.removeAllElements(); } Vector<String[]> edgesToRemove = getInvalidEdges(); for (String[] edge : edgesToRemove) { internalCaseDAG.removeEdge(edge[0], edge[1]); } propagateRelevance(internalCaseDAG); propagateAvailabile(internalCaseDAG); propagateLive(internalCaseDAG); for (Enumeration iterator = internalCaseDAG.getNodes(); iterator.hasMoreElements(); ) { int[] node = (int[])iterator.nextElement(); if (!caseStatusIs(node[0], STATUS_ALIVE)) { idsToRemove.addElement(new Integer(node[1])); } } }