use of org.opennms.web.rest.v2.bsm.model.MapFunctionDTO in project opennms by OpenNMS.
the class BusinessServiceRequestDTO method addIpService.
public void addIpService(int ipServiceId, MapFunctionDTO mapFunction, int weight, String friendlyName) {
IpServiceEdgeRequestDTO edge = new IpServiceEdgeRequestDTO();
edge.setIpServiceId(ipServiceId);
edge.setMapFunction(mapFunction);
edge.setWeight(weight);
edge.setFriendlyName(friendlyName);
getIpServices().add(edge);
}
use of org.opennms.web.rest.v2.bsm.model.MapFunctionDTO in project opennms by OpenNMS.
the class FunctionsManager method getMapFunctionDTO.
public MapFunctionDTO getMapFunctionDTO(MapFunction mapFunction) {
Objects.requireNonNull(mapFunction);
final FunctionMetaDTO functionMeta = new FunctionMetaDTO(mapFunction.getClass(), FunctionType.MapFunction);
final MapFunctionDTO mapFunctionDTO = new MapFunctionDTO();
mapFunctionDTO.setType(functionMeta.getName());
mapFunctionDTO.setProperties(getFunctionProperties(mapFunction));
return mapFunctionDTO;
}
use of org.opennms.web.rest.v2.bsm.model.MapFunctionDTO in project opennms by OpenNMS.
the class BusinessServiceRequestDTOMarshalTest method data.
@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
final SetTo setTo = new SetTo();
setTo.setStatus(Status.CRITICAL);
final MapFunctionDTO increaseDto = createMapFunctionDTO(new Increase());
final MapFunctionDTO setToDto = createMapFunctionDTO(setTo);
final BusinessServiceRequestDTO requestDTO = new BusinessServiceRequestDTO();
requestDTO.setReduceFunction(createReduceFunctionDTO(new HighestSeverity()));
requestDTO.setName("Web Servers");
requestDTO.addAttribute("dc", "RDU");
requestDTO.addAttribute("some-key", "some-value");
requestDTO.addChildService(2L, increaseDto, 5);
requestDTO.addChildService(3L, setToDto, 5);
requestDTO.addReductionKey("myReductionKeyA", increaseDto, 7, "reduction-key-a-friendly-name");
requestDTO.addReductionKey("myReductionKeyB", increaseDto, 7, "reduction-key-b-friendly-name");
requestDTO.addIpService(1, increaseDto, 9, "ip-service-friendly-name");
return Arrays.asList(new Object[][] { { BusinessServiceRequestDTO.class, requestDTO, "{" + " \"name\" : \"Web Servers\"," + " \"attributes\" : {" + " \"attribute\" : [ {" + " \"key\" : \"dc\"," + " \"value\" : \"RDU\"" + " }, {" + " \"key\" : \"some-key\"," + " \"value\" : \"some-value\"" + " } ]" + " }," + " \"reduce-function\" : {" + " \"type\" : \"HighestSeverity\"," + " \"properties\" : { }" + " }," + " \"child-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 5," + " \"child-id\" : 2" + " }," + " {" + " \"map-function\" : {" + " \"type\" : \"SetTo\"," + " \"properties\" : {" + " \"status\" : \"Critical\"" + " }" + " }," + " \"weight\" : 5," + " \"child-id\" : 3" + " }," + " ]," + " \"ip-service-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 9," + " \"ip-service-id\" : 1," + " \"friendly-name\" : \"ip-service-friendly-name\"" + " }," + " ]," + " \"reduction-key-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 7," + " \"reduction-key\" : \"myReductionKeyA\"," + " \"friendly-name\" : \"reduction-key-a-friendly-name\"" + " }," + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 7," + " \"reduction-key\" : \"myReductionKeyB\"," + " \"friendly-name\" : \"reduction-key-b-friendly-name\"" + " }," + " ]," + "}", "<business-service>\n" + " <name>Web Servers</name>\n" + " <attributes>\n" + " <attribute>\n" + " <key>dc</key>\n" + " <value>RDU</value>\n" + " </attribute>\n" + " <attribute>\n" + " <key>some-key</key>\n" + " <value>some-value</value>\n" + " </attribute>\n" + " </attributes>\n" + " <ip-service-edges>\n" + " <ip-service-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>9</weight>\n" + " <friendly-name>ip-service-friendly-name</friendly-name>\n" + " <ip-service-id>1</ip-service-id>\n" + " </ip-service-edge>\n" + " </ip-service-edges>\n" + " <child-edges>\n" + " <child-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>5</weight>\n" + " <child-id>2</child-id>\n" + " </child-edge>\n" + " <child-edge>\n" + " <map-function>\n" + " <type>SetTo</type>\n" + " <properties>\n" + " <entry>\n" + " <key>status</key>\n" + " <value>Critical</value>\n" + " </entry>\n" + " </properties>\n" + " </map-function>\n" + " <weight>5</weight>\n" + " <child-id>3</child-id>\n" + " </child-edge>\n" + " </child-edges>\n" + " <reduction-key-edges>\n" + " <reduction-key-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>7</weight>\n" + " <friendly-name>reduction-key-a-friendly-name</friendly-name>\n" + " <reduction-key>myReductionKeyA</reduction-key>\n" + " </reduction-key-edge>\n" + " <reduction-key-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>7</weight>\n" + " <friendly-name>reduction-key-b-friendly-name</friendly-name>\n" + " <reduction-key>myReductionKeyB</reduction-key>\n" + " </reduction-key-edge>\n" + " </reduction-key-edges>\n" + " <reduce-function>\n" + " <type>HighestSeverity</type>\n" + " </reduce-function>\n" + "</business-service>" } });
}
use of org.opennms.web.rest.v2.bsm.model.MapFunctionDTO in project opennms by OpenNMS.
the class BusinessServiceResponseDTOMarshalTest method createIpServiceEdgeResponse.
private static IpServiceEdgeResponseDTO createIpServiceEdgeResponse(long id, IpServiceResponseDTO ipServiceResponseDTO, MapFunctionDTO mapFunctionDTO, Status status, ResourceLocation location, String friendlyName) {
IpServiceEdgeResponseDTO responseDTO = new IpServiceEdgeResponseDTO();
responseDTO.setOperationalStatus(status);
responseDTO.setId(id);
responseDTO.setLocation(location);
responseDTO.getReductionKeys().add("key1");
responseDTO.getReductionKeys().add("key2");
responseDTO.setIpService(ipServiceResponseDTO);
responseDTO.setWeight(5);
responseDTO.setMapFunction(mapFunctionDTO);
responseDTO.setFriendlyName(friendlyName);
return responseDTO;
}
use of org.opennms.web.rest.v2.bsm.model.MapFunctionDTO in project opennms by OpenNMS.
the class ReductionKeyEdgeResponseDTOMarshalTest method data.
@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
MapFunctionDTO mapFunctionDTO = new MapFunctionDTO();
mapFunctionDTO.getProperties().put("key1", "value1");
mapFunctionDTO.setType("SetTo");
ReductionKeyEdgeResponseDTO edge = new ReductionKeyEdgeResponseDTO();
edge.setLocation(new ResourceLocation(ApiVersion.Version2, "business-services", "edges", "1"));
edge.setReductionKey("my-custom-reduction-key");
edge.setOperationalStatus(Status.WARNING);
edge.setMapFunction(mapFunctionDTO);
edge.setId(1);
edge.setWeight(17);
edge.setFriendlyName("reduction-key-friendly-name");
return Arrays.asList(new Object[][] { { ReductionKeyEdgeResponseDTO.class, edge, "{" + " \"id\" : 1," + " \"operational-status\" : \"WARNING\"," + " \"map-function\" : {" + " \"type\" : \"SetTo\"," + " \"properties\" : {" + " \"key1\" : \"value1\"" + " }" + " }," + " \"location\" : \"/api/v2/business-services/edges/1\"," + " \"reduction-keys\" : [" + " \"my-custom-reduction-key\"" + " ]," + " \"weight\" : 17," + " \"friendly-name\" : \"reduction-key-friendly-name\"," + "}", "<reduction-key-edge>\n" + " <id>1</id>\n" + " <operational-status>WARNING</operational-status>\n" + " <map-function>\n" + " <type>SetTo</type>\n" + " <properties>\n" + " <entry>\n" + " <key>key1</key>\n" + " <value>value1</value>\n" + " </entry>\n" + " </properties>\n" + " </map-function>\n" + " <location>/api/v2/business-services/edges/1</location>\n" + " <reduction-keys>\n" + " <reduction-key>my-custom-reduction-key</reduction-key>\n" + " </reduction-keys>\n" + " <weight>17</weight>\n" + " <friendly-name>reduction-key-friendly-name</friendly-name>\n" + "</reduction-key-edge>" } });
}
Aggregations