Umožněno nastavení nabízených středisek k typům požadavků.

refs #130
This commit is contained in:
2014-08-31 15:48:55 +02:00
parent b1664ca656
commit 60accd156c
6 changed files with 133 additions and 0 deletions
@@ -6,6 +6,9 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
@@ -25,9 +28,16 @@ public class RequirementType extends BaseData {
@LazyCollection(LazyCollectionOption.FALSE)
@OrderBy("CENTRE, WORDER")
private List<Workflow> workflow;
@Column(name = "LIMIT_CENTRES")
private Boolean limitCentres;
@ManyToMany
@LazyCollection(LazyCollectionOption.FALSE)
@JoinTable(name="REQUIREMENTTYPE_WORKGROUP", joinColumns={@JoinColumn(name="REQUIREMENTTYPE_ID")}, inverseJoinColumns={@JoinColumn(name="WORKGROUP_ID")})
private List<Workgroup> offeredCentres;
public RequirementType() {
workflow = new ArrayList<Workflow>();
offeredCentres = new ArrayList<Workgroup>();
}
public RequirementType(String type, String description) {
@@ -68,4 +78,20 @@ public class RequirementType extends BaseData {
return false;
}
public Boolean getLimitCentres() {
return limitCentres;
}
public void setLimitCentres(Boolean limitCentres) {
this.limitCentres = limitCentres;
}
public List<Workgroup> getOfferedCentres() {
return offeredCentres;
}
public void setOfferedCentres(List<Workgroup> offeredCentres) {
this.offeredCentres = offeredCentres;
}
}
@@ -0,0 +1,49 @@
package info.bukova.isspst.ui.requirement;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ExecutionArgParam;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;
import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.ListChecks;
public class OfferedCentresVM {
private RequirementType selectedType;
@WireVariable
private WorkgroupService workgroupService;
private ListChecks<Workgroup> wgChecks;
@Init
public void init(@ExecutionArgParam("type") RequirementType type) {
this.selectedType = type;
wgChecks = new ListChecks<Workgroup>(selectedType.getOfferedCentres(), workgroupService.getCentres());
}
@Command
public void save(@BindingParam("window") Window window) {
window.detach();
}
public boolean isCanSave() {
return true;
}
public RequirementType getSelectedType() {
return selectedType;
}
public void setSelectedType(RequirementType selectedType) {
this.selectedType = selectedType;
}
public ListChecks<Workgroup> getWgChecks() {
return wgChecks;
}
}
@@ -242,6 +242,23 @@ public class RequirementTypesVM {
public void refresh() {
reqTypeService.update(selected);
}
@Command
public void centresDialog() {
Map<String, RequirementType> param = new HashMap<String, RequirementType>();
param.put("type", selected);
Window win = (Window) Executions.createComponents("/settings/workflow/offeredCentres.zul", null, param);
win.doModal();
}
@Command
@NotifyChange("selected")
public void clearCentres() {
if (!selected.getLimitCentres()) {
selected.getOfferedCentres().clear();
refresh();
}
}
public Workflow getWgSelWorkflow() {
return wgSelWorkflow;