Search in sources :

Example 36 with Relationships

use of org.onap.aaiclient.client.aai.entities.Relationships in project so by onap.

the class AppcRunTasks method getVserversForAppc.

protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException {
    AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf);
    if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) {
        return;
    }
    Relationships relationships = aaiRW.getRelationships().get();
    List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER);
    JSONArray vserverIds = new JSONArray();
    JSONArray vserverSelfLinks = new JSONArray();
    if (vserverUris != null) {
        for (AAIResourceUri j : vserverUris) {
            if (j != null) {
                if (j.getURIKeys() != null) {
                    String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId);
                    vserverIds.put(vserverId);
                }
                aaiVnfResources.getVserver(j).ifPresent((vserver) -> {
                    String vserverSelfLink = vserver.getVserverSelflink();
                    vserverSelfLinks.put(vserverSelfLink);
                });
            }
        }
    }
    JSONObject vmidsArray = new JSONObject();
    JSONObject vserveridsArray = new JSONObject();
    vmidsArray.put("vmIds", vserverSelfLinks.toString());
    vserveridsArray.put("vserverIds", vserverIds.toString());
    logger.debug("vmidsArray is: {}", vmidsArray.toString());
    logger.debug("vserveridsArray is: {}", vserveridsArray.toString());
    execution.setVariable("vmIdList", vmidsArray.toString());
    execution.setVariable("vserverIdList", vserveridsArray.toString());
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

Relationships (org.onap.aaiclient.client.aai.entities.Relationships)36 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)27 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)20 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)10 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)6 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)6 HashMap (java.util.HashMap)4 List (java.util.List)4 VpnBinding (org.onap.aai.domain.yang.VpnBinding)4 IPAddressString (inet.ipaddr.IPAddressString)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 NotFoundException (javax.ws.rs.NotFoundException)2