//comment_id and childCommentData received from view Comment cm=Comment.findByCommentId(comment_id); //find comment from id ,findByCommentId() defined in Comment entity ChildComment childCom=new ChildComment(childCommentData,cm); //create new object of ChildComment ChildComment childComment=ChildComment.save(childCom); //persist the child comment object in db ,save() is a function in model which saves ChildComment object and return it List<ChildComments> allChildComments=cm.getChildComments(); //getting list of all the ChildComments . allChildComments.add(childComment); //add new comment to list cm.setChildComments(allChildComments); //set all the child comments in Comment Entity cm.update(comment_id); //update the Comments entity in db
/** * Creates a comment from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Comment(RestClient restclient, JSONObject json, String issueKey) { super(restclient); this.issueKey = issueKey; if (json != null) deserialise(json); }
/** * Retrieves the given comment record. * * @param restclient REST client instance * @param issue Internal JIRA ID of the associated issue * @param id Internal JIRA ID of the comment * * @return a comment instance * * @throws JiraException when the retrieval fails */ public static Comment get(RestClient restclient, String issue, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "issue/" + issue + "/comment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve comment " + id + " on issue " + issue, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Comment(restclient, (JSONObject)result); }
/** * Updates the comment body. * * @param issue associated issue record * @param body Comment text * * @throws JiraException when the comment update fails */ public void update(String body) throws JiraException { update(body, null, null); }
String issueUri = getBaseUri() + "issue/" + issueKey; result = restclient.put(issueUri + "/comment/" + id, req); } catch (Exception ex) { deserialise((JSONObject) result);
/** * Adds a comment to this issue with limited visibility. * * @param body Comment text * @param visType Target audience type (role or group) * @param visName Name of the role or group to limit visibility to * * @throws JiraException when the comment creation fails */ public Comment addComment(String body, String visType, String visName) throws JiraException { JSONObject req = new JSONObject(); req.put("body", body); if (visType != null && visName != null) { JSONObject vis = new JSONObject(); vis.put("type", visType); vis.put("value", visName); req.put("visibility", vis); } JSON result = null; try { result = restclient.post(getRestUri(key) + "/comment", req); } catch (Exception ex) { throw new JiraException("Failed add comment to issue " + key, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return new Comment(restclient, (JSONObject) result, key); }
/** * Retrieves the given comment record. * * @param restclient REST client instance * @param issue Internal JIRA ID of the associated issue * @param id Internal JIRA ID of the comment * * @return a comment instance * * @throws JiraException when the retrieval fails */ public static Comment get(RestClient restclient, String issue, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "issue/" + issue + "/comment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve comment " + id + " on issue " + issue, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Comment(restclient, (JSONObject)result, issue); }
result = (T)new ChangeLogItem(restclient, (JSONObject)r); else if (type == Comment.class) result = (T)new Comment(restclient, (JSONObject)r); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r);
result = (T)new ChangeLogItem(restclient, (JSONObject)r); else if (type == Comment.class) result = (T)new Comment(restclient, (JSONObject)r, parentId); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r);
/** * Creates a comment from a JSON payload. * * @param restclient REST client instance * @param json JSON payload */ protected Comment(RestClient restclient, JSONObject json) { super(restclient); if (json != null) deserialise(json); }