use of org.jbpm.casemgmt.api.model.instance.CommentInstance in project jbpm by kiegroup.
the class CommentNotificationEventListener method buildAndPublishNotification.
protected void buildAndPublishNotification(CaseCommentEvent event) {
if (publishers.isEmpty()) {
logger.debug("No publishers available, skipping comment notifications");
return;
}
CommentInstance comment = event.getComment();
List<String> mentionedRoles = extractMentionedRoles(comment.getComment());
if (mentionedRoles.isEmpty()) {
logger.debug("No one has been mentioned in the comment, skipping comment notification");
return;
}
logger.debug("Found mentions {} in comment {}", mentionedRoles, comment.getId());
StringBuilder commentContent = new StringBuilder(comment.getComment());
Set<OrganizationalEntity> recipients = collectOrgEntitiesByRole(mentionedRoles, event, commentContent);
String notificationSubject = MessageFormat.format(subject, event.getCaseId());
Map<String, Object> parameters = buildParams(event, commentContent);
for (NotificationPublisher publisher : publishers) {
if (!publisher.isActive()) {
logger.debug("Publisher {} is not active, skipping it", publisher);
continue;
}
try {
publisher.publish(sender, notificationSubject, recipients, template, parameters);
} catch (IllegalArgumentException e) {
publisher.publish(sender, notificationSubject, recipients, commentContent.toString());
}
}
}
use of org.jbpm.casemgmt.api.model.instance.CommentInstance in project jbpm by kiegroup.
the class CaseFileInstanceMarshallingStrategy method unmarshal.
@SuppressWarnings("unchecked")
@Override
public Object unmarshal(Context context, ObjectInputStream is, byte[] object, ClassLoader classloader) throws IOException, ClassNotFoundException {
logger.debug("About to read {} bytes to unmarshal CaseFileInstance", (object == null ? 0 : object.length));
Map<String, Object> caseFileContent = (Map<String, Object>) caseFileMarshaller.unmarshal(context, is, object, classloader);
CaseFileInstanceImpl caseFileInstance = new CaseFileInstanceImpl();
caseFileInstance.setCaseId((String) caseFileContent.get(CASE_ID_KEY));
caseFileInstance.setDefinitionId((String) caseFileContent.get(CASE_DEF_ID_KEY));
caseFileInstance.setCaseStartDate((Date) caseFileContent.get(CASE_START_KEY));
caseFileInstance.setCaseEndDate((Date) caseFileContent.get(CASE_END_KEY));
caseFileInstance.setCaseReopenDate((Date) caseFileContent.get(CASE_REOPEN_KEY));
caseFileInstance.setRolesAssignments((Map<String, CaseRoleInstance>) caseFileContent.get(CASE_ROLE_ASSIGNMENTS_KEY));
caseFileInstance.setComments((List<CommentInstance>) caseFileContent.get(CASE_COMMENTS_KEY));
logger.debug("CaseFileInstance meta data unmarshalled properly into {}", caseFileInstance);
List<SerializedContent> caseDataContent = (List<SerializedContent>) caseFileContent.get(CASE_DATA_KEY);
logger.debug("About to read serialized content {}", caseDataContent);
for (SerializedContent serializedContent : caseDataContent) {
ObjectMarshallingStrategy marshaller = marshallersByName.get(serializedContent.getMarshaller());
logger.debug("Marshaller for {} is of type {}", serializedContent, marshaller);
Object value = marshaller.unmarshal(context, is, serializedContent.getContent(), classloader);
caseFileInstance.add(serializedContent.getName(), value);
logger.debug("Data unmarshalled into {} and put into case file under '{}' name", value, serializedContent.getName());
}
caseFileInstance.setAccessRestrictions((Map<String, List<String>>) caseFileContent.get(CASE_DATA_RESTRICTIONS_KEY));
caseFileInstance.setParentInstanceId((Long) caseFileContent.get(CASE_PARENT_INSTANCE_ID_KEY));
caseFileInstance.setParentWorkItemId((Long) caseFileContent.get(CASE_PARENT_WORK_ITEM_ID_KEY));
logger.debug("Unmarshal of CaseFileInstance completed - result {}", caseFileInstance);
return caseFileInstance;
}
Aggregations