Hi Gorka,
Good that you brought this up. Here are some replies from my side:

This blog can be interesting:
http://mtopenbravo.blogspot.com/2010/01/integrating-data-access-layer-with.html

You are right that it is difficult to find all these utility methods. For the 
DAL I propose to centralize them in one location, for example the package: 
org.openbravo.dal.service.

The generic DAO mentioned by you seems to be a good candidate for having in 
there also.

Another thing to consider is that it could be quite easy to generate DAO 
classes for each entity. So instead of hand coding we could add a generate step 
when generating entities. To comment in detail I would need to see the DAO 
classes you currently have. 

Regarding the IN clause remark. Last week I added the possibility to set a List 
parameter in the OBQuery. So then it is not needed anymore to do this comma 
delimited String conversion. 

So something like this hql: 
from Client where organization in (:orgList)
and then:
query.setNamedParameter("orgList", organizationList);
where organizationList is a List of Organization instances.

The same works for id's also:
from Client where organization.id in (:orgIdList)
and then:
query.setNamedParameter("orgIdList", organizationIdList);
where organizationIdList is a List of String objects

gr. Martin

Gorka Ion Damián wrote:
> Hi all,
>
> In core there has always been some utility classes, the main one 
> org.openbravo.erpCommon.utility.Utility, with generic methods to be used 
> in the servlets. Since 2.50 and the introduction of DAL it has increased 
> the necessity of new methods based on this new technology.
>
> During the last months I've seen how the same methods have been applied 
> on different modules that I think should be in core.
>
> These are some examples of methods that could be in core:
>
> * A method that given a String it parses to return a java.util.Date 
> object. With xsql this wasn't necessary as we needed strings to build 
> the queries, but now using OBCriteria we need a java.util.Date object to 
> filter by dates so the need to parse the String with the Dates has 
> increased a lot.
>
> * A method that given a class and a current value id it returns a String 
> with the options html code, or a FieldProvider with the data to fill 
> dependent combos. BPDebtConsolidation, mass advanced payments, mass 
> invoicing and so on have different methods to build combos using lists 
> instead of using ComboTableData. We should centralize them and make 
> these modules to use them.
>
> * This one is maybe not a good example, but it is happening, a method 
> that given a OBObject class and a string with its id returns the 
> corresponding object. This can be currently done with: 
> "OBDal.getInstance().get(class, strId)". In recent modules we are 
> building a dao class where we do all the DAL accesses. This is, if we 
> have a String with an invoice id we are creating a getInvoice method in 
> the dao class to get the Invoice object with the 
> "OBDal.getInstance().get(Invoice.class, strInvoiceId)" code. In the last 
> module that I've developed I've created a more generic method with the 
> OBObject class as a parameter.
>
> * A method that given a List with OBObjects it returns a String with the 
> ids separated by commas. Currently we work with List objects, but if we 
> have to create a OBQuery with an IN clause we have to convert them to a 
> String.
>
> And I'm sure that are much more examples. I can provide the code of the 
> mentioned methods if needed.
>
> As a side issue, it is almost impossible to know the currently available 
> methods. Most of them are included in the mentioned Utility class 
> without a specific order and there are other classes with useful 
> methods. We should reorder them in different classes with friendly names 
> and include the API somewhere in the wiki so it is easier to developers 
> to know if it is available.
>
> Regards
> Gorka Ion
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> Openbravo-development mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbravo-development
>
>   


-- 

With Regards, Martin Taal

Openbravo
M: +31 6 288 48 943
@: [email protected]
Skype: martintaal

Openbravo Headquarters:
P: +34 93 27 25 947
F: +34 93 27 25 905
Address: Edificio Slan, Planta 2a, Landaben, Calle J, 31012 Pamplona, Navarra, 
Spain
Mailing address: PO Box 5117, 31010 Pamplona, Navarra, Spain



------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Openbravo-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-development

Reply via email to