Author: jleroux
Date: Tue Oct 13 11:31:55 2015 New Revision: 1708346 URL: http://svn.apache.org/viewvc?rev=1708346&view=rev Log: "Applied fix from trunk for revision: 1708341" (w/o changes in party model, were not in this branch) ------------------------------------------------------------------------ r1708341 | jleroux | 2015-10-13 13:24:17 +0200 (mar. 13 oct. 2015) | 88 lignes A patch from Wei for "The filter-by-date="true" of <entity-condition></entity> in view entity PartyExport does not work" https://issues.apache.org/jira/browse/OFBIZ-6495 I changed ViewEntityCondition.getWhereCondition(), ViewConditionExpr.createCondition() and ViewConditionList.createCondition() which will add additional condition of filtering by date to where clause. Please test by following steps. 1. Change the code below in GenericDAO if (queryTotalTime > 150) { Debug.logTiming("Ran query in " + queryTotalTime + " milli-seconds: " + " EntityName: " + modelEntity.getEntityName() + " Sql: " + sql + " where clause:" + whereEntityConditionParams, module); } to {code:title=GenericDAO.java|borderStyle=solid} if (queryTotalTime > 0) { Debug.logTiming("Ran query in " + queryTotalTime + " milli-seconds: " + " EntityName: " + modelEntity.getEntityName() + " Sql: " + sql + " where clause:" + whereEntityConditionParams, module); } It will always log the sql to the log file. 2. Open https://localhost:8443/partymgr/control/ImportExport 2. Enter a valid partyId for export and click SUBMIT 3. Check ofbiz.log file under runtime folder. You should able to see the query below which contains filter data condition SELECT PRT.PARTY_ID, PRT.STATUS_ID, PRT.PREFERRED_CURRENCY_UOM_ID, GRP.GROUP_NAME, PER.FIRST_NAME, PER.MIDDLE_NAME, PER.LAST_NAME, PR.PARTY_ID_FROM, CGRP.GROUP_NAME, PRL.ROLE_TYPE_ID, CM.CONTACT_MECH_TYPE_ID, PCP.CONTACT_MECH_PURPOSE_TYPE_ID, CM.INFO_STRING, TN.COUNTRY_CODE, TN.AREA_CODE, TN.CONTACT_NUMBER, PA.ADDRESS1, PA.ADDRESS2, PA.CITY, PA.STATE_PROVINCE_GEO_ID, PA.POSTAL_CODE, PA.COUNTRY_GEO_ID, PCM.FROM_DATE, PCM.THRU_DATE FROM (((((((((public.PARTY PRT LEFT OUTER JOIN public.PARTY_GROUP GRP ON PRT.PARTY_ID = GRP.PARTY_ID) LEFT OUTER JOIN public.PERSON PER ON PRT.PARTY_ID = PER.PARTY_ID) LEFT OUTER JOIN public.PARTY_RELATIONSHIP PR ON PRT.PARTY_ID = PR.PARTY_ID_TO AND ((PR.ROLE_TYPE_ID_FROM = 'ACCOUNT' AND PR.PARTY_RELATIONSHIP_TYPE_ID = 'EMPLOYMENT'))) LEFT OUTER JOIN public.PARTY_GROUP CGRP ON PR.PARTY_ID_FROM = CGRP.PARTY_ID) LEFT OUTER JOIN public.PARTY_ROLE PRL ON PRT.PARTY_ID = PRL.PARTY_ID) LEFT OUTER JOIN public.PARTY_CONTACT_MECH PCM ON PRT.PARTY_ID = PCM.PARTY_ID AND (((PCM.THRU_DATE IS NULL OR PCM.THRU_DATE > '2015-06-15 13:21:30.157') AND (PCM.FROM_DATE IS NULL OR PCM.FROM_DATE <= '2015-06-15 13:21:30.157')))) LEFT OUTER JOIN public.POSTAL_ADDRESS PA ON PCM.CONTACT_MECH_ID = PA.CONTACT_MECH_ID) LEFT OUTER JOIN public.CONTACT_MECH CM ON PCM.CONTACT_MECH_ID = CM.CONTACT_MECH_ID) LEFT OUTER JOIN public.TELECOM_NUMBER TN ON PCM.CONTACT_MECH_ID = TN.CONTACT_MECH_ID) LEFT OUTER JOIN public.PARTY_CONTACT_MECH_PURPOSE PCP ON PCM.CONTACT_MECH_ID = PCP.CONTACT_MECH_ID AND (((PCM.THRU_DATE IS NULL OR PCM.THRU_DATE > '2015-06-15 13:21:30.157') AND (PCM.FROM_DATE IS NULL OR PCM.FROM_DATE <= '2015-06-15 13:21:30.157'))) AND PCM.PARTY_ID = PCP.PARTY_ID AND (((PCM.THRU_DATE IS NULL OR PCM.THRU_DATE > '2015-06-15 13:21:30.236') AND (PCM.FROM_DATE IS NULL OR PCM.FROM_DATE <= '2015-06-15 13:21:30.236'))) WHERE (((PRL.ROLE_TYPE_ID = ? OR PRL.ROLE_TYPE_ID = ? OR PRL.ROLE_TYPE_ID = ?) AND (PRT.STATUS_ID <> ? OR PRT.STATUS_ID IS NULL) AND PRT.PARTY_ID = ?)) ORDER BY PRT.PARTY_ID ASC ------------------------------------------------------------------------ Modified: ofbiz/branches/release13.07/ (props changed) ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Propchange: ofbiz/branches/release13.07/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Oct 13 11:31:55 2015 @@ -5,4 +5,4 @@ /ofbiz/branches/jquery:952958-1044489 /ofbiz/branches/multitenant20100310:921280-927264 /ofbiz/branches/release12.04:1557118 -/ofbiz/trunk:1506269,1506499,1506504,1506828,1509164,1510042,1511279,1512376,1512573,1516094,1517629,1517702,1517780,1517947,1518336,1518950,1519245,1519999,1520319,1520321,1520326,1524361,1524676,1524704,1524769,1524835,1524950,1525523,1526276,1526387,1526463,1527212,1527254,1527609,1527626,1527810,1528144,1528146,1528149,1528298,1529412,1529418,1529588,1530273,1530634,1530876,1530972,1530976,1531848,1532342,1532366,1533542,1533839,1535961,1536170,1536656,1537023,1537086,1537179,1537996,1538096,1539147,1539156,1539781,1542264,1542388,1542442,1543744,1543766,1543781,1543994,1544444,1547548,1548143,1549015,1550255,1550258,1550515,1551585,1551744,1552149,1552290,1552500,1552901,1552908,1554064,1554242,1554265,1554290,1554373,1554536,1554681,1554685,1554706,1554764,1554787,1555142,1557409-1557410,1557427,1557440,1557443,1557447,1557456-1557457,1557462,1557593,1558145,1558241,1558373,1558774,1559814,1560048,1560056,1560176,1560203,1560205,1560699,1561286,1561290,1561305,1561311,1561327, 1561467,1562767,1563238,1563683,1563958,1564111,1564113,1564463,1564473,1564493,1566096,1566273,1569078,1569743,1570611,1570622,1570639-1570640,1571207,1571219,1571247,1573161,1573498,1573639,1574019,1574201,1574404,1575508,1576259,1576331,1576378,1576506,1576511,1576757,1576839,1577268,1577744,1579155,1579161,1579277,1579309,1580455,1580850,1581386,1581972,1581997,1582762,1583040,1583427-1583428,1583551,1583674,1583681,1583689,1583696,1584873,1585033,1585574,1585958-1585959,1586987,1587841,1587843,1588733,1589589,1589602,1589606,1589612,1589625,1589669,1592530,1592588,1592745,1592977,1593902,1593908,1593952,1597239,1597464,1598113,1598327,1598475,1598544,1598913,1603439,1603732,1603739,1604357,1604363,1604522,1604554,1605029,1605269,1605348,1605354,1605707,1607457,1608355,1608495,1608526,1608698,1609047,1609065,1609076,1609087,1609149,1609155,1609167,1609184,1609389,1609394,1609398,1609406,1609418,1609885,1609889,1610355,1610420,1610425,1610685,1610918,1610925,1611321,1612190,16122 02,1613121,1614019,1614025,1614280,1614355,1614366,1614556,1615296-1615297,1616272,1616684,1616940,1617229,1617473,1617480,1617936,1617938,1618395,1618397,1618570,1618831,1619087,1619098,1619300,1621335,1621363,1621413,1621436,1621438-1621439,1621442,1621599,1621683,1622050,1622170,1622672,1623370,1624538,1624767,1624809,1624817,1626797,1627230,1627763,1628096,1628130,1628937,1628940,1629382,1629391,1629426,1631203,1631299-1631300,1632764,1632793,1633100,1633188,1633550,1636864,1637883,1639606,1639835,1639840-1639841,1639846,1639863,1639887,1640288,1640299,1640515,1640717,1641066,1641131,1641165,1641548,1641804,1642423,1643341,1644904,1645950,1646204,1646935,1646977,1646984,1647266,1647338,1647559,1647606,1648668,1649239,1649393,1650240,1650583,1650642,1650678,1650882,1650938,1651593,1652361,1652725,1652731,1652739,1653456,1654175,1654273,1655046,1655795,1656983,1660389,1660444,1661358,1661612,1661778,1661853,1661873,1661940,1661951,1661977,1662361,1662500,1663912,1663979,1664602,16 64604,1666633,1666836,1666939,1666949,1667055,1667253,1668214,1668246,1668258,1668265,1668314,1669317,1670952,1672862,1672873,1673764,1674447,1674491,1674496,1674908,1676674,1677123,1677597,1677769-1677770,1678294,1678882,1678911,1679689,1679697,1680155,1680304,1680672,1680733,1680840,1680873,1680881,1682272,1682415,1683998,1686566,1686569,1686574,1686583,1686635,1686651,1687427,1690086,1692458,1693579,1696018,1696234,1697993,1701164,1702704,1703121,1703586,1703965,1703977,1703981,1704000,1704018,1704043,1704052,1704082,1704140,1704230,1705004,1706316,1706561,1706591,1706694,1707837 +/ofbiz/trunk:1506269,1506499,1506504,1506828,1509164,1510042,1511279,1512376,1512573,1516094,1517629,1517702,1517780,1517947,1518336,1518950,1519245,1519999,1520319,1520321,1520326,1524361,1524676,1524704,1524769,1524835,1524950,1525523,1526276,1526387,1526463,1527212,1527254,1527609,1527626,1527810,1528144,1528146,1528149,1528298,1529412,1529418,1529588,1530273,1530634,1530876,1530972,1530976,1531848,1532342,1532366,1533542,1533839,1535961,1536170,1536656,1537023,1537086,1537179,1537996,1538096,1539147,1539156,1539781,1542264,1542388,1542442,1543744,1543766,1543781,1543994,1544444,1547548,1548143,1549015,1550255,1550258,1550515,1551585,1551744,1552149,1552290,1552500,1552901,1552908,1554064,1554242,1554265,1554290,1554373,1554536,1554681,1554685,1554706,1554764,1554787,1555142,1557409-1557410,1557427,1557440,1557443,1557447,1557456-1557457,1557462,1557593,1558145,1558241,1558373,1558774,1559814,1560048,1560056,1560176,1560203,1560205,1560699,1561286,1561290,1561305,1561311,1561327, 1561467,1562767,1563238,1563683,1563958,1564111,1564113,1564463,1564473,1564493,1566096,1566273,1569078,1569743,1570611,1570622,1570639-1570640,1571207,1571219,1571247,1573161,1573498,1573639,1574019,1574201,1574404,1575508,1576259,1576331,1576378,1576506,1576511,1576757,1576839,1577268,1577744,1579155,1579161,1579277,1579309,1580455,1580850,1581386,1581972,1581997,1582762,1583040,1583427-1583428,1583551,1583674,1583681,1583689,1583696,1584873,1585033,1585574,1585958-1585959,1586987,1587841,1587843,1588733,1589589,1589602,1589606,1589612,1589625,1589669,1592530,1592588,1592745,1592977,1593902,1593908,1593952,1597239,1597464,1598113,1598327,1598475,1598544,1598913,1603439,1603732,1603739,1604357,1604363,1604522,1604554,1605029,1605269,1605348,1605354,1605707,1607457,1608355,1608495,1608526,1608698,1609047,1609065,1609076,1609087,1609149,1609155,1609167,1609184,1609389,1609394,1609398,1609406,1609418,1609885,1609889,1610355,1610420,1610425,1610685,1610918,1610925,1611321,1612190,16122 02,1613121,1614019,1614025,1614280,1614355,1614366,1614556,1615296-1615297,1616272,1616684,1616940,1617229,1617473,1617480,1617936,1617938,1618395,1618397,1618570,1618831,1619087,1619098,1619300,1621335,1621363,1621413,1621436,1621438-1621439,1621442,1621599,1621683,1622050,1622170,1622672,1623370,1624538,1624767,1624809,1624817,1626797,1627230,1627763,1628096,1628130,1628937,1628940,1629382,1629391,1629426,1631203,1631299-1631300,1632764,1632793,1633100,1633188,1633550,1636864,1637883,1639606,1639835,1639840-1639841,1639846,1639863,1639887,1640288,1640299,1640515,1640717,1641066,1641131,1641165,1641548,1641804,1642423,1643341,1644904,1645950,1646204,1646935,1646977,1646984,1647266,1647338,1647559,1647606,1648668,1649239,1649393,1650240,1650583,1650642,1650678,1650882,1650938,1651593,1652361,1652725,1652731,1652739,1653456,1654175,1654273,1655046,1655795,1656983,1660389,1660444,1661358,1661612,1661778,1661853,1661873,1661940,1661951,1661977,1662361,1662500,1663912,1663979,1664602,16 64604,1666633,1666836,1666939,1666949,1667055,1667253,1668214,1668246,1668258,1668265,1668314,1669317,1670952,1672862,1672873,1673764,1674447,1674491,1674496,1674908,1676674,1677123,1677597,1677769-1677770,1678294,1678882,1678911,1679689,1679697,1680155,1680304,1680672,1680733,1680840,1680873,1680881,1682272,1682415,1683998,1686566,1686569,1686574,1686583,1686635,1686651,1687427,1690086,1692458,1693579,1696018,1696234,1697993,1701164,1702704,1703121,1703586,1703965,1703977,1703981,1704000,1704018,1704043,1704052,1704082,1704140,1704230,1705004,1706316,1706561,1706591,1706694,1707837,1708341 Modified: ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=1708346&r1=1708345&r2=1708346&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original) +++ ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Tue Oct 13 11:31:55 2015 @@ -52,7 +52,8 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityConditionParam; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.config.model.*; +import org.ofbiz.entity.config.model.Datasource; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.jdbc.DatabaseUtil; import org.ofbiz.entity.jdbc.SQLProcessor; Modified: ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=1708346&r1=1708345&r2=1708346&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original) +++ ofbiz/branches/release13.07/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Tue Oct 13 11:31:55 2015 @@ -45,6 +45,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityJoinOperator; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.jdbc.SqlJdbcUtil; +import org.ofbiz.entity.util.EntityUtil; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -1288,11 +1289,16 @@ public class ModelViewEntity extends Mod } public EntityCondition getWhereCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) { + + List<EntityCondition> conditionList = new LinkedList<EntityCondition>(); + if(this.filterByDate) { + conditionList.add(EntityUtil.getFilterByDateExpr()); + } if (this.whereCondition != null) { - return this.whereCondition.createCondition(modelFieldTypeReader, entityAliasStack); - } else { - return null; + conditionList.add(whereCondition.createCondition(modelFieldTypeReader, entityAliasStack)); } + + return EntityCondition.makeCondition(conditionList, EntityOperator.AND); } public EntityCondition getHavingCondition(ModelFieldTypeReader modelFieldTypeReader, List<String> entityAliasStack) { @@ -1396,30 +1402,42 @@ public class ModelViewEntity extends Mod rhs = EntityFieldValue.makeFieldValue(this.relFieldName, this.relEntityAlias, entityAliasStack, this.viewEntityCondition.modelViewEntity); } + EntityCondition entityCondition; + if (this.operator == EntityOperator.NOT_EQUAL && value != null) { // since some databases don't consider nulls in != comparisons, explicitly include them // this makes more sense logically, but if anyone ever needs it to not behave this way we should add an "or-null" attribute that is true by default if (ignoreCase) { - return EntityCondition.makeCondition( + entityCondition = EntityCondition.makeCondition( EntityCondition.makeCondition(EntityFunction.UPPER(lhs), this.operator, EntityFunction.UPPER(rhs)), EntityOperator.OR, EntityCondition.makeCondition(lhs, EntityOperator.EQUALS, null)); } else { - return EntityCondition.makeCondition( + entityCondition = EntityCondition.makeCondition( EntityCondition.makeCondition(lhs, this.operator, rhs), EntityOperator.OR, EntityCondition.makeCondition(lhs, EntityOperator.EQUALS, null)); } } else if ( value == null && this.relFieldName == null && (this.operator == EntityOperator.EQUALS || this.operator == EntityOperator.NOT_EQUAL)) { - return EntityCondition.makeCondition(lhs, this.operator, null); + entityCondition = EntityCondition.makeCondition(lhs, this.operator, null); } else { if (ignoreCase) { // use the stuff to upper case both sides - return EntityCondition.makeCondition(EntityFunction.UPPER(lhs), this.operator, EntityFunction.UPPER(rhs)); + entityCondition = EntityCondition.makeCondition(EntityFunction.UPPER(lhs), this.operator, EntityFunction.UPPER(rhs)); } else { - return EntityCondition.makeCondition(lhs, this.operator, rhs); + entityCondition = EntityCondition.makeCondition(lhs, this.operator, rhs); } } + + if(this.viewEntityCondition.filterByDate) { + List<EntityCondition> conditionList = new LinkedList<EntityCondition>(); + conditionList.add(entityCondition); + conditionList.add(EntityUtil.getFilterByDateExpr()); + return EntityCondition.makeCondition(conditionList, EntityOperator.AND); + } else { + return entityCondition; + } + } } @@ -1478,6 +1496,14 @@ public class ModelViewEntity extends Mod } } + if(this.viewEntityCondition.filterByDate) { + entityConditionList.add(EntityUtil.getFilterByDateExpr()); + } + + if(this.viewEntityCondition.filterByDate) { + entityConditionList.add(EntityUtil.getFilterByDateExpr()); + } + return EntityCondition.makeCondition(entityConditionList, this.operator); } } |
Free forum by Nabble | Edit this page |