X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fsparky%2Fviewandinspect%2Fservices%2FVisualizationService.java;fp=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fsparky%2Fviewandinspect%2Fservices%2FVisualizationService.java;h=0a9797fc6084b5abab6d84173caaac4c9a55b231;hb=e72b52437992610d38939700d38c42336cade235;hp=924d026d71105131b8c14a7da39394f248acf64a;hpb=27da2e3395b009702c9032f9fa184f253747c8a7;p=aai%2Fsparky-be.git diff --git a/src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationService.java b/src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationService.java index 924d026..0a9797f 100644 --- a/src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationService.java +++ b/src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationService.java @@ -62,10 +62,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; public class VisualizationService { - + private static final Logger LOG = LoggerFactory.getInstance().getLogger(VisualizationService.class); - + private OxmModelLoader loader; private ObjectMapper mapper = new ObjectMapper(); @@ -74,13 +74,13 @@ public class VisualizationService { private final ElasticSearchDataProvider esProvider; private final ElasticSearchConfig esConfig; private final ExecutorService aaiExecutorService; - + private ConcurrentHashMap contextMap; private final SecureRandom secureRandom; - + private ActiveInventoryConfig aaiConfig; private VisualizationConfig visualizationConfig; - + public VisualizationService(OxmModelLoader loader) throws Exception { this.loader = loader; @@ -106,17 +106,17 @@ public class VisualizationService { RestfulDataAccessor nonCachingRestProvider = new RestfulDataAccessor(esClientBuilder); this.esConfig = ElasticSearchConfig.getConfig(); this.esProvider = new ElasticSearchAdapter(nonCachingRestProvider, this.esConfig); - + this.mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - + this.contextMap = new ConcurrentHashMap(); this.visualizationConfig = VisualizationConfig.getConfig(); this.aaiConfig = ActiveInventoryConfig.getConfig(); this.aaiExecutorService = NodeUtils.createNamedExecutor("SLNC-WORKER", aaiConfig.getAaiRestConfig().getNumResolverWorkers(), LOG); } - + public OxmModelLoader getLoader() { return loader; } @@ -124,7 +124,7 @@ public class VisualizationService { public void setLoader(OxmModelLoader loader) { this.loader = loader; } - + /** * Analyze query request body. * @@ -153,7 +153,7 @@ public class VisualizationService { return queryBody; } - + /** * Log optime. * @@ -164,13 +164,14 @@ public class VisualizationService { LOG.info(AaiUiMsgs.OPERATION_TIME, method, String.valueOf(System.currentTimeMillis() - opStartTimeInMs)); } - - private SearchableEntity extractSearchableEntityFromElasticEntity(OperationResult operationResult) { + + private SearchableEntity extractSearchableEntityFromElasticEntity( + OperationResult operationResult) { if (operationResult == null || !operationResult.wasSuccessful()) { // error, return empty collection return null; } - + SearchableEntity sourceEntity = null; if (operationResult.wasSuccessful()) { @@ -182,14 +183,16 @@ public class VisualizationService { if (sourceField != null) { sourceEntity = new SearchableEntity(); - - String entityType = NodeUtils.extractFieldValueFromObject(sourceField, "entityType"); - sourceEntity.setEntityType(entityType); - String entityPrimaryKeyValue = NodeUtils.extractFieldValueFromObject(sourceField, "entityPrimaryKeyValue"); + + String entityType = NodeUtils.extractFieldValueFromObject(sourceField, "entityType"); + sourceEntity.setEntityType(entityType); + String entityPrimaryKeyValue = + NodeUtils.extractFieldValueFromObject(sourceField, "entityPrimaryKeyValue"); sourceEntity.setEntityPrimaryKeyValue(entityPrimaryKeyValue); - String link = NodeUtils.extractFieldValueFromObject(sourceField, "link"); + String link = NodeUtils.extractFieldValueFromObject(sourceField, "link"); sourceEntity.setLink(link); - String lastmodTimestamp = NodeUtils.extractFieldValueFromObject(sourceField, "lastmodTimestamp"); + String lastmodTimestamp = + NodeUtils.extractFieldValueFromObject(sourceField, "lastmodTimestamp"); sourceEntity.setEntityTimeStamp(lastmodTimestamp); } } @@ -266,7 +269,7 @@ public class VisualizationService { return returnValue; } - + /** * Gets the visualization output basedon generic query. * @@ -334,13 +337,12 @@ public class VisualizationService { transformer.buildLinksFromGraphCollection(cachedNodeMap); /* - * - Apply configuration-driven styling - * - Build the final transformation response object - * - Use information we have to populate the GraphMeta object + * - Apply configuration-driven styling - Build the final transformation response object - Use + * information we have to populate the GraphMeta object */ transformer.addSearchTargetAttributesToRootNode(); - + GraphMeta graphMeta = new GraphMeta(); D3VisualizationOutput output = null; @@ -368,13 +370,13 @@ public class VisualizationService { logOptime("[build flat node array, add relationship data, search target," + " color scheme, and generate visualization output]", overlayDataStartTimeInMs); - + logOptime("doFilter()", opStartTimeInMs); return jsonResponse; } - + public void shutdown() { aaiProvider.shutdown(); aaiExecutorService.shutdown();