@Override public void removeEdge(final BusinessService businessService, final Edge edge) { final BusinessServiceEntity businessServiceEntity = getBusinessServiceEntity(businessService); final BusinessServiceEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); businessServiceEntity.removeEdge(edgeEntity); }
@Override public boolean deleteEdge(BusinessService source, Edge edge) { BusinessServiceEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); BusinessServiceEntity businessServiceEntity = getBusinessServiceEntity(source); // does not exist, no update necessary if (!businessServiceEntity.getEdges().contains(edgeEntity)) { return false; } // remove and update businessServiceEntity.removeEdge(edgeEntity); return true; }
@Override public void setReductionKeyEdges(BusinessService businessService, Set<ReductionKeyEdge> reductionKeyEdges) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(businessService); for (final SingleReductionKeyEdgeEntity e : parentEntity.getReductionKeyEdges()) { parentEntity.removeEdge(e); } reductionKeyEdges.forEach(e -> parentEntity.addEdge(((ReductionKeyEdgeImpl) e).getEntity())); }
@Override public void setIpServiceEdges(BusinessService businessService, Set<IpServiceEdge> ipServiceEdges) { final BusinessServiceEntity entity = getBusinessServiceEntity(businessService); for (final IPServiceEdgeEntity e : entity.getIpServiceEdges()) { entity.removeEdge(e); } ipServiceEdges.forEach(e -> entity.addEdge(((IpServiceEdgeImpl) e).getEntity())); }
@Override public void setApplicationEdges(BusinessService businessService, Set<ApplicationEdge> applicationEdges) { final BusinessServiceEntity entity = getBusinessServiceEntity(businessService); for (final ApplicationEdgeEntity e : entity.getApplicationEdges()) { entity.removeEdge(e); } applicationEdges.forEach(e -> entity.addEdge(((ApplicationEdgeImpl) e).getEntity())); }
@Override public void setChildEdges(BusinessService parentService, Set<ChildEdge> childEdges) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(parentService); for (final BusinessServiceChildEdgeEntity e : parentEntity.getChildEdges()) { parentEntity.removeEdge(e); } childEdges.forEach(e -> parentEntity.addEdge(((ChildEdgeImpl) e).getEntity())); }
@Override public void deleteBusinessService(BusinessService businessService) { BusinessServiceEntity entity = getBusinessServiceEntity(businessService); // remove all parent -> child associations for(BusinessServiceEntity parent : getDao().findParents(entity)) { List<BusinessServiceChildEdgeEntity> collect = parent.getChildEdges().stream().filter(e -> entity.equals(e.getChild())).collect(Collectors.toList()); collect.forEach(x -> { parent.removeEdge(x); edgeDao.delete(x); // we need to delete this edge manually as they cannot be deleted automatically }); } // edges of the entity are deleted automatically by hibernate getDao().delete(entity); }