2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.viewandinspect.services;
28 import static java.util.concurrent.CompletableFuture.supplyAsync;
30 import java.net.URISyntaxException;
31 import java.util.ArrayList;
32 import java.util.Collection;
33 import java.util.Iterator;
34 import java.util.List;
36 import java.util.Map.Entry;
37 import java.util.concurrent.ConcurrentHashMap;
38 import java.util.concurrent.ExecutorService;
39 import java.util.concurrent.atomic.AtomicInteger;
41 import org.apache.http.client.utils.URIBuilder;
42 import org.openecomp.cl.api.Logger;
43 import org.openecomp.cl.eelf.LoggerFactory;
44 import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
45 import org.openecomp.sparky.config.oxm.OxmModelLoader;
46 import org.openecomp.sparky.dal.aai.ActiveInventoryDataProvider;
47 import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfig;
48 import org.openecomp.sparky.dal.rest.OperationResult;
49 import org.openecomp.sparky.logging.AaiUiMsgs;
50 import org.openecomp.sparky.synchronizer.entity.SearchableEntity;
51 import org.openecomp.sparky.util.NodeUtils;
52 import org.openecomp.sparky.viewandinspect.config.TierSupportUiConstants;
53 import org.openecomp.sparky.viewandinspect.config.VisualizationConfig;
54 import org.openecomp.sparky.viewandinspect.entity.ActiveInventoryNode;
55 import org.openecomp.sparky.viewandinspect.entity.InlineMessage;
56 import org.openecomp.sparky.viewandinspect.entity.NodeProcessingTransaction;
57 import org.openecomp.sparky.viewandinspect.entity.QueryParams;
58 import org.openecomp.sparky.viewandinspect.entity.Relationship;
59 import org.openecomp.sparky.viewandinspect.entity.RelationshipData;
60 import org.openecomp.sparky.viewandinspect.entity.RelationshipList;
61 import org.openecomp.sparky.viewandinspect.entity.SelfLinkDeterminationTransaction;
62 import org.openecomp.sparky.viewandinspect.enumeration.NodeProcessingAction;
63 import org.openecomp.sparky.viewandinspect.enumeration.NodeProcessingState;
64 import org.openecomp.sparky.viewandinspect.task.PerformNodeSelfLinkProcessingTask;
65 import org.openecomp.sparky.viewandinspect.task.PerformSelfLinkDeterminationTask;
67 import com.fasterxml.jackson.annotation.JsonInclude.Include;
68 import com.fasterxml.jackson.databind.JsonNode;
69 import com.fasterxml.jackson.databind.ObjectMapper;
70 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
73 * The Class SelfLinkNodeCollector.
75 public class VisualizationContext {
77 private static final int MAX_DEPTH_EVALUATION_ATTEMPTS = 100;
78 private static final String DEPTH_ALL_MODIFIER = "?depth=all";
79 private static final String NODES_ONLY_MODIFIER = "?nodes-only";
80 private static final String SERVICE_INSTANCE = "service-instance";
82 private static final Logger LOG = LoggerFactory.getInstance().getLogger(
83 VisualizationContext.class);
84 private final ActiveInventoryDataProvider aaiProvider;
86 private int maxSelfLinkTraversalDepth;
87 private AtomicInteger numLinksDiscovered;
88 private AtomicInteger numSuccessfulLinkResolveFromCache;
89 private AtomicInteger numSuccessfulLinkResolveFromFromServer;
90 private AtomicInteger numFailedLinkResolve;
91 private AtomicInteger aaiWorkOnHand;
93 private ActiveInventoryConfig aaiConfig;
94 private VisualizationConfig visualizationConfig;
95 private List<String> shallowEntities;
97 private AtomicInteger totalLinksRetrieved;
99 private final long contextId;
100 private final String contextIdStr;
102 private OxmModelLoader loader;
103 private ObjectMapper mapper;
104 private InlineMessage inlineMessage = null;
106 private ExecutorService aaiExecutorService;
109 * The node cache is intended to be a flat structure indexed by a primary key to avoid needlessly
110 * re-requesting the same self-links over-and-over again, to speed up the overall render time and
111 * more importantly to reduce the network cost of determining information we already have.
113 private ConcurrentHashMap<String, ActiveInventoryNode> nodeCache;
116 * Instantiates a new self link node collector.
118 * @param loader the loader
119 * @throws Exception the exception
121 public VisualizationContext(long contextId, ActiveInventoryDataProvider aaiDataProvider,
122 ExecutorService aaiExecutorService, OxmModelLoader loader) throws Exception {
124 this.contextId = contextId;
125 this.contextIdStr = "[Context-Id=" + contextId + "]";
126 this.aaiProvider = aaiDataProvider;
127 this.aaiExecutorService = aaiExecutorService;
128 this.loader = loader;
130 this.nodeCache = new ConcurrentHashMap<String, ActiveInventoryNode>();
131 this.numLinksDiscovered = new AtomicInteger(0);
132 this.totalLinksRetrieved = new AtomicInteger(0);
133 this.numSuccessfulLinkResolveFromCache = new AtomicInteger(0);
134 this.numSuccessfulLinkResolveFromFromServer = new AtomicInteger(0);
135 this.numFailedLinkResolve = new AtomicInteger(0);
136 this.aaiWorkOnHand = new AtomicInteger(0);
138 this.aaiConfig = ActiveInventoryConfig.getConfig();
139 this.visualizationConfig = VisualizationConfig.getConfig();
140 this.shallowEntities = aaiConfig.getAaiRestConfig().getShallowEntities();
142 this.maxSelfLinkTraversalDepth = visualizationConfig.getMaxSelfLinkTraversalDepth();
144 this.mapper = new ObjectMapper();
145 mapper.setSerializationInclusion(Include.NON_EMPTY);
146 mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy());
149 public long getContextId() {
154 * A utility method for extracting all entity-type primary key values from a provided self-link
155 * and return a set of generic-query API keys.
157 * @param parentEntityType
159 * @return a list of key values that can be used for this entity with the AAI generic-query API
161 protected List<String> extractQueryParamsFromSelfLink(String link) {
163 List<String> queryParams = new ArrayList<String>();
166 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR, "self link is null");
170 Map<String, OxmEntityDescriptor> entityDescriptors = loader.getEntityDescriptors();
174 URIBuilder urlBuilder = new URIBuilder(link);
175 String urlPath = urlBuilder.getPath();
177 OxmEntityDescriptor descriptor = null;
178 String[] urlPathElements = urlPath.split("/");
179 List<String> primaryKeyNames = null;
181 String entityType = null;
183 while (index < urlPathElements.length) {
185 descriptor = entityDescriptors.get(urlPathElements[index]);
187 if (descriptor != null) {
188 entityType = urlPathElements[index];
189 primaryKeyNames = descriptor.getPrimaryKeyAttributeName();
192 * Make sure from what ever index we matched the parent entity-type on that we can extract
193 * additional path elements for the primary key values.
196 if (index + primaryKeyNames.size() < urlPathElements.length) {
198 for (String primaryKeyName : primaryKeyNames) {
200 queryParams.add(entityType + "." + primaryKeyName + ":" + urlPathElements[index]);
203 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR,
204 "Could not extract query parametrs for entity-type = '" + entityType
205 + "' from self-link = " + link);
212 } catch (URISyntaxException exc) {
214 LOG.error(AaiUiMsgs.QUERY_PARAM_EXTRACTION_ERROR,
215 "Error extracting query parameters from self-link = " + link + ". Error = "
224 * Decode complex attribute group.
227 * @param attributeGroup the attribute group
228 * @return boolean indicating whether operation was successful (true), / failure(false).
230 public boolean decodeComplexAttributeGroup(ActiveInventoryNode ain, JsonNode attributeGroup) {
234 Iterator<Entry<String, JsonNode>> entityArrays = attributeGroup.fields();
235 Entry<String, JsonNode> entityArray = null;
237 if (entityArrays == null) {
238 LOG.error(AaiUiMsgs.ATTRIBUTE_GROUP_FAILURE, attributeGroup.toString());
239 ain.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
243 while (entityArrays.hasNext()) {
245 entityArray = entityArrays.next();
247 String entityType = entityArray.getKey();
248 JsonNode entityArrayObject = entityArray.getValue();
250 if (entityArrayObject.isArray()) {
252 Iterator<JsonNode> entityCollection = entityArrayObject.elements();
253 JsonNode entity = null;
254 while (entityCollection.hasNext()) {
255 entity = entityCollection.next();
257 if (LOG.isDebugEnabled()) {
258 LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "decodeComplexAttributeGroup(),"
259 + " entity = " + entity.toString());
263 * Here's what we are going to do:
265 * <li>In the ActiveInventoryNode, on construction maintain a collection of queryParams
266 * that is added to for the purpose of discovering parent->child hierarchies.
268 * <li>When we hit this block of the code then we'll use the queryParams to feed the
269 * generic query to resolve the self-link asynchronously.
271 * <li>Upon successful link determination, then and only then will we create a new node
272 * in the nodeCache and process the child
276 ActiveInventoryNode newNode = new ActiveInventoryNode();
277 newNode.setEntityType(entityType);
280 * This is partially a lie because we actually don't have a self-link for complex nodes
281 * discovered in this way.
283 newNode.setSelfLinkProcessed(true);
284 newNode.changeState(NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
285 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_OK);
288 * copy parent query params into new child
291 if (SERVICE_INSTANCE.equals(entityType)) {
294 * 1707 AAI has an issue being tracked with AAI-8932 where the generic-query cannot be
295 * resolved if all the service-instance path keys are provided. The query only works
296 * if only the service-instance key and valude are passed due to a historical reason.
297 * A fix is being worked on for 1707, and when it becomes available we can revert this
301 newNode.clearQueryParams();
306 * For all other entity-types we want to copy the parent query parameters into the new node
310 for (String queryParam : ain.getQueryParams()) {
311 newNode.addQueryParam(queryParam);
317 if (!addComplexGroupToNode(newNode, entity)) {
318 LOG.error(AaiUiMsgs.ATTRIBUTE_GROUP_FAILURE, "Failed to add child to parent for child = " + entity.toString());
321 if (!addNodeQueryParams(newNode)) {
322 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "Error determining node id and key for node = " + newNode.dumpNodeTree(true)
323 + " skipping relationship processing");
324 newNode.changeState(NodeProcessingState.ERROR,
325 NodeProcessingAction.NODE_IDENTITY_ERROR);
329 newNode.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
330 NodeProcessingAction.COMPLEX_ATTRIBUTE_GROUP_PARSE_OK);
336 * Order matters for the query params. We need to set the parent ones before the child
340 String selfLinkQuery =
341 aaiProvider.getGenericQueryForSelfLink(entityType, newNode.getQueryParams());
344 * <li>get the self-link
345 * <li>add it to the new node
346 * <li>generate node id
347 * <li>add node to node cache
348 * <li>add node id to parent outbound links list
349 * <li>process node children (should be automatic) (but don't query and resolve
350 * self-link as we already have all the data)
353 SelfLinkDeterminationTransaction txn = new SelfLinkDeterminationTransaction();
355 txn.setQueryString(selfLinkQuery);
356 txn.setNewNode(newNode);
357 txn.setParentNodeId(ain.getNodeId());
358 aaiWorkOnHand.incrementAndGet();
359 supplyAsync(new PerformSelfLinkDeterminationTask(txn, null, aaiProvider),
360 aaiExecutorService).whenComplete((nodeTxn, error) -> {
361 aaiWorkOnHand.decrementAndGet();
363 LOG.error(AaiUiMsgs.SELF_LINK_DETERMINATION_FAILED_GENERIC, selfLinkQuery);
366 OperationResult opResult = nodeTxn.getOpResult();
368 ActiveInventoryNode newChildNode = txn.getNewNode();
370 if (opResult != null && opResult.wasSuccessful()) {
372 if (opResult.isResolvedLinkFailure()) {
373 numFailedLinkResolve.incrementAndGet();
376 if (opResult.isResolvedLinkFromCache()) {
377 numSuccessfulLinkResolveFromCache.incrementAndGet();
380 if (opResult.isResolvedLinkFromServer()) {
381 numSuccessfulLinkResolveFromFromServer.incrementAndGet();
385 * extract the self-link from the operational result.
388 Collection<JsonNode> entityLinks = new ArrayList<JsonNode>();
389 JsonNode genericQueryResult = null;
392 NodeUtils.convertJsonStrToJsonNode(nodeTxn.getOpResult().getResult());
393 } catch (Exception exc) {
394 LOG.error(AaiUiMsgs.JSON_CONVERSION_ERROR, JsonNode.class.toString(), exc.getMessage());
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, String.valueOf(entityLinks.size()));
407 selfLink = ((JsonNode) entityLinks.toArray()[0]).asText();
409 newChildNode.setSelfLink(selfLink);
410 newChildNode.setNodeId(NodeUtils.generateUniqueShaDigest(selfLink));
412 String uri = NodeUtils.calculateEditAttributeUri(selfLink);
414 newChildNode.addProperty(TierSupportUiConstants.URI_ATTR_NAME, uri);
417 ActiveInventoryNode parent = nodeCache.get(txn.getParentNodeId());
419 if (parent != null) {
420 parent.addOutboundNeighbor(newChildNode.getNodeId());
421 newChildNode.addInboundNeighbor(parent.getNodeId());
424 newChildNode.setSelfLinkPendingResolve(false);
425 newChildNode.setSelfLinkProcessed(true);
427 newChildNode.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
428 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
430 nodeCache.putIfAbsent(newChildNode.getNodeId(), newChildNode);
435 LOG.error(AaiUiMsgs.SELF_LINK_RETRIEVAL_FAILED, txn.getQueryString(),
436 String.valueOf(nodeTxn.getOpResult().getResultCode()), nodeTxn.getOpResult().getResult());
437 newChildNode.setSelflinkRetrievalFailure(true);
438 newChildNode.setSelfLinkProcessed(true);
439 newChildNode.setSelfLinkPendingResolve(false);
441 newChildNode.changeState(NodeProcessingState.ERROR,
442 NodeProcessingAction.SELF_LINK_DETERMINATION_ERROR);
455 LOG.error(AaiUiMsgs.UNHANDLED_OBJ_TYPE_FOR_ENTITY_TYPE, entityType);
459 } catch (Exception exc) {
460 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Exception caught while"
461 + " decoding complex attribute group - " + exc.getMessage());
469 * Process self link response.
471 * @param nodeId the node id
473 private void processSelfLinkResponse(String nodeId) {
475 if (nodeId == null) {
476 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Cannot process self link"
477 + " response because nodeId is null");
481 ActiveInventoryNode ain = nodeCache.get(nodeId);
484 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Cannot process self link response"
485 + " because can't find node for id = " + nodeId);
489 JsonNode jsonNode = null;
492 jsonNode = mapper.readValue(ain.getOpResult().getResult(), JsonNode.class);
493 } catch (Exception exc) {
494 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to marshal json"
495 + " response str into JsonNode with error, " + exc.getLocalizedMessage());
496 ain.changeState(NodeProcessingState.ERROR,
497 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
501 if (jsonNode == null) {
502 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to parse json node str."
503 + " Parse resulted a null value.");
504 ain.changeState(NodeProcessingState.ERROR,
505 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
509 Iterator<Entry<String, JsonNode>> fieldNames = jsonNode.fields();
510 Entry<String, JsonNode> field = null;
512 RelationshipList relationshipList = null;
514 while (fieldNames.hasNext()) {
516 field = fieldNames.next();
517 String fieldName = field.getKey();
519 if ("relationship-list".equals(fieldName)) {
522 relationshipList = mapper.readValue(field.getValue().toString(), RelationshipList.class);
524 if (relationshipList != null) {
525 ain.addRelationshipList(relationshipList);
528 } catch (Exception exc) {
529 LOG.error(AaiUiMsgs.SELF_LINK_JSON_PARSE_ERROR, "Failed to parse relationship-list"
530 + " attribute. Parse resulted in error, " + exc.getLocalizedMessage());
531 ain.changeState(NodeProcessingState.ERROR,
532 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_ERROR);
538 JsonNode nodeValue = field.getValue();
540 if (nodeValue != null && nodeValue.isValueNode()) {
542 if (loader.getEntityDescriptor(fieldName) == null) {
545 * entity property name is not an entity, thus we can add this property name and value
546 * to our property set
549 ain.addProperty(fieldName, nodeValue.asText());
555 if (nodeValue.isArray()) {
557 if (loader.getEntityDescriptor(fieldName) == null) {
560 * entity property name is not an entity, thus we can add this property name and value
561 * to our property set
564 ain.addProperty(field.getKey(), nodeValue.toString());
570 ain.addComplexGroup(nodeValue);
579 String uri = NodeUtils.calculateEditAttributeUri(ain.getSelfLink());
581 ain.addProperty(TierSupportUiConstants.URI_ATTR_NAME, uri);
585 * We need a special behavior for intermediate entities from the REST model
587 * Tenants are not top level entities, and when we want to visualization
588 * their children, we need to construct keys that include the parent entity query
589 * keys, the current entity type keys, and the child keys. We'll always have the
590 * current entity and children, but never the parent entity in the current (1707) REST
593 * We have two possible solutions:
595 * 1) Try to use the custom-query approach to learn about the entity keys
596 * - this could be done, but it could be very expensive for large objects. When we do the first
597 * query to get a tenant, it will list all the in and out edges related to this entity,
598 * there is presently no way to filter this. But the approach could be made to work and it would be
599 * somewhat data-model driven, other than the fact that we have to first realize that the entity
600 * that is being searched for is not top-level entity. Once we have globally unique ids for resources
601 * this logic will not be needed and everything will be simpler. The only reason we are in this logic
602 * at all is to be able to calculate a url for the child entities so we can hash it to generate
603 * a globally unique id that can be safely used for the node.
605 * *2* Extract the keys from the pathed self-link.
606 * This is a bad solution and I don't like it but it will be fast for all resource types, as the
607 * information is already encoded in the URI. When we get to a point where we switch to a better
608 * globally unique entity identity model, then a lot of the code being used to calculate an entity url
609 * to in-turn generate a deterministic globally unique id will disappear.
612 * right now we have the following:
614 * - cloud-regions/cloud-region/{cloud-region-id}/{cloud-owner-id}/tenants/tenant/{tenant-id}
619 * For all entity types use the self-link extraction method to be consistent. Once we have a
620 * globally unique identity mechanism for entities, this logic can be revisited.
622 ain.clearQueryParams();
623 ain.addQueryParams(extractQueryParamsFromSelfLink(ain.getSelfLink()));
625 ain.changeState(NodeProcessingState.NEIGHBORS_UNPROCESSED,
626 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
631 * Perform self link resolve.
633 * @param nodeId the node id
635 private void performSelfLinkResolve(String nodeId) {
637 if (nodeId == null) {
638 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Resolve of self-link"
639 + " has been skipped because provided nodeId is null");
643 ActiveInventoryNode ain = nodeCache.get(nodeId);
646 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Failed to find node with id, " + nodeId
647 + ", from node cache. Resolve self-link method has been skipped.");
651 if (!ain.isSelfLinkPendingResolve()) {
653 ain.setSelfLinkPendingResolve(true);
655 // kick off async self-link resolution
657 if (LOG.isDebugEnabled()) {
658 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
659 "About to process node in SELF_LINK_UNPROCESSED State, link = " + ain.getSelfLink());
662 numLinksDiscovered.incrementAndGet();
664 String depthModifier = DEPTH_ALL_MODIFIER;
667 * If the current node is the search target, we want to see everything the node has to offer
668 * from the self-link and not filter it to a single node.
671 if (shallowEntities.contains(ain.getEntityType()) && !ain.isRootNode()) {
672 depthModifier = NODES_ONLY_MODIFIER;
675 NodeProcessingTransaction txn = new NodeProcessingTransaction();
676 txn.setProcessingNode(ain);
677 txn.setRequestParameters(depthModifier);
678 aaiWorkOnHand.incrementAndGet();
680 new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider),
681 aaiExecutorService).whenComplete((nodeTxn, error) -> {
682 aaiWorkOnHand.decrementAndGet();
686 * an error processing the self link should probably result in the node processing
687 * state shifting to ERROR
690 nodeTxn.getProcessingNode().setSelflinkRetrievalFailure(true);
692 nodeTxn.getProcessingNode().changeState(NodeProcessingState.ERROR,
693 NodeProcessingAction.SELF_LINK_RESOLVE_ERROR);
695 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
699 totalLinksRetrieved.incrementAndGet();
701 OperationResult opResult = nodeTxn.getOpResult();
703 if (opResult != null && opResult.wasSuccessful()) {
705 if (opResult.isResolvedLinkFailure()) {
706 numFailedLinkResolve.incrementAndGet();
709 if (opResult.isResolvedLinkFromCache()) {
710 numSuccessfulLinkResolveFromCache.incrementAndGet();
713 if (opResult.isResolvedLinkFromServer()) {
714 numSuccessfulLinkResolveFromFromServer.incrementAndGet();
718 nodeTxn.getProcessingNode().setOpResult(opResult);
719 nodeTxn.getProcessingNode().changeState(
720 NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
721 NodeProcessingAction.SELF_LINK_RESOLVE_OK);
723 nodeTxn.getProcessingNode().setSelfLinkProcessed(true);
724 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
727 LOG.error(AaiUiMsgs.SELF_LINK_PROCESSING_ERROR, "Self Link retrieval for link,"
728 + txn.getSelfLinkWithModifiers() + ", failed with error code,"
729 + nodeTxn.getOpResult().getResultCode() + ", and message,"
730 + nodeTxn.getOpResult().getResult());
732 nodeTxn.getProcessingNode().setSelflinkRetrievalFailure(true);
733 nodeTxn.getProcessingNode().setSelfLinkProcessed(true);
735 nodeTxn.getProcessingNode().changeState(NodeProcessingState.ERROR,
736 NodeProcessingAction.SELF_LINK_RESOLVE_ERROR);
738 nodeTxn.getProcessingNode().setSelfLinkPendingResolve(false);
753 * @param nodeId the node id
755 private void processNeighbors(String nodeId) {
757 if (nodeId == null) {
758 LOG.error(AaiUiMsgs.SELF_LINK_PROCESS_NEIGHBORS_ERROR, "Failed to process"
759 + " neighbors because nodeId is null.");
763 ActiveInventoryNode ain = nodeCache.get(nodeId);
766 LOG.error(AaiUiMsgs.SELF_LINK_PROCESS_NEIGHBORS_ERROR, "Failed to process"
767 + " neighbors because node could not be found in nodeCache with id, " + nodeId);
772 * process complex attribute and relationships
775 boolean neighborsProcessedSuccessfully = true;
777 for (JsonNode n : ain.getComplexGroups()) {
778 neighborsProcessedSuccessfully &= decodeComplexAttributeGroup(ain, n);
781 for (RelationshipList relationshipList : ain.getRelationshipLists()) {
782 neighborsProcessedSuccessfully &= addSelfLinkRelationshipChildren(ain, relationshipList);
786 if (neighborsProcessedSuccessfully) {
787 ain.changeState(NodeProcessingState.READY, NodeProcessingAction.NEIGHBORS_PROCESSED_OK);
789 ain.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
794 * If neighbors fail to process, there is already a call to change the state within the
795 * relationship and neighbor processing functions.
801 * Find and mark root node.
803 * @param queryParams the query params
804 * @return true, if successful
806 private boolean findAndMarkRootNode(QueryParams queryParams) {
808 for (ActiveInventoryNode cacheNode : nodeCache.values()) {
810 if (queryParams.getSearchTargetNodeId().equals(cacheNode.getNodeId())) {
811 cacheNode.setNodeDepth(0);
812 cacheNode.setRootNode(true);
813 LOG.info(AaiUiMsgs.ROOT_NODE_DISCOVERED, queryParams.getSearchTargetNodeId());
823 * Process current node states.
825 * @param rootNodeDiscovered the root node discovered
827 private void processCurrentNodeStates(boolean rootNodeDiscovered) {
829 * Force an evaluation of node depths before determining if we should limit state-based
830 * traversal or processing.
832 if (rootNodeDiscovered) {
833 evaluateNodeDepths();
836 for (ActiveInventoryNode cacheNode : nodeCache.values()) {
838 if (LOG.isDebugEnabled()) {
839 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
840 "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 = -- "
881 + cacheNode.getState() + " 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, "Failed to parse"
946 + " 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,
960 "Unexpected array type with a key = " + fieldName);
962 } else if (fieldValue.isValueNode()) {
963 if (loader.getEntityDescriptor(field.getKey()) == null) {
965 * property key is not an entity type, add it to our property set.
967 targetNode.addProperty(field.getKey(), fieldValue.asText());
973 } else if (attributeGroup.isArray()) {
974 if (LOG.isDebugEnabled()) {
975 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
976 "Unexpected array type for attributeGroup = " + attributeGroup);
978 } else if (attributeGroup.isValueNode()) {
979 if (LOG.isDebugEnabled()) {
980 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
981 "Unexpected value type for attributeGroup = " + attributeGroup);
988 public int getNumSuccessfulLinkResolveFromCache() {
989 return numSuccessfulLinkResolveFromCache.get();
992 public int getNumSuccessfulLinkResolveFromFromServer() {
993 return numSuccessfulLinkResolveFromFromServer.get();
996 public int getNumFailedLinkResolve() {
997 return numFailedLinkResolve.get();
1000 public InlineMessage getInlineMessage() {
1001 return inlineMessage;
1004 public void setInlineMessage(InlineMessage inlineMessage) {
1005 this.inlineMessage = inlineMessage;
1008 public void setMaxSelfLinkTraversalDepth(int depth) {
1009 this.maxSelfLinkTraversalDepth = depth;
1012 public int getMaxSelfLinkTraversalDepth() {
1013 return this.maxSelfLinkTraversalDepth;
1016 public ConcurrentHashMap<String, ActiveInventoryNode> getNodeCache() {
1021 * Gets the relationship primary key values.
1024 * @param entityType the entity type
1025 * @param pkeyNames the pkey names
1026 * @return the relationship primary key values
1028 private String getRelationshipPrimaryKeyValues(Relationship r, String entityType,
1029 List<String> pkeyNames) {
1031 StringBuilder sb = new StringBuilder(64);
1033 if (pkeyNames.size() > 0) {
1034 String primaryKey = extractKeyValueFromRelationData(r, entityType + "." + pkeyNames.get(0));
1035 if (primaryKey != null) {
1037 sb.append(primaryKey);
1040 // this should be a fatal error because unless we can
1041 // successfully retrieve all the expected keys we'll end up
1042 // with a garbage node
1043 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: Failed to extract"
1044 + " keyName, " + entityType + "." + pkeyNames.get(0)
1045 + ", from relationship data, " + r.toString());
1049 for (int i = 1; i < pkeyNames.size(); i++) {
1051 String kv = extractKeyValueFromRelationData(r, entityType + "." + pkeyNames.get(i));
1053 sb.append("/").append(kv);
1055 // this should be a fatal error because unless we can
1056 // successfully retrieve all the expected keys we'll end up
1057 // with a garbage node
1058 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: failed to extract keyName, "
1059 + entityType + "." + pkeyNames.get(i)
1060 + ", from relationship data, " + r.toString());
1065 return sb.toString();
1074 * Extract key value from relation data.
1077 * @param keyName the key name
1078 * @return the string
1080 private String extractKeyValueFromRelationData(Relationship r, String keyName) {
1082 RelationshipData[] rdList = r.getRelationshipData();
1084 for (RelationshipData relData : rdList) {
1086 if (relData.getRelationshipKey().equals(keyName)) {
1087 return relData.getRelationshipValue();
1095 * Determine node id and key.
1097 * @param ain the ain
1098 * @return true, if successful
1100 private boolean addNodeQueryParams(ActiveInventoryNode ain) {
1103 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "ActiveInventoryNode is null");
1107 List<String> pkeyNames =
1108 loader.getEntityDescriptor(ain.getEntityType()).getPrimaryKeyAttributeName();
1110 if (pkeyNames == null || pkeyNames.size() == 0) {
1111 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE_NODE_ID, "Primary key names is empty");
1115 StringBuilder sb = new StringBuilder(64);
1117 if (pkeyNames.size() > 0) {
1118 String primaryKey = ain.getProperties().get(pkeyNames.get(0));
1119 if (primaryKey != null) {
1120 sb.append(primaryKey);
1122 // this should be a fatal error because unless we can
1123 // successfully retrieve all the expected keys we'll end up
1124 // with a garbage node
1125 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: Failed to extract keyName, "
1126 + pkeyNames.get(0) + ", from entity properties");
1130 for (int i = 1; i < pkeyNames.size(); i++) {
1132 String kv = ain.getProperties().get(pkeyNames.get(i));
1134 sb.append("/").append(kv);
1136 // this should be a fatal error because unless we can
1137 // successfully retrieve all the expected keys we'll end up
1138 // with a garbage node
1139 LOG.error(AaiUiMsgs.EXTRACTION_ERROR, "ERROR: Failed to extract keyName, "
1140 + pkeyNames.get(i) + ", from entity properties");
1145 /*final String nodeId = NodeUtils.generateUniqueShaDigest(ain.getEntityType(),
1146 NodeUtils.concatArray(pkeyNames, "/"), sb.toString());*/
1148 //ain.setNodeId(nodeId);
1149 ain.setPrimaryKeyName(NodeUtils.concatArray(pkeyNames, "/"));
1150 ain.setPrimaryKeyValue(sb.toString());
1152 if (ain.getEntityType() != null && ain.getPrimaryKeyName() != null
1153 && ain.getPrimaryKeyValue() != null) {
1155 ain.getEntityType() + "." + ain.getPrimaryKeyName() + ":" + ain.getPrimaryKeyValue());
1166 * Adds the self link relationship children.
1168 * @param processingNode the processing node
1169 * @param relationshipList the relationship list
1170 * @return true, if successful
1172 private boolean addSelfLinkRelationshipChildren(ActiveInventoryNode processingNode,
1173 RelationshipList relationshipList) {
1175 if (relationshipList == null) {
1176 LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "No relationships added to parent node = "
1177 + processingNode.getNodeId() + " because relationshipList is empty");
1178 processingNode.changeState(NodeProcessingState.ERROR,
1179 NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
1183 OxmModelLoader modelLoader = OxmModelLoader.getInstance();
1185 Relationship[] relationshipArray = relationshipList.getRelationshipList();
1186 OxmEntityDescriptor descriptor = null;
1187 String repairedSelfLink = null;
1189 if (relationshipArray != null) {
1191 ActiveInventoryNode newNode = null;
1193 for (Relationship r : relationshipArray) {
1195 repairedSelfLink = aaiConfig.repairSelfLink(r.getRelatedLink());
1197 String nodeId = NodeUtils.generateUniqueShaDigest(repairedSelfLink);
1199 if (nodeId == null) {
1201 LOG.error(AaiUiMsgs.SKIPPING_RELATIONSHIP, r.toString());
1202 processingNode.changeState(NodeProcessingState.ERROR,
1203 NodeProcessingAction.NODE_IDENTITY_ERROR);
1207 newNode = new ActiveInventoryNode();
1209 String entityType = r.getRelatedTo();
1211 if (r.getRelationshipData() != null) {
1212 for (RelationshipData rd : r.getRelationshipData()) {
1213 newNode.addQueryParam(rd.getRelationshipKey() + ":" + rd.getRelationshipValue());
1217 descriptor = modelLoader.getEntityDescriptor(r.getRelatedTo());
1219 newNode.setNodeId(nodeId);
1220 newNode.setEntityType(entityType);
1221 newNode.setSelfLink(repairedSelfLink);
1223 processingNode.addOutboundNeighbor(nodeId);
1225 if (descriptor != null) {
1227 List<String> pkeyNames = descriptor.getPrimaryKeyAttributeName();
1229 newNode.changeState(NodeProcessingState.SELF_LINK_UNRESOLVED,
1230 NodeProcessingAction.SELF_LINK_SET);
1232 newNode.setPrimaryKeyName(NodeUtils.concatArray(pkeyNames, "/"));
1234 String primaryKeyValues = getRelationshipPrimaryKeyValues(r, entityType, pkeyNames);
1235 newNode.setPrimaryKeyValue(primaryKeyValues);
1239 LOG.error(AaiUiMsgs.VISUALIZATION_OUTPUT_ERROR,
1240 "Failed to parse entity because OXM descriptor could not be found for type = "
1241 + r.getRelatedTo());
1243 newNode.changeState(NodeProcessingState.ERROR,
1244 NodeProcessingAction.NEIGHBORS_PROCESSED_ERROR);
1248 if (nodeCache.putIfAbsent(nodeId, newNode) != null) {
1249 if (LOG.isDebugEnabled()) {
1250 LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
1251 "Failed to add node to nodeCache because it already exists. Node id = "
1252 + newNode.getNodeId());
1265 * Process initial state.
1267 * @param nodeId the node id
1269 private void processInitialState(String nodeId) {
1271 if (nodeId == null) {
1272 LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_INITIAL_STATE, "Node id is null");
1276 ActiveInventoryNode cachedNode = nodeCache.get(nodeId);
1278 if (cachedNode == null) {
1279 LOG.error(AaiUiMsgs.FAILED_TO_PROCESS_INITIAL_STATE, "Node cannot be"
1280 + " found for nodeId, " + nodeId);
1284 if (cachedNode.getSelfLink() == null) {
1286 if (cachedNode.getNodeId() == null ) {
1289 * if the self link is null at the INIT state, which could be valid if this node is a
1290 * complex attribute group which didn't originate from a self-link, but in that situation
1291 * both the node id and node key should already be set.
1294 cachedNode.changeState(NodeProcessingState.ERROR, NodeProcessingAction.NODE_IDENTITY_ERROR);
1298 if (cachedNode.getNodeId() != null) {
1301 * This should be the success path branch if the self-link is not set
1304 cachedNode.changeState(NodeProcessingState.SELF_LINK_RESPONSE_UNPROCESSED,
1305 NodeProcessingAction.SELF_LINK_RESPONSE_PARSE_OK);
1311 if (cachedNode.hasResolvedSelfLink()) {
1312 LOG.error(AaiUiMsgs.INVALID_RESOLVE_STATE_DURING_INIT);
1313 cachedNode.changeState(NodeProcessingState.ERROR,
1314 NodeProcessingAction.UNEXPECTED_STATE_TRANSITION);
1316 cachedNode.changeState(NodeProcessingState.SELF_LINK_UNRESOLVED,
1317 NodeProcessingAction.SELF_LINK_SET);
1323 * Process skeleton node.
1325 * @param skeletonNode the skeleton node
1326 * @param queryParams the query params
1328 private void processSearchableEntity(SearchableEntity searchTargetEntity, 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(
1350 newNode.getEntityType() + "." + newNode.getPrimaryKeyName() + ":" + 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, contextIdStr + " - Failed to"
1443 + " 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
1465 * we'll need to decouple the visualization processing from the main thread so it can continue to process while
1466 * the main thread is waiting on for count-down-latch gate to open. This may also be easier once we move to the
1467 * 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, "node primary key"
1625 + " name because entity type is null");
1629 OxmEntityDescriptor descriptor = loader.getEntityDescriptor(entityType);
1631 if (descriptor == null) {
1632 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE, "oxm entity"
1633 + " descriptor for entityType = " + entityType);
1637 List<String> pkeyNames = descriptor.getPrimaryKeyAttributeName();
1639 if (pkeyNames == null || pkeyNames.size() == 0) {
1640 LOG.error(AaiUiMsgs.FAILED_TO_DETERMINE, "node primary"
1641 + " key because descriptor primary key names is empty");
1645 return NodeUtils.concatArray(pkeyNames, "/");