use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceSearchProvider method queryVertices.
@Override
public List<? extends VertexRef> queryVertices(SearchQuery searchQuery, GraphContainer container) {
List<BusinessServiceVertex> results = Lists.newArrayList();
String queryString = searchQuery.getQueryString();
CriteriaBuilder bldr = new CriteriaBuilder(BusinessService.class);
if (queryString != null && queryString.length() > 0) {
bldr.ilike("name", String.format("%%%s%%", queryString));
}
bldr.orderBy("name", true);
bldr.limit(10);
Criteria dbQueryCriteria = bldr.toCriteria();
for (BusinessService bs : businessServiceManager.findMatching(dbQueryCriteria)) {
final BusinessServiceVertex businessServiceVertex = new BusinessServiceVertex(bs, 0);
// Only consider results which are available in the Topology Provider, see BSM-191
if (container.getTopologyServiceClient().getVertex(businessServiceVertex) != null) {
results.add(businessServiceVertex);
}
}
return results;
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServicesTopologyProvider method getDefaults.
@Override
public Defaults getDefaults() {
return new Defaults().withPreferredLayout("Hierarchy Layout").withCriteria(() -> {
// Grab the business service with the smallest id
List<BusinessService> businessServices = businessServiceManager.findMatching(new CriteriaBuilder(BusinessService.class).orderBy("id", true).limit(1).toCriteria());
// If one was found, use it for the default focus
if (!businessServices.isEmpty()) {
BusinessService businessService = businessServices.iterator().next();
BusinessServiceVertex businessServiceVertex = new BusinessServiceVertex(businessService, 0);
return Lists.newArrayList(new VertexHopGraphProvider.DefaultVertexHopCriteria(businessServiceVertex));
}
return null;
});
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServicesBoxController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int numberOfRows = Integer.getInteger("opennms.businessServicesWithProblems.count", DEFAULT_ROW_COUNT);
BusinessServiceSearchCriteriaBuilder criteriaBuilder = new BusinessServiceSearchCriteriaBuilder().order(BusinessServiceSearchCriteriaBuilder.Order.Severity).greaterSeverity(Status.NORMAL).desc();
List<BusinessService> bsList = criteriaBuilder.apply(businessServiceManager, businessServiceManager.getAllBusinessServices());
boolean more = bsList.size() - numberOfRows > 0;
if (bsList.size() > numberOfRows) {
bsList = bsList.subList(0, numberOfRows);
}
ModelAndView modelAndView = new ModelAndView(m_successView);
modelAndView.addObject("more", more);
modelAndView.addObject("services", bsList);
return modelAndView;
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceRestService method addReductionKeyEdge.
@POST
@Path("{id}/reduction-key-edge")
public // Add Reduction Key
Response addReductionKeyEdge(@PathParam("id") final Long serviceId, final ReductionKeyEdgeRequestDTO edgeRequest) {
final BusinessService businessService = getManager().getBusinessServiceById(serviceId);
boolean changed = getManager().addReductionKeyEdge(businessService, edgeRequest.getReductionKey(), transform(edgeRequest.getMapFunction()), edgeRequest.getWeight(), edgeRequest.getFriendlyName());
if (!changed) {
return Response.notModified().build();
}
businessService.save();
return Response.ok().build();
}
use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.
the class BusinessServiceRestService method getById.
@GET
@Path("{id}")
public Response getById(@PathParam("id") Long id) {
BusinessService service = getManager().getBusinessServiceById(id);
final BusinessServiceResponseDTO response = new BusinessServiceResponseDTO();
response.setId(service.getId());
response.setName(service.getName());
response.setAttributes(service.getAttributes());
response.setLocation(ResourceLocationFactory.createBusinessServiceLocation(service.getId().toString()));
response.setParentServices(service.getParentServices().stream().map(BusinessService::getId).collect(Collectors.toSet()));
response.setOperationalStatus(service.getOperationalStatus());
response.setReduceFunction(transform(service.getReduceFunction()));
service.getEdges().forEach(eachEdge -> eachEdge.accept(new EdgeVisitor<Void>() {
@Override
public Void visit(IpServiceEdge edge) {
response.getIpServices().add(transform(edge));
return null;
}
@Override
public Void visit(ReductionKeyEdge edge) {
response.getReductionKeys().add(transform(edge));
return null;
}
@Override
public Void visit(ChildEdge edge) {
response.getChildren().add(transform(edge));
return null;
}
}));
return Response.ok(response).build();
}
Aggregations