2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.viewandinspect.services;
25 import static java.util.concurrent.CompletableFuture.supplyAsync;
27 import java.net.URISyntaxException;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.Iterator;
31 import java.util.List;
33 import java.util.Map.Entry;
34 import java.util.concurrent.ConcurrentHashMap;
35 import java.util.concurrent.ExecutorService;
36 import java.util.concurrent.atomic.AtomicInteger;
38 import org.apache.http.client.utils.URIBuilder;
39 import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
40 import org.onap.aai.sparky.config.oxm.OxmModelLoader;
41 import org.onap.aai.sparky.dal.aai.ActiveInventoryDataProvider;
42 import org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig;
43 import org.onap.aai.sparky.dal.rest.OperationResult;
44 import org.onap.aai.sparky.logging.AaiUiMsgs;
45 import org.onap.aai.sparky.synchronizer.entity.SearchableEntity;
46 import org.onap.aai.sparky.util.NodeUtils;
47 import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
48 import org.onap.aai.sparky.viewandinspect.config.VisualizationConfig;
49 import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
50 import org.onap.aai.sparky.viewandinspect.entity.InlineMessage;
51 import org.onap.aai.sparky.viewandinspect.entity.NodeProcessingTransaction;
52 import org.onap.aai.sparky.viewandinspect.entity.QueryParams;
53 import org.onap.aai.sparky.viewandinspect.entity.Relationship;
54 import org.onap.aai.sparky.viewandinspect.entity.RelationshipData;
55 import org.onap.aai.sparky.viewandinspect.entity.RelationshipList;
56 import org.onap.aai.sparky.viewandinspect.entity.SelfLinkDeterminationTransaction;
57 import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingAction;
58 import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingState;
59 import org.onap.aai.sparky.viewandinspect.task.PerformNodeSelfLinkProcessingTask;
60 import org.onap.aai.sparky.viewandinspect.task.PerformSelfLinkDeterminationTask;
61 import org.onap.aai.cl.api.Logger;
62 import org.onap.aai.cl.eelf.LoggerFactory;
64 import com.fasterxml.jackson.annotation.JsonInclude.Include;
65 import com.fasterxml.jackson.databind.JsonNode;
66 import com.fasterxml.jackson.databind.ObjectMapper;
67 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
70 * The Class SelfLinkNodeCollector.
72 public class VisualizationContext {
74 private static final int MAX_DEPTH_EVALUATION_ATTEMPTS = 100;
75 private static final String DEPTH_ALL_MODIFIER = "?depth=all";
76 private static final String NODES_ONLY_MODIFIER = "?nodes-only";
77 private static final String SERVICE_INSTANCE = "service-instance";
79 private static final Logger LOG =
80 LoggerFactory.getInstance().getLogger(VisualizationContext.class);
81 private final ActiveInventoryDataProvider aaiProvider;
83 private int maxSelfLinkTraversalDepth;
84 private AtomicInteger numLinksDiscovered;
85 private AtomicInteger numSuccessfulLinkResolveFromCache;
86 private AtomicInteger numSuccessfulLinkResolveFromFromServer;
87 private AtomicInteger numFailedLinkResolve;
88 private AtomicInteger aaiWorkOnHand;
90 private ActiveInventoryConfig aaiConfig;
91 private VisualizationConfig visualizationConfig;
92 private List<String> shallowEntities;
94 private AtomicInteger totalLinksRetrieved;
96 private final long contextId;
97 private final String contextIdStr;
99 private OxmModelLoader loader;
100 private ObjectMapper mapper;
101 private InlineMessage inlineMessage = null;
103 private ExecutorService aaiExecutorService;
106 * The node cache is intended to be a flat structure indexed by a primary key to avoid needlessly
107 * re-requesting the same self-links over-and-over again, to speed up the overall render time and
108 * more importantly to reduce the network cost of determining information we already have.
110 private ConcurrentHashMap<String, ActiveInventoryNode> nodeCache;
113 * Instantiates a new self link node collector.
115 * @param loader the loader
116 * @throws Exception the exception
118 public VisualizationContext(long contextId, ActiveInventoryDataProvider aaiDataProvider,
119 ExecutorService aaiExecutorService, OxmModelLoader loader) throws Exception {
121 this.contextId = contextId;
122 this.contextIdStr = "[Context-Id=" + contextId + "]";
123 this.aaiProvider = aaiDataProvider;
124 this.aaiExecutorService = aaiExecutorService;
125 this.loader = loader;
127 this.nodeCache = new ConcurrentHashMap<String, ActiveInventoryNode>();
128 this.numLinksDiscovered = new AtomicInteger(0);
129 this.totalLinksRetrieved = new AtomicInteger(0);
130 this.numSuccessfulLinkResolveFromCache = new AtomicInteger(0);
131 this.numSuccessfulLinkResolveFromFromServer = new AtomicInteger(0);
132 this.numFailedLinkResolve = new AtomicInteger(0);
133 this.aaiWorkOnHand = new AtomicInteger(0);
135 this.aaiConfig = ActiveInventoryConfig.getConfig();
136 this.visualizationConfig = VisualizationConfig.getConfig();
137 this.shallowEntities = aaiConfig.getAaiRestConfig().getShallowEntities();
139 this.maxSelfLinkTraversalDepth = visualizationConfig.getMaxSelfLinkTraversalDepth();
141 this.mapper = new ObjectMapper();
142 mapper.setSerializationInclusion(Include.NON_EMPTY);
143 mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy());
146 public long getContextId() {
151 * A utility method for extracting all entity-type primary key values from a provided self-link
152 * and return a set of generic-query API keys.
154 * @param parentEntityType
156 * @return a list of key values that can be used for this entity with the AAI generic-query API
158 protected List<String> extractQueryParamsFromSelfLink(String link) {
160 List<String> queryParams = new ArrayList<String>();
163 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR, "self link is null");
167 Map<String, OxmEntityDescriptor> entityDescriptors = loader.getEntityDescriptors();
171 URIBuilder urlBuilder = new URIBuilder(link);
172 String urlPath = urlBuilder.getPath();
174 OxmEntityDescriptor descriptor = null;
175 String[] urlPathElements = urlPath.split("/");
176 List<String> primaryKeyNames = null;
178 String entityType = null;
180 while (index < urlPathElements.length) {
182 descriptor = entityDescriptors.get(urlPathElements[index]);
184 if (descriptor != null) {
185 entityType = urlPathElements[index];
186 primaryKeyNames = descriptor.getPrimaryKeyAttributeName();
189 * Make sure from what ever index we matched the parent entity-type on that we can extract
190 * additional path elements for the primary key values.
193 if (index + primaryKeyNames.size() < urlPathElements.length) {
195 for (String primaryKeyName : primaryKeyNames) {
197 queryParams.add(entityType + "." + primaryKeyName + ":" + urlPathElements[index]);
200 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR,
201 "Could not extract query parametrs for entity-type = '" + entityType
202 + "' from self-link = " + link);
209 } catch (URISyntaxException exc) {
211 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR,
212 "Error extracting query parameters from self-link = " + link + ". Error = "
221 * Decode complex attribute group.
224 * @param attributeGroup the attribute group
225 * @return boolean indicating whether operation was successful (true), / failure(false).
227 public boolean decodeComplexAttributeGroup(ActiveInventoryNode ain, JsonNode attributeGroup) {
231 Iterator<Entry<String, JsonNode>> entityArrays = attributeGroup.fields();
232 Entry<String, JsonNode> entityArray = null;
234 if (entityArrays == null) {
235 LOG.error(AaiUiMsgs.ATTRIBUTE_GROUP_FAILURE, attributeGroup.toString());
236 ain.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
240 while (entityArrays.hasNext()) {
242 entityArray = entityArrays.next();
244 String entityType = entityArray.getKey();
245 JsonNode entityArrayObject = entityArray.getValue();
247 if (entityArrayObject.isArray()) {
249 Iterator<JsonNode> entityCollection = entityArrayObject.elements();
250 JsonNode entity = null;
251 while (entityCollection.hasNext()) {
252 entity = entityCollection.next();
254 if (LOG.isDebugEnabled()) {
255 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
256 "decodeComplexAttributeGroup()," + " entity = " + entity.toString());
260 * Here's what we are going to do:
262 * <li>In the ActiveInventoryNode, on construction maintain a collection of queryParams
263 * that is added to for the purpose of discovering parent->child hierarchies.
265 * <li>When we hit this block of the code then we'll use the queryParams to feed the
266 * generic query to resolve the self-link asynchronously.
268 * <li>Upon successful link determination, then and only then will we create a new node
269 * in the nodeCache and process the child
273 ActiveInventoryNode newNode = new ActiveInventoryNode();
274 newNode.setEntityType(entityType);
277 * This is partially a lie because we actually don't have a self-link for complex nodes
278 * discovered in this way.
280 newNode.setSelfLinkProcessed(true);
281 newNode.changeState(NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
282 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_OK);
285 * copy parent query params into new child
288 if (SERVICE_INSTANCE.equals(entityType)) {
291 * 1707 AAI has an issue being tracked with AAI-8932 where the generic-query cannot be
292 * resolved if all the service-instance path keys are provided. The query only works
293 * if only the service-instance key and valude are passed due to a historical reason.
294 * A fix is being worked on for 1707, and when it becomes available we can revert this
298 newNode.clearQueryParams();
303 * For all other entity-types we want to copy the parent query parameters into the new
304 * node query parameters.
307 for (String queryParam : ain.getQueryParams()) {
308 newNode.addQueryParam(queryParam);
314 if (!addComplexGroupToNode(newNode, entity)) {
315 LOG.error(AaiUiMsgs.ATTRIBUTE_GROUP_FAILURE,
316 "Failed to add child to parent for child = " + entity.toString());
319 if (!addNodeQueryParams(newNode)) {
320 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID,
321 "Error determining node id and key for node = " + newNode.dumpNodeTree(true)
322 + " skipping relationship processing");
323 newNode.changeState(NodeProcessingState.ERROR,
324 NodeProcessingAction.NODE_IDENTITY_ERROR);
328 newNode.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
329 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_OK);
335 * Order matters for the query params. We need to set the parent ones before the child
339 String selfLinkQuery =
340 aaiProvider.getGenericQueryForSelfLink(entityType, newNode.getQueryParams());
343 * <li>get the self-link
344 * <li>add it to the new node
345 * <li>generate node id
346 * <li>add node to node cache
347 * <li>add node id to parent outbound links list
348 * <li>process node children (should be automatic) (but don't query and resolve
349 * self-link as we already have all the data)
352 SelfLinkDeterminationTransaction txn = new SelfLinkDeterminationTransaction();
354 txn.setQueryString(selfLinkQuery);
355 txn.setNewNode(newNode);
356 txn.setParentNodeId(ain.getNodeId());
357 aaiWorkOnHand.incrementAndGet();
358 supplyAsync(new PerformSelfLinkDeterminationTask(txn, null, aaiProvider),
359 aaiExecutorService).whenComplete((nodeTxn, error) -> {
360 aaiWorkOnHand.decrementAndGet();
362 LOG.error(AaiUiMsgs.SELF_LINK_DETERMINATION_FAILED_GENERIC, selfLinkQuery);
365 OperationResult opResult = nodeTxn.getOpResult();
367 ActiveInventoryNode newChildNode = txn.getNewNode();
369 if (opResult != null && opResult.wasSuccessful()) {
371 if (opResult.isResolvedLinkFailure()) {
372 numFailedLinkResolve.incrementAndGet();
375 if (opResult.isResolvedLinkFromCache()) {
376 numSuccessfulLinkResolveFromCache.incrementAndGet();
379 if (opResult.isResolvedLinkFromServer()) {
380 numSuccessfulLinkResolveFromFromServer.incrementAndGet();
384 * extract the self-link from the operational result.
387 Collection<JsonNode> entityLinks = new ArrayList<JsonNode>();
388 JsonNode genericQueryResult = null;
391 NodeUtils.convertJsonStrToJsonNode(nodeTxn.getOpResult().getResult());
392 } catch (Exception exc) {
393 LOG.error(AaiUiMsgs.JSON_CONVERSION_ERROR, JsonNode.class.toString(),
397 NodeUtils.extractObjectsByKey(genericQueryResult, "resource-link",
400 String selfLink = null;
402 if (entityLinks.size() != 1) {
404 LOG.error(AaiUiMsgs.SELF_LINK_DETERMINATION_FAILED_UNEXPECTED_LINKS,
405 String.valueOf(entityLinks.size()));
408 selfLink = ((JsonNode) entityLinks.toArray()[0]).asText();
409 selfLink = ActiveInventoryConfig.extractResourcePath(selfLink);
411 newChildNode.setSelfLink(selfLink);
412 newChildNode.setNodeId(NodeUtils.generateUniqueShaDigest(selfLink));
414 String uri = NodeUtils.calculateEditAttributeUri(selfLink);
416 newChildNode.addProperty(TierSupportUiConstants.URI_ATTR_NAME, uri);
419 ActiveInventoryNode parent = nodeCache.get(txn.getParentNodeId());
421 if (parent != null) {
422 parent.addOutboundNeighbor(newChildNode.getNodeId());
423 newChildNode.addInboundNeighbor(parent.getNodeId());
426 newChildNode.setSelfLinkPendingResolve(false);
427 newChildNode.setSelfLinkProcessed(true);
429 newChildNode.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
430 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
432 nodeCache.putIfAbsent(newChildNode.getNodeId(), newChildNode);
437 LOG.error(AaiUiMsgs.SELF_LINK_RETRIEVAL_FAILED, txn.getQueryString(),
438 String.valueOf(nodeTxn.getOpResult().getResultCode()),
439 nodeTxn.getOpResult().getResult());
440 newChildNode.setSelflinkRetrievalFailure(true);
441 newChildNode.setSelfLinkProcessed(true);
442 newChildNode.setSelfLinkPendingResolve(false);
444 newChildNode.changeState(NodeProcessingState.ERROR,
445 NodeProcessingAction.SELF_LINK_DETERMINATION_ERROR);
458 LOG.error(AaiUiMsgs.UNHANDLED_OBJ_TYPE_FOR_ENTITY_TYPE, entityType);
462 } catch (Exception exc) {
463 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
464 "Exception caught while" + " decoding complex attribute group - " + exc.getMessage());
472 * Process self link response.
474 * @param nodeId the node id
476 private void processSelfLinkResponse(String nodeId) {
478 if (nodeId == null) {
479 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
480 "Cannot process self link" + " response because nodeId is null");
484 ActiveInventoryNode ain = nodeCache.get(nodeId);
487 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
488 "Cannot process self link response" + " because can't find node for id = " + nodeId);
492 JsonNode jsonNode = null;
495 jsonNode = mapper.readValue(ain.getOpResult().getResult(), JsonNode.class);
496 } catch (Exception exc) {
497 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to marshal json"
498 + " response str into JsonNode with error, " + exc.getLocalizedMessage());
499 ain.changeState(NodeProcessingState.ERROR,
500 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
504 if (jsonNode == null) {
505 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR,
506 "Failed to parse json node str." + " Parse resulted a null value.");
507 ain.changeState(NodeProcessingState.ERROR,
508 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
512 Iterator<Entry<String, JsonNode>> fieldNames = jsonNode.fields();
513 Entry<String, JsonNode> field = null;
515 RelationshipList relationshipList = null;
517 while (fieldNames.hasNext()) {
519 field = fieldNames.next();
520 String fieldName = field.getKey();
522 if ("relationship-list".equals(fieldName)) {
525 relationshipList = mapper.readValue(field.getValue().toString(), RelationshipList.class);
527 if (relationshipList != null) {
528 ain.addRelationshipList(relationshipList);
531 } catch (Exception exc) {
532 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to parse relationship-list"
533 + " attribute. Parse resulted in error, " + exc.getLocalizedMessage());
534 ain.changeState(NodeProcessingState.ERROR,
535 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
541 JsonNode nodeValue = field.getValue();
543 if (nodeValue != null && nodeValue.isValueNode()) {
545 if (loader.getEntityDescriptor(fieldName) == null) {
548 * entity property name is not an entity, thus we can add this property name and value
549 * to our property set
552 ain.addProperty(fieldName, nodeValue.asText());
558 if (nodeValue.isArray()) {
560 if (loader.getEntityDescriptor(fieldName) == null) {
563 * entity property name is not an entity, thus we can add this property name and value
564 * to our property set
567 ain.addProperty(field.getKey(), nodeValue.toString());
573 ain.addComplexGroup(nodeValue);
582 String uri = NodeUtils.calculateEditAttributeUri(ain.getSelfLink());
584 ain.addProperty(TierSupportUiConstants.URI_ATTR_NAME, uri);
588 * We need a special behavior for intermediate entities from the REST model
590 * Tenants are not top level entities, and when we want to visualization their children, we need
591 * to construct keys that include the parent entity query keys, the current entity type keys,
592 * and the child keys. We'll always have the current entity and children, but never the parent
593 * entity in the current (1707) REST data model.
595 * We have two possible solutions:
597 * 1) Try to use the custom-query approach to learn about the entity keys - this could be done,
598 * but it could be very expensive for large objects. When we do the first query to get a tenant,
599 * it will list all the in and out edges related to this entity, there is presently no way to
600 * filter this. But the approach could be made to work and it would be somewhat data-model
601 * driven, other than the fact that we have to first realize that the entity that is being
602 * searched for is not top-level entity. Once we have globally unique ids for resources this
603 * logic will not be needed and everything will be simpler. The only reason we are in this logic
604 * at all is to be able to calculate a url for the child entities so we can hash it to generate
605 * a globally unique id that can be safely used for the node.
607 * *2* Extract the keys from the pathed self-link. This is a bad solution and I don't like it
608 * but it will be fast for all resource types, as the information is already encoded in the URI.
609 * When we get to a point where we switch to a better globally unique entity identity model,
610 * then a lot of the code being used to calculate an entity url to in-turn generate a
611 * deterministic globally unique id will disappear.
614 * right now we have the following:
616 * - cloud-regions/cloud-region/{cloud-region-id}/{cloud-owner-id}/tenants/tenant/{tenant-id}
621 * For all entity types use the self-link extraction method to be consistent. Once we have a
622 * globally unique identity mechanism for entities, this logic can be revisited.
624 ain.clearQueryParams();
625 ain.addQueryParams(extractQueryParamsFromSelfLink(ain.getSelfLink()));
627 ain.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
628 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
633 * Perform self link resolve.
635 * @param nodeId the node id
637 private void performSelfLinkResolve(String nodeId) {
639 if (nodeId == null) {
640 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
641 "Resolve of self-link" + " has been skipped because provided nodeId is null");
645 ActiveInventoryNode ain = nodeCache.get(nodeId);
648 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Failed to find node with id, " + nodeId
649 + ", from node cache. Resolve self-link method has been skipped.");
653 if (!ain.isSelfLinkPendingResolve()) {
655 ain.setSelfLinkPendingResolve(true);
657 // kick off async self-link resolution
659 if (LOG.isDebugEnabled()) {
660 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
661 "About to process node in SELF_LINK_UNPROCESSED State, link = " + ain.getSelfLink());
664 numLinksDiscovered.incrementAndGet();
666 String depthModifier = DEPTH_ALL_MODIFIER;
669 * If the current node is the search target, we want to see everything the node has to offer
670 * from the self-link and not filter it to a single node.
673 if (shallowEntities.contains(ain.getEntityType()) && !ain.isRootNode()) {
674 depthModifier = NODES_ONLY_MODIFIER;
677 NodeProcessingTransaction txn = new NodeProcessingTransaction();
678 txn.setProcessingNode(ain);
679 txn.setRequestParameters(depthModifier);
680 aaiWorkOnHand.incrementAndGet();
681 supplyAsync(new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider, aaiConfig),
682 aaiExecutorService).whenComplete((nodeTxn, error) -> {
683 aaiWorkOnHand.decrementAndGet();
687 * an error processing the self link should probably result in the node processing
688 * state shifting to ERROR
691 nodeTxn.getProcessingNode().setSelflinkRetrievalFailure(true);
693 nodeTxn.getProcessingNode().changeState(NodeProcessingState.ERROR,
694 NodeProcessingAction.SELF_LINK_RESOLVE_ERROR);
696 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
700 totalLinksRetrieved.incrementAndGet();
702 OperationResult opResult = nodeTxn.getOpResult();
704 if (opResult != null && opResult.wasSuccessful()) {
706 if (opResult.isResolvedLinkFailure()) {
707 numFailedLinkResolve.incrementAndGet();
710 if (opResult.isResolvedLinkFromCache()) {
711 numSuccessfulLinkResolveFromCache.incrementAndGet();
714 if (opResult.isResolvedLinkFromServer()) {
715 numSuccessfulLinkResolveFromFromServer.incrementAndGet();
719 nodeTxn.getProcessingNode().setOpResult(opResult);
720 nodeTxn.getProcessingNode().changeState(
721 NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
722 NodeProcessingAction.SELF_LINK_RESOLVE_OK);
724 nodeTxn.getProcessingNode().setSelfLinkProcessed(true);
725 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
728 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
729 "Self Link retrieval for link," + txn.getSelfLinkWithModifiers()
730 + ", failed with error code," + nodeTxn.getOpResult().getResultCode()
731 + ", and message," + nodeTxn.getOpResult().getResult());
733 nodeTxn.getProcessingNode().setSelflinkRetrievalFailure(true);
734 nodeTxn.getProcessingNode().setSelfLinkProcessed(true);
736 nodeTxn.getProcessingNode().changeState(NodeProcessingState.ERROR,
737 NodeProcessingAction.SELF_LINK_RESOLVE_ERROR);
739 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
754 * @param nodeId the node id
756 private void processNeighbors(String nodeId) {
758 if (nodeId == null) {
759 LOG.error(AaiUiMsgs.SELF_LINK_PROCESS_NEIGHBORS_ERROR,
760 "Failed to process" + " neighbors because nodeId is null.");
764 ActiveInventoryNode ain = nodeCache.get(nodeId);
767 LOG.error(AaiUiMsgs.SELF_LINK_PROCESS_NEIGHBORS_ERROR, "Failed to process"
768 + " neighbors because node could not be found in nodeCache with id, " + nodeId);
773 * process complex attribute and relationships
776 boolean neighborsProcessedSuccessfully = true;
778 for (JsonNode n : ain.getComplexGroups()) {
779 neighborsProcessedSuccessfully &= decodeComplexAttributeGroup(ain, n);
782 for (RelationshipList relationshipList : ain.getRelationshipLists()) {
783 neighborsProcessedSuccessfully &= addSelfLinkRelationshipChildren(ain, relationshipList);
787 if (neighborsProcessedSuccessfully) {
788 ain.changeState(NodeProcessingState.READY, NodeProcessingAction.NEIGHBORS_PROCESSED_OK);
790 ain.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
795 * If neighbors fail to process, there is already a call to change the state within the
796 * relationship and neighbor processing functions.
802 * Find and mark root node.
804 * @param queryParams the query params
805 * @return true, if successful
807 private boolean findAndMarkRootNode(QueryParams queryParams) {
809 for (ActiveInventoryNode cacheNode : nodeCache.values()) {
811 if (queryParams.getSearchTargetNodeId().equals(cacheNode.getNodeId())) {
812 cacheNode.setNodeDepth(0);
813 cacheNode.setRootNode(true);
814 LOG.info(AaiUiMsgs.ROOT_NODE_DISCOVERED, queryParams.getSearchTargetNodeId());
824 * Process current node states.
826 * @param rootNodeDiscovered the root node discovered
828 private void processCurrentNodeStates(boolean rootNodeDiscovered) {
830 * Force an evaluation of node depths before determining if we should limit state-based
831 * traversal or processing.
833 if (rootNodeDiscovered) {
834 evaluateNodeDepths();
837 for (ActiveInventoryNode cacheNode : nodeCache.values()) {
839 if (LOG.isDebugEnabled()) {
840 LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "processCurrentNodeState(), nid = "
841 + cacheNode.getNodeId() + " , nodeDepth = " + cacheNode.getNodeDepth());
844 switch (cacheNode.getState()) {
847 processInitialState(cacheNode.getNodeId());
856 case SELF_LINK_UNRESOLVED: {
857 performSelfLinkResolve(cacheNode.getNodeId());
861 case SELF_LINK_RESPONSE_UNPROCESSED: {
862 processSelfLinkResponse(cacheNode.getNodeId());
866 case NEIGHBORS_UNPROCESSED: {
869 * We use the rootNodeDiscovered flag to ignore depth retrieval thresholds until the root
870 * node is identified. Then the evaluative depth calculations should re-balance the graph
871 * around the root node.
874 if (!rootNodeDiscovered || cacheNode.getNodeDepth() < VisualizationConfig.getConfig()
875 .getMaxSelfLinkTraversalDepth()) {
877 if (LOG.isDebugEnabled()) {
878 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
879 "SLNC::processCurrentNodeState() -- Node at max depth,"
880 + " halting processing at current state = -- " + cacheNode.getState()
881 + " nodeId = " + cacheNode.getNodeId());
886 processNeighbors(cacheNode.getNodeId());
904 * Adds the complex group to node.
906 * @param targetNode the target node
907 * @param attributeGroup the attribute group
908 * @return true, if successful
910 private boolean addComplexGroupToNode(ActiveInventoryNode targetNode, JsonNode attributeGroup) {
912 if (attributeGroup == null) {
913 targetNode.changeState(NodeProcessingState.ERROR,
914 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_OK);
918 RelationshipList relationshipList = null;
920 if (attributeGroup.isObject()) {
922 Iterator<Entry<String, JsonNode>> fields = attributeGroup.fields();
923 Entry<String, JsonNode> field = null;
927 while (fields.hasNext()) {
928 field = fields.next();
929 fieldName = field.getKey();
930 fieldValue = field.getValue();
932 if (fieldValue.isObject()) {
934 if (fieldName.equals("relationship-list")) {
938 mapper.readValue(field.getValue().toString(), RelationshipList.class);
940 if (relationshipList != null) {
941 targetNode.addRelationshipList(relationshipList);
944 } catch (Exception exc) {
945 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR,
946 "Failed to parse" + " relationship-list attribute. Parse resulted in error, "
947 + exc.getLocalizedMessage());
948 targetNode.changeState(NodeProcessingState.ERROR,
949 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_ERROR);
954 targetNode.addComplexGroup(fieldValue);
957 } else if (fieldValue.isArray()) {
958 if (LOG.isDebugEnabled()) {
959 LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "Unexpected array type with a key = " + fieldName);
961 } else if (fieldValue.isValueNode()) {
962 if (loader.getEntityDescriptor(field.getKey()) == null) {
964 * property key is not an entity type, add it to our property set.
966 targetNode.addProperty(field.getKey(), fieldValue.asText());
972 } else if (attributeGroup.isArray()) {
973 if (LOG.isDebugEnabled()) {
974 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
975 "Unexpected array type for attributeGroup = " + attributeGroup);
977 } else if (attributeGroup.isValueNode()) {
978 if (LOG.isDebugEnabled()) {
979 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
980 "Unexpected value type for attributeGroup = " + attributeGroup);
987 public int getNumSuccessfulLinkResolveFromCache() {
988 return numSuccessfulLinkResolveFromCache.get();
991 public int getNumSuccessfulLinkResolveFromFromServer() {
992 return numSuccessfulLinkResolveFromFromServer.get();
995 public int getNumFailedLinkResolve() {
996 return numFailedLinkResolve.get();
999 public InlineMessage getInlineMessage() {
1000 return inlineMessage;
1003 public void setInlineMessage(InlineMessage inlineMessage) {
1004 this.inlineMessage = inlineMessage;
1007 public void setMaxSelfLinkTraversalDepth(int depth) {
1008 this.maxSelfLinkTraversalDepth = depth;
1011 public int getMaxSelfLinkTraversalDepth() {
1012 return this.maxSelfLinkTraversalDepth;
1015 public ConcurrentHashMap<String, ActiveInventoryNode> getNodeCache() {
1020 * Gets the relationship primary key values.
1023 * @param entityType the entity type
1024 * @param pkeyNames the pkey names
1025 * @return the relationship primary key values
1027 private String getRelationshipPrimaryKeyValues(Relationship r, String entityType,
1028 List<String> pkeyNames) {
1030 StringBuilder sb = new StringBuilder(64);
1032 if (pkeyNames.size() > 0) {
1033 String primaryKey = extractKeyValueFromRelationData(r, entityType + "." + pkeyNames.get(0));
1034 if (primaryKey != null) {
1036 sb.append(primaryKey);
1039 // this should be a fatal error because unless we can
1040 // successfully retrieve all the expected keys we'll end up
1041 // with a garbage node
1042 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: Failed to extract" + " keyName, " + entityType
1043 + "." + pkeyNames.get(0) + ", from relationship data, " + r.toString());
1047 for (int i = 1; i < pkeyNames.size(); i++) {
1049 String kv = extractKeyValueFromRelationData(r, entityType + "." + pkeyNames.get(i));
1051 sb.append("/").append(kv);
1053 // this should be a fatal error because unless we can
1054 // successfully retrieve all the expected keys we'll end up
1055 // with a garbage node
1056 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: failed to extract keyName, " + entityType
1057 + "." + pkeyNames.get(i) + ", from relationship data, " + r.toString());
1062 return sb.toString();
1071 * Extract key value from relation data.
1074 * @param keyName the key name
1075 * @return the string
1077 private String extractKeyValueFromRelationData(Relationship r, String keyName) {
1079 RelationshipData[] rdList = r.getRelationshipData();
1081 for (RelationshipData relData : rdList) {
1083 if (relData.getRelationshipKey().equals(keyName)) {
1084 return relData.getRelationshipValue();
1092 * Determine node id and key.
1094 * @param ain the ain
1095 * @return true, if successful
1097 private boolean addNodeQueryParams(ActiveInventoryNode ain) {
1100 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "ActiveInventoryNode is null");
1104 List<String> pkeyNames =
1105 loader.getEntityDescriptor(ain.getEntityType()).getPrimaryKeyAttributeName();
1107 if (pkeyNames == null || pkeyNames.size() == 0) {
1108 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "Primary key names is empty");
1112 StringBuilder sb = new StringBuilder(64);
1114 if (pkeyNames.size() > 0) {
1115 String primaryKey = ain.getProperties().get(pkeyNames.get(0));
1116 if (primaryKey != null) {
1117 sb.append(primaryKey);
1119 // this should be a fatal error because unless we can
1120 // successfully retrieve all the expected keys we'll end up
1121 // with a garbage node
1122 LOG.error(AaiUiMsgs.EXTRACTION_ERROR,
1123 "ERROR: Failed to extract keyName, " + pkeyNames.get(0) + ", from entity properties");
1127 for (int i = 1; i < pkeyNames.size(); i++) {
1129 String kv = ain.getProperties().get(pkeyNames.get(i));
1131 sb.append("/").append(kv);
1133 // this should be a fatal error because unless we can
1134 // successfully retrieve all the expected keys we'll end up
1135 // with a garbage node
1136 LOG.error(AaiUiMsgs.EXTRACTION_ERROR,
1137 "ERROR: Failed to extract keyName, " + pkeyNames.get(i) + ", from entity properties");
1143 * final String nodeId = NodeUtils.generateUniqueShaDigest(ain.getEntityType(),
1144 * NodeUtils.concatArray(pkeyNames, "/"), sb.toString());
1147 // ain.setNodeId(nodeId);
1148 ain.setPrimaryKeyName(NodeUtils.concatArray(pkeyNames, "/"));
1149 ain.setPrimaryKeyValue(sb.toString());
1151 if (ain.getEntityType() != null && ain.getPrimaryKeyName() != null
1152 && ain.getPrimaryKeyValue() != null) {
1154 ain.getEntityType() + "." + ain.getPrimaryKeyName() + ":" + ain.getPrimaryKeyValue());
1165 * Adds the self link relationship children.
1167 * @param processingNode the processing node
1168 * @param relationshipList the relationship list
1169 * @return true, if successful
1171 private boolean addSelfLinkRelationshipChildren(ActiveInventoryNode processingNode,
1172 RelationshipList relationshipList) {
1174 if (relationshipList == null) {
1175 LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "No relationships added to parent node = "
1176 + processingNode.getNodeId() + " because relationshipList is empty");
1177 processingNode.changeState(NodeProcessingState.ERROR,
1178 NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
1182 OxmModelLoader modelLoader = OxmModelLoader.getInstance();
1184 Relationship[] relationshipArray = relationshipList.getRelationshipList();
1185 OxmEntityDescriptor descriptor = null;
1187 if (relationshipArray != null) {
1189 ActiveInventoryNode newNode = null;
1190 String resourcePath = null;
1192 for (Relationship r : relationshipArray) {
1194 resourcePath = ActiveInventoryConfig.extractResourcePath(r.getRelatedLink());
1196 String nodeId = NodeUtils.generateUniqueShaDigest(resourcePath);
1198 if (nodeId == null) {
1200 LOG.error(AaiUiMsgs.SKIPPING_RELATIONSHIP, r.toString());
1201 processingNode.changeState(NodeProcessingState.ERROR,
1202 NodeProcessingAction.NODE_IDENTITY_ERROR);
1206 newNode = new ActiveInventoryNode();
1208 String entityType = r.getRelatedTo();
1210 if (r.getRelationshipData() != null) {
1211 for (RelationshipData rd : r.getRelationshipData()) {
1212 newNode.addQueryParam(rd.getRelationshipKey() + ":" + rd.getRelationshipValue());
1216 descriptor = modelLoader.getEntityDescriptor(r.getRelatedTo());
1218 newNode.setNodeId(nodeId);
1219 newNode.setEntityType(entityType);
1220 newNode.setSelfLink(resourcePath);
1222 processingNode.addOutboundNeighbor(nodeId);
1224 if (descriptor != null) {
1226 List<String> pkeyNames = descriptor.getPrimaryKeyAttributeName();
1228 newNode.changeState(NodeProcessingState.SELF_LINK_UNRESOLVED,
1229 NodeProcessingAction.SELF_LINK_SET);
1231 newNode.setPrimaryKeyName(NodeUtils.concatArray(pkeyNames, "/"));
1233 String primaryKeyValues = getRelationshipPrimaryKeyValues(r, entityType, pkeyNames);
1234 newNode.setPrimaryKeyValue(primaryKeyValues);
1238 LOG.error(AaiUiMsgs.VISUALIZATION_OUTPUT_ERROR,
1239 "Failed to parse entity because OXM descriptor could not be found for type = "
1240 + r.getRelatedTo());
1242 newNode.changeState(NodeProcessingState.ERROR,
1243 NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
1247 if (nodeCache.putIfAbsent(nodeId, newNode) != null) {
1248 if (LOG.isDebugEnabled()) {
1249 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
1250 "Failed to add node to nodeCache because it already exists. Node id = "
1251 + newNode.getNodeId());
1264 * Process initial state.
1266 * @param nodeId the node id
1268 private void processInitialState(String nodeId) {
1270 if (nodeId == null) {
1271 LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_INITIAL_STATE, "Node id is null");
1275 ActiveInventoryNode cachedNode = nodeCache.get(nodeId);
1277 if (cachedNode == null) {
1278 LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_INITIAL_STATE,
1279 "Node cannot be" + " found for nodeId, " + nodeId);
1283 if (cachedNode.getSelfLink() == null) {
1285 if (cachedNode.getNodeId() == null) {
1288 * if the self link is null at the INIT state, which could be valid if this node is a
1289 * complex attribute group which didn't originate from a self-link, but in that situation
1290 * both the node id and node key should already be set.
1293 cachedNode.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NODE_IDENTITY_ERROR);
1297 if (cachedNode.getNodeId() != null) {
1300 * This should be the success path branch if the self-link is not set
1303 cachedNode.changeState(NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
1304 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
1310 if (cachedNode.hasResolvedSelfLink()) {
1311 LOG.error(AaiUiMsgs.INVALID_RESOLVE_STATE_DURING_INIT);
1312 cachedNode.changeState(NodeProcessingState.ERROR,
1313 NodeProcessingAction.UNEXPECTED_STATE_TRANSITION);
1315 cachedNode.changeState(NodeProcessingState.SELF_LINK_UNRESOLVED,
1316 NodeProcessingAction.SELF_LINK_SET);
1322 * Process skeleton node.
1324 * @param skeletonNode the skeleton node
1325 * @param queryParams the query params
1327 private void processSearchableEntity(SearchableEntity searchTargetEntity,
1328 QueryParams queryParams) {
1330 if (searchTargetEntity == null) {
1334 if (searchTargetEntity.getId() == null) {
1335 LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_SKELETON_NODE, "Failed to process skeleton"
1336 + " node because nodeId is null for node, " + searchTargetEntity.getLink());
1340 ActiveInventoryNode newNode = new ActiveInventoryNode();
1342 newNode.setNodeId(searchTargetEntity.getId());
1343 newNode.setEntityType(searchTargetEntity.getEntityType());
1344 newNode.setPrimaryKeyName(getEntityTypePrimaryKeyName(searchTargetEntity.getEntityType()));
1345 newNode.setPrimaryKeyValue(searchTargetEntity.getEntityPrimaryKeyValue());
1347 if (newNode.getEntityType() != null && newNode.getPrimaryKeyName() != null
1348 && newNode.getPrimaryKeyValue() != null) {
1349 newNode.addQueryParam(newNode.getEntityType() + "." + newNode.getPrimaryKeyName() + ":"
1350 + newNode.getPrimaryKeyValue());
1353 * This code may need some explanation. In any graph there will be a single root node. The root
1354 * node is really the center of the universe, and for now, we are tagging the search target as
1355 * the root node. Everything else in the visualization of the graph will be centered around this
1356 * node as the focal point of interest.
1358 * Due to it's special nature, there will only ever be one root node, and it's node depth will
1359 * always be equal to zero.
1362 if (queryParams.getSearchTargetNodeId().equals(newNode.getNodeId())) {
1363 newNode.setNodeDepth(0);
1364 newNode.setRootNode(true);
1365 LOG.info(AaiUiMsgs.ROOT_NODE_DISCOVERED, queryParams.getSearchTargetNodeId());
1368 newNode.setSelfLink(searchTargetEntity.getLink());
1370 nodeCache.putIfAbsent(newNode.getNodeId(), newNode);
1374 * Checks for out standing work.
1376 * @return true, if successful
1378 private boolean hasOutStandingWork() {
1380 int numNodesWithPendingStates = 0;
1383 * Force an evaluation of node depths before determining if we should limit state-based
1384 * traversal or processing.
1387 evaluateNodeDepths();
1389 for (ActiveInventoryNode n : nodeCache.values()) {
1391 switch (n.getState()) {
1395 // do nothing, these are our normal
1400 case NEIGHBORS_UNPROCESSED: {
1402 if (n.getNodeDepth() < VisualizationConfig.getConfig().getMaxSelfLinkTraversalDepth()) {
1404 * Only process our neighbors relationships if our current depth is less than the max
1407 numNodesWithPendingStates++;
1416 * for all other states, there is work to be done
1418 numNodesWithPendingStates++;
1425 LOG.debug(AaiUiMsgs.OUTSTANDING_WORK_PENDING_NODES, String.valueOf(numNodesWithPendingStates));
1427 return (numNodesWithPendingStates > 0);
1432 * Process self links.
1434 * @param skeletonNode the skeleton node
1435 * @param queryParams the query params
1437 public void processSelfLinks(SearchableEntity searchtargetEntity, QueryParams queryParams) {
1441 if (searchtargetEntity == null) {
1442 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR,
1443 contextIdStr + " - Failed to" + " processSelfLinks, searchtargetEntity is null");
1447 processSearchableEntity(searchtargetEntity, queryParams);
1449 long startTimeInMs = System.currentTimeMillis();
1452 * wait until all transactions are complete or guard-timer expires.
1455 long totalResolveTime = 0;
1456 boolean hasOutstandingWork = hasOutStandingWork();
1457 boolean outstandingWorkGuardTimerFired = false;
1458 long maxGuardTimeInMs = 5000;
1459 long guardTimeInMs = 0;
1460 boolean foundRootNode = false;
1464 * TODO: Put a count-down-latch in place of the while loop, but if we do that then we'll need
1465 * to decouple the visualization processing from the main thread so it can continue to process
1466 * while the main thread is waiting on for count-down-latch gate to open. This may also be
1467 * easier once we move to the VisualizationService + VisualizationContext ideas.
1471 while (hasOutstandingWork || !outstandingWorkGuardTimerFired) {
1473 if (!foundRootNode) {
1474 foundRootNode = findAndMarkRootNode(queryParams);
1477 processCurrentNodeStates(foundRootNode);
1479 verifyOutboundNeighbors();
1483 } catch (InterruptedException exc) {
1484 LOG.error(AaiUiMsgs.PROCESSING_LOOP_INTERUPTED, exc.getMessage());
1488 totalResolveTime = (System.currentTimeMillis() - startTimeInMs);
1490 if (!hasOutstandingWork) {
1492 guardTimeInMs += 500;
1494 if (guardTimeInMs > maxGuardTimeInMs) {
1495 outstandingWorkGuardTimerFired = true;
1501 hasOutstandingWork = hasOutStandingWork();
1505 long opTime = System.currentTimeMillis() - startTimeInMs;
1507 LOG.info(AaiUiMsgs.ALL_TRANSACTIONS_RESOLVED, String.valueOf(totalResolveTime),
1508 String.valueOf(totalLinksRetrieved.get()), String.valueOf(opTime));
1510 } catch (Exception exc) {
1511 LOG.error(AaiUiMsgs.VISUALIZATION_OUTPUT_ERROR, exc.getMessage());
1517 * Verify outbound neighbors.
1519 private void verifyOutboundNeighbors() {
1521 for (ActiveInventoryNode srcNode : nodeCache.values()) {
1523 for (String targetNodeId : srcNode.getOutboundNeighbors()) {
1525 ActiveInventoryNode targetNode = nodeCache.get(targetNodeId);
1527 if (targetNode != null && srcNode.getNodeId() != null) {
1529 targetNode.addInboundNeighbor(srcNode.getNodeId());
1531 if (VisualizationConfig.getConfig().makeAllNeighborsBidirectional()) {
1532 targetNode.addOutboundNeighbor(srcNode.getNodeId());
1544 * Evaluate node depths.
1546 private void evaluateNodeDepths() {
1548 int numChanged = -1;
1549 int numAttempts = 0;
1551 while (numChanged != 0) {
1556 for (ActiveInventoryNode srcNode : nodeCache.values()) {
1558 if (srcNode.getState() == NodeProcessingState.INIT) {
1561 * this maybe the only state that we don't want to to process the node depth on, because
1562 * typically it won't have any valid fields set, and it may remain in a partial state
1563 * until we have processed the self-link.
1570 for (String targetNodeId : srcNode.getOutboundNeighbors()) {
1571 ActiveInventoryNode targetNode = nodeCache.get(targetNodeId);
1573 if (targetNode != null) {
1575 if (targetNode.changeDepth(srcNode.getNodeDepth() + 1)) {
1581 for (String targetNodeId : srcNode.getInboundNeighbors()) {
1582 ActiveInventoryNode targetNode = nodeCache.get(targetNodeId);
1584 if (targetNode != null) {
1586 if (targetNode.changeDepth(srcNode.getNodeDepth() + 1)) {
1593 if (numAttempts >= MAX_DEPTH_EVALUATION_ATTEMPTS) {
1594 LOG.info(AaiUiMsgs.MAX_EVALUATION_ATTEMPTS_EXCEEDED);
1600 if (LOG.isDebugEnabled()) {
1601 if (numAttempts > 0) {
1602 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
1603 "Evaluate node depths completed in " + numAttempts + " attempts");
1605 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
1606 "Evaluate node depths completed in 0 attempts because all nodes at correct depth");
1614 * Gets the entity type primary key name.
1616 * @param entityType the entity type
1617 * @return the entity type primary key name
1621 private String getEntityTypePrimaryKeyName(String entityType) {
1623 if (entityType == null) {
1624 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE,
1625 "node primary key" + " name because entity type is null");
1629 OxmEntityDescriptor descriptor = loader.getEntityDescriptor(entityType);
1631 if (descriptor == null) {
1632 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE,
1633 "oxm entity" + " descriptor for entityType = " + entityType);
1637 List<String> pkeyNames = descriptor.getPrimaryKeyAttributeName();
1639 if (pkeyNames == null || pkeyNames.size() == 0) {
1640 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE,
1641 "node primary" + " key because descriptor primary key names is empty");
1645 return NodeUtils.concatArray(pkeyNames, "/");