Agenda "Fakturace požadavků" nyní podporuje řazení.

Po otevření agendy je nastaveno řazení podle sloupce čísla požadavku.
U textových sloupců se data řadí podle CZ pravidel.
Přidána možnost řadit vnořené property podle CZ pravidel.


closes #189
Verze_1.0
František Přibyl 10 years ago
parent d37076cd27
commit 8e33bb8ef7

@ -1,5 +1,6 @@
package info.bukova.isspst; package info.bukova.isspst;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.zkoss.util.resource.Labels; import org.zkoss.util.resource.Labels;
@ -149,4 +150,47 @@ public class StringUtils
return result; return result;
} }
public static List<String> split(String value, String separator)
{
String tmp = value;
List<String> list = new ArrayList<String>();
if (tmp != null)
{
if ((separator == null) || separator.isEmpty() || tmp.isEmpty())
{
list.add(tmp);
}
else
{
int separatorLength = separator.length();
while (!tmp.isEmpty())
{
String part = "";
int idx = tmp.indexOf(separator);
if (idx > -1)
{
part = tmp.substring(0, idx);
list.add(part);
tmp = tmp.substring(idx + separatorLength);
if (tmp.isEmpty())
{
list.add("");
}
}
else
{
list.add(tmp);
tmp = "";
}
}
}
}
return list;
}
} }

@ -1,19 +1,21 @@
package info.bukova.isspst.sort; package info.bukova.isspst.sort;
import info.bukova.isspst.StringUtils;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.Collator; import java.text.Collator;
import java.text.ParseException; import java.text.ParseException;
import java.text.RuleBasedCollator; import java.text.RuleBasedCollator;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
public class CzechStringComparator implements Comparator<Object> { public class CzechStringComparator implements Comparator<Object> {
private String m_rule; private String m_rule;
private final String m_property; private final List<String> m_propertyPath;
private final boolean m_ascending; private final boolean m_ascending;
private Method m_getter;
private Comparator<Object> m_comparator; private Comparator<Object> m_comparator;
public CzechStringComparator(String property, boolean ascending) { public CzechStringComparator(String property, boolean ascending) {
@ -47,7 +49,7 @@ public class CzechStringComparator implements Comparator<Object> {
m_rule += "< Y,y < Ý,ý "; m_rule += "< Y,y < Ý,ý ";
m_rule += "< Z,z < Ź,ź < Ž,ž "; m_rule += "< Z,z < Ź,ź < Ž,ž ";
m_property = property; m_propertyPath = StringUtils.split(property, ".");
m_ascending = ascending; m_ascending = ascending;
} }
@ -72,21 +74,56 @@ public class CzechStringComparator implements Comparator<Object> {
return 0; return 0;
} }
private Object getValue(Object caller)
{
Object obj = caller;
for (String property : m_propertyPath)
{
if (obj == null)
{
return null;
}
Method method = ReflectionTools.getGetterMethod(obj, property);
try
{
obj = method.invoke(obj);
}
catch (IllegalAccessException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InvocationTargetException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return obj;
}
private int internalCompare(Object argL, Object argR) private int internalCompare(Object argL, Object argR)
throws ParseException, IllegalAccessException, throws ParseException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException { IllegalArgumentException, InvocationTargetException {
if (m_getter == null) {
m_getter = ReflectionTools.getGetterMethod(argL, m_property);
}
if (m_comparator == null) { if (m_comparator == null)
{
Collator c = new RuleBasedCollator(m_rule); Collator c = new RuleBasedCollator(m_rule);
c.setStrength(Collator.TERTIARY); c.setStrength(Collator.TERTIARY);
m_comparator = c; m_comparator = c;
} }
Object valL = m_getter.invoke(argL); Object valL = this.getValue(argL);
Object valR = m_getter.invoke(argR); Object valR = this.getValue(argR);
boolean isNullValL = (valL == null); boolean isNullValL = (valL == null);
boolean isNullValR = (valR == null); boolean isNullValR = (valR == null);

@ -29,10 +29,10 @@ public class SelectMaterialItems extends SelectItems
private MaterialFilter dataFilterMaterial; private MaterialFilter dataFilterMaterial;
@Init @Init(superclass = true)
public void init() public void initSelectMaterialItems()
{ {
super.init(); // super.init();
this.setFullMaterialList(materialService.getAll()); this.setFullMaterialList(materialService.getAll());
this.setMaterialList(this.getFullMaterialList()); this.setMaterialList(this.getFullMaterialList());

@ -3,13 +3,14 @@ package info.bukova.isspst.ui.main.orders.requirements;
import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.data.RequirementSubject; import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.ui.DocumentViewModel;
import java.util.List; import java.util.List;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
public class SelectItems public class SelectItems extends DocumentViewModel
{ {
protected RequirementSubject selectedItem; protected RequirementSubject selectedItem;
@ -19,8 +20,8 @@ public class SelectItems
protected List<MUnitEmb> munitList; protected List<MUnitEmb> munitList;
@Init @Init(superclass = true)
public void init() public void initSelectItems()
{ {
this.setMunitList(munitService.getEmbAll()); this.setMunitList(munitService.getEmbAll());
} }

@ -29,10 +29,10 @@ public class SelectServicesItems extends SelectItems
private ServiceItemFilter dataFilterService; private ServiceItemFilter dataFilterService;
@Init @Init(superclass = true)
public void init() public void initSelectServicesItems()
{ {
super.init(); // super.init();
this.setFullServiceItemList(serviceItemService.getAll()); this.setFullServiceItemList(serviceItemService.getAll());
this.setServiceItemList(this.getFullServiceItemList()); this.setServiceItemList(this.getFullServiceItemList());

@ -18,35 +18,43 @@
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader <listheader
label="${labels.InvoicingRequirementNumber}" label="${labels.InvoicingRequirementNumber}"
sort="czech(requirement.numser)"
onCreate="self.sort(true)"
width="130px" /> width="130px" />
<listheader <listheader
label="${labels.RequirementsGridReqDate}" label="${labels.RequirementsGridReqDate}"
sort="auto(requirement.reqDate)"
width="150px" /> width="150px" />
<listheader <listheader
label="${labels.RequirementsGridCenter}" label="${labels.RequirementsGridCenter}"
sort="czech(requirement.centre.fullName)"
width="180px" /> width="180px" />
<listheader <listheader
label="${labels.RequirementsGridWorkgroup}" label="${labels.RequirementsGridWorkgroup}"
sort="czech(requirement.workgroup.fullName)"
width="180px" /> width="180px" />
<listheader <listheader
label="${labels.InvoicingApplicant}" label="${labels.InvoicingApplicant}"
sort="czech(requirement.ownedBy.fullName)"
width="180px" /> width="180px" />
<listheader <listheader
label="${labels.InvoicingDescription}" label="${labels.InvoicingDescription}"
sort="czech(requirement.description)"
width="" /> width="" />
<listheader <listheader
label="${labels.InvoicingRequirementPrice}" label="${labels.InvoicingRequirementPrice}"
sort="auto(requirement.sumTotal)"
align="right" align="right"
width="130px" /> width="130px" />
<listheader <listheader
label="${labels.InvoicingInvoicedPrice}" label="${labels.InvoicingInvoicedPrice}"
align="right" align="right"
sort="auto(totalInvoiced)"
width="130px" /> width="130px" />
</listhead> </listhead>
<auxhead <auxhead
sclass="category-center" sclass="category-center"
visible="@load(vm.filter)"> visible="@load(vm.filter)">
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
@ -160,7 +168,6 @@
</div> </div>
</div--> </div-->
</auxheader> </auxheader>
</auxhead> </auxhead>
<template name="model"> <template name="model">
<listitem> <listitem>
@ -171,7 +178,8 @@
<listcell label="@load(each.requirement.ownedBy)" /> <listcell label="@load(each.requirement.ownedBy)" />
<listcell label="@load(each.requirement.description)" /> <listcell label="@load(each.requirement.description)" />
<listcell label="@load(each.requirement.sumTotal) @converter(vm.standardBigDecimalConverter)" /> <listcell label="@load(each.requirement.sumTotal) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.totalInvoiced) @converter(vm.standardBigDecimalConverter)" <listcell
label="@load(each.totalInvoiced) @converter(vm.standardBigDecimalConverter)"
style="@load(vm.dataBean.totalInvoiced gt vm.dataBean.requirement.sumTotal ? ' color: red;' : '' )" /> style="@load(vm.dataBean.totalInvoiced gt vm.dataBean.requirement.sumTotal ? ' color: red;' : '' )" />
</listitem> </listitem>
</template> </template>

Loading…
Cancel
Save