Implementováno třístavové vyhledávání boolean hodnot.

Agendu Schválené položky požadavků lze nyní filtrovat podle materiálu a
služeb.

#closes 206
Verze_2.0
František Přibyl 10 years ago
parent ecd3cf426b
commit 724f6b3559

@ -1,13 +1,48 @@
package info.bukova.isspst; package info.bukova.isspst;
import org.jfree.util.Log;
public class BooleanUtils public class BooleanUtils
{ {
public static boolean isEqualByBoolean(Boolean b1, Boolean b2) private static final String TAG = BooleanUtils.class.getSimpleName();
public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
{ {
boolean bool1 = ((b1 == null) ? false : b1.booleanValue()); boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
boolean bool2 = ((b2 == null) ? false : b2.booleanValue()); boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
boolean equals = (bool1 == bool2); boolean equals = (bool1 == bool2);
return equals; return equals;
} }
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
{
if ((b1 == null) && (b2 == null))
{
return true;
}
else if ((b1 != null) && (b2 != null))
{
return (b1.booleanValue() == b2.booleanValue());
}
return false;
}
public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
{
if (filterValue == null)
{
// Show all records
return true;
}
if (value == null)
{
// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
return true;
}
return (value.booleanValue() == filterValue.booleanValue());
}
} }

@ -1,5 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -220,6 +222,23 @@ public class JoinedItem implements DataModel, FilterableRequirement
this.ownedBy = owner; this.ownedBy = owner;
} }
protected Boolean itemMaterial;
public boolean isItemMaterialReal()
{
return ((this.requirement != null) && (this.requirement.getKind() == Constants.REQ_TYPE_MATERIAL));
}
public Boolean getItemMaterial()
{
return this.itemMaterial;
}
public void setItemMaterial(Boolean value)
{
this.itemMaterial = value;
}
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {

@ -0,0 +1,57 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
@SuppressWarnings("serial")
public class BooleanFilterListbox extends Listbox
{
class TristateBooleanListItem extends TristateBoolean
{
public TristateBooleanListItem(String text, int value)
{
this.setText(text);
this.setValue(value);
}
private String text;
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}
public BooleanFilterListbox()
{
super();
List<TristateBooleanListItem> list = new ArrayList<TristateBooleanListItem>();
list.add(new TristateBooleanListItem(StringUtils.localize("LabelAll"), TristateBoolean.NULL));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelNo"), TristateBoolean.FALSE));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelYes"), TristateBoolean.TRUE));
for (int i = 0; i < list.size(); i++)
{
TristateBooleanListItem triStateItem = (TristateBooleanListItem) list.get(i);
this.appendItem(triStateItem.getText(), "");
Listitem item = this.getItemAtIndex(i);
item.setValue((TristateBoolean) triStateItem);
}
this.setSelectedIndex(0);
// this.setHflex("1");
this.setMold("select");
}
}

@ -1,5 +1,6 @@
package info.bukova.isspst.filters; package info.bukova.isspst.filters;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.MUnitEmb;
@ -42,6 +43,7 @@ public class JoinedItemFilter implements Filter<JoinedItem>
@Override @Override
public boolean matchesSafely(JoinedItem item) public boolean matchesSafely(JoinedItem item)
{ {
boolean foundItemMaterial = BooleanUtils.isEqualFilterByBoolean(item.isItemMaterialReal(), condition.getItemMaterial());
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode()); boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName()); boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem()); boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
@ -56,7 +58,18 @@ public class JoinedItemFilter implements Filter<JoinedItem>
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre()); boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription); return (foundItemMaterial
&& foundCode
&& foundName
&& foundTextItem
&& foundDescription
&& foundQuantity
&& foundUnitPrice
&& foundMUnit
&& foundTotal
&& foundWorkgroup
&& foundCenter
&& foundOwner && foundDescription);
} }
@Factory @Factory

@ -47,7 +47,7 @@ public class RequirementFilter implements Filter<Requirement>
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundProject = BooleanUtils.isEqualByBoolean(item.getProject(), condition.getProject()); boolean foundProject = BooleanUtils.isEqualByBooleanValue(item.getProject(), condition.getProject());
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject); return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject);
} }

@ -0,0 +1,87 @@
package info.bukova.isspst.filters;
import org.jfree.util.Log;
public class TristateBoolean
{
private static final String TAG = TristateBoolean.class.getSimpleName();
public static final int NULL = -1;
public static final int FALSE = 0;
public static final int TRUE = 1;
public static final int getValidValue(final int value)
{
if ((value != TristateBoolean.NULL) && (value != TristateBoolean.FALSE) && (value != TristateBoolean.TRUE))
{
Log.warn(TAG + "\nBad tristate boolean value.");
return TristateBoolean.NULL;
}
return value;
}
public TristateBoolean()
{
this.setValue(TristateBoolean.NULL);
}
public TristateBoolean(boolean value)
{
this.setValue(value ? TristateBoolean.TRUE : TristateBoolean.FALSE);
}
public TristateBoolean(int value)
{
this.setValue(value);
}
protected int value;
public int getValue()
{
return value;
}
public void setValue(int value)
{
this.value = TristateBoolean.getValidValue(value);
}
public Boolean getBoolean()
{
switch (this.value)
{
case TristateBoolean.FALSE:
return new Boolean(false);
case TristateBoolean.TRUE:
return new Boolean(true);
default:
return null;
}
}
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof TristateBoolean)
{
TristateBoolean item = (TristateBoolean) obj;
int thisValue = this.getValue();
int itemValue = item.getValue();
return (thisValue == itemValue);
}
}
return false;
}
public boolean equals(int value)
{
return (this.getValue() == value);
}
}

@ -5,11 +5,11 @@ import info.bukova.isspst.data.Order;
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.filters.JoinedItemFilter; import info.bukova.isspst.filters.JoinedItemFilter;
import info.bukova.isspst.filters.TristateBoolean;
import info.bukova.isspst.services.orders.ApprovedService; import info.bukova.isspst.services.orders.ApprovedService;
import info.bukova.isspst.services.orders.OrderService; import info.bukova.isspst.services.orders.OrderService;
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.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
import java.util.ArrayList; import java.util.ArrayList;
@ -38,24 +38,17 @@ public class ApprovedList extends ListViewModel<JoinedItem>
@WireVariable @WireVariable
protected OrderService orderService; protected OrderService orderService;
private BigDecimalConverter bigDecimalConverter;
protected List<JoinedItem> selectedItems; protected List<JoinedItem> selectedItems;
@Init @Init(superclass = true)
public void initApprovedList() public void initApprovedList()
{ {
service = approvedService; service = approvedService;
dataClass = JoinedItem.class; dataClass = JoinedItem.class;
// formZul = "form.zul"; // formZul = "form.zul";
dataFilter = new JoinedItemFilter(getFilterTemplate()); dataFilter = new JoinedItemFilter(getFilterTemplate());
bigDecimalConverter = new BigDecimalConverter();
selectedItems = new ArrayList<JoinedItem>(); selectedItems = new ArrayList<JoinedItem>();
} this.itemMaterial = new TristateBoolean();
public BigDecimalConverter getBigDecimalConverter()
{
return bigDecimalConverter;
} }
public List<JoinedItem> getItems() public List<JoinedItem> getItems()
@ -123,4 +116,17 @@ public class ApprovedList extends ListViewModel<JoinedItem>
return new ArrayList<JoinedItem>(); return new ArrayList<JoinedItem>();
} }
} }
protected TristateBoolean itemMaterial;
public TristateBoolean getItemMaterial()
{
return this.itemMaterial;
}
public void setItemMaterial(TristateBoolean tristate)
{
this.itemMaterial = tristate;
this.getFilterTemplate().setItemMaterial(tristate.getBoolean());
}
} }

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xml>
<language-addon>
<addon-name>BooleanFilterListbox</addon-name>
<language-name>xul/html</language-name>
<component>
<component-name>booleanfilterlistbox</component-name>
<extends>listbox</extends>
<component-class>info.bukova.isspst.filters.BooleanFilterListbox</component-class>
</component>
</language-addon>

@ -289,6 +289,9 @@ DbValidationError=Chyba validace
true=Ano true=Ano
false=Ne false=Ne
LabelAll=Vše
LabelYes=Ano
LabelNo=Ne
Information=Informace Information=Informace
@ -301,6 +304,7 @@ MaterialRequirements=Požadavky na materiál
ServiceRequirement=Požadavek na službu ServiceRequirement=Požadavek na službu
ServiceRequirements=Požadavky na služby ServiceRequirements=Požadavky na služby
ApprovedRequirementItems=Schválené položky požadavků ApprovedRequirementItems=Schválené položky požadavků
Material = Materiál
CurrentRequirements=Aktuální požadavky CurrentRequirements=Aktuální požadavky
CreatedOrders=Vytvořené objednávky CreatedOrders=Vytvořené objednávky

@ -18,6 +18,7 @@
<addon-uri>/WEB-INF/lang-addons/mapa-lang-addon.xml</addon-uri> <addon-uri>/WEB-INF/lang-addons/mapa-lang-addon.xml</addon-uri>
<addon-uri>/WEB-INF/lang-addons/ckez-bind-lang-addon.xml</addon-uri> <addon-uri>/WEB-INF/lang-addons/ckez-bind-lang-addon.xml</addon-uri>
<addon-uri>/WEB-INF/lang-addons/CzechSortListheader.xml</addon-uri> <addon-uri>/WEB-INF/lang-addons/CzechSortListheader.xml</addon-uri>
<addon-uri>/WEB-INF/lang-addons/BooleanFilterListbox.xml</addon-uri>
</language-config> </language-config>
<desktop-config> <desktop-config>
<theme-uri>/css/zk-modify.css</theme-uri> <theme-uri>/css/zk-modify.css</theme-uri>

@ -31,6 +31,10 @@
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader width="27" /> <listheader width="27" />
<listheader
hflex="4"
sort="auto(itemMaterialReal)"
label="${labels.Material}" />
<listheader <listheader
hflex="6" hflex="6"
sort="czech(requirement.numser)" sort="czech(requirement.numser)"
@ -85,6 +89,11 @@
</listhead> </listhead>
<auxhead visible="@load(vm.filter)"> <auxhead visible="@load(vm.filter)">
<auxheader /> <auxheader />
<auxheader>
<booleanfilterlistbox
selectedItem="@bind(vm.itemMaterial)"
onSelect="@command('doFilter')" />
</auxheader>
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
@ -287,14 +296,15 @@
<template name="model"> <template name="model">
<listitem context="popupMenu"> <listitem context="popupMenu">
<listcell /> <listcell />
<listcell label="@load(each.itemMaterialReal) @converter(vm.standardBoolConverter)" />
<listcell label="@load(each.requirement.numser)" /> <listcell label="@load(each.requirement.numser)" />
<listcell label="@load(each.code)" /> <listcell label="@load(each.code)" />
<listcell label="@load(each.name)" /> <listcell label="@load(each.name)" />
<listcell label="@load(each.textItem)" /> <listcell label="@load(each.textItem)" />
<listcell label="@load(each.quantity) @converter(vm.bigDecimalConverter)" /> <listcell label="@load(each.quantity) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.munit.name)" /> <listcell label="@load(each.munit.name)" />
<listcell label="@load(each.unitPrice) @converter(vm.bigDecimalConverter)" /> <listcell label="@load(each.unitPrice) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.total) @converter(vm.bigDecimalConverter)" /> <listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.workgroup.fullName)" /> <listcell label="@load(each.workgroup.fullName)" />
<listcell label="@load(each.centre.fullName)" /> <listcell label="@load(each.centre.fullName)" />
<listcell label="@load(each.ownedBy.fullName)" /> <listcell label="@load(each.ownedBy.fullName)" />

Loading…
Cancel
Save