|
|
|
@ -20,6 +20,21 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
public abstract class RequirementBaseServiceImpl<T extends RequirementBase> extends
|
|
|
|
|
AbstractOwnedService<T> implements RequirementBaseService<T> {
|
|
|
|
|
|
|
|
|
|
protected void addWorkflow(T entity) {
|
|
|
|
|
if (entity.getType() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Workflow w : entity.getType().getWorkflow()) {
|
|
|
|
|
Workflow workflow = new Workflow();
|
|
|
|
|
workflow.setCentre(w.getCentre());
|
|
|
|
|
workflow.setLimit(w.getLimit());
|
|
|
|
|
workflow.setOrder(w.getOrder());
|
|
|
|
|
workflow.setRole(w.getRole());
|
|
|
|
|
entity.getWorkflow().add(workflow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public List<User> getNextApprover(T entity) {
|
|
|
|
@ -60,6 +75,23 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
|
entity.setAuthorization(e.getAuthorization());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void loadType(T data) {
|
|
|
|
|
T e = dao.getById(data.getId());
|
|
|
|
|
e.getType().getType();
|
|
|
|
|
data.setType(e.getType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void loadWorkflow(T data) {
|
|
|
|
|
T e = dao.getById(data.getId());
|
|
|
|
|
e.getWorkflow().size();
|
|
|
|
|
data.setWorkflow(e.getWorkflow());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
@PreAuthorize("this.canApprove(#entity)")
|
|
|
|
@ -103,16 +135,20 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|
|
|
|
|
|
|
|
|
private Workflow getNextWorkflow(T e) {
|
|
|
|
|
AuthItem authItem = null;
|
|
|
|
|
if (e.getWorkflow() == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.getAuthorization().size() > 0) {
|
|
|
|
|
authItem = e.getAuthorization().get(e.getAuthorization().size() - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Workflow wf = null;
|
|
|
|
|
for (int i = 0; i < e.getType().getWorkflow().size(); i++) {
|
|
|
|
|
wf = e.getType().getWorkflow().get(i);
|
|
|
|
|
for (int i = 0; i < e.getWorkflow().size(); i++) {
|
|
|
|
|
wf = e.getWorkflow().get(i);
|
|
|
|
|
if (authItem != null && wf.getRole().equals(authItem.getRole())) {
|
|
|
|
|
if (i + 1 < e.getType().getWorkflow().size()) {
|
|
|
|
|
wf = e.getType().getWorkflow().get(i + 1);
|
|
|
|
|
if (i + 1 < e.getWorkflow().size()) {
|
|
|
|
|
wf = e.getWorkflow().get(i + 1);
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|