/** * @param model * @return */ public static Document getDoc(DocumentModel model) { if (model == null) { return null; } Document doc = new Document(); doc.setCreated(model.getCreated()); doc.setDescription(model.getDescription()); doc.setDocumentDate(model.getDocumentDate()); doc.setId(model.getId()); doc.setOwner(LoginHelper.get().getUser(model.getCreatedBy())); doc.setCaseNo(model.getSubject()); doc.setType(getType(model.getType())); doc.setDocumentDate(model.getDocumentDate()); doc.setPartner(model.getPartner()); doc.setPriority(model.getPriority()); doc.setValue(model.getValue()); doc.setStatus(model.getStatus()); doc.setProcessInstanceId(model.getProcessInstanceId()); if (model.getProcessInstanceId() != null) { ProcessInstanceLog log = JPAProcessInstanceDbLog.findProcessInstance(model.getProcessInstanceId()); if (log != null) doc.setDateSubmitted(log.getStart()); } if (model.getProcessInstanceId() != null) { try { JBPMHelper.get().loadProgressInfo(doc, model.getProcessInstanceId()); } catch (Exception e) { e.printStackTrace(); } } if (model.getProcessId() == null && model.getType() != null) { doc.setProcessId(model.getType().getProcessDef().getProcessId()); } else { doc.setProcessId(model.getProcessId()); } if (doc.getProcessId() != null) { doc.setProcessName(JBPMHelper.get().getProcessName(doc.getProcessId())); } doc.setSessionId(model.getSessionId()); doc.setHasAttachment(DB.getAttachmentDao().getHasAttachment(model.getId())); Collection<ADValue> values = model.getValues(); if (values != null) { for (ADValue val : values) { // val. DataType type = getDataType(val); doc.setValue(val.getFieldName(), getValue(val, type)); } } doc.setDetails(getDetails(model.getDetails())); return doc; }
private String getOwner(String ownerId) { String owner = ownerId; if (ownerId != null) { HTUser user = LoginHelper.get().getUser(ownerId); if (user != null) { owner = user.getFullName(); } } return owner; }
public void sendNotification(ADTaskNotification template, Map<String, Object> params) { String caseNo = null; String noteType = null; String documentId = null; String groupId = null; String actorId = null; String ownerId = null; Object isApproved = null; String html = null; if (template != null && !template.isUseDefaultNotification() && template.getNotificationTemplate() != null) { html = template.getNotificationTemplate(); } caseNo = (String) params.get("Subject"); // noteType = (String) params.get("NotificationType"); // NotificationType type = NotificationType.valueOf(noteType); documentId = (String) params.get("DocumentId"); groupId = (String) params.get("GroupId"); actorId = (String) params.get("ActorId"); ownerId = (String) params.get("OwnerId"); // isApproved = params.get("isApproved"); String[] groups = null; if (groupId != null) { groups = groupId.split(","); } Document doc = params.get("document") == null ? null : (Document) params.get("document"); try { doc = DocumentDaoHelper.getDocument(Long.parseLong(documentId)); } catch (Exception e) { } log.debug("Class : " + this.getClass()); log.debug("Subject : " + caseNo); log.debug("NotificationType : " + noteType); log.debug("DocumentId : " + documentId); log.debug("GroupId : " + groupId); log.debug("ActorId : " + actorId); log.debug("OwnerId : " + ownerId); List<HTUser> receipients = null; // notification.setTargetUserId(targetUserId); if (actorId != null && !actorId.trim().isEmpty()) { receipients = new ArrayList<>(); receipients.add(LoginHelper.get().getUser(actorId)); } else if (groups != null) { receipients = LoginHelper.get().getUsersForGroups(groups); } // List<HTUser> owner = new ArrayList<>(); // owner.add(LoginHelper.get().getUser(ownerId)); String emailSubject = (doc.getType() == null ? "Work item" : doc.getType().getDisplayName()) + " " + doc.getCaseNo(); if (template != null) { emailSubject = parse(template.getSubject(), doc); } params.put("emailSubject", emailSubject); sendMail(html, doc, receipients, params); log.info("EMAILSUBJECT = " + emailSubject); log.info("EMAILRECIEPIENTS = " + receipients); }