Entity Class for Display Information.
Issue-ID: SDC-1129
Change-Id: I8b9a895b068de1537c9c0320be26e4a3fe641ac0
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
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;
try {
ExtendActivity[] extActivities = retriveExtActivites(sence);
-
return Response.status(Response.Status.OK).entity(extActivities).build();
} catch (IOException e) {
LOGGER.error("Get ExtActivities failed.", e);
@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),
@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);
+ }
+
}
--- /dev/null
+/**\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
--- /dev/null
+/**\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
--- /dev/null
+/**\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