Conflicts:
	src/main/java/info/bukova/isspst/services/requirement/RequirementService.java
	src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java
multitenant
Josef Rokos 10 years ago
commit f05318b9ba

@ -131,4 +131,20 @@ public abstract class RequirementSubject implements OwnedDataModel {
this.valid = valid; this.valid = valid;
} }
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof RequirementSubject)
{
RequirementSubject item = (RequirementSubject) obj;
return (this.getId() == item.getId());
}
}
return false;
}
} }

@ -7,5 +7,6 @@ import info.bukova.isspst.data.Requirement;
public interface RequirementService extends RequirementBaseService<Requirement> public interface RequirementService extends RequirementBaseService<Requirement>
{ {
public void loadGroups(Requirement req);
public List<JoinedItem> getItemsForOrder(); public List<JoinedItem> getItemsForOrder();
} }

@ -5,6 +5,7 @@ import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementItem; import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workflow; import info.bukova.isspst.data.Workflow;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
@ -73,4 +74,53 @@ public class RequirementServiceImpl extends
return items; return items;
} }
/*
* Lazy load pro načtení seznamu skupin materiálu nebo služeb do comba.
* Ošetřuje se zde případné neexistující vazby na ID smazaných skupin
* materiálu nebo služeb.
*
* @see
* info.bukova.isspst.services.requirement.RequirementService#loadGroups
* (info.bukova.isspst.data.Requirement)
*/
@Transactional
@LazyLoader("form")
@Override
public void loadGroups(Requirement req)
{
if (req == null)
{
return;
}
Requirement reqDb = this.getById(req.getId());
// Načíst položky požadavku
List<RequirementItem> items = reqDb.getItems();
for (int i = 0; i < items.size(); i++)
{
RequirementItem item = items.get(i);
try
{
// K položce získat skupinu materiálnu nebo služby
RequirementSubject subject = item.getReqSubject();
// Pokud ID skupiny nebylo nalezeno, padá do výjimky
// Pokud ID skupiny bylo nalezeno, přinutí zavolání metody
// načíst záznam se skupinou = lazy load
subject.getCode();
// Zapsat načtená data o skupině
item.setReqSubject(subject);
}
catch (Throwable e)
{
item.setReqSubject(null);
}
}
// Zaktualizovat položky záznamu tak, aby byly odkazy na skupiny
// materiálů a služeb konzistentní
req.setItems(items);
}
} }

@ -1,21 +1,34 @@
package info.bukova.isspst.ui.main.orders.material; package info.bukova.isspst.ui.main.orders.material;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.ui.main.orders.requirements.RequirementForm; import info.bukova.isspst.ui.main.orders.requirements.RequirementForm;
import info.bukova.isspst.ui.main.orders.services.ReqServicesForm;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window; import org.zkoss.zul.Window;
public class ReqMaterialForm extends RequirementForm public class ReqMaterialForm extends RequirementForm
{ {
// private final static Logger log = @SuppressWarnings("unused")
// LoggerFactory.getLogger(ReqServicesForm.class.getName()); private final static Logger log = LoggerFactory.getLogger(ReqServicesForm.class.getName());
@WireVariable
private MaterialService materialService;
@SuppressWarnings("unchecked")
@Init(superclass = true) @Init(superclass = true)
public void init() public void init()
{ {
super.init(); // Získat seznam všech skupin materiálu pro výběr z comba
this.setRequirementGroups((List<RequirementSubject>) (List<?>) materialService.getAll());
} }
@Command @Command

@ -45,6 +45,21 @@ public class RequirementForm extends FormViewModel<Requirement>
@WireVariable @WireVariable
private RequirementService requirementService; private RequirementService requirementService;
/**
* Seznam obsahující kód a název skupiny materálu/služby
*/
private List<RequirementSubject> requirementGroups;
public List<RequirementSubject> getRequirementGroups()
{
return requirementGroups;
}
public void setRequirementGroups(List<RequirementSubject> requirementGroups)
{
this.requirementGroups = requirementGroups;
}
private RequirementItem selectedItem; private RequirementItem selectedItem;
private int selItemIndex; private int selItemIndex;
@ -103,7 +118,7 @@ public class RequirementForm extends FormViewModel<Requirement>
} }
@Init(superclass = true) @Init(superclass = true)
public void init() public void initRequirementForm()
{ {
this.setSelItemIndex(-1); this.setSelItemIndex(-1);
this.setBigDecimalConverter(new BigDecimalConverter()); this.setBigDecimalConverter(new BigDecimalConverter());
@ -123,14 +138,6 @@ public class RequirementForm extends FormViewModel<Requirement>
this.syncItems = syncItems; this.syncItems = syncItems;
} }
@Command
public void addSelectedItem()
{
// Window window = (Window)
// Executions.createComponents("/main/selectItems.zul", null, null);
// window.doModal();
}
@Command @Command
public void onFocusItem(@BindingParam("item") RequirementItem item, @BindingParam("ctrl") InputElement ctrl) public void onFocusItem(@BindingParam("item") RequirementItem item, @BindingParam("ctrl") InputElement ctrl)
{ {
@ -230,4 +237,47 @@ public class RequirementForm extends FormViewModel<Requirement>
BindUtils.postNotifyChange(null, null, form, "*"); BindUtils.postNotifyChange(null, null, form, "*");
} }
} }
@Command
@NotifyChange({ "selectedItem", "syncItems" })
public void onChangeGroup()
{
// Někdo změnil skupinu materiálu nebo služby
if (this.selectedItem == null)
{
log.warn("Zavolat z formuláře onFocus pro nastavení vybrané položky!");
return;
}
// Zjistit, zda je propojená skupina materiálu nebo služeb
RequirementSubject subject = this.selectedItem.getReqSubject();
if (subject != null)
{
// Skupina materiálu nebo služeb je propojená, nastavit k zadanému
// kódu i správný název skupiny materiálu nebo služby
this.selectedItem.setName(subject.getName());
}
}
@Command
@NotifyChange({ "selectedItem", "syncItems" })
public void addNewItem()
{
RequirementItem item = new RequirementItem();
item.setReqSubject(null);
item.setCode("");
item.setName("");
item.setQuantity(BigDecimal.valueOf(1));
item.setUnitPrice(BigDecimal.valueOf(0));
item.setTotal(BigDecimal.valueOf(0));
item.setDescription("");
item.setMunit(null);
this.setSelectedItem(item);
this.getDataBean().getItems().add(item);
this.setSelItemIndex(this.getDataBean().getItems().indexOf(item));
}
} }

@ -1,21 +1,33 @@
package info.bukova.isspst.ui.main.orders.services; package info.bukova.isspst.ui.main.orders.services;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
import info.bukova.isspst.ui.main.orders.requirements.RequirementForm; import info.bukova.isspst.ui.main.orders.requirements.RequirementForm;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window; import org.zkoss.zul.Window;
public class ReqServicesForm extends RequirementForm public class ReqServicesForm extends RequirementForm
{ {
// private final static Logger log = @SuppressWarnings("unused")
// LoggerFactory.getLogger(ReqServicesForm.class.getName()); private final static Logger log = LoggerFactory.getLogger(ReqServicesForm.class.getName());
@WireVariable
private ServiceItemService serviceItemService;
@SuppressWarnings("unchecked")
@Init(superclass = true) @Init(superclass = true)
public void init() public void init()
{ {
super.init(); // Získat seznam všech skupin služeb pro výběr z comba
this.setRequirementGroups((List<RequirementSubject>) (List<?>) serviceItemService.getAll());
} }
@Command @Command

@ -287,6 +287,7 @@ LoginViaGoogle=Přihlásit účtem Google
DateFormat=dd. MM. yyyy DateFormat=dd. MM. yyyy
AddItem=Přidat položku AddItem=Přidat položku
SelectGroup=Vybrat skupinu...
RemoveItem=Smazat RemoveItem=Smazat
Amount=Částka Amount=Částka

@ -1,4 +1,4 @@
<?page title="Informace" contentType="text/html;charset=UTF-8"?> <?page title="${labels.Information}" contentType="text/html;charset=UTF-8"?>
<zk> <zk>
<zscript> <zscript>

@ -1,4 +1,4 @@
<?page title="Informace" contentType="text/html;charset=UTF-8"?> <?page title="${labels.Information}" contentType="text/html;charset=UTF-8"?>
<zk> <zk>
<window <window
vflex="1" vflex="1"
@ -8,14 +8,17 @@
<caption <caption
zclass="form-caption" zclass="form-caption"
label="${labels.Information}" /> label="${labels.Information}" />
<vbox vflex="1"> <vbox
<hbox> vflex="1"
hflex="1">
<hbox hflex="1">
<label value="${labels.LogedInUser}" /> <label value="${labels.LogedInUser}" />
<image src="/img/user-small.png" /> <image src="/img/user-small.png" />
<label value="@load(vm.user)" /> <label value="@load(vm.user)" />
</hbox> </hbox>
<groupbox <groupbox
vflex="1" vflex="1"
hflex="1"
mold="3d"> mold="3d">
<caption <caption
image="/img/commission-small.png" image="/img/commission-small.png"

@ -2,6 +2,8 @@
<zk> <zk>
<window <window
id="editWin" id="editWin"
width="95%"
height="95%"
closable="true" closable="true"
border="normal" border="normal"
position="center" position="center"
@ -12,6 +14,8 @@
image="/img/beam-032.png" image="/img/beam-032.png"
zclass="form-caption" zclass="form-caption"
label="${labels.MaterialRequirement}" /> label="${labels.MaterialRequirement}" />
<include src="/main/orders/requirements/reqForm.zul" /> <include
vflex="1"
src="/main/orders/requirements/reqForm.zul" />
</window> </window>
</zk> </zk>

@ -5,13 +5,14 @@
closable="true" closable="true"
border="normal" border="normal"
position="center" position="center"
vflex="1"
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.material.SelectMaterialItems')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.material.SelectMaterialItems')">
<caption <caption
src="/img/palet-032.png" src="/img/palet-032.png"
zclass="form-caption" zclass="form-caption"
label="${labels.AgendaMaterial}" /> label="${labels.AgendaMaterial}" />
<vlayout> <vlayout vflex="1">
<toolbar> <toolbar>
<toolbarbutton <toolbarbutton
image="/img/funnel.png" image="/img/funnel.png"
@ -20,6 +21,7 @@
onClick="@command('onFilterMaterial')" /> onClick="@command('onFilterMaterial')" />
</toolbar> </toolbar>
<listbox <listbox
vflex="1"
model="@load(vm.materialList)" model="@load(vm.materialList)"
selectedItem="@bind(vm.selectedItem)"> selectedItem="@bind(vm.selectedItem)">
<listhead menupopup="auto"> <listhead menupopup="auto">

@ -1,6 +1,7 @@
<vlayout <vlayout
form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.requirementFormValidator)" form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.requirementFormValidator)"
hflex="1"> hflex="1"
vflex="1">
<grid hflex="min"> <grid hflex="min">
<columns> <columns>
<column <column
@ -83,11 +84,17 @@
disabled="@load(empty fx.centre)" disabled="@load(empty fx.centre)"
image="/img/item-add.png" image="/img/item-add.png"
label="${labels.AddItem}" label="${labels.AddItem}"
onClick="@command('addNewItem')"
sclass="nicebutton" />
<button
disabled="@load(empty fx.centre)"
image="/img/item-add.png"
label="${labels.SelectGroup}"
onClick="@command('addSelectedItem')" onClick="@command('addSelectedItem')"
sclass="nicebutton" /> sclass="nicebutton" />
</hbox> </hbox>
<listbox <listbox
height="180px" vflex="1"
model="@load(vm.syncItems)" model="@load(vm.syncItems)"
selectedItem="@bind(vm.selectedItem)" selectedItem="@bind(vm.selectedItem)"
selectedIndex="@bind(vm.selItemIndex)"> selectedIndex="@bind(vm.selItemIndex)">
@ -124,17 +131,27 @@
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell> <listcell>
<textbox <combobox
width="100%"
value="@bind(each.code)"
model="@load(vm.requirementGroups)"
inplace="true" inplace="true"
sclass="grid-textbox-max"
readonly="true"
onFocus="@command('onFocusItem', item=each, ctrl=self)" onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.code)" /> onChange="@command('onChangeGroup')"
autocomplete="true"
selectedItem="@bind(each.reqSubject)">
<template
name="model"
var="subject">
<comboitem label="@load(subject.code)" />
</template>
</combobox>
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
sclass="grid-textbox-max" sclass="grid-textbox-max"
readonly="false"
onFocus="@command('onFocusItem', item=each, ctrl=self)" onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.name)" /> value="@bind(each.name)" />
</listcell> </listcell>

@ -2,6 +2,8 @@
<zk> <zk>
<window <window
id="editWin" id="editWin"
width="95%"
height="95%"
closable="true" closable="true"
border="normal" border="normal"
position="center" position="center"
@ -12,6 +14,8 @@
image="/img/worker-032.png" image="/img/worker-032.png"
zclass="form-caption" zclass="form-caption"
label="${labels.ServiceRequirement}" /> label="${labels.ServiceRequirement}" />
<include src="/main/orders/requirements/reqForm.zul" /> <include
vflex="1"
src="/main/orders/requirements/reqForm.zul" />
</window> </window>
</zk> </zk>
Loading…
Cancel
Save