use of com.serotonin.m2m2.vo.comment.UserCommentVO in project ma-modules-public by infiniteautomation.
the class EventInstanceModel method setComments.
@JsonSetter
public void setComments(List<UserCommentModel> commentModels) {
List<UserCommentVO> comments = this.data.getEventComments();
if (comments == null) {
comments = new ArrayList<UserCommentVO>();
this.data.setEventComments(comments);
}
for (UserCommentModel model : commentModels) {
comments.add(model.getDataAsComment());
}
}
use of com.serotonin.m2m2.vo.comment.UserCommentVO in project ma-modules-public by infiniteautomation.
the class EventInstanceModel method getComments.
@JsonGetter
public List<UserCommentModel> getComments() {
List<UserCommentModel> commentModels = new ArrayList<UserCommentModel>();
List<UserCommentVO> comments = this.data.getEventComments();
if (comments == null)
return null;
for (UserCommentVO comment : comments) {
commentModels.add(new UserCommentModel(comment));
}
return commentModels;
}
use of com.serotonin.m2m2.vo.comment.UserCommentVO in project ma-modules-public by infiniteautomation.
the class ReportDao method getReportInstanceEvents.
public List<EventInstance> getReportInstanceEvents(int instanceId) {
// Get the events.
final List<EventInstance> events = query(EVENT_SELECT, new Object[] { instanceId }, new EventDao.EventInstanceRowMapper());
// Add in the comments.
ejt.query(EVENT_COMMENT_SELECT, new Object[] { instanceId, UserCommentVO.TYPE_EVENT }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
// Create the comment
UserCommentVO c = new UserCommentVO();
c.setUsername(rs.getString(1));
c.setTs(rs.getLong(3));
c.setComment(rs.getString(4));
// Find the event and add the comment
int eventId = rs.getInt(2);
for (EventInstance event : events) {
if (event.getId() == eventId) {
if (event.getEventComments() == null)
event.setEventComments(new ArrayList<UserCommentVO>());
event.addEventComment(c);
}
}
}
});
// Done
return events;
}
use of com.serotonin.m2m2.vo.comment.UserCommentVO in project ma-core-public by infiniteautomation.
the class BaseDwr method addUserComment.
/**
* Logs a user comment after validation.
*
* @param eventId
* @param comment
* @return
*/
@DwrPermission(user = true)
public UserCommentVO addUserComment(int typeId, int referenceId, String comment) {
if (StringUtils.isBlank(comment))
return null;
User user = Common.getHttpUser();
UserCommentVO c = new UserCommentVO();
c.setXid(UserCommentDao.instance.generateUniqueXid());
c.setComment(comment);
c.setTs(Common.timer.currentTimeMillis());
c.setUserId(user.getId());
c.setUsername(user.getUsername());
c.setReferenceId(referenceId);
if (typeId == UserCommentVO.TYPE_EVENT) {
c.setCommentType(UserCommentVO.TYPE_EVENT);
EventDao.instance.insertEventComment(c);
} else if (typeId == UserCommentVO.TYPE_POINT) {
c.setCommentType(UserCommentVO.TYPE_POINT);
UserCommentDao.instance.save(c);
} else
throw new ShouldNeverHappenException("Invalid comment type: " + typeId);
return c;
}
use of com.serotonin.m2m2.vo.comment.UserCommentVO in project ma-core-public by infiniteautomation.
the class EventInstanceVO method getCommentsHTML.
/**
* Construct the comments html
* @return
*/
public String getCommentsHTML() {
StringBuilder builder = new StringBuilder("");
if (eventComments != null) {
builder.append("</br>");
for (UserCommentVO comment : this.eventComments) {
builder.append("<span class='copyTitle'>");
builder.append("<img style='padding-right: 5px' src='/images/comment.png' title='").append(Common.translate("notes.note")).append("'/>");
builder.append(DeltamationCommon.formatDate(comment.getTs())).append(" ");
builder.append(Common.translate("notes.by")).append(" ");
if (comment.getUsername() == null)
builder.append(Common.translate("common.deleted"));
else
builder.append(comment.getUsername());
builder.append("</span></br>");
builder.append(comment.getComment()).append("</br>");
}
}
return builder.toString();
}
Aggregations