use of org.apache.syncope.core.persistence.api.entity.Relationship in project syncope by apache.
the class JPARelationshipTypeDAO method delete.
@Override
public void delete(final String key) {
RelationshipType type = find(key);
if (type == null) {
return;
}
findRelationshipsByType(type).stream().map(relationship -> {
if (relationship instanceof URelationship) {
((URelationship) relationship).getLeftEnd().getRelationships().remove((URelationship) relationship);
} else if (relationship instanceof UMembership) {
((UMembership) relationship).getLeftEnd().getMemberships().remove((UMembership) relationship);
} else if (relationship instanceof ARelationship) {
((ARelationship) relationship).getLeftEnd().getRelationships().remove((ARelationship) relationship);
} else if (relationship instanceof AMembership) {
((AMembership) relationship).getLeftEnd().getMemberships().remove((AMembership) relationship);
}
relationship.setLeftEnd(null);
return relationship;
}).forEachOrdered(relationship -> entityManager().remove(relationship));
entityManager().remove(type);
}
Aggregations