Search in sources :

Example 1 with MapFunctionDTO

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);
}
Also used : IpServiceEdgeRequestDTO(org.opennms.web.rest.v2.bsm.model.edge.IpServiceEdgeRequestDTO)

Example 2 with MapFunctionDTO

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;
}
Also used : MapFunctionDTO(org.opennms.web.rest.v2.bsm.model.MapFunctionDTO)

Example 3 with 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>" } });
}
Also used : TestHelper.createMapFunctionDTO(org.opennms.web.rest.v2.bsm.model.TestHelper.createMapFunctionDTO) HighestSeverity(org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity) Increase(org.opennms.netmgt.bsm.service.model.functions.map.Increase) SetTo(org.opennms.netmgt.bsm.service.model.functions.map.SetTo)

Example 4 with MapFunctionDTO

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;
}
Also used : IpServiceEdgeResponseDTO(org.opennms.web.rest.v2.bsm.model.edge.IpServiceEdgeResponseDTO)

Example 5 with MapFunctionDTO

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>" } });
}
Also used : MapFunctionDTO(org.opennms.web.rest.v2.bsm.model.MapFunctionDTO) ResourceLocation(org.opennms.web.rest.api.ResourceLocation)

Aggregations

ResourceLocation (org.opennms.web.rest.api.ResourceLocation)4 MapFunctionDTO (org.opennms.web.rest.v2.bsm.model.MapFunctionDTO)4 HighestSeverity (org.opennms.netmgt.bsm.service.model.functions.reduce.HighestSeverity)2 TestHelper.createMapFunctionDTO (org.opennms.web.rest.v2.bsm.model.TestHelper.createMapFunctionDTO)2 Ignore (org.opennms.netmgt.bsm.service.model.functions.map.Ignore)1 Increase (org.opennms.netmgt.bsm.service.model.functions.map.Increase)1 MapFunction (org.opennms.netmgt.bsm.service.model.functions.map.MapFunction)1 SetTo (org.opennms.netmgt.bsm.service.model.functions.map.SetTo)1 ChildEdgeRequestDTO (org.opennms.web.rest.v2.bsm.model.edge.ChildEdgeRequestDTO)1 ChildEdgeResponseDTO (org.opennms.web.rest.v2.bsm.model.edge.ChildEdgeResponseDTO)1 IpServiceEdgeRequestDTO (org.opennms.web.rest.v2.bsm.model.edge.IpServiceEdgeRequestDTO)1 IpServiceEdgeResponseDTO (org.opennms.web.rest.v2.bsm.model.edge.IpServiceEdgeResponseDTO)1 ReductionKeyEdgeRequestDTO (org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeRequestDTO)1 ReductionKeyEdgeResponseDTO (org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO)1 FunctionsManager (org.opennms.web.rest.v2.bsm.model.meta.FunctionsManager)1