Search in sources :

Example 1 with EdgeEntityVisitor

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;
}
Also used : SingleReductionKeyEdgeEntity(org.opennms.netmgt.bsm.persistence.api.SingleReductionKeyEdgeEntity) IPServiceEdgeEntity(org.opennms.netmgt.bsm.persistence.api.IPServiceEdgeEntity) EdgeEntityVisitor(org.opennms.netmgt.bsm.persistence.api.EdgeEntityVisitor) BusinessServiceRequestDTO(org.opennms.web.rest.v2.bsm.model.BusinessServiceRequestDTO) BusinessServiceChildEdgeEntity(org.opennms.netmgt.bsm.persistence.api.BusinessServiceChildEdgeEntity)

Aggregations

BusinessServiceChildEdgeEntity (org.opennms.netmgt.bsm.persistence.api.BusinessServiceChildEdgeEntity)1 EdgeEntityVisitor (org.opennms.netmgt.bsm.persistence.api.EdgeEntityVisitor)1 IPServiceEdgeEntity (org.opennms.netmgt.bsm.persistence.api.IPServiceEdgeEntity)1 SingleReductionKeyEdgeEntity (org.opennms.netmgt.bsm.persistence.api.SingleReductionKeyEdgeEntity)1 BusinessServiceRequestDTO (org.opennms.web.rest.v2.bsm.model.BusinessServiceRequestDTO)1