gizmo.client-cert-password=1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10
gizmo.trust-store=tomcat_keystore
gizmo.apiVersion=v12
+gizmo.maxSelfLinkTraversalDepth=2
resources.client-cert=client-cert-onap.p12
resources.client-cert-password=1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10
resources.trust-store=tomcat_keystore
+resources.maxSelfLinkTraversalDepth=2
<bean id="visualizationConfigurations"
class="org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs">
- <property name="maxSelfLinkTraversalDepth" value="2" />
+ <property name="maxSelfLinkTraversalDepth" value="${gizmo.maxSelfLinkTraversalDepth:2}" />
<property name="visualizationDebugEnabled" value="false" />
<property name="aaiEntityNodeDescriptors" value="/descriptors/aaiEntityNodeDescriptors.json" />
<property name="generalNodeClassName" value="generalNodeClass" />
<bean id="visualizationConfigurations"
class="org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs">
- <property name="maxSelfLinkTraversalDepth" value="2" />
+ <property name="maxSelfLinkTraversalDepth" value="${resources.maxSelfLinkTraversalDepth:2}" />
<property name="visualizationDebugEnabled" value="false" />
<property name="aaiEntityNodeDescriptors" value="/descriptors/aaiEntityNodeDescriptors.json" />
<property name="generalNodeClassName" value="generalNodeClass" />
}
ObjectMapper mapper = new ObjectMapper();
- JsonNode rootNode = null;
List<SearchSuggestion> suggestionEntityList = new ArrayList<SearchSuggestion>();
try {
- rootNode = mapper.readTree(operationResult);
+ JsonNode rootNode = mapper.readTree(operationResult);
JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT);
// Check if there are hits that are coming back
if (hitsNode.has(KEY_HITS)) {
* next we iterate over the values in the hit array elements
*/
Iterator<JsonNode> nodeIterator = hitsArray.elements();
- JsonNode entityNode = null;
- CommonSearchSuggestion responseSuggestion = null;
- JsonNode sourceNode = null;
-
while (nodeIterator.hasNext()) {
- entityNode = nodeIterator.next();
- String responseText = getValueFromNode(entityNode, KEY_TEXT);
- // do the point transformation as we build the response?
- responseSuggestion = new CommonSearchSuggestion();
- responseSuggestion.setRoute(vnfSearchSuggestionRoute);
- responseSuggestion.setText(responseText);
- responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
-
- sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT);
- if (sourceNode.has(KEY_FILTER_LIST)) {
- ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
- for (int i = 0; i < filtersArray.size(); i++) {
- String filterValueString = filtersArray.get(i).toString();
- UiFilterValueEntity filterValue =
- mapper.readValue(filterValueString, UiFilterValueEntity.class);
- responseSuggestion.getFilterValues().add(filterValue);
- }
+ JsonNode entityNode = nodeIterator.next();
+ if(entityNode != null) {
+ String responseText = getValueFromNode(entityNode, KEY_TEXT);
+
+ CommonSearchSuggestion responseSuggestion = createCommonSearchSuggestion(mapper, entityNode, responseText);
+ suggestionEntityList.add(responseSuggestion);
}
- suggestionEntityList.add(responseSuggestion);
}
}
} catch (IOException exc) {
}
+ private CommonSearchSuggestion createCommonSearchSuggestion(ObjectMapper mapper, JsonNode entityNode, String responseText) throws IOException {
+ // do the point transformation as we build the response?
+ CommonSearchSuggestion responseSuggestion = new CommonSearchSuggestion();
+ responseSuggestion.setRoute(vnfSearchSuggestionRoute);
+ responseSuggestion.setText(responseText);
+ responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
+
+ JsonNode keyDocument = entityNode.get(KEY_DOCUMENT);
+ JsonNode sourceNode = keyDocument.get(KEY_CONTENT);
+ if (sourceNode.has(KEY_FILTER_LIST)) {
+ ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
+ for (int i = 0; i < filtersArray.size(); i++) {
+ String filterValueString = filtersArray.get(i).toString();
+ UiFilterValueEntity filterValue =
+ mapper.readValue(filterValueString, UiFilterValueEntity.class);
+ responseSuggestion.getFilterValues().add(filterValue);
+ }
+ }
+ return responseSuggestion;
+ }
+
private String getValueFromNode(JsonNode node, String fieldName) {
- if (node == null || fieldName == null) {
+ if (fieldName == null) {
return null;
}
/**
* Instantiates a new entity aggregation synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public AggregationSynchronizer(String entityType, ElasticSearchSchemaConfig schemaConfig,
Map<String, Object> map = mapper.convertValue(entityNode, Map.class);
doc.copyAttributeKeyValuePair(map);
}
-
+
/**
* Process entity type self links.
*
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
+ if (operationResult == null) {
+ return;
}
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message =
- "Could not deserialize JSON (representing operation result) as node tree. " +
- "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ JsonNode resultData = rootNode.get("result-data");
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- OxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ OxmEntityDescriptor descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
+ selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
+ }
}
}
+ } catch (IOException exc) {
+ String message =
+ "Could not deserialize JSON (representing operation result) as node tree. " +
+ "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}
/**
* Instantiates a new historical entity summarizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public AutosuggestionSynchronizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
+ if (operationResult == null) {
+ return;
}
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message = "Could not deserialize JSON (representing operation result) as node tree. "
- + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- OxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ OxmEntityDescriptor descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
+ selflinks.add(new SelfLinkDescriptor(resourceLink,
+ SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
}
- selflinks.add(new SelfLinkDescriptor(resourceLink,
- SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
-
}
}
+ } catch (IOException exc) {
+ String message = "Could not deserialize JSON (representing operation result) as node tree. "
+ + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}
}
/**
* Instantiates a new cross entity reference synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public CrossEntityReferenceSynchronizer(ElasticSearchSchemaConfig schemaConfig,
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- // TODO // TODO -> LOG, waht should be logged here?
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- CrossEntityReferenceDescriptor descriptor = null;
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- if (resourceType != null && resourceLink != null) {
- descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().get(resourceType);
+ if (resourceType != null && resourceLink != null) {
+ CrossEntityReferenceDescriptor descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().get(resourceType);
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
- if (descriptor.hasCrossEntityReferences()) {
- selflinks.add(new SelfLinkDescriptor(
- resourceLink,SynchronizerConstants.DEPTH_ALL_MODIFIER, resourceType));
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
+ if (descriptor.hasCrossEntityReferences()) {
+ selflinks.add(new SelfLinkDescriptor(
+ resourceLink, SynchronizerConstants.DEPTH_ALL_MODIFIER, resourceType));
+ }
}
}
}
+ } catch (IOException exc) {
+ // TODO // TODO -> LOG, waht should be logged here?
}
}
}
}
} else {
- String message = "Entity sync failed because AAI query failed with error " + aaiQueryResult.getResult();
+ String result = aaiQueryResult != null ? aaiQueryResult.getResult() : "unknown";
+ String message = "Entity sync failed because AAI query failed with error " + result;
LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
}
String[] cspFields = getCspData(request);
if (cspFields != null && cspFields.length > 5)
uid = cspFields[5];
- } catch (Throwable t) {
+ } catch (Exception t) {
LOG.info(AaiUiMsgs.LOGIN_FILTER_INFO,
"getLoginIdFromCookie failed " + t.getLocalizedMessage());
}
*
* @param doc the doc
* @param txn the txn
- * @param esDataProvider the es data provider
+ * @param esAdapter the es adapter
*/
public StoreDocumentTask(IndexDocument doc, NetworkTransaction txn,
ElasticSearchAdapter esAdapter) {
long startTimeInMs = System.currentTimeMillis();
MDC.setContextMap(contextMap);
- OperationResult operationResult = null;
+ OperationResult operationResult = new OperationResult();
try {
/**
* Instantiates a new geo synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public GeoSynchronizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, exc);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ if (geoDescriptorMap.containsKey(resourceType)) {
+ selflinks.add(new SelfLinkDescriptor(resourceLink + "?nodes-only", resourceType));
+ } else {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- if (geoDescriptorMap.containsKey(resourceType)) {
- selflinks.add(new SelfLinkDescriptor(resourceLink + "?nodes-only", resourceType));
- } else {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
}
-
}
}
+ } catch (IOException exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, exc);
}
}
} else {
JsonNode nodeValue = field.getValue();
- if (nodeValue != null && nodeValue.isValueNode()) {
+ if (nodeValue != null) {
+ if (nodeValue.isValueNode()) {
- /*
- * before we blindly add the fieldName and value to our property set, let's do one more
- * check to see if the field name is an entity type. If it is, then our complex
- * attribute processing code will pick it up and process it instead, but this is
- * probably more likely just for array node types, but we'll see.
- */
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
/*
- * this is no an entity type as far as we can tell, so we can add it to our property
- * set.
+ * before we blindly add the fieldName and value to our property set, let's do one more
+ * check to see if the field name is an entity type. If it is, then our complex
+ * attribute processing code will pick it up and process it instead, but this is
+ * probably more likely just for array node types, but we'll see.
*/
- addProperty(fieldName, nodeValue.asText());
-
- }
-
- } else {
+ handleNodeValue(fieldName, nodeValue.asText());
- if (nodeValue.isArray()) {
+ } else if (nodeValue.isArray()) {
/*
* make sure array entity-type collection is not an entityType before adding it to the
* complex group or relationship.
*/
- if (oxmEntityLookup.getEntityDescriptors().get(field.getKey()) == null) {
- /*
- * this is no an entity type as far as we can tell, so we can add it to our property
- * set.
- */
-
- addProperty(field.getKey(), nodeValue.toString());
-
- }
-
+ handleNodeValue(field.getKey(), nodeValue.toString());
} else {
-
complexGroups.add(nodeValue);
-
}
}
-
}
-
}
} catch (IOException exc) {
}
+ private void handleNodeValue(String fieldName, String fieldValue) {
+ if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
+ /*
+ * this is no an entity type as far as we can tell, so we can add it to our property
+ * set.
+ */
+
+ addProperty(fieldName, fieldValue);
+
+ }
+ }
+
public void setSelfLink(String selfLink) {
this.selfLink = selfLink;
}
suggestionEntity
.setText(annotateSearchTags(searchTags, searchTagIds, entityType, queryStr));
} catch (Exception exc) {
- LOG.error(AaiUiMsgs.SEARCH_TAG_ANNOTATION_ERROR, searchTags.toString(),
+ String searchTagsAsText = searchTags != null ? searchTags.toString() : "n/a";
+ LOG.error(AaiUiMsgs.SEARCH_TAG_ANNOTATION_ERROR, searchTagsAsText,
exc.getLocalizedMessage());
// at least send back the un-annotated search tags
suggestionEntity.setText(searchTags);
JsonNode nodeValue = field.getValue();
- if (nodeValue != null && nodeValue.isValueNode()) {
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
-
- /*
- * entity property name is not an entity, thus we can add this property name and value
- * to our property set
- */
-
- ain.addProperty(fieldName, nodeValue.asText());
-
- }
-
- } else {
-
- if (nodeValue.isArray()) {
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
-
- /*
- * entity property name is not an entity, thus we can add this property name and value
- * to our property set
- */
-
- ain.addProperty(field.getKey(), nodeValue.toString());
-
- }
-
+ if(nodeValue!=null) {
+ if (nodeValue.isValueNode()) {
+ String key = fieldName;
+ handleNodeValue(ain, fieldName, key, nodeValue.asText());
+ } else if (nodeValue.isArray()) {
+ String key = field.getKey();
+ handleNodeValue(ain, fieldName, key, nodeValue.toString());
} else {
-
- ain.addComplexGroup(nodeValue);
-
+ ain.addComplexGroup(nodeValue);
}
}
}
+ private void handleNodeValue(ActiveInventoryNode ain, String fieldName, String key, String value) {
+ if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
+
+ /*
+ * entity property name is not an entity, thus we can add this property name and value
+ * to our property set
+ */
+
+ ain.addProperty(key, value);
+
+ }
+ }
+
/**
* Perform self link resolve.
*
/**
* Process current node states.
*
- * @param rootNodeDiscovered the root node discovered
*/
private void processCurrentNodeStates(QueryParams queryParams) {
/*
throw new ServletException(e1);
}
- String jsonResponse = null;
-
long startTimeInMs = System.currentTimeMillis();
visContext.processSelfLinks(searchtargetEntity, queryParams);
GraphMeta graphMeta = new GraphMeta();
- D3VisualizationOutput output = null;
- try {
- output = transformer
- .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
- } catch (JsonProcessingException exc) {
- throw new ServletException("Caught an exception while generation visualization output", exc);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
- }
+ D3VisualizationOutput output = getD3VisualizationOutput(opStartTimeInMs, transformer, graphMeta);
- output.setInlineMessage(visContext.getInlineMessage());
- output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
- visContext.getNumSuccessfulLinkResolveFromCache());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
- visContext.getNumSuccessfulLinkResolveFromFromServer());
+ String jsonResponse = null;
- try {
- jsonResponse = transformer.convertVisualizationOutputToJson(output);
- } catch (JsonProcessingException jpe) {
- throw new ServletException(
- "Caught an exception while converting visualization output to json", jpe);
+ if (output != null) {
+ output.setInlineMessage(visContext.getInlineMessage());
+ output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
+ visContext.getNumSuccessfulLinkResolveFromCache());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
+ visContext.getNumSuccessfulLinkResolveFromFromServer());
+
+ try {
+ jsonResponse = transformer.convertVisualizationOutputToJson(output);
+ } catch (JsonProcessingException jpe) {
+ throw new ServletException(
+ "Caught an exception while converting visualization output to json", jpe);
+ }
}
logOptime("[build flat node array, add relationship data, search target,"
return jsonResponse;
}
-
+
+ private D3VisualizationOutput getD3VisualizationOutput(long opStartTimeInMs, VisualizationTransformer transformer, GraphMeta graphMeta) throws ServletException {
+ D3VisualizationOutput output = null;
+ try {
+ output = transformer
+ .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
+ } catch (JsonProcessingException exc) {
+ throw new ServletException("Caught an exception while generation visualization output", exc);
+ } catch (IOException exc) {
+ LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
+ }
+ return output;
+ }
+
public void shutdown() {
aaiExecutorService.shutdown();
}
/**
* Instantiates a new searchable entity synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public ViewInspectEntitySynchronizer(ElasticSearchSchemaConfig schemaConfig,
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message =
- "Could not deserialize JSON (representing operation result) as node tree. " +
- "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ SearchableOxmEntityDescriptor descriptor = null;
- SearchableOxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ descriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resourceType);
- descriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resourceType);
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
+ if (descriptor.hasSearchableAttributes()) {
+ selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
+ }
- if (descriptor.hasSearchableAttributes()) {
- selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
}
-
}
}
+ } catch (IOException exc) {
+ String message =
+ "Could not deserialize JSON (representing operation result) as node tree. " +
+ "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}