|
|
|
@ -5,23 +5,58 @@ import info.bukova.isspst.data.JobMapping;
|
|
|
|
|
import info.bukova.isspst.data.RequirementBase;
|
|
|
|
|
import info.bukova.isspst.data.RequirementState;
|
|
|
|
|
import info.bukova.isspst.data.Role;
|
|
|
|
|
import info.bukova.isspst.data.SettingsData;
|
|
|
|
|
import info.bukova.isspst.data.User;
|
|
|
|
|
import info.bukova.isspst.data.Workflow;
|
|
|
|
|
import info.bukova.isspst.data.Workgroup;
|
|
|
|
|
import info.bukova.isspst.mail.MailMessage;
|
|
|
|
|
import info.bukova.isspst.mail.Mailer;
|
|
|
|
|
import info.bukova.isspst.mail.MessageBuilder;
|
|
|
|
|
import info.bukova.isspst.services.AbstractOwnedService;
|
|
|
|
|
import info.bukova.isspst.services.LazyLoader;
|
|
|
|
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.hibernate.LazyInitializationException;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
public abstract class RequirementBaseServiceImpl<T extends RequirementBase> extends
|
|
|
|
|
AbstractOwnedService<T> implements RequirementBaseService<T> {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private Mailer mailer;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MessageBuilder messageBuilder;
|
|
|
|
|
@Autowired
|
|
|
|
|
private GlobalSettingsService settingsService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void add(T entity) {
|
|
|
|
|
super.add(entity);
|
|
|
|
|
|
|
|
|
|
this.sendToApprovers(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendToApprovers(T entity) {
|
|
|
|
|
SettingsData settings = settingsService.getSettings();
|
|
|
|
|
List<User> approvers = this.getNextApprover(entity);
|
|
|
|
|
if (approvers != null && !approvers.isEmpty()) {
|
|
|
|
|
MailMessage message = messageBuilder.buildMessage(settings.getNewReqTemplate(), entity);
|
|
|
|
|
message.setTo(userService.getEmailsForSend(approvers));
|
|
|
|
|
|
|
|
|
|
mailer.send(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void addWorkflow(T entity) {
|
|
|
|
|
if (entity.getType() == null) {
|
|
|
|
|
return;
|
|
|
|
@ -153,6 +188,23 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
|
entity.getAuthorization().add(auth);
|
|
|
|
|
|
|
|
|
|
this.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) {
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getConfReqTemplate(), e);
|
|
|
|
|
} else {
|
|
|
|
|
message = messageBuilder.buildMessage(settings.getAuthReqTemplate(), e);
|
|
|
|
|
}
|
|
|
|
|
message.setTo(e.getOwnedBy().getEmail());
|
|
|
|
|
mailer.send(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|