use of org.opennms.netmgt.bsm.persistence.api.EdgeEntityVisitor in project opennms by OpenNMS.
the class BsmTestUtils method toRequestDto.
public static BusinessServiceRequestDTO toRequestDto(BusinessServiceEntity input) {
Objects.requireNonNull(input);
BusinessServiceRequestDTO request = new BusinessServiceRequestDTO();
request.setName(input.getName());
request.setAttributes(new HashMap<>(input.getAttributes()));
request.setReduceFunction(transform(input.getReductionFunction()));
input.getEdges().forEach(eachEdge -> eachEdge.accept(new EdgeEntityVisitor<Void>() {
@Override
public Void visit(BusinessServiceChildEdgeEntity edgeEntity) {
request.addChildService(edgeEntity.getChild().getId(), transform(edgeEntity.getMapFunction()), edgeEntity.getWeight());
return null;
}
@Override
public Void visit(SingleReductionKeyEdgeEntity edgeEntity) {
request.addReductionKey(edgeEntity.getReductionKey(), transform(edgeEntity.getMapFunction()), edgeEntity.getWeight(), edgeEntity.getFriendlyName());
return null;
}
@Override
public Void visit(IPServiceEdgeEntity edgeEntity) {
request.addIpService(edgeEntity.getIpService().getId(), transform(edgeEntity.getMapFunction()), edgeEntity.getWeight(), edgeEntity.getFriendlyName());
return null;
}
}));
return request;
}
Aggregations