use of org.opennms.netmgt.bsm.service.internal.edge.ReductionKeyEdgeImpl in project opennms by OpenNMS.
the class BusinessServiceManagerImpl method addReductionKeyEdge.
@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;
}
use of org.opennms.netmgt.bsm.service.internal.edge.ReductionKeyEdgeImpl in project opennms by OpenNMS.
the class BusinessServiceManagerImpl method setReductionKeyEdges.
@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()));
}
use of org.opennms.netmgt.bsm.service.internal.edge.ReductionKeyEdgeImpl in project opennms by OpenNMS.
the class BusinessServiceManagerImpl method createEdge.
@SuppressWarnings("unchecked")
private <T extends Edge> T createEdge(Class<T> type, BusinessService source, MapFunction mapFunction, int weight) {
T edge = null;
if (type == IpServiceEdge.class) {
edge = (T) new IpServiceEdgeImpl(this, new IPServiceEdgeEntity());
}
if (type == ChildEdge.class) {
edge = (T) new ChildEdgeImpl(this, new BusinessServiceChildEdgeEntity());
}
if (type == ReductionKeyEdge.class) {
edge = (T) new ReductionKeyEdgeImpl(this, new SingleReductionKeyEdgeEntity());
}
if (edge != null) {
edge.setSource(source);
edge.setMapFunction(mapFunction);
edge.setWeight(weight);
return edge;
}
throw new IllegalArgumentException("Could not create edge for type " + type);
}
Aggregations