BrightSide Workbench Full Report + Source Code
org.turro.commentit.CommentItUtil Class Reference

Static Public Member Functions

static void addComment (Object entity, String comment, SoftContact contact)
 
static void addComment (String path, String comment, SoftContact contact)
 
static void acceptComment (CommentIt comment)
 
static void remove (String id)
 
static Collection< CommentItcomments (Object entity, SoftContact contact)
 
static Collection< CommentItcomments (String path, SoftContact contact)
 
static Collection< CommentItallComments (Object entity)
 
static Collection< CommentItallComments (String path)
 
static Collection< CommentItpending ()
 
static long countPending ()
 
static long count ()
 
static long count (Object entity, SoftContact contact)
 
static long count (String path, SoftContact contact)
 
static Collection< String > paths (String path, int fromDays)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 46 of file CommentItUtil.java.

Member Function Documentation

◆ acceptComment()

static void org.turro.commentit.CommentItUtil.acceptComment ( CommentIt  comment)
static

Definition at line 84 of file CommentItUtil.java.

84  {
85  comment.setAccepted(true);
86  new ContactsPU().saveObject(comment);
87  IElephantEntity iee = Entities.getController(comment.getPath());
88  try {
89  new MailQueue()
90  .setRoot("/comments")
91  .addByEntity(comment.getPath(), AssistantConstants.participants())
92  .setCategory(GenericElephantNotification.GENERIC_NOTIFICATION)
93  .setReason(I_.get("Comments"))
94  .put("iee", iee)
95  .put("commentIt", comment)
96  .put("entityUrl", iee.getEntityUrl())
97  .sendTemplate("comment", I_.get("Comment"));
98  } catch (EmailException ex) {
99  Logger.getLogger(CommentItUtil.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
100  }
101  }
Here is the call graph for this function:

◆ addComment() [1/2]

static void org.turro.commentit.CommentItUtil.addComment ( Object  entity,
String  comment,
SoftContact  contact 
)
static

Definition at line 48 of file CommentItUtil.java.

48  {
49  String path = Entities.getController(entity).getPath();
50  if(path != null) {
51  addComment(path, comment, contact);
52  }
53  }
static void addComment(Object entity, String comment, SoftContact contact)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addComment() [2/2]

static void org.turro.commentit.CommentItUtil.addComment ( String  path,
String  comment,
SoftContact  contact 
)
static

Definition at line 55 of file CommentItUtil.java.

55  {
56  if(!Strings.isBlank(path) && contact != null && contact.isValid()) {
57  Dao dao = new ContactsPU();
58  CommentIt commentIt = new CommentIt();
59  commentIt.setCreator((Contact) contact.getContact());
60  commentIt.setAuthor(contact.author);
61  commentIt.setAuthor_email(contact.author_email);
62  commentIt.setAuthor_ip(contact.author_ip);
63  commentIt.setAuthor_web(contact.author_web);
64  commentIt.setDateCreation(new Date());
65  commentIt.setBody(HTMLEntities.escape(comment));
66  commentIt.setPath(path);
67  dao.saveObject(commentIt);
68  IElephantEntity iee = Entities.getController(path);
69  try {
70  new MailQueue()
71  .setRoot("/comments")
72  .addAdministrators()
73  .addByRole("PublicationAdmin")
74  .setReason(I_.get("Pending revision"))
75  .put("iee", iee)
76  .put("commentIt", commentIt)
77  .sendTemplate("new-comment", I_.get("New comment"));
78  } catch (EmailException ex) {
79  Logger.getLogger(CommentItUtil.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
80  }
81  }
82  }
Here is the call graph for this function:

◆ allComments() [1/2]

static Collection<CommentIt> org.turro.commentit.CommentItUtil.allComments ( Object  entity)
static

Definition at line 140 of file CommentItUtil.java.

140  {
141  String path = Entities.getController(entity).getPath();
142  if(path != null) {
143  return allComments(path);
144  }
145  return null;
146  }
static Collection< CommentIt > allComments(Object entity)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allComments() [2/2]

static Collection<CommentIt> org.turro.commentit.CommentItUtil.allComments ( String  path)
static

Definition at line 148 of file CommentItUtil.java.

148  {
149  Dao dao = new ContactsPU();
150  return dao.getResultList(
151  " select c from CommentIt c " +
152  " where path = ? " +
153  " order by dateCreation ",
154  new Object[] { path }
155  );
156  }

◆ comments() [1/2]

static Collection<CommentIt> org.turro.commentit.CommentItUtil.comments ( Object  entity,
SoftContact  contact 
)
static

Definition at line 111 of file CommentItUtil.java.

111  {
112  String path = Entities.getController(entity).getPath();
113  if(path != null) {
114  return comments(path, contact);
115  }
116  return null;
117  }
static Collection< CommentIt > comments(Object entity, SoftContact contact)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ comments() [2/2]

static Collection<CommentIt> org.turro.commentit.CommentItUtil.comments ( String  path,
SoftContact  contact 
)
static

Definition at line 119 of file CommentItUtil.java.

119  {
120  Dao dao = new ContactsPU();
121  if(contact.getContact() != null) {
122  return dao.getResultList(
123  " select c from CommentIt c " +
124  " where path = ? " +
125  " and (accepted = TRUE or creator = ?) " +
126  " order by dateCreation ",
127  new Object[] { path, contact.getContact() }
128  );
129  } else {
130  return dao.getResultList(
131  " select c from CommentIt c " +
132  " where path = ? " +
133  " and (accepted = TRUE or author_ip = ?) " +
134  " order by dateCreation ",
135  new Object[] { path, contact.author_ip }
136  );
137  }
138  }
Here is the call graph for this function:

◆ count() [1/3]

static long org.turro.commentit.CommentItUtil.count ( )
static

Definition at line 175 of file CommentItUtil.java.

175  {
176  Dao dao = new ContactsPU();
177  return (Long) dao.getSingleResultOrNull(
178  " select count(c) from CommentIt c "
179  );
180  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ count() [2/3]

static long org.turro.commentit.CommentItUtil.count ( Object  entity,
SoftContact  contact 
)
static

Definition at line 182 of file CommentItUtil.java.

182  {
183  String path = Entities.getController(entity).getPath();
184  if(path != null) {
185  return count(path, contact);
186  }
187  return 0;
188  }
Here is the call graph for this function:

◆ count() [3/3]

static long org.turro.commentit.CommentItUtil.count ( String  path,
SoftContact  contact 
)
static

Definition at line 190 of file CommentItUtil.java.

190  {
191  Dao dao = new ContactsPU();
192  Long count = 0L;
193  if(contact.getContact() != null) {
194  count = (Long) dao.getSingleResultOrNull(
195  " select count(c) from CommentIt c " +
196  " where path = ? " +
197  " and (accepted = TRUE or creator = ?) " +
198  " order by dateCreation desc ",
199  new Object[] { path, contact.getContact() }
200  );
201  } else {
202  count = (Long) dao.getSingleResultOrNull(
203  " select count(c) from CommentIt c " +
204  " where path = ? " +
205  " and (accepted = TRUE or author_ip = ?) " +
206  " order by dateCreation desc ",
207  new Object[] { path, contact.author_ip }
208  );
209  }
210  if(count != null) {
211  return count;
212  }
213  return 0;
214  }
Here is the call graph for this function:

◆ countPending()

static long org.turro.commentit.CommentItUtil.countPending ( )
static

Definition at line 167 of file CommentItUtil.java.

167  {
168  Dao dao = new ContactsPU();
169  return (Long) dao.getSingleResultOrNull(
170  " select count(c) from CommentIt c " +
171  " where accepted = FALSE "
172  );
173  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paths()

static Collection<String> org.turro.commentit.CommentItUtil.paths ( String  path,
int  fromDays 
)
static

Definition at line 216 of file CommentItUtil.java.

216  {
217  Dao dao = new ContactsPU();
218  return dao.getResultList(
219  " select g.path from CommentIt g " +
220  " where g.path like ? " +
221  " and g.dateCreation >= ?",
222  new Object[] { path + "/%", new CheckDate().addDays(-fromDays).getDate() }
223  );
224  }

◆ pending()

static Collection<CommentIt> org.turro.commentit.CommentItUtil.pending ( )
static

Definition at line 158 of file CommentItUtil.java.

158  {
159  Dao dao = new ContactsPU();
160  return dao.getResultList(
161  " select c from CommentIt c " +
162  " where accepted = FALSE " +
163  " order by dateCreation "
164  );
165  }

◆ remove()

static void org.turro.commentit.CommentItUtil.remove ( String  id)
static

Definition at line 103 of file CommentItUtil.java.

103  {
104  Dao dao = new ContactsPU();
105  dao.executeUpdate(
106  " delete from CommentIt c " +
107  " where c.id = '" + id + "'"
108  );
109  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: