public boolean isParentOf(HierarchicalRecord record) { if (record != null) { for (HierarchicalRecord parent : record.getParentRecords()) { if (this == parent) return true; if (isParentOf(parent)) return true; } } return false; }
@Override public void mergeWith(Record record, Map<Record, Object> recordsToRefresh) { super.mergeWith(record, recordsToRefresh); HierarchicalRecord hierarchicalRecord = (HierarchicalRecord) record; // parent ids for (HierarchicalRecord parentRecord : hierarchicalRecord.getParentRecords()) { if (!isParentOf(parentRecord) && !parentRecord.isRoot()) getHierarchicalIndex().addRelationship(parentRecord, this); } // child ids for (HierarchicalRecord childRecord : hierarchicalRecord.getChildRecords()) { if (!isChildOf(childRecord)) getHierarchicalIndex().addRelationship(this, childRecord); } }