details: https://code.openbravo.com/erp/devel/pi/rev/b718b3ee2462 changeset: 21679:b718b3ee2462 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Dec 20 07:39:46 2013 +0100 summary: related to bug 25248: prevent null values in delivery and invoice status
this causes backend sorting to to work as expected details: https://code.openbravo.com/erp/devel/pi/rev/a9326df8fa4a changeset: 21680:a9326df8fa4a user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Dec 20 07:40:50 2013 +0100 summary: fixed bug 25248: error when sorting by a computed column diffstat: modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java | 40 ++++++--- src-db/database/sourcedata/AD_COLUMN.xml | 8 +- 2 files changed, 30 insertions(+), 18 deletions(-) diffs (110 lines): diff -r 3ce09750f1bd -r a9326df8fa4a modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java --- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java Thu Dec 19 16:34:59 2013 +0100 +++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java Fri Dec 20 07:40:50 2013 +0100 @@ -1195,7 +1195,7 @@ if (isIdentifier) { Entity searchEntity = getEntity(); // a path to an entity, find the last entity - final String prefix; + String prefix; if (!localOrderBy.equals(JsonConstants.IDENTIFIER)) { // be lazy get the last property, it belongs to the last entity final Property prop = DalUtil.getPropertyFromPath(searchEntity, localOrderBy); @@ -1203,6 +1203,13 @@ + searchEntity); searchEntity = prop.getEntity(); prefix = localOrderBy.substring(0, localOrderBy.lastIndexOf(DalUtil.DOT) + 1); + + String originalPropName = localOrderBy.replace(DalUtil.DOT + JsonConstants.IDENTIFIER, ""); + Property originalProp = DalUtil.getPropertyFromPath(getEntity(), originalPropName); + if (originalProp.isComputedColumn()) { + prefix += Entity.COMPUTED_COLUMNS_PROXY_PROPERTY + DalUtil.DOT + prefix; + } + } else { prefix = ""; } @@ -1225,13 +1232,6 @@ } } } else { - Entity searchEntity = getEntity(); - Property property = searchEntity.getProperty(localOrderBy, false); - if (property != null && property.isComputedColumn()) { - // Computed columns are accessed through proxy - localOrderBy = Entity.COMPUTED_COLUMNS_PROXY_PROPERTY + DalUtil.DOT + localOrderBy; - } - paths.add(localOrderBy); } @@ -1451,8 +1451,16 @@ return alias; } Property prop = props.get(props.size() - 1); - String propName = prop.isComputedColumn() ? Entity.COMPUTED_COLUMNS_PROXY_PROPERTY - + DalUtil.DOT + prop.getName() : prop.getName(); + String propName = null; + if (props.get(0).isComputedColumn()) { + propName = Entity.COMPUTED_COLUMNS_PROXY_PROPERTY; + for (Property p : props) { + propName += DalUtil.DOT + p.getName(); + } + } else { + propName = prop.getName(); + } + return alias + DalUtil.DOT + propName; } @@ -1482,14 +1490,18 @@ } public String getJoinStatement() { + String propName; + if (property.isComputedColumn()) { + propName = Entity.COMPUTED_COLUMNS_PROXY_PROPERTY + DalUtil.DOT + property.getName(); + } else { + propName = property.getName(); + } if (orNesting > 0) { return " left outer join " + (fetchJoin ? "fetch " : "") - + (ownerAlias != null ? ownerAlias + DalUtil.DOT : "") + property.getName() + " as " - + joinAlias; + + (ownerAlias != null ? ownerAlias + DalUtil.DOT : "") + propName + " as " + joinAlias; } else { return " left join " + (fetchJoin ? "fetch " : "") - + (ownerAlias != null ? ownerAlias + DalUtil.DOT : "") + property.getName() + " as " - + joinAlias; + + (ownerAlias != null ? ownerAlias + DalUtil.DOT : "") + propName + " as " + joinAlias; } } diff -r 3ce09750f1bd -r a9326df8fa4a src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml Thu Dec 19 16:34:59 2013 +0100 +++ b/src-db/database/sourcedata/AD_COLUMN.xml Fri Dec 20 07:40:50 2013 +0100 @@ -290174,10 +290174,10 @@ <!--9E82E728716246B393C40D2CDCA0133A--> <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW> <!--9E82E728716246B393C40D2CDCA0133A--> <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION> <!--9E82E728716246B393C40D2CDCA0133A--> <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE> -<!--9E82E728716246B393C40D2CDCA0133A--> <SQLLOGIC><![CDATA[(select case when sum(abs(ol.qtyordered)) = 0 then 0 else +<!--9E82E728716246B393C40D2CDCA0133A--> <SQLLOGIC><![CDATA[(coalesce((select case when sum(abs(ol.qtyordered)) = 0 then 0 else round(coalesce(sum(abs(ol.qtydelivered)), 0)/sum(abs(ol.qtyordered)) * 100, 0) end from c_orderline ol where ol.c_order_id=c_order_id and ol.c_order_discount_id is null - )]]></SQLLOGIC> + ),0))]]></SQLLOGIC> <!--9E82E728716246B393C40D2CDCA0133A--></AD_COLUMN> <!--9E96300C46ED4928E040007F01006BD5--><AD_COLUMN> @@ -299214,9 +299214,9 @@ <!--B5B203AE8D674B8DABC6669419815CA7--> <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW> <!--B5B203AE8D674B8DABC6669419815CA7--> <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION> <!--B5B203AE8D674B8DABC6669419815CA7--> <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE> -<!--B5B203AE8D674B8DABC6669419815CA7--> <SQLLOGIC><![CDATA[(select case when sum(abs(ol.qtyordered)) = 0 then 0 else +<!--B5B203AE8D674B8DABC6669419815CA7--> <SQLLOGIC><![CDATA[(coalesce((select case when sum(abs(ol.qtyordered)) = 0 then 0 else round(coalesce(sum(abs(ol.qtyinvoiced)), 0)/sum(abs(ol.qtyordered)) * 100, 0) end -from c_orderline ol where ol.c_order_id=c_order_id and ol.c_order_discount_id is null)]]></SQLLOGIC> +from c_orderline ol where ol.c_order_id=c_order_id and ol.c_order_discount_id is null), 0))]]></SQLLOGIC> <!--B5B203AE8D674B8DABC6669419815CA7--></AD_COLUMN> <!--B5B4E54AEAC82679E040007F01004CAA--><AD_COLUMN> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
