use of org.onap.aai.introspection.Introspector in project aai-graphadmin by onap.
the class MigrateSAREvcInventory method createNewConfigurationFromSARData.
private Vertex createNewConfigurationFromSARData(Map<String, String> sarColValues, Vertex forwardingPathVtx, int lineNumber) {
Vertex configurationVtx = null;
String forwardingPathId = forwardingPathVtx != null ? forwardingPathVtx.value(this.FOWARDING_PATH_ID) : "";
try {
List<Vertex> configList = g.V(forwardingPathVtx).out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("configuration-id", forwardingPathId).toList();
if (configList != null && !configList.isEmpty()) {
logger.info("\t configuration already exists for evc " + forwardingPathId + " - skipping");
return configList.iterator().next();
}
// If configuration does not exist, create it
Introspector configuration = loader.introspectorFromName(CONFIGURATION_NODE_TYPE);
configurationVtx = serializer.createNewVertex(configuration);
configuration.setValue("configuration-id", forwardingPathId);
configuration.setValue("configuration-type", "forwarding-path");
configuration.setValue("configuration-sub-type", "evc");
this.createCousinEdge(forwardingPathVtx, configurationVtx);
serializer.serializeSingleVertex(configurationVtx, configuration, "migrations");
logger.info("\t Created new configuration for forwarding-path " + configurationVtx + " with configuration-id= " + configurationVtx.value("configuration-id").toString());
String dmaapMsg = System.nanoTime() + "_" + configurationVtx.id().toString() + "_" + configurationVtx.value("resource-version").toString();
dmaapMsgList.add(dmaapMsg);
} catch (Exception e) {
logger.info("\t ERROR: Failure to PUT configuration for EVC [" + forwardingPathId + "]");
processedEvcsCount--;
falloutEvcsCount++;
falloutEvcsMap.put((lineNumber + 1) + "", "[" + forwardingPathId + "] - Failure to PUT configuration for EVC");
}
return configurationVtx;
}
use of org.onap.aai.introspection.Introspector in project aai-graphadmin by onap.
the class MigrateSAREvcInventory method createNewEvcFromSARData.
private Vertex createNewEvcFromSARData(Map<String, String> sarColValues, Vertex configurationVtx, int lineNumber) {
String evcId = null;
Vertex evcVtx = null;
try {
Introspector evc = loader.introspectorFromName(EVC_NODE_TYPE);
evcVtx = serializer.createNewVertex(evc);
evcId = configurationVtx != null ? configurationVtx.value(this.PROPERTY_CONFIGURATION_ID) : "";
String cir = sarColValues.get("evcAccessCIR");
int length = cir.length();
String cirValue = cir.substring(0, (length - 4));
String cirUnits = cir.substring((length - 4), (length));
String espEvcCircuitId = sarColValues.get("espEvcCircuitId");
String espName = sarColValues.get("espName");
String collectorTagMode = sarColValues.get("collectorTagMode");
String bearerTagMode = sarColValues.get("bearerTagMode");
evc.setValue("evc-id", evcId);
evc.setValue("forwarding-path-topology", "PointToPoint");
evc.setValue("cir-value", checkForNull(cirValue));
evc.setValue("cir-units", checkForNull(cirUnits));
evc.setValue("esp-evc-circuit-id", checkForNull(espEvcCircuitId));
evc.setValue("esp-evc-cir-value", checkForNull(cirValue));
evc.setValue("esp-evc-cir-units", checkForNull(cirUnits));
evc.setValue("esp-itu-code", checkForNull(espName));
evc.setValue("tagmode-access-ingress", checkForNull(collectorTagMode));
evc.setValue("tagmode-access-egress", checkForNull(bearerTagMode));
this.createTreeEdge(configurationVtx, evcVtx);
serializer.serializeSingleVertex(evcVtx, evc, "migrations");
logger.info("\t Created new evc as a child of configuration " + evcVtx + " with evc-id= " + evcVtx.value("evc-id").toString());
String dmaapMsg = System.nanoTime() + "_" + evcVtx.id().toString() + "_" + evcVtx.value("resource-version").toString();
dmaapMsgList.add(dmaapMsg);
// Introspector introspector = serializer.getLatestVersionView(evcVtx);
// this.notificationHelper.addEvent(evcVtx, introspector, EventAction.CREATE, this.serializer.getURIForVertex(evcVtx, false));
// logger.info("\t Dmaap event sent for " + evcVtx + " with evc-id = " + evcId);
} catch (Exception e) {
logger.info("\t ERROR: Failure to PUT EVC for evc-name [" + evcId + "]");
processedEvcsCount--;
falloutEvcsCount++;
falloutEvcsMap.put((lineNumber + 1) + "", "[" + evcId + "] - Failure to PUT EVC");
}
return evcVtx;
}
use of org.onap.aai.introspection.Introspector in project aai-graphadmin by onap.
the class MigrateSAREvcInventory method createNewForwardingPathFromSARData.
private Vertex createNewForwardingPathFromSARData(Map<String, String> sarColValues, Vertex serviceInstanceVtx, int lineNumber) {
Vertex fpVertex = null;
String serviceInstanceId = serviceInstanceVtx.value(this.SERVICE_INSTANCE_ID);
try {
List<Vertex> fpList = g.V(serviceInstanceVtx).in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path").has("forwarding-path-id", serviceInstanceId).toList();
if (fpList != null && !fpList.isEmpty()) {
logger.info("\t forwarding-path already exists for evc " + serviceInstanceId + " - skipping");
return fpList.iterator().next();
}
// If forwarding-path does not exist, create it
Introspector fpIntrospector = loader.introspectorFromName(FORWARDING_PATH_NODE_TYPE);
fpVertex = serializer.createNewVertex(fpIntrospector);
fpIntrospector.setValue("forwarding-path-id", serviceInstanceId);
fpIntrospector.setValue("forwarding-path-name", serviceInstanceId);
this.createCousinEdge(fpVertex, serviceInstanceVtx);
serializer.serializeSingleVertex(fpVertex, fpIntrospector, "migrations");
logger.info("\t Created new forwarding-path " + fpVertex + " with forwarding-path-id = " + fpVertex.value("forwarding-path-id").toString());
String dmaapMsg = System.nanoTime() + "_" + fpVertex.id().toString() + "_" + fpVertex.value("resource-version").toString();
dmaapMsgList.add(dmaapMsg);
} catch (Exception e) {
logger.info("\t ERROR: Failure to PUT forwarding-path for EVC [" + serviceInstanceId + "]");
processedEvcsCount--;
falloutEvcsCount++;
falloutEvcsMap.put((lineNumber + 1) + "", "[" + serviceInstanceId + "] - Failure to PUT forwarding-path for EVC");
}
return fpVertex;
}
use of org.onap.aai.introspection.Introspector in project aai-graphadmin by onap.
the class NotificationHelper method getRelatedObjects.
private HashMap<String, Introspector> getRelatedObjects(DBSerializer serializer, QueryEngine queryEngine, Vertex v) throws AAIException {
HashMap<String, Introspector> relatedVertices = new HashMap<>();
List<Vertex> vertexChain = queryEngine.findParents(v);
for (Vertex vertex : vertexChain) {
try {
final Introspector vertexObj = serializer.getVertexProperties(vertex);
relatedVertices.put(vertexObj.getObjectId(), vertexObj);
} catch (AAIUnknownObjectException | UnsupportedEncodingException e) {
LOGGER.warn("Unable to get vertex properties, partial list of related vertices returned");
}
}
return relatedVertices;
}
use of org.onap.aai.introspection.Introspector in project aai-graphadmin by onap.
the class VertexMerge method getURI.
private String getURI(Vertex v) throws UnsupportedEncodingException, AAIException {
Introspector obj = loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(""));
this.serializer.dbToObject(Collections.singletonList(v), obj, 0, true, "false");
return obj.getURI();
}
Aggregations