|
|
@ -1,7 +1,10 @@
|
|
|
|
package info.bukova.isspst.services.requirement;
|
|
|
|
package info.bukova.isspst.services.requirement;
|
|
|
|
|
|
|
|
|
|
|
|
import info.bukova.isspst.Constants;
|
|
|
|
import info.bukova.isspst.Constants;
|
|
|
|
|
|
|
|
import info.bukova.isspst.Module;
|
|
|
|
|
|
|
|
import info.bukova.isspst.ModuleUtils;
|
|
|
|
import info.bukova.isspst.data.AuthItem;
|
|
|
|
import info.bukova.isspst.data.AuthItem;
|
|
|
|
|
|
|
|
import info.bukova.isspst.data.DataModel;
|
|
|
|
import info.bukova.isspst.data.JobMapping;
|
|
|
|
import info.bukova.isspst.data.JobMapping;
|
|
|
|
import info.bukova.isspst.data.RequirementBase;
|
|
|
|
import info.bukova.isspst.data.RequirementBase;
|
|
|
|
import info.bukova.isspst.data.RequirementState;
|
|
|
|
import info.bukova.isspst.data.RequirementState;
|
|
|
@ -13,11 +16,19 @@ import info.bukova.isspst.data.Workgroup;
|
|
|
|
import info.bukova.isspst.mail.MailMessage;
|
|
|
|
import info.bukova.isspst.mail.MailMessage;
|
|
|
|
import info.bukova.isspst.mail.Mailer;
|
|
|
|
import info.bukova.isspst.mail.Mailer;
|
|
|
|
import info.bukova.isspst.mail.MessageBuilder;
|
|
|
|
import info.bukova.isspst.mail.MessageBuilder;
|
|
|
|
|
|
|
|
import info.bukova.isspst.reporting.Generator;
|
|
|
|
|
|
|
|
import info.bukova.isspst.reporting.GeneratorFactory;
|
|
|
|
|
|
|
|
import info.bukova.isspst.reporting.ParamFiller;
|
|
|
|
|
|
|
|
import info.bukova.isspst.reporting.Report;
|
|
|
|
|
|
|
|
import info.bukova.isspst.reporting.ReportDefinition;
|
|
|
|
import info.bukova.isspst.services.AbstractOwnedService;
|
|
|
|
import info.bukova.isspst.services.AbstractOwnedService;
|
|
|
|
import info.bukova.isspst.services.LazyLoader;
|
|
|
|
import info.bukova.isspst.services.LazyLoader;
|
|
|
|
|
|
|
|
import info.bukova.isspst.services.Service;
|
|
|
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|
|
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
|
|
|
|
import info.bukova.isspst.signapi.SignData;
|
|
|
|
|
|
|
|
import info.bukova.isspst.storage.FileStorage;
|
|
|
|
import org.hibernate.LazyInitializationException;
|
|
|
|
import org.hibernate.LazyInitializationException;
|
|
|
|
import org.hibernate.Query;
|
|
|
|
import org.hibernate.Query;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -25,9 +36,11 @@ import org.springframework.security.access.prepost.PostFilter;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author Pepa Rokos
|
|
|
|
* @author Pepa Rokos
|
|
|
@ -50,6 +63,16 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
private UserService userService;
|
|
|
|
private UserService userService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
protected WorkgroupService workgroupService;
|
|
|
|
protected WorkgroupService workgroupService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ReportDefinition reportDefinition;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ParamFiller paramFiller;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private GeneratorFactory genFactory;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ServletContext servletContext;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private FileStorage storage;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
@ -408,4 +431,53 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
return Constants.PERM_DELETE_NEW;
|
|
|
|
return Constants.PERM_DELETE_NEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean prepareSignData(T entity, Date approveDate) {
|
|
|
|
|
|
|
|
SignData data = new SignData();
|
|
|
|
|
|
|
|
sessionData.setProperty(Constants.KEY_SIGN_DATA, data);
|
|
|
|
|
|
|
|
data.setSignGuid(UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
sessionData.setProperty(Constants.KEY_SIGN_GUID, data.getSignGuid());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reportDefinition.clear();
|
|
|
|
|
|
|
|
reportDefinition.setSingleObject(entityForReport(entity));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module module = ModuleUtils.getModule(entityForReport(entity), servletContext);
|
|
|
|
|
|
|
|
Report report = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Report r : module.getReports()) {
|
|
|
|
|
|
|
|
if (r.isSignable()) {
|
|
|
|
|
|
|
|
report = r;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (report == null) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reportDefinition.setReport(report);
|
|
|
|
|
|
|
|
reportDefinition.setService((Service<Object>) ModuleUtils.getServiceInstance(module, servletContext));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paramFiller.fill();
|
|
|
|
|
|
|
|
Generator gen = genFactory.createGenerator(reportDefinition);
|
|
|
|
|
|
|
|
data.setPdfData(gen.generate());
|
|
|
|
|
|
|
|
data.setDescription(entity.getDescription());
|
|
|
|
|
|
|
|
data.setNumser(entity.getNumser());
|
|
|
|
|
|
|
|
data.setSignDate(approveDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.getState() == RequirementState.NEW) {
|
|
|
|
|
|
|
|
data.setAreaId(1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
loadAuthItems(entity);
|
|
|
|
|
|
|
|
data.setAreaId(entity.getAuthorization().size() + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected DataModel entityForReport(T entity) {
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|