|
|
@ -182,10 +182,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void approve(T entity, User user) {
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
@PreAuthorize("this.canApprove(#entity)")
|
|
|
|
|
|
|
|
public void approve(T entity) {
|
|
|
|
|
|
|
|
T e = (T) dao.getById(entity.getId());
|
|
|
|
T e = (T) dao.getById(entity.getId());
|
|
|
|
|
|
|
|
|
|
|
|
Workflow wf = getNextWorkflow(e);
|
|
|
|
Workflow wf = getNextWorkflow(e);
|
|
|
@ -195,7 +192,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
|
|
|
|
|
|
|
|
Role role = wf.getRole();
|
|
|
|
Role role = wf.getRole();
|
|
|
|
AuthItem auth = new AuthItem();
|
|
|
|
AuthItem auth = new AuthItem();
|
|
|
|
auth.setApprover(getLoggedInUser());
|
|
|
|
auth.setApprover(user);
|
|
|
|
auth.setRole(role);
|
|
|
|
auth.setRole(role);
|
|
|
|
auth.setAuthDate(new Date());
|
|
|
|
auth.setAuthDate(new Date());
|
|
|
|
|
|
|
|
|
|
|
@ -211,26 +208,39 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
|
|
|
|
|
|
|
|
super.update(e);
|
|
|
|
super.update(e);
|
|
|
|
|
|
|
|
|
|
|
|
this.sendToApprovers(e);
|
|
|
|
if (!autoApprove(entity)) {
|
|
|
|
|
|
|
|
this.sendToApprovers(e);
|
|
|
|
SettingsData settings = settingsService.getSettings();
|
|
|
|
|
|
|
|
MailMessage message = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.getOwnedBy().getEmail() != null
|
|
|
|
|
|
|
|
&& !e.getOwnedBy().getEmail().isEmpty()
|
|
|
|
|
|
|
|
&& e.getOwnedBy().isNotify()) {
|
|
|
|
|
|
|
|
if (e.getState() == RequirementState.APPROVED && settings.getConfReqTemplate() != null) {
|
|
|
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getConfReqTemplate(), e);
|
|
|
|
|
|
|
|
} else if (settings.getAuthReqTemplate() != null) {
|
|
|
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getAuthReqTemplate(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (message != null) {
|
|
|
|
SettingsData settings = settingsService.getSettings();
|
|
|
|
message.setTo(e.getOwnedBy().getEmail());
|
|
|
|
MailMessage message = null;
|
|
|
|
mailer.send(message);
|
|
|
|
|
|
|
|
|
|
|
|
if (e.getOwnedBy().getEmail() != null
|
|
|
|
|
|
|
|
&& !e.getOwnedBy().getEmail().isEmpty()
|
|
|
|
|
|
|
|
&& e.getOwnedBy().isNotify()) {
|
|
|
|
|
|
|
|
if (e.getState() == RequirementState.APPROVED && settings.getConfReqTemplate() != null) {
|
|
|
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getConfReqTemplate(), e);
|
|
|
|
|
|
|
|
} else if (settings.getAuthReqTemplate() != null) {
|
|
|
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getAuthReqTemplate(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (message != null) {
|
|
|
|
|
|
|
|
message.setTo(e.getOwnedBy().getEmail());
|
|
|
|
|
|
|
|
mailer.send(message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
@PreAuthorize("this.canApprove(#entity)")
|
|
|
|
|
|
|
|
public void approve(T entity) {
|
|
|
|
|
|
|
|
approve(entity, getLoggedInUser());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean autoApprove(T entity) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
@ -243,7 +253,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Workflow getNextWorkflow(T e) {
|
|
|
|
protected Workflow getNextWorkflow(T e) {
|
|
|
|
AuthItem authItem = null;
|
|
|
|
AuthItem authItem = null;
|
|
|
|
if (e.getWorkflow() == null) {
|
|
|
|
if (e.getWorkflow() == null) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|