@Override public boolean equalsDefinition(BusinessServiceEdgeEntity other) { boolean equalsSuper = super.equalsDefinition(other); if (equalsSuper) { return Objects.equals(child.getId(), ((BusinessServiceChildEdgeEntity) other).getChild().getId()); } return false; }
private boolean checkDescendantForLoop(final BusinessServiceEntity parent, final BusinessServiceEntity descendant) { if (parent.equals(descendant)) { return true; } for (BusinessServiceChildEdgeEntity eachChildEdge : descendant.getChildEdges()) { return this.checkDescendantForLoop(parent, eachChildEdge.getChild()); } return false; }
@Override public BusinessService getChild() { return new BusinessServiceImpl(getManager(), getEntity().getChild()); }
@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); }
public static ChildEdgeResponseDTO toResponseDTO(BusinessServiceChildEdgeEntity input) { ChildEdgeResponseDTO edge = new ChildEdgeResponseDTO(); edge.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(input.getBusinessService().getId(), input.getId())); edge.setReductionKeys(edge.getReductionKeys()); edge.setMapFunction(transform(input.getMapFunction())); edge.setId(input.getId()); edge.setChildId(input.getChild().getId()); edge.setWeight(input.getWeight()); edge.setOperationalStatus(Status.INDETERMINATE); // we assume INDETERMINATE return edge; }