Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0020635Openbravo ERPA. Platformpublic2012-05-30 09:472012-06-22 10:01
ngarcia 
AugustoMauch 
normalminoralways
closedfixed 
5
pi 
3.0MP143.0MP13 
Core
No
0020635: Cannot convert a date from a parameter of a widget to the HQL Query
Cannot convert a date from a parameter of a widget to the HQL Query
As system administrator:
  Go to the Widget screen and create a new record with Query/List as the Widget Superclass
  Go to the Parameters tab
  Create a record with the following info:
     DB Column Name: dateFrom (for example)
     Reference: Date
     Fixed: not checked
  Go tho Query tab and create a record with the following HQL (for example):
     select inv.id as invoiceId, inv.documentNo as documentNo
     from Invoice as inv
     where inv.invoiceDate = :dateFrom
  Go to Column subtab and add some columns for example with the following Display Column Aliases: documentNo and invoiceDate
  Go to the Workspace and add the widget

When choosing the date and clicking on Save the following exception is thrown:

ERROR org.openbravo.client.application.ParameterUtils - Error trying to set value for paramter: From
java.text.ParseException: Unparseable date: "2012-05-02"
No tags attached.
Issue History
2012-05-30 09:47ngarciaNew Issue
2012-05-30 09:47ngarciaAssigned To => alostale
2012-05-30 09:47ngarciaModules => Core
2012-05-30 09:47ngarciaResolution time => 1344808800
2012-06-04 11:51alostaleAssigned Toalostale => AugustoMauch
2012-06-05 19:20hgbotCheckin
2012-06-05 19:20hgbotNote Added: 0049630
2012-06-05 19:23AugustoMauchNote Added: 0049631
2012-06-05 19:29hgbotCheckin
2012-06-05 19:29hgbotNote Added: 0049632
2012-06-05 19:29hgbotStatusnew => resolved
2012-06-05 19:29hgbotResolutionopen => fixed
2012-06-05 19:29hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/a067d7d8026469593bf767a93b46152ff2800862 [^]
2012-06-06 15:32hgbotCheckin
2012-06-06 15:32hgbotNote Added: 0049650
2012-06-11 13:09ngarciaNote Added: 0049728
2012-06-11 13:09ngarciaStatusresolved => closed
2012-06-11 13:47AugustoMauchStatusclosed => new
2012-06-11 13:47AugustoMauchResolutionfixed => open
2012-06-11 13:47AugustoMauchStatusnew => scheduled
2012-06-11 13:47AugustoMauchfix_in_branch => pi
2012-06-11 13:47AugustoMauchStatusscheduled => resolved
2012-06-11 13:47AugustoMauchResolutionopen => fixed
2012-06-12 12:56ngarciaIssue Monitored: networkb
2012-06-22 10:01alostaleNote Added: 0050022
2012-06-22 10:01alostaleStatusresolved => closed
2012-06-22 10:01alostaleFixed in Version => 3.0MP13

Notes
(0049630)
hgbot   
2012-06-05 19:20   
Repository: erp/devel/pi
Changeset: f2db58a09d687182cc8f2e6df0b00cabbcf228e4
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jun 05 19:19:17 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/f2db58a09d687182cc8f2e6df0b00cabbcf228e4 [^]

Related to issue 20635: Date is parsed correctly

The date was not being parsed correctly because ParameterUtils was only supporting the yyyy-MM-dd'T'HH:mm:ss pattern, and the value was formatted with the yyy-MM-dd pattern.

Now, the method createFromString() of the DateDomainType is being used to parse the date. This method supports both patterns.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/ParameterUtils.java
---
(0049631)
AugustoMauch   
2012-06-05 19:23   
The previous fix is not enough to fix the issue. Now, even though the date is correctly parsed, the hibernate query fails, because it received the date as a String, but is expecting a Date.

This is due of the design of the class, which uses a Map<String, String> to represent the parameters of the widget.

To solve this, the reference of the parameters should be checked, and it they are dates, they should be converted from String to Date.
(0049632)
hgbot   
2012-06-05 19:29   
Repository: erp/devel/pi
Changeset: a067d7d8026469593bf767a93b46152ff2800862
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jun 05 19:28:42 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/a067d7d8026469593bf767a93b46152ff2800862 [^]

Fixes issue 20635: date parameter works in Query/List widget

If a parameter is a Date, it is converted from its original class (String) to Date before setting the query parameter.

---
M modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
---
(0049650)
hgbot   
2012-06-06 15:32   
Repository: erp/devel/pi
Changeset: eabe78fe0e7aff8b5ad8d3bb4a6605ce8bc933ba
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Jun 06 15:31:19 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/eabe78fe0e7aff8b5ad8d3bb4a6605ce8bc933ba [^]

Related to issue 20635: a wrong property was being checked.

In the isDate method of QueryListDataSource, the field name was being used to check if a parameter was contained in the parameter list. This was wrong, the dbColumnName field is the one to be checked.

---
M modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
---
(0049728)
ngarcia   
2012-06-11 13:09   
Verified
(0050022)
alostale   
2012-06-22 10:01   
code reviewed on pi@889f630ff69d