public BusinessServiceEntity addChildServiceEdge(BusinessServiceEntity child, AbstractMapFunctionEntity mapFunction, int weight) { BusinessServiceChildEdgeEntity edge = new BusinessServiceChildEdgeEntity(); edge.setBusinessService(this); edge.setChild(Objects.requireNonNull(child)); edge.setWeight(weight); edge.setMapFunction(Objects.requireNonNull(mapFunction)); addEdge(edge); return this; }
@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 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())); }
public BusinessServiceEntity addIpServiceEdge(OnmsMonitoredService ipService, AbstractMapFunctionEntity mapFunction, int weight, String friendlyName) { IPServiceEdgeEntity edge = new IPServiceEdgeEntity(); edge.setBusinessService(this); edge.setIpService(Objects.requireNonNull(ipService)); edge.setWeight(weight); edge.setMapFunction(Objects.requireNonNull(mapFunction)); edge.setFriendlyName(friendlyName); addEdge(edge); return this; }
public BusinessServiceEntity addReductionKeyEdge(String reductionKey, AbstractMapFunctionEntity mapFunction, int weight, String friendlyName) { SingleReductionKeyEdgeEntity edge = new SingleReductionKeyEdgeEntity(); edge.setBusinessService(this); edge.setReductionKey(Objects.requireNonNull(reductionKey)); edge.setWeight(weight); edge.setMapFunction(Objects.requireNonNull(mapFunction)); edge.setFriendlyName(friendlyName); addEdge(edge); return this; } }
@Override public boolean addApplicationEdge(BusinessService businessService, Application application, MapFunction mapFunction, int weight) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(businessService); // Create the edge final ApplicationEdge edge = createEdge(ApplicationEdge.class, businessService, mapFunction, weight); edge.setApplication(application); // if already exists, no update final ApplicationEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); long count = parentEntity.getApplicationEdges().stream().filter(e -> e.equalsDefinition(edgeEntity)).count(); if (count > 0) { return false; } parentEntity.addEdge(((ApplicationEdgeImpl)edge).getEntity()); return true; }
@Override public boolean addReductionKeyEdge(BusinessService businessService, String reductionKey, MapFunction mapFunction, int weight, String friendlyName) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(businessService); // Create the edge final ReductionKeyEdgeImpl edge = (ReductionKeyEdgeImpl) createEdge(ReductionKeyEdge.class, businessService, mapFunction, weight); edge.setReductionKey(reductionKey); edge.setFriendlyName(friendlyName); // if already exists, no update final SingleReductionKeyEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); long count = parentEntity.getReductionKeyEdges().stream().filter(e -> e.equalsDefinition(edgeEntity)).count(); if (count > 0) { return false; } parentEntity.addEdge(edge.getEntity()); return true; }
@Override public boolean addIpServiceEdge(BusinessService businessService, IpService ipService, MapFunction mapFunction, int weight, String friendlyName) { final BusinessServiceEntity parentEntity = getBusinessServiceEntity(businessService); // Create the edge final IpServiceEdge edge = createEdge(IpServiceEdge.class, businessService, mapFunction, weight); edge.setIpService(ipService); edge.setFriendlyName(friendlyName); // if already exists, no update final IPServiceEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(edge); long count = parentEntity.getIpServiceEdges().stream().filter(e -> e.equalsDefinition(edgeEntity)).count(); if (count > 0) { return false; } parentEntity.addEdge(((IpServiceEdgeImpl)edge).getEntity()); return true; }
@Override public boolean addChildEdge(BusinessService parentService, BusinessService childService, MapFunction mapFunction, int weight) { // verify that exists final BusinessServiceEntity parentEntity = getBusinessServiceEntity(parentService); final BusinessServiceEntity childEntity = getBusinessServiceEntity(childService); // Create the edge ChildEdge childEdge = createEdge(ChildEdge.class, parentService, mapFunction, weight); childEdge.setChild(childService); // Verify no loop if (this.checkDescendantForLoop(parentEntity, childEntity)) { throw new IllegalArgumentException("Service will form a loop"); } // if already exists, no update final BusinessServiceChildEdgeEntity edgeEntity = getBusinessServiceEdgeEntity(childEdge); long count = parentEntity.getChildEdges().stream().filter(e -> e.equalsDefinition(edgeEntity)).count(); if (count > 0) { return false; } parentEntity.addEdge(((ChildEdgeImpl)childEdge).getEntity()); return true; }