public SecuredMessageTriggerBean execute(SecuredMessageTriggerBean message) throws GranException { SecuredTaskBean task1 = message.getTask(); HashMap udf = new HashMap(); udf.put("Спринт", task1.getName() + " [#" + task1.getNumber() + "]"); String readyState = SCRUM_ITEM_STATE_READY; String planOperation = SCRUM_ITEM_OPERATION_RUN; KernelManager.getFind().findMstatus(planOperation); Long budget = task1.getBudget(); Long calculatedBudget = 0L; for (SecuredTaskBean task : message.getTask().getChildren()) { calculatedBudget += task.getBudget(); } if (budget > 0) { if (budget >= calculatedBudget) { for (SecuredTaskBean task : message.getTask().getChildren()) { if (task.getStatusId().equals(readyState)) TriggerManager.getInstance() .createMessage( message.getSecure(), task.getId(), planOperation, message.getDescription(), 0L, task.getHandlerUserId(), task.getHandlerGroupId(), null, null, message.getDeadline() == null ? task1.getDeadline() : message.getDeadline(), task.getBudget(), udf, false, null); } return message; } else { throw new UserException( "Бюджет спринта меньше бюджета входящих в него задач. Переопределите бюджет или состав спринта", true); } } else throw new UserException("Сначала определите бюджет спринта", true); }
public SecuredTaskTriggerBean execute(SecuredTaskTriggerBean task) throws GranException { String s = task.getDescription(); // String userStatusId = task.getSubmitter().getPrstatusId(); if (s != null && s.length() > 0) { String emailPattern = "From:\\s*\\\"?(\\S+\\s*\\S+[^\\\"])?\\\"?\\s+(<|<)?(([-a-z0-9!#$%&'*+/=?^_`{|}~]+(\\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([a-z0-9.]+))(>|>)?"; // From: [email protected] // From: Maxim Vasenkov <*****@*****.**> // From: Maxim Vasenkov <[email protected]> // From: Winzard <*****@*****.**> // From: Admin <admin@localhost> // From: "Максим Васенков" <*****@*****.**> // From: "Максим Васенков" <[email protected]> Pattern pat = Pattern.compile(emailPattern); Matcher mat = pat.matcher(s); if (mat.find()) { String userName = mat.group(1); String userEmail = mat.group(3); if (userName == null) userName = mat.group(4); String fId = KernelManager.getUser() .findUserIdByEmailNameProject(userEmail, userEmail, task.getParentId()); if (fId == null) { String id = AdapterManager.getInstance() .getSecuredUserAdapterManager() .createUser( task.getSecure(), Null.beNull(task.getSubmitterId()), userEmail, userName, Null.beNull(SUBMITTER_ROLE_ID)); AdapterManager.getInstance() .getSecuredUserAdapterManager() .updateUser( task.getSecure(), id, userEmail, userName, null, userEmail, SUBMITTER_ROLE_ID, task.getSubmitterId(), task.getSecure().getUser().getTimezone(), task.getSecure().getUser().getLocale(), task.getSecure().getUser().getCompany(), null, null, null, null, true); String aclid = AdapterManager.getInstance() .getSecuredAclAdapterManager() .createAcl(task.getSecure(), task.getParentId(), null, id, null); AdapterManager.getInstance() .getSecuredAclAdapterManager() .updateTaskAcl(task.getSecure(), aclid, SUBMITTER_ROLE_ID, false); if (id != null) task.setSubmitterId(id); } } } return task; }