multitenant
František Přibyl 10 years ago
commit aa8a0ebd2a

@ -6,6 +6,9 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
@ -25,9 +28,16 @@ public class RequirementType extends BaseData {
@LazyCollection(LazyCollectionOption.FALSE) @LazyCollection(LazyCollectionOption.FALSE)
@OrderBy("CENTRE, WORDER") @OrderBy("CENTRE, WORDER")
private List<Workflow> workflow; 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() { public RequirementType() {
workflow = new ArrayList<Workflow>(); workflow = new ArrayList<Workflow>();
offeredCentres = new ArrayList<Workgroup>();
} }
public RequirementType(String type, String description) { public RequirementType(String type, String description) {
@ -68,4 +78,20 @@ public class RequirementType extends BaseData {
return false; 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;
}
} }

@ -1,10 +1,14 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.util.List;
public interface RequirementTypeService extends Service<RequirementType> { public interface RequirementTypeService extends Service<RequirementType> {
public RequirementType getTypeById(String id); public RequirementType getTypeById(String id);
public List<Workgroup> filterCentres(RequirementType reqType, List<Workgroup> source);
} }

@ -1,8 +1,12 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import java.util.ArrayList;
import java.util.List;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
public class RequirementTypeServiceImpl extends AbstractOwnedService<RequirementType> implements RequirementTypeService { public class RequirementTypeServiceImpl extends AbstractOwnedService<RequirementType> implements RequirementTypeService {
@ -13,4 +17,23 @@ public class RequirementTypeServiceImpl extends AbstractOwnedService<Requiremen
return selectSingle("from RequirementType where type = '" + id + "'"); return selectSingle("from RequirementType where type = '" + id + "'");
} }
@Override
public List<Workgroup> filterCentres(RequirementType reqType,
List<Workgroup> source) {
if (!reqType.getLimitCentres()) {
return source;
}
List<Workgroup> filtered = new ArrayList<Workgroup>();
for (Workgroup wg : source) {
if (reqType.getOfferedCentres().contains(wg)) {
filtered.add(wg);
}
}
return filtered;
}
} }

@ -5,6 +5,7 @@ import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementItem; import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.RequirementSubject; import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.requirement.RequirementTypeService;
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.ui.BigDecimalConverter; import info.bukova.isspst.ui.BigDecimalConverter;
@ -36,6 +37,9 @@ public class RequirementForm extends FormViewModel<Requirement>
@WireVariable @WireVariable
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
@WireVariable
private RequirementTypeService reqTypeService;
private RequirementItem selectedItem; private RequirementItem selectedItem;
@ -46,10 +50,12 @@ public class RequirementForm extends FormViewModel<Requirement>
private RequirementFormValidator requirementFormValidator; private RequirementFormValidator requirementFormValidator;
private List<RequirementItem> syncItems; private List<RequirementItem> syncItems;
private List<Workgroup> centres;
public List<Workgroup> getCentres() public List<Workgroup> getCentres()
{ {
return workgroupService.getUserCentres(userService.getCurrent()); return centres;
} }
public RequirementItem getSelectedItem() public RequirementItem getSelectedItem()
@ -91,7 +97,7 @@ public class RequirementForm extends FormViewModel<Requirement>
{ {
this.requirementFormValidator = requirementFormValidator; this.requirementFormValidator = requirementFormValidator;
} }
@Init(superclass = true) @Init(superclass = true)
public void init() public void init()
{ {
@ -99,6 +105,7 @@ public class RequirementForm extends FormViewModel<Requirement>
this.setBigDecimalConverter(new BigDecimalConverter()); this.setBigDecimalConverter(new BigDecimalConverter());
this.setRequirementFormValidator(new RequirementFormValidator()); this.setRequirementFormValidator(new RequirementFormValidator());
this.setSyncItems(this.getDataBean().getItems()); this.setSyncItems(this.getDataBean().getItems());
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
} }
public List<RequirementItem> getSyncItems() public List<RequirementItem> getSyncItems()

@ -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() { public void refresh() {
reqTypeService.update(selected); 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() { public Workflow getWgSelWorkflow() {
return wgSelWorkflow; return wgSelWorkflow;

@ -12,6 +12,7 @@ import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.requirement.RequirementTypeService;
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;
@ -26,6 +27,8 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
@WireVariable @WireVariable
private GlobalSettingsService settingsService; private GlobalSettingsService settingsService;
@WireVariable
private RequirementTypeService reqTypeService;
private List<Workgroup> centres; private List<Workgroup> centres;
private List<User> users; private List<User> users;
private List<User> passengers; private List<User> passengers;
@ -34,7 +37,7 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
@Init(superclass = true) @Init(superclass = true)
public void init() { public void init() {
centres = workgroupService.getUserCentres(userService.getCurrent()); centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
users = userService.getAll(); users = userService.getAll();
passengers = getDataBean().getPassengers(); passengers = getDataBean().getPassengers();
validator = new TripRequirementFormValidator(); validator = new TripRequirementFormValidator();

@ -137,6 +137,10 @@ CentreWorkflow=Schválení ve středisku
LimitFormTitle=Limit pro schválení LimitFormTitle=Limit pro schválení
Limit=Limit: Limit=Limit:
OverLimit=Pouze nadlimitní OverLimit=Pouze nadlimitní
Centres=Střediska
OfferSelectedOnly=Nabízet pouze vybraná střediska
Select=Vybrat
OfferedCentres=Nabízená střediska
Number=Číslo: Number=Číslo:
Prefix=Prefix: Prefix=Prefix:

@ -0,0 +1,19 @@
<?page title="${labels.OfferedCentres}" contentType="text/html;charset=UTF-8"?>
<zk>
<window border="normal" apply="org.zkoss.bind.BindComposer"
id="editWin"
width="500px"
closable="true"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.OfferedCentresVM')">
<caption zclass="form-caption" label="${labels.OfferedCentres}" />
<vbox children="@load(vm.wgChecks.checks)">
<template name="children">
<checkbox label="@load(each.member)" checked="@bind(each.checked)"/>
</template>
</vbox>
<include src="/app/formButtons.zul" />
</window>
</zk>

@ -13,6 +13,24 @@
</template> </template>
</combobox> </combobox>
</hbox> </hbox>
<groupbox mold="3d">
<caption label="${labels.Centres}"/>
<vbox>
<checkbox label="${labels.OfferSelectedOnly}"
checked="@bind(vm.selected.limitCentres)"
disabled="@load(empty vm.selected)"
onClick="@command('clearCentres')" />
<button label="${labels.Select}"
disabled="@load(empty vm.selected or not vm.selected.limitCentres)"
onClick="@command('centresDialog')"
sclass="nicebutton"/>
<hbox children="@load(vm.selected.offeredCentres)">
<template name="children">
<label value="@load(each.fullName.concat(', '))"/>
</template>
</hbox>
</vbox>
</groupbox>
<hbox> <hbox>
<div hflex="1"> <div hflex="1">
<groupbox mold="3d" hflex="1"> <groupbox mold="3d" hflex="1">

Loading…
Cancel
Save