Search in sources :

Example 1 with CommentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.CommentEntity in project camunda-bpm-platform by camunda.

the class AddCommentCmd method execute.

public Comment execute(CommandContext commandContext) {
    if (processInstanceId == null && taskId == null) {
        throw new ProcessEngineException("Process instance id and task id is null");
    }
    ensureNotNull("Message", message);
    String userId = commandContext.getAuthenticatedUserId();
    CommentEntity comment = new CommentEntity();
    comment.setUserId(userId);
    comment.setType(CommentEntity.TYPE_COMMENT);
    comment.setTime(ClockUtil.getCurrentTime());
    comment.setTaskId(taskId);
    comment.setProcessInstanceId(processInstanceId);
    comment.setAction(Event.ACTION_ADD_COMMENT);
    String eventMessage = message.replaceAll("\\s+", " ");
    if (eventMessage.length() > 163) {
        eventMessage = eventMessage.substring(0, 160) + "...";
    }
    comment.setMessage(eventMessage);
    comment.setFullMessage(message);
    commandContext.getCommentManager().insert(comment);
    return comment;
}
Also used : ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) CommentEntity(org.camunda.bpm.engine.impl.persistence.entity.CommentEntity)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 CommentEntity (org.camunda.bpm.engine.impl.persistence.entity.CommentEntity)1