summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java
diff options
context:
space:
mode:
authorElena Kuleshov <evn@att.com>2019-04-10 09:26:02 -0400
committerElena Kuleshov <evn@att.com>2019-04-12 11:05:20 -0400
commita2aea243a8a0c16209cd6b48d83c19aec1183ed5 (patch)
tree14fd28749e3d0425c5a79d5f2e56a042d425411d /asdc-controller/src/main/java
parent2f89bc38f624e4ff5e5644ba7e61afd2ed957ee2 (diff)
Deploy activities to SDC from Catalog
Deploy activities to SDC from Catalog Change-Id: I1c91b79a060889f14cf0b653b3ed1a60e934c8bf Issue-ID: SO-1725 Signed-off-by: Kuleshov, Elena <evn@att.com>
Diffstat (limited to 'asdc-controller/src/main/java')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java85
1 files changed, 77 insertions, 8 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
index 46d0f78e35..87008f1d8f 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
@@ -20,14 +20,18 @@
package org.onap.so.asdc.activity;
-import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.onap.so.asdc.activity.beans.ActivitySpec;
-import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.asdc.activity.beans.Input;
+import org.onap.so.asdc.activity.beans.Output;
+import org.onap.so.db.catalog.beans.ActivitySpecActivitySpecCategories;
+import org.onap.so.db.catalog.beans.ActivitySpecActivitySpecParameters;
+import org.onap.so.db.catalog.beans.ActivitySpecParameters;
+import org.onap.so.db.catalog.data.repository.ActivitySpecRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,17 +43,24 @@ public class DeployActivitySpecs {
@Autowired
private Environment env;
+ @Autowired
+ private ActivitySpecRepository activitySpecRepository;
+
private static final String SDC_ENDPOINT = "mso.asdc.config.activity.endpoint";
+ private static final String DIRECTION_INPUT = "input";
+ private static final String DIRECTION_OUTPUT = "output";
protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class);
- public void deployActivities() throws Exception {
- String hostname = this.env.getProperty(SDC_ENDPOINT);
- List<ActivitySpec> activitySpecs = new ArrayList<ActivitySpec>();
- // Initialize activitySpecs from Catalog DB
-
- for (ActivitySpec activitySpec : activitySpecs) {
+ public void deployActivities() throws Exception {
+ String hostname = env.getProperty(SDC_ENDPOINT);
+ if (hostname == null || hostname.isEmpty()) {
+ return;
+ }
+ List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll();
+ for (org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog : activitySpecsFromCatalog) {
+ ActivitySpec activitySpec = mapActivitySpecFromCatalogToSdc(activitySpecFromCatalog);
String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
if (activitySpecId != null) {
logger.info("{} {}", "Successfully created activitySpec", activitySpec.getName());
@@ -64,4 +75,62 @@ public class DeployActivitySpecs {
}
}
}
+
+ public ActivitySpec mapActivitySpecFromCatalogToSdc(
+ org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog) {
+ ActivitySpec activitySpec = new ActivitySpec();
+ activitySpec.setName(activitySpecFromCatalog.getName());
+ activitySpec.setDescription(activitySpecFromCatalog.getDescription());
+ mapCategoryList(activitySpecFromCatalog.getActivitySpecActivitySpecCategories(), activitySpec);
+ mapInputsAndOutputs(activitySpecFromCatalog.getActivitySpecActivitySpecParameters(), activitySpec);
+ return activitySpec;
+ }
+
+ private void mapCategoryList(List<ActivitySpecActivitySpecCategories> activitySpecActivitySpecCategories,
+ ActivitySpec activitySpec) {
+ if (activitySpecActivitySpecCategories == null || activitySpecActivitySpecCategories.size() == 0) {
+ return;
+ }
+ List<String> categoryList = new ArrayList<String>();
+ for (ActivitySpecActivitySpecCategories activitySpecCat : activitySpecActivitySpecCategories) {
+ if (activitySpecCat != null) {
+ if (activitySpecCat.getActivitySpecCategories() != null) {
+ categoryList.add(activitySpecCat.getActivitySpecCategories().getName());
+ }
+ }
+ }
+ activitySpec.setCategoryList(categoryList);
+ }
+
+ private void mapInputsAndOutputs(List<ActivitySpecActivitySpecParameters> activitySpecActivitySpecParameters,
+ ActivitySpec activitySpec) {
+ if (activitySpecActivitySpecParameters == null || activitySpecActivitySpecParameters.size() == 0) {
+ return;
+ }
+ List<Input> inputs = new ArrayList<Input>();
+ List<Output> outputs = new ArrayList<Output>();
+ for (ActivitySpecActivitySpecParameters activitySpecParam : activitySpecActivitySpecParameters) {
+ if (activitySpecParam != null) {
+ if (activitySpecParam.getActivitySpecParameters() != null) {
+ ActivitySpecParameters activitySpecParameters = activitySpecParam.getActivitySpecParameters();
+ if (activitySpecParameters != null) {
+ if (activitySpecParameters.getDirection().equals(DIRECTION_INPUT)) {
+ Input input = new Input();
+ input.setName(activitySpecParameters.getName());
+ input.setType(activitySpecParameters.getType());
+ inputs.add(input);
+ } else if (activitySpecParameters.getDirection().equals(DIRECTION_OUTPUT)) {
+ Output output = new Output();
+ output.setName(activitySpecParameters.getName());
+ output.setType(activitySpecParameters.getType());
+ outputs.add(output);
+ }
+ }
+ }
+ }
+ }
+ activitySpec.setInputs(inputs);
+ activitySpec.setOutputs(outputs);
+ return;
+ }
}