From a31c1cb7240b28f9ee5b0a4a847545ae3ea8039d Mon Sep 17 00:00:00 2001 From: richarv Date: Mon, 15 Jan 2018 13:22:40 -0500 Subject: Adding subscription api from separate repo Change-Id: Ic4c0ef849501b95059c806beab16f2ccf3d16695 Signed-off-by: richarv Issue-ID: AAI-660 Signed-off-by: richarv --- .../sparky/config/oxm/SearchableEntityLookup.java | 2 +- .../sparky/config/oxm/SuggestionEntityLookup.java | 1 - .../aai/sparky/dal/ActiveInventoryAdapter.java | 1 + .../subscription/config/SubscriptionConfig.java | 204 +++++++++++++++++++++ .../subscription/payload/entity/Message.java | 58 ++++++ .../payload/entity/ObjectInspectorPayload.java | 127 +++++++++++++ .../sparky/subscription/payload/entity/Params.java | 58 ++++++ .../subscription/payload/entity/Payload.java | 58 ++++++ .../subscription/services/SubscriptionService.java | 57 ++++++ .../sparky/sync/entity/SuggestionSearchEntity.java | 1 - .../viewandinspect/config/SparkyConstants.java | 3 + .../viewandinspect/entity/SparkyGraphNode.java | 48 ++++- .../sync/ViewInspectEntitySynchronizer.java | 3 - .../sync/ViewInspectSyncController.java | 9 +- 14 files changed, 614 insertions(+), 16 deletions(-) create mode 100644 src/main/java/org/onap/aai/sparky/subscription/config/SubscriptionConfig.java create mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Message.java create mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/ObjectInspectorPayload.java create mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Params.java create mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Payload.java create mode 100644 src/main/java/org/onap/aai/sparky/subscription/services/SubscriptionService.java (limited to 'src/main') diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java index 288ce8e..faea602 100644 --- a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java +++ b/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java @@ -81,7 +81,7 @@ public class SearchableEntityLookup implements OxmModelProcessor { if (oxmProperties.containsKey("searchableAttributes")) { searchableOxmModel.put(entityName, oxmProperties); } - + } for (Entry> searchableModel : searchableOxmModel.entrySet()) { diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java index 86262b2..6b0c309 100644 --- a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java +++ b/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java @@ -156,7 +156,6 @@ public class SuggestionEntityLookup implements OxmModelProcessor { suggestionSearchEntityDescriptors.put(entityName, entity); } - } public Map> getSuggestionSearchEntityOxmModel() { diff --git a/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java b/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java index a60c853..e815a08 100644 --- a/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java +++ b/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java @@ -207,6 +207,7 @@ public class ActiveInventoryAdapter { link = getFullUrl("/search/nodes-query?search-node-type=" + entityType + "&filter=" + primaryKeyStr + ":EXISTS"); + return restClient.get(link, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE); } diff --git a/src/main/java/org/onap/aai/sparky/subscription/config/SubscriptionConfig.java b/src/main/java/org/onap/aai/sparky/subscription/config/SubscriptionConfig.java new file mode 100644 index 0000000..96228a5 --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/config/SubscriptionConfig.java @@ -0,0 +1,204 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.config; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Properties; + +import org.onap.aai.sparky.util.ConfigHelper; +import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; + + +/** + * The Class SubscriptionConfig. + */ +public class SubscriptionConfig { + + public static final String CONFIG_FILE = + SparkyConstants.DYNAMIC_CONFIG_APP_LOCATION + "subscription.properties"; + + private static SubscriptionConfig instance; + + private String subscriptionTarget; + + private String subscriptionOrigin; + + private String subscriptionMessageType; + + private String subscriptionTopic; + + private String launchOITarget; + + private String launchOIOrigin; + + private String launchOIMessageType; + + private String launchOITopic; + + private Boolean isLaunchOIEnabled; + + private Collection annEntitiyTypes; + + private static final String TARGET = ""; + + private static final String ORIGIN = ""; + + private static final String MESSAGE_TYPE = ""; + + private static final String TOPIC = ""; + + + + + public static SubscriptionConfig getConfig(){ + + if (instance == null) { + instance = new SubscriptionConfig(); + instance.initializeProperties(); + } + return instance; + } + + public static void setConfig(SubscriptionConfig config) { + /* + * Explicitly allow setting the configuration singleton. This will be useful for automation. + */ + + SubscriptionConfig.instance = config; + } + + /** + * Instantiates a new Subscription config. + */ + public SubscriptionConfig() { + // test method + } + + + /** + * Initialize properties. + */ + private void initializeProperties() { + Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE); + + if (props == null || props.isEmpty()) { + //Disable subscription launch if the file is missing + this.setIsLaunchOIEnabled(false); + return; + } + subscriptionTarget = props.getProperty("subscription.target", TARGET); + subscriptionOrigin = props.getProperty("subscription.origin", ORIGIN); + subscriptionMessageType = props.getProperty("subscription.messageType", MESSAGE_TYPE); + subscriptionTopic = props.getProperty("subscription.topic", TOPIC); + + this.setLaunchOITarget(props.getProperty("launchOI.target", TARGET)); + this.setLaunchOIOrigin(props.getProperty("launchOI.origin", ORIGIN)); + this.setLaunchOIMessageType(props.getProperty("launchOI.messageType", MESSAGE_TYPE)); + this.setLaunchOITopic(props.getProperty("launchOI.topic", TOPIC)); + + this.setAnnEntitiyTypes(Arrays.asList(props.getProperty("launchOI.entityTypes", "").split(","))); + this.setIsLaunchOIEnabled(Boolean.parseBoolean(props.getProperty("launchOI.enable", "false"))); + } + + + public String getSubscriptionTarget() { + return subscriptionTarget; + } + + public void setSubscriptionTarget(String target) { + this.subscriptionTarget = target; + } + + public String getSubscriptionOrigin() { + return subscriptionOrigin; + } + + public void setSubscriptionOrigin(String origin) { + this.subscriptionOrigin = origin; + } + + public String getSubscriptionMessageType() { + return subscriptionMessageType; + } + + public void setSubscriptionMessageType(String messageType) { + this.subscriptionMessageType = messageType; + } + + public String getSubscriptionTopic() { + return subscriptionTopic; + } + + public void setSubscriptionTopic(String topic) { + this.subscriptionTopic = topic; + } + +public String getLaunchOITarget() { + return launchOITarget; +} + +public void setLaunchOITarget(String launchOITarget) { + this.launchOITarget = launchOITarget; +} + +public String getLaunchOIOrigin() { + return launchOIOrigin; +} + +public void setLaunchOIOrigin(String launchOIOrigin) { + this.launchOIOrigin = launchOIOrigin; +} + +public String getLaunchOIMessageType() { + return launchOIMessageType; +} + +public void setLaunchOIMessageType(String launchOIMessageType) { + this.launchOIMessageType = launchOIMessageType; +} + +public String getLaunchOITopic() { + return launchOITopic; +} + +public void setLaunchOITopic(String launchOITopic) { + this.launchOITopic = launchOITopic; +} + +public Collection getAnnEntitiyTypes() { + return annEntitiyTypes; +} + +public void setAnnEntitiyTypes(Collection annEntitiyTypes) { + this.annEntitiyTypes = annEntitiyTypes; +} + +public Boolean getIsLaunchOIEnabled() { + return isLaunchOIEnabled; +} + +public void setIsLaunchOIEnabled(Boolean isLaunchOIEnabled) { + this.isLaunchOIEnabled = isLaunchOIEnabled; +} +} diff --git a/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Message.java b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Message.java new file mode 100644 index 0000000..908be73 --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Message.java @@ -0,0 +1,58 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.payload.entity; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "applicationName", "payload" }) +public class Message { + + @JsonProperty("applicationName") + private String applicationName; + @JsonProperty("payload") + private Payload payload; + + @JsonProperty("applicationName") + public String getApplicationName() { + return applicationName; + } + + @JsonProperty("applicationName") + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + @JsonProperty("payload") + public Payload getPayload() { + return payload; + } + + @JsonProperty("payload") + public void setPayload(Payload payload) { + this.payload = payload; + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/aai/sparky/subscription/payload/entity/ObjectInspectorPayload.java b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/ObjectInspectorPayload.java new file mode 100644 index 0000000..b4f2502 --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/ObjectInspectorPayload.java @@ -0,0 +1,127 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.payload.entity; + +import java.io.File; +import java.io.IOException; + +import org.onap.aai.sparky.subscription.config.SubscriptionConfig; +import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "target", "origin", "messageType", "topic", "message" }) +public class ObjectInspectorPayload { + + @JsonProperty("target") + private String target; + @JsonProperty("origin") + private String origin; + @JsonProperty("messageType") + private String messageType; + @JsonProperty("topic") + private String topic; + @JsonProperty("message") + private Message message; + + @JsonProperty("target") + public String getTarget() { + return target; + } + + @JsonProperty("target") + public void setTarget(String target) { + this.target = target; + } + + @JsonProperty("origin") + public String getOrigin() { + return origin; + } + + @JsonProperty("origin") + public void setOrigin(String origin) { + this.origin = origin; + } + + @JsonProperty("messageType") + public String getMessageType() { + return messageType; + } + + @JsonProperty("messageType") + public void setMessageType(String messageType) { + this.messageType = messageType; + } + + @JsonProperty("topic") + public String getTopic() { + return topic; + } + + @JsonProperty("topic") + public void setTopic(String topic) { + this.topic = topic; + } + + @JsonProperty("message") + public Message getMessage() { + return message; + } + + @JsonProperty("message") + public void setMessage(Message message) { + this.message = message; + } + + private static ObjectInspectorPayload lic; + public static ObjectInspectorPayload getOIPayload() throws JsonParseException, JsonMappingException, IOException{ + if(lic == null){ + ObjectMapper mapper = new ObjectMapper(); + lic = mapper.readValue(new File(SparkyConstants.SUBSCRIPTION_OI_MAPPING), ObjectInspectorPayload.class); + lic.intitializeOIPayload(); + } + + return lic; + } + + private void intitializeOIPayload(){ + try { + SubscriptionConfig subscriptionConf = SubscriptionConfig.getConfig(); + lic.setOrigin(subscriptionConf.getLaunchOIOrigin()); + lic.setTarget(subscriptionConf.getLaunchOITarget()); + lic.setTopic(subscriptionConf.getLaunchOITopic()); + lic.setMessageType(subscriptionConf.getLaunchOIMessageType()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Params.java b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Params.java new file mode 100644 index 0000000..07870c7 --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Params.java @@ -0,0 +1,58 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.payload.entity; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "contexts", "objectName", "externalClassId"}) +public class Params { + + @JsonProperty("objectName") + private String objectName; + @JsonProperty("externalClassId") + private String externalClassId; + + @JsonProperty("objectName") + public String getObjectName() { + return objectName; + } + + @JsonProperty("objectName") + public void setObjectName(String objectName) { + this.objectName = objectName; + } + + @JsonProperty("externalClassId") + public String getExternalClassId() { + return externalClassId; + } + + @JsonProperty("externalClassId") + public void setExternalClassId(String externalClassId) { + this.externalClassId = externalClassId; + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Payload.java b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Payload.java new file mode 100644 index 0000000..eebc59c --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/payload/entity/Payload.java @@ -0,0 +1,58 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.payload.entity; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "action", "params" }) +public class Payload { + + @JsonProperty("action") + private String action; + @JsonProperty("params") + private Params params; + + @JsonProperty("action") + public String getAction() { + return action; + } + + @JsonProperty("action") + public void setAction(String action) { + this.action = action; + } + + @JsonProperty("params") + public Params getParams() { + return params; + } + + @JsonProperty("params") + public void setParams(Params params) { + this.params = params; + } + +} diff --git a/src/main/java/org/onap/aai/sparky/subscription/services/SubscriptionService.java b/src/main/java/org/onap/aai/sparky/subscription/services/SubscriptionService.java new file mode 100644 index 0000000..f0b0733 --- /dev/null +++ b/src/main/java/org/onap/aai/sparky/subscription/services/SubscriptionService.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai.sparky.subscription.services; + +import org.json.JSONObject; +import org.onap.aai.restclient.client.OperationResult; +import org.onap.aai.sparky.subscription.config.SubscriptionConfig; + + +public class SubscriptionService { + + public OperationResult buildSubscriptionPayload() throws Exception { + OperationResult returnValue = new OperationResult(); + returnValue.setResultCode(200); + SubscriptionConfig subscriptionConf = getSubscriptionPayload(); + JSONObject subscriptionRequest = new JSONObject(); + + + if(subscriptionConf.getSubscriptionTarget().isEmpty() && subscriptionConf.getSubscriptionTopic().isEmpty() && + subscriptionConf.getSubscriptionMessageType().isEmpty() && subscriptionConf.getSubscriptionOrigin().isEmpty()) { + returnValue.setResult(500,"{}"); + } else { + subscriptionRequest.put("target", subscriptionConf.getSubscriptionTarget()); + subscriptionRequest.put("topic", subscriptionConf.getSubscriptionTopic()); + subscriptionRequest.put("messageType", subscriptionConf.getSubscriptionMessageType()); + subscriptionRequest.put("origin", subscriptionConf.getSubscriptionOrigin()); + returnValue.setResult(subscriptionRequest.toString()); + returnValue.setResultCode(200); + } + return returnValue; + + + } + public SubscriptionConfig getSubscriptionPayload() throws Exception { + return SubscriptionConfig.getConfig(); + } +} diff --git a/src/main/java/org/onap/aai/sparky/sync/entity/SuggestionSearchEntity.java b/src/main/java/org/onap/aai/sparky/sync/entity/SuggestionSearchEntity.java index 5d7b55d..9324cef 100644 --- a/src/main/java/org/onap/aai/sparky/sync/entity/SuggestionSearchEntity.java +++ b/src/main/java/org/onap/aai/sparky/sync/entity/SuggestionSearchEntity.java @@ -89,7 +89,6 @@ public class SuggestionSearchEntity extends IndexableEntity implements IndexDocu this.entityLookup = entityLookup; FiltersDetailsConfig filterConfigList = filtersConfig.getFiltersConfig(); - // Populate the map with keys that will match the suggestableAttr values for(UiFilterConfig filter : filterConfigList.getFilters()) { if(filter.getDataSource() != null) { diff --git a/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java b/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java index 5d62646..37b6909 100644 --- a/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java +++ b/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java @@ -86,6 +86,9 @@ public class SparkyConstants { public static final String FILTER_MAPPING_FILE_DEFAULT = CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_views.json"; + public static final String SUBSCRIPTION_OI_MAPPING = + CONFIG_FILTERS_BASE_LOCATION + "subscription_object_inspector_mapping.json"; + public static final String SUGGESTION_TEXT_SEPARATOR = " -- "; // Injected Attributes diff --git a/src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphNode.java b/src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphNode.java index 66c49c4..1fb5272 100644 --- a/src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphNode.java +++ b/src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphNode.java @@ -22,11 +22,18 @@ */ package org.onap.aai.sparky.viewandinspect.entity; +import java.io.IOException; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.eelf.LoggerFactory; +import org.onap.aai.sparky.aggregatevnf.search.AggregateSummaryProcessor; +import org.onap.aai.sparky.logging.AaiUiMsgs; +import org.onap.aai.sparky.subscription.config.SubscriptionConfig; +import org.onap.aai.sparky.subscription.payload.entity.ObjectInspectorPayload; +import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -61,6 +68,7 @@ public class SparkyGraphNode { private String itemNameValue; private Map itemProperties; private NodeMeta nodeMeta; + private ObjectInspectorPayload externalResourcePayload; @JsonIgnore private boolean isRootNode; @@ -76,8 +84,8 @@ public class SparkyGraphNode { @JsonIgnore - private static final Logger LOG = Logger.getLogger(SparkyGraphNode.class); - + private static final Logger LOG = LoggerFactory.getInstance().getLogger(SparkyGraphNode.class); + private VisualizationConfigs visualizationConfigs; @@ -86,7 +94,7 @@ public class SparkyGraphNode { * * @param ain the ain */ - public SparkyGraphNode(ActiveInventoryNode ain,VisualizationConfigs visualizationConfigs ) { + public SparkyGraphNode(ActiveInventoryNode ain, VisualizationConfigs visualizationConfigs) { this.resourceKey = ain.getNodeId(); this.itemProperties = ain.getProperties(); this.setItemType(ain.getEntityType()); @@ -106,7 +114,7 @@ public class SparkyGraphNode { outboundNeighbors = ain.getOutboundNeighbors(); nodeMeta = new NodeMeta(this.visualizationConfigs); - + nodeMeta.setNodeIssue(ain.isNodeIssue()); nodeMeta.setNodeValidated(ain.isNodeValidated()); nodeMeta.setNodeDepth(ain.getNodeDepth()); @@ -119,6 +127,24 @@ public class SparkyGraphNode { nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred()); nodeMeta.setHasNeighbors( ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0); + SubscriptionConfig subscriptionConf = SubscriptionConfig.getConfig(); + if (subscriptionConf.getIsLaunchOIEnabled()) { + try { + Collection entityTypes = subscriptionConf.getAnnEntitiyTypes(); + for (String entityType : entityTypes) { + if (entityType.equals(this.getItemType())) { + ObjectInspectorPayload lic = ObjectInspectorPayload.getOIPayload(); + lic.getMessage().getPayload().getParams().setObjectName(this.getItemNameValue()); + this.setExternalResourcePayload(lic); + break; + } + } + } catch (IOException e) { + String message = "Could not map JSON to object " + "Attempted to convert: " + + SparkyConstants.SUBSCRIPTION_OI_MAPPING + ". Error: " + e.getLocalizedMessage(); + LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message); + } + } nodeMeta.setProcessingState(ain.getState()); } @@ -183,7 +209,17 @@ public class SparkyGraphNode { return isRootNode; } - /* (non-Javadoc) + public ObjectInspectorPayload getExternalResourcePayload() { + return externalResourcePayload; + } + + public void setExternalResourcePayload(ObjectInspectorPayload externalResourcePayload) { + this.externalResourcePayload = externalResourcePayload; + } + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java b/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java index 9de2973..ee8a7ef 100644 --- a/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java +++ b/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java @@ -148,9 +148,6 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer * @return the operation state */ private OperationState collectAllTheWork() { - - - final Map contextMap = MDC.getCopyOfContextMap(); Map descriptorMap = searchableEntityLookup.getSearchableEntityDescriptors(); diff --git a/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectSyncController.java b/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectSyncController.java index 8d53d16..b804fc9 100644 --- a/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectSyncController.java +++ b/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectSyncController.java @@ -57,6 +57,7 @@ public class ViewInspectSyncController extends SyncControllerImpl SearchableEntityLookup searchableEntityLookup) throws Exception { super(syncControllerConfig); + // final String controllerName = "View and Inspect Entity Synchronizer"; this.aaiAdapter = aaiAdapter; @@ -68,29 +69,29 @@ public class ViewInspectSyncController extends SyncControllerImpl registerIndexValidator(indexValidator); + ViewInspectEntitySynchronizer ses = new ViewInspectEntitySynchronizer(schemaConfig, syncControllerConfig.getNumInternalSyncWorkers(), syncControllerConfig.getNumSyncActiveInventoryWorkers(), syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig, oxmEntityLookup, searchableEntityLookup); - ses.setAaiAdapter(aaiAdapter); ses.setElasticSearchAdapter(esAdapter); registerEntitySynchronizer(ses); - + CrossEntityReferenceSynchronizer cers = new CrossEntityReferenceSynchronizer(schemaConfig, syncControllerConfig.getNumInternalSyncWorkers(), syncControllerConfig.getNumSyncActiveInventoryWorkers(), syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig,esStatConfig, crossEntityReferenceLookup, oxmEntityLookup, searchableEntityLookup); - + cers.setAaiAdapter(aaiAdapter); cers.setElasticSearchAdapter(esAdapter); registerEntitySynchronizer(cers); - + IndexCleaner indexCleaner = new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig); -- cgit 1.2.3-korg