K požadavku se ukládá aktuální nastavení procesu schválení, takže změna

nastavení neovlivní existující požadavky. 
refs #108 
refs #100
multitenant
Josef Rokos 11 years ago
parent 773ba7c4a8
commit 365290f856

@ -21,9 +21,13 @@ import org.hibernate.annotations.LazyCollectionOption;
@MappedSuperclass
public class RequirementBase extends BaseData {
@ManyToOne(fetch = FetchType.EAGER)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
private RequirementType type;
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.TRUE)
@OrderBy("WORDER")
private List<Workflow> workflow;
@Column(name = "NUMSER", unique = true)
private String numser;
@Column(name = "REQ_DATE")
@ -46,6 +50,7 @@ public class RequirementBase extends BaseData {
public RequirementBase() {
authorization = new ArrayList<AuthItem>();
workflow = new ArrayList<Workflow>();
}
public RequirementType getType() {
@ -114,4 +119,12 @@ public class RequirementBase extends BaseData {
this.centre = centre;
}
public List<Workflow> getWorkflow() {
return workflow;
}
public void setWorkflow(List<Workflow> workflow) {
this.workflow = workflow;
}
}

@ -21,7 +21,7 @@ public class RequirementType extends BaseData {
private String type;
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade = CascadeType.ALL)
@OneToMany(cascade = CascadeType.ALL, orphanRemoval=true)
@LazyCollection(LazyCollectionOption.FALSE)
@OrderBy("WORDER")
private List<Workflow> workflow;

@ -8,6 +8,8 @@ import java.util.List;
public interface RequirementBaseService<T extends RequirementBase> {
public void loadAuthItems(T data);
public void loadType(T data);
public void loadWorkflow(T data);
public void approve(T entity);
public boolean canApprove(T entity);
public List<User> getNextApprover(T entity);

@ -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;

@ -29,6 +29,7 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
tr.setReqDate(new Date());
tr.setType(reqTypeService.getTypeById(Constants.REQTYPE_BUSINESSTRIP));
tr.setState(RequirementState.NEW);
addWorkflow(tr);
return tr;
}

@ -19,6 +19,8 @@ public class RequirementSubpage<T extends RequirementBase> extends ListViewModel
@Override
protected void loadLazyData(T data) {
this.getReqService().loadAuthItems(data);
this.getReqService().loadWorkflow(data);
this.getReqService().loadType(data);
}
@Command

@ -3,7 +3,7 @@
<label value="Stav schválení: "/>
<button label="Schválit" onClick="@command('approve')" disabled="@load(not vmSub.canApprove)"/>
<vbox children="@load(vmSub.dataBean.type.workflow)">
<vbox children="@load(vmSub.dataBean.workflow)">
<template name="children">
<grid model="@load(vmSub.dataBean.authorization)">
<columns>

Loading…
Cancel
Save