use of org.opennms.netmgt.bsm.service.model.functions.map.MapFunction 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.model.functions.map.MapFunction in project opennms by OpenNMS.
the class BusinessServiceEdgeEditWindow method getMapFunction.
@SuppressWarnings("unchecked")
private MapFunction getMapFunction() {
try {
final MapFunction mapFunction = ((Class<? extends MapFunction>) m_mapFunctionSelect.getValue()).newInstance();
mapFunction.accept(new MapFunctionVisitor<Void>() {
@Override
public Void visit(Decrease decrease) {
return null;
}
@Override
public Void visit(Identity identity) {
return null;
}
@Override
public Void visit(Ignore ignore) {
return null;
}
@Override
public Void visit(Increase increase) {
return null;
}
@Override
public Void visit(SetTo setTo) {
setTo.setStatus((Status) m_mapFunctionSeveritySelect.getValue());
return null;
}
});
return mapFunction;
} catch (final InstantiationException | IllegalAccessException e) {
throw Throwables.propagate(e);
}
}
use of org.opennms.netmgt.bsm.service.model.functions.map.MapFunction in project opennms by OpenNMS.
the class BusinessServiceManagerImpl method addIpServiceEdge.
@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;
}
use of org.opennms.netmgt.bsm.service.model.functions.map.MapFunction in project opennms by OpenNMS.
the class BusinessServiceManagerImpl method addChildEdge.
@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;
}
use of org.opennms.netmgt.bsm.service.model.functions.map.MapFunction in project opennms by OpenNMS.
the class BsmTestUtils method transform.
private static MapFunctionDTO transform(AbstractMapFunctionEntity input) {
Objects.requireNonNull(input);
MapFunction mapFunction = new MapFunctionMapper().toServiceFunction(input);
return new FunctionsManager().getMapFunctionDTO(mapFunction);
}
Aggregations