List<GroupDefinition> groupDefinitions = Context.getProcessEngineConfiguration().getGroupDefinitions();
if (taskInstance.getAssignee() != null) {
String to = taskInstance.getAssignee();
if (!to.equals("")) {
UserTo userTo = userDefinition.findUserByUserId(to);
if (userTo != null) {
String eamil = StringUtil.getString(userTo.getPropertyValue("EMAIL"));
if (eamil != null && !eamil.equals("")) {
sendMail(eamil, mailTitle, mailContent,taskInstance);
}
}
}
} else {
String to = "";
for (IdentityLink identityLink : taskInstance.getTaskIdentityLinks()) {
if (identityLink.getUserId() != null) {
UserTo userTo = Authentication.findUserInfoByUserId(identityLink.getUserId());
if (userTo != null) {
String eamil = StringUtil.getString(userTo.getPropertyValue("EMAIL"));
if (eamil != null && !eamil.equals("")) {
// sendMail(eamil,title,mailContent);
to = to + eamil + ",";
}
}
} else {
String groupIdString = identityLink.getGroupId();
String groupTypeString = identityLink.getGroupType();
GroupTo groupTo = Authentication.findGroupByGroupIdAndType(groupIdString, groupTypeString);
if (groupTo != null) {
for (GroupDefinition groupDefinition : groupDefinitions) {
if (groupDefinition.getId().equals(groupTypeString)) {
List<UserTo> userTos = groupDefinition.findUserByGroupId(groupIdString);
for (UserTo userTo : userTos) {
if (userTo != null) {
String eamil = StringUtil.getString(userTo.getPropertyValue("EMAIL"));
if (eamil != null && !eamil.equals("")) {
// sendMail(eamil,title,mailContent);
to = to + eamil + ",";
}
}