Pokud má další schvalovatel v pořadí nastaveno schvalování pouze

nadlimitních požadavků a požadavek je pod limitem, schválí se za tohoto
schvalovatele automaticky.
closes #133
multitenant
Josef Rokos 10 years ago
parent 4047418fba
commit b7967e66c0

@ -14,7 +14,7 @@ import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
public class ReqMaterialServiceImpl extends RequirementBaseServiceImpl<Requirement> implements RequirementService, RequirementBaseService<Requirement>
public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{
@Autowired
private RequirementTypeService reqTypeService;

@ -14,7 +14,7 @@ import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
public class ReqServicesServiceImpl extends RequirementBaseServiceImpl<Requirement> implements RequirementService, RequirementBaseService<Requirement>
public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{
@Autowired
private RequirementTypeService reqTypeService;

@ -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,6 +208,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
super.update(e);
if (!autoApprove(entity)) {
this.sendToApprovers(e);
SettingsData settings = settingsService.getSettings();
@ -231,6 +229,18 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
}
}
}
}
@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;

@ -3,8 +3,11 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workflow;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,4 +29,21 @@ public class RequirementServiceImpl extends
return entity;
}
@Override
protected boolean autoApprove(Requirement entity) {
List<User> approvers = this.getNextApprover(entity);
Workflow nextWf = this.getNextWorkflow(entity);
if (approvers == null || approvers.isEmpty() || nextWf == null || nextWf.getLimit() == null) {
return false;
}
if (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1) {
approve(entity, approvers.get(0));
return true;
}
return false;
}
}

Loading…
Cancel
Save