diff options
author | YuanHu <yuan.hu1@zte.com.cn> | 2018-04-12 14:49:18 +0800 |
---|---|---|
committer | YuanHu <yuan.hu1@zte.com.cn> | 2018-04-12 15:00:49 +0800 |
commit | 59547f49e965167c8fd1a4bf78ca6d300a4c37ad (patch) | |
tree | 6efd534b3203994e452783187b010fb6a3c6af4c | |
parent | d447c76fe62dbbb39e6a2d6f2a2bcb53fc53d01e (diff) |
Add AdapterType.
DEFAULT: retrive data from local.
SDC: retrive data from sdc.
Issue-ID: SDC-1212
Change-Id: I53d53f062cbe705738f2f4797621aee465e60fa4
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
6 files changed, 149 insertions, 6 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java index a30a026d..e5b065ec 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java @@ -12,7 +12,8 @@ package org.onap.sdc.workflowdesigner; -import org.glassfish.jersey.media.multipart.MultiPartFeature; +//import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.onap.sdc.workflowdesigner.config.AdapterType; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.resources.ExtendActivityResource; import org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource; @@ -53,15 +54,15 @@ public class WorkflowDesignerApp extends Application<WorkflowDesignerConfigurati public void run(WorkflowDesignerConfiguration configuration, Environment environment) { LOGGER.info("Start to initialize Workflow Designer."); - AppConfig.setSdcServiceProxy(configuration.getSdcServiceProxy()); + saveAppConfig(configuration); environment.jersey().register(new WorkflowModelerResource()); environment.jersey().register(new ExtendActivityResource()); // register rest interface environment.jersey().packages("org.onap.sdc.workflowdesigner.resources"); - // upload file by inputstream need to register MultiPartFeature - environment.jersey().register(MultiPartFeature.class); +// // upload file by inputstream need to register MultiPartFeature +// environment.jersey().register(MultiPartFeature.class); initSwaggerConfig(environment, configuration); @@ -69,6 +70,14 @@ public class WorkflowDesignerApp extends Application<WorkflowDesignerConfigurati } /** + * @param configuration + */ + private void saveAppConfig(WorkflowDesignerConfiguration configuration) { + AppConfig.setAdapterType(AdapterType.valueOf(configuration.getAdapterType())); + AppConfig.setSdcServiceProxy(configuration.getSdcServiceProxy()); + } + + /** * initialize swagger configuration. * * @param environment environment information diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java index 28c96c71..cde361a8 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java @@ -27,9 +27,13 @@ public class WorkflowDesignerConfiguration extends Configuration { @NotEmpty private String defaultName = "Workflow Designer"; + @NotEmpty + private String adapterType; + @NotNull private SDCServiceProxyInfo sdcServiceProxy; - + + @JsonProperty public String getTemplate() { return template; @@ -49,6 +53,22 @@ public class WorkflowDesignerConfiguration extends Configuration { public void setDefaultName(String name) { this.defaultName = name; } + + /** + * @return the adapterType + */ + @JsonProperty + public String getAdapterType() { + return adapterType; + } + + /** + * @param adapterType the adapterType to set + */ + @JsonProperty + public void setAdapterType(String adapterType) { + this.adapterType = adapterType; + } /** * @return the sdcServiceProxy diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AdapterType.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AdapterType.java new file mode 100644 index 00000000..6f9c291b --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AdapterType.java @@ -0,0 +1,20 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.config;
+
+/**
+ *
+ */
+public enum AdapterType {
+ DEFAULT, SDC
+
+}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java index c617c1f6..9a4afb39 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java @@ -21,11 +21,27 @@ import org.onap.sdc.workflowdesigner.SDCServiceProxyInfo; * */ public class AppConfig { + private static AdapterType adapterType; + private static SDCServiceProxyInfo sdcServiceProxy; - + private AppConfig() {} /** + * @return the adapterType + */ + public static AdapterType getAdapterType() { + return adapterType; + } + + /** + * @param adapterType the adapterType to set + */ + public static void setAdapterType(AdapterType adapterType) { + AppConfig.adapterType = adapterType; + } + + /** * @param sdcServiceProxy */ public static void setSdcServiceProxy(SDCServiceProxyInfo sdcServiceProxy) { @@ -39,4 +55,11 @@ public class AppConfig { return sdcServiceProxy; } + /** + * @return + */ + public static boolean isSDCAdapter() { + return adapterType.equals(AdapterType.SDC); + } + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/ToolUtils.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/ToolUtils.java new file mode 100644 index 00000000..c5bdee70 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/ToolUtils.java @@ -0,0 +1,26 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.utils;
+
+/**
+ *
+ */
+public class ToolUtils {
+ /**
+ * @param val
+ * @return
+ */
+ public static boolean isEmpty(String val) {
+ return val == null || val.trim().isEmpty();
+ }
+
+}
diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java new file mode 100644 index 00000000..fa9de6ea --- /dev/null +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/config/AdapterTypeTest.java @@ -0,0 +1,45 @@ +/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.config;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class AdapterTypeTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {}
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void test() {
+ AdapterType at = AdapterType.valueOf("SDC");
+ assertEquals(AdapterType.SDC, at);
+ AdapterType at1 = AdapterType.valueOf("DEFAULT");
+ assertEquals(AdapterType.DEFAULT, at1);
+ }
+
+}
|