List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:controllers.api.v1.Dataset.java
public static Result getDatasetImpactAnalysisByID(int id) { List<ImpactDataset> impactDatasetList = DatasetsDAO.getImpactAnalysisByID(id); ObjectNode result = Json.newObject(); if (impactDatasetList != null) { result.put("status", "ok"); result.set("impacts", Json.toJson(impactDatasetList)); } else {// ww w.j a v a 2s . c om result.put("status", "error"); result.put("message", "record not found"); } return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result getDatasetListNodes() { ObjectNode result = Json.newObject(); String urn = request().getQueryString("urn"); result.put("status", "ok"); result.set("nodes", Json.toJson(DatasetsDAO.getDatasetListViewNodes(urn))); return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result deleteDatasetComment(int id, int commentId) { ObjectNode result = Json.newObject(); if (DatasetsDAO.deleteComment(commentId)) { result.put("status", "success"); } else {/* w w w . ja v a 2s . c om*/ result.put("status", "failed"); } return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result getWatchedUrnId() { ObjectNode result = Json.newObject(); String urn = request().getQueryString("urn"); result.put("status", "success"); Long id = 0L;//from www .j a v a 2 s. c om if (StringUtils.isNotBlank(urn)) { String username = session("user"); if (StringUtils.isNotBlank(username)) { id = DatasetsDAO.getWatchId(urn, username); } } result.put("id", id); return ok(result); }
From source file:controllers.user.CommentApp.java
/** * ?// w ww . j a v a 2s.c o m * * @return */ @Transactional public static Result list() { JsonNode json = getJson(); int pageIndex = json.findPath("pageIndex").asInt(1); int pageSize = json.findPath("pageSize").asInt(10); Long userId = json.findPath("userId").asLong(0); Long serviceId = json.findPath("serviceId").asLong(0); int level = json.findPath("level").asInt(0); String type = json.findPath("type").asText(); ObjectNode result = Json.newObject(); List<ObjectNode> nodes = new ArrayList<ObjectNode>(); List<Integer> levelList = new ArrayList<Integer>(); if (level != 0) levelList.add(level); Page<Comment> page = null; if (type.equals("expert")) { ExpertComment comment = new ExpertComment(); page = comment.getExpertParentComments(pageIndex, pageSize, userId, null, levelList); } else if (type.equals("service")) { ServiceComment comment = new ServiceComment(); page = comment.getExpertParentComments(pageIndex, pageSize, null, serviceId, levelList); } result.put("totalRecords", page.getTotalRowCount()); if (CollectionUtils.isNotEmpty(page.getList())) { for (Comment c : page.getList()) { ObjectNode node = Json.newObject(); node.put("headUrl", c.commentUser.getAvatar(70)); node.put("id", c.id); node.put("uid", c.commentUser.id); node.put("username", c.commentUser.getName()); node.put("level", c.level); node.put("commentTime", DateUtils.format(c.commentTime, DateUtils.FORAMT_DATE_TIME)); node.put("content", c.content); nodes.add(node); } } result.putPOJO("comments", nodes); return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result deleteDatasetColumnComment(int id, int columnId, int commentId) { ObjectNode result = Json.newObject(); if (DatasetsDAO.deleteColumnComment(id, columnId, commentId)) { result.put("status", "success"); } else {/* ww w. j av a 2 s. c o m*/ result.put("status", "failed"); } return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result assignCommentToColumn(int datasetId, int columnId) { ObjectNode json = Json.newObject();//from ww w . j a v a 2 s. c o m ArrayNode res = json.arrayNode(); JsonNode req = request().body().asJson(); if (req == null) { return badRequest("Expecting JSON data"); } if (req.isArray()) { for (int i = 0; i < req.size(); i++) { JsonNode obj = req.get(i); Boolean isSuccess = DatasetsDAO.assignColumnComment(obj.get("datasetId").asInt(), obj.get("columnId").asInt(), obj.get("commentId").asInt()); ObjectNode itemResponse = Json.newObject(); if (isSuccess) { itemResponse.put("success", "true"); } else { itemResponse.put("error", "true"); itemResponse.put("datasetId", datasetId); itemResponse.put("columnId", columnId); itemResponse.set("commentId", obj.get("comment_id")); } res.add(itemResponse); } } else { Boolean isSuccess = DatasetsDAO.assignColumnComment(datasetId, columnId, req.get("commentId").asInt()); ObjectNode itemResponse = Json.newObject(); if (isSuccess) { itemResponse.put("success", "true"); } else { itemResponse.put("error", "true"); itemResponse.put("datasetId", datasetId); itemResponse.put("columnId", columnId); itemResponse.set("commentId", req.get("commentId")); } res.add(itemResponse); } ObjectNode result = Json.newObject(); result.putArray("results").addAll(res); return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result getDatasetColumnByID(int datasetId, int columnId) { List<DatasetColumn> datasetColumnList = DatasetsDAO.getDatasetColumnByID(datasetId, columnId); ObjectNode result = Json.newObject(); if (datasetColumnList != null && datasetColumnList.size() > 0) { result.put("status", "ok"); result.set("columns", Json.toJson(datasetColumnList)); } else {/* w w w . j a va2s . c o m*/ result.put("status", "error"); result.put("message", "record not found"); } return ok(result); }
From source file:controllers.api.v1.Dataset.java
public static Result getDatasetColumnsByID(int id) { List<DatasetColumn> datasetColumnList = DatasetsDAO.getDatasetColumnsByID(id); ObjectNode result = Json.newObject(); if (datasetColumnList != null && datasetColumnList.size() > 0) { result.put("status", "ok"); result.set("columns", Json.toJson(datasetColumnList)); } else {/*w w w . jav a 2 s .com*/ result.put("status", "error"); result.put("message", "record not found"); } return ok(result); }
From source file:api.Status.java
public static Result getStatus() { ObjectNode metrics = Json.newObject(); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); TreeMap<String, Object> values = new TreeMap<String, Object>(); for (Method method : os.getClass().getDeclaredMethods()) { method.setAccessible(true);//from ww w . j a v a 2 s .c o m if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) { Object value; try { value = method.invoke(os); values.put(method.getName(), value); } catch (Exception e) { Logger.warn("Error when invoking " + os.getClass().getName() + " (OperatingSystemMXBean) method " + method.getName() + ": " + e); } // try } // if } // for metrics.put("jvmLoad", (Double) values.get("getProcessCpuLoad")); metrics.put("cpuLoad", (Double) values.get("getSystemCpuLoad")); metrics.put("openFD", (Long) values.get("getOpenFileDescriptorCount")); metrics.put("maxFD", (Long) values.get("getMaxFileDescriptorCount")); metrics.put("freeMemory", (Long) values.get("getFreePhysicalMemorySize")); metrics.put("totalMemory", (Long) values.get("getTotalPhysicalMemorySize")); return ok(metrics.toString()); }