Entity Class for Display Information. 83/37283/1
authorYuanHu <yuan.hu1@zte.com.cn>
Wed, 21 Mar 2018 01:04:54 +0000 (09:04 +0800)
committerYuanHu <yuan.hu1@zte.com.cn>
Wed, 21 Mar 2018 01:05:41 +0000 (09:05 +0800)
Entity Class for Display Information.

Issue-ID: SDC-1129

Change-Id: I8b9a895b068de1537c9c0320be26e4a3fe641ac0
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryData.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfo.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategory.java [new file with mode: 0644]

index 7ed2170..10269a3 100644 (file)
@@ -23,6 +23,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import org.eclipse.jetty.http.HttpStatus;
+import org.onap.sdc.workflowdesigner.resources.entity.ExtActivityDisplayInfo;
 import org.onap.sdc.workflowdesigner.resources.entity.ExtendActivity;
 import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
 import org.onap.sdc.workflowdesigner.utils.RestUtils;
@@ -74,7 +75,6 @@ public class ExtendActivityResource {
 
     try {
       ExtendActivity[] extActivities = retriveExtActivites(sence);
-      
       return Response.status(Response.Status.OK).entity(extActivities).build();
     } catch (IOException e) {
       LOGGER.error("Get ExtActivities failed.", e);
@@ -99,7 +99,7 @@ public class ExtendActivityResource {
   @GET
   @Consumes(MediaType.APPLICATION_JSON)
   @Produces(MediaType.APPLICATION_JSON)
-  @ApiOperation(value = "Get Extend Activities DisplayInfo", response = String.class)
+  @ApiOperation(value = "Get Extend Activities DisplayInfo", response = ExtActivityDisplayInfo.class)
   @ApiResponses(value = {
       @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found",
           response = String.class),
@@ -110,12 +110,23 @@ public class ExtendActivityResource {
   @Timed
   public Response getDisplayInfo(@ApiParam(value = "sence") @QueryParam("sence") String sence) {
     try {
-      String json = FileCommonUtils.readString(EXT_ACTIVITIES_DISPLAY_INFO_FILE_NAME);
-      return Response.status(Response.Status.OK).entity(json).build();
+      ExtActivityDisplayInfo displayInfo = retriveDisplayInfo(sence);
+      return Response.status(Response.Status.OK).entity(displayInfo).build();
     } catch (IOException e) {
       LOGGER.error("Get Extend Activities DisplayInfo failed.", e);
       throw RestUtils.newInternalServerErrorException(e);
     }
   }
 
+  /**
+   * @param sence 
+   * @return
+   * @throws IOException
+   */
+  private ExtActivityDisplayInfo retriveDisplayInfo(String sence) throws IOException {
+    String json = FileCommonUtils.readString(EXT_ACTIVITIES_DISPLAY_INFO_FILE_NAME);
+    Gson gson = new Gson();
+    return gson.fromJson(json, ExtActivityDisplayInfo.class);
+  }
+
 }
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryData.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/CategoryData.java
new file mode 100644 (file)
index 0000000..1c92120
--- /dev/null
@@ -0,0 +1,50 @@
+/**\r
+ * Copyright (c) 2018 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ *     ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.resources.entity;\r
+\r
+/**\r
+ *\r
+ */\r
+public class CategoryData {\r
+  private I18nString displayName;\r
+  \r
+  private boolean collapse;\r
+\r
+  /**\r
+   * @return the displayName\r
+   */\r
+  public I18nString getDisplayName() {\r
+    return displayName;\r
+  }\r
+\r
+  /**\r
+   * @param displayName the displayName to set\r
+   */\r
+  public void setDisplayName(I18nString displayName) {\r
+    this.displayName = displayName;\r
+  }\r
+\r
+  /**\r
+   * @return the collapse\r
+   */\r
+  public boolean isCollapse() {\r
+    return collapse;\r
+  }\r
+\r
+  /**\r
+   * @param collapse the collapse to set\r
+   */\r
+  public void setCollapse(boolean collapse) {\r
+    this.collapse = collapse;\r
+  }\r
+  \r
+}\r
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfo.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/ExtActivityDisplayInfo.java
new file mode 100644 (file)
index 0000000..960a65c
--- /dev/null
@@ -0,0 +1,52 @@
+/**\r
+ * Copyright (c) 2018 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ *     ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.resources.entity;\r
+\r
+import java.util.Map;\r
+\r
+/**\r
+ *\r
+ */\r
+public class ExtActivityDisplayInfo {\r
+  private Map<String, NodeCategory> nodes;\r
+  \r
+  private Map<String, CategoryData> categoryData;\r
+\r
+  /**\r
+   * @return the nodes\r
+   */\r
+  public Map<String, NodeCategory> getNodes() {\r
+    return nodes;\r
+  }\r
+\r
+  /**\r
+   * @param nodes the nodes to set\r
+   */\r
+  public void setNodes(Map<String, NodeCategory> nodes) {\r
+    this.nodes = nodes;\r
+  }\r
+\r
+  /**\r
+   * @return the categoryData\r
+   */\r
+  public Map<String, CategoryData> getCategoryData() {\r
+    return categoryData;\r
+  }\r
+\r
+  /**\r
+   * @param categoryData the categoryData to set\r
+   */\r
+  public void setCategoryData(Map<String, CategoryData> categoryData) {\r
+    this.categoryData = categoryData;\r
+  }\r
+\r
+}\r
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategory.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/entity/NodeCategory.java
new file mode 100644 (file)
index 0000000..bcafca6
--- /dev/null
@@ -0,0 +1,34 @@
+/**\r
+ * Copyright (c) 2018 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ *     ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.resources.entity;\r
+\r
+/**\r
+ *\r
+ */\r
+public class NodeCategory {\r
+  private String category;\r
+\r
+  /**\r
+   * @return the category\r
+   */\r
+  public String getCategory() {\r
+    return category;\r
+  }\r
+\r
+  /**\r
+   * @param category the category to set\r
+   */\r
+  public void setCategory(String category) {\r
+    this.category = category;\r
+  }\r
+\r
+}\r