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