@Override public void saveEntity(Object entity) { Class<? extends Object> entityType = entity.getClass(); if (entity instanceof IdentityBean<?> && _entityReplacementStrategy.hasReplacementEntities(entityType)) { IdentityBean<?> bean = (IdentityBean<?>) entity; Serializable id = bean.getId(); if (_entityReplacementStrategy.hasReplacementEntity(entityType, id)) return; } super.saveEntity(entity); }
private void applyObjectToAnnotation(Graph graph, AnnotationObject annotation, Object o) { if (o instanceof Edge) { annotation.edge = graph.getIdForEdge((Edge) o); } else if (o instanceof Vertex) { annotation.vertex = ((Vertex) o).getLabel(); } else if (o instanceof String) { annotation.message = (String) o; } else if (o instanceof IdentityBean) { IdentityBean<?> bean = (IdentityBean<?>) o; Object id = bean.getId(); applyObjectToAnnotation(graph, annotation, id); } else if (o instanceof AgencyAndId) { AgencyAndId id = (AgencyAndId) o; annotation.agency = id.getAgencyId(); annotation.id = id.getId(); } else if (o instanceof Collection) { Collection<?> collection = (Collection<?>) o; if (collection.isEmpty()) return; Object first = collection.iterator().next(); applyObjectToAnnotation(graph, annotation, first); } }