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;
}
@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 void loadGroups(Requirement req);
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.RequirementItem;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workflow;
import info.bukova.isspst.data.Workgroup;
@ -73,4 +74,53 @@ public class RequirementServiceImpl extends
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;
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.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.Init;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;
public class ReqMaterialForm extends RequirementForm
{
// private final static Logger log =
// LoggerFactory.getLogger(ReqServicesForm.class.getName());
@SuppressWarnings("unused")
private final static Logger log = LoggerFactory.getLogger(ReqServicesForm.class.getName());
@WireVariable
private MaterialService materialService;
@SuppressWarnings("unchecked")
@Init(superclass = true)
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

@ -38,13 +38,28 @@ public class RequirementForm extends FormViewModel<Requirement>
@WireVariable
private WorkgroupService workgroupService;
@WireVariable
private RequirementTypeService reqTypeService;
@WireVariable
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 int selItemIndex;
@ -54,7 +69,7 @@ public class RequirementForm extends FormViewModel<Requirement>
private RequirementFormValidator requirementFormValidator;
private List<RequirementItem> syncItems;
private List<Workgroup> centres;
public List<Workgroup> getCentres()
@ -101,16 +116,16 @@ public class RequirementForm extends FormViewModel<Requirement>
{
this.requirementFormValidator = requirementFormValidator;
}
@Init(superclass = true)
public void init()
public void initRequirementForm()
{
this.setSelItemIndex(-1);
this.setBigDecimalConverter(new BigDecimalConverter());
this.setRequirementFormValidator(new RequirementFormValidator());
this.setSyncItems(this.getDataBean().getItems());
requirementService.loadType(getDataBean());
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
}
public List<RequirementItem> getSyncItems()
@ -123,14 +138,6 @@ public class RequirementForm extends FormViewModel<Requirement>
this.syncItems = syncItems;
}
@Command
public void addSelectedItem()
{
// Window window = (Window)
// Executions.createComponents("/main/selectItems.zul", null, null);
// window.doModal();
}
@Command
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, "*");
}
}
@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;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
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.Init;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;
public class ReqServicesForm extends RequirementForm
{
// private final static Logger log =
// LoggerFactory.getLogger(ReqServicesForm.class.getName());
@SuppressWarnings("unused")
private final static Logger log = LoggerFactory.getLogger(ReqServicesForm.class.getName());
@WireVariable
private ServiceItemService serviceItemService;
@SuppressWarnings("unchecked")
@Init(superclass = true)
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

@ -287,6 +287,7 @@ LoginViaGoogle=Přihlásit účtem Google
DateFormat=dd. MM. yyyy
AddItem=Přidat položku
SelectGroup=Vybrat skupinu...
RemoveItem=Smazat
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>
<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>
<window
vflex="1"
@ -8,14 +8,17 @@
<caption
zclass="form-caption"
label="${labels.Information}" />
<vbox vflex="1">
<hbox>
<vbox
vflex="1"
hflex="1">
<hbox hflex="1">
<label value="${labels.LogedInUser}" />
<image src="/img/user-small.png" />
<label value="@load(vm.user)" />
</hbox>
<groupbox
vflex="1"
hflex="1"
mold="3d">
<caption
image="/img/commission-small.png"

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

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

@ -1,6 +1,7 @@
<vlayout
form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.requirementFormValidator)"
hflex="1">
hflex="1"
vflex="1">
<grid hflex="min">
<columns>
<column
@ -83,11 +84,17 @@
disabled="@load(empty fx.centre)"
image="/img/item-add.png"
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')"
sclass="nicebutton" />
</hbox>
<listbox
height="180px"
vflex="1"
model="@load(vm.syncItems)"
selectedItem="@bind(vm.selectedItem)"
selectedIndex="@bind(vm.selItemIndex)">
@ -124,17 +131,27 @@
<template name="model">
<listitem>
<listcell>
<textbox
<combobox
width="100%"
value="@bind(each.code)"
model="@load(vm.requirementGroups)"
inplace="true"
sclass="grid-textbox-max"
readonly="true"
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>
<textbox
inplace="true"
sclass="grid-textbox-max"
readonly="false"
onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.name)" />
</listcell>

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