Thank you very much Martin! That worked perfectly :)

I attached the new diff that easily permits to save one XSQL file by
replacing the query by DAL.

I hope that it helps you :)

Cheers!

Rafa Roda Palacios

2009/10/5 Martin Taal <[email protected]>

> Hi Rafa,
> Based on quick read of your diff, I think you can replace most of the
> where-clause and OBQuery with these lines:
>
>   final PriceList priceList = OBDal.getInstance().get(PriceList.class,
> strMPriceListID);
>   if (priceList != null) {
>       strPriceListCurrency = pl.getCurrency().getId();
>   }
>
> gr. Martiin
>
> Rafa Roda @ Openbravo wrote:
>
>> Hi Openbravo developers!
>>
>> I've been playing around a bit with DAL replacing an XSQL from a callout
>> by a DAL OBQuery.
>>
>> The callout is SL_Project_PriceList.java [1], a simple callout that
>> selects the Currency from the Price List chosen in the Multiphase or Service
>> Project header.
>>
>> The diff attached does the job but I would like to know if it can be
>> achieved in a cleaner way from a code perspective.
>>
>> Based on this, I would like to update the How-To Callout example [2] in
>> order to use DAL OBQuery instead of an xSQL file.
>>
>> Thanks for any comment.
>>
>> Rafa Roda Palacios
>>
>> [1]
>> https://code.openbravo.com/erp/devel/pi/file/74eb0fd11265/src/org/openbravo/erpCommon/ad_callouts/SL_Project_PriceList.java
>> [2]
>> http://wiki.openbravo.com/wiki/ERP/2.50/Developers_Guide/How_to_develop_a_callout
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
>
>
diff -r 402da4a11d1c src/org/openbravo/erpCommon/ad_callouts/SL_Project_PriceList.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_Project_PriceList.java	Wed Sep 23 15:34:56 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_Project_PriceList.java	Thu Oct 01 17:41:04 2009 +0200
@@ -28,6 +28,8 @@
 
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.pricing.pricelist.*;
 import org.openbravo.xmlEngine.XmlDocument;
 
 public class SL_Project_PriceList extends HttpSecureAppServlet {
@@ -66,6 +68,17 @@
 
     SLProjectPriceListData[] data = SLProjectPriceListData.select(this, strMPriceListID);
     StringBuffer resultado = new StringBuffer();
+    
+    // Start DAL code
+   
+    String strPriceListCurrency = "";
+    
+    final PriceList priceList = OBDal.getInstance().get(PriceList.class, strMPriceListID);
+    if (priceList != null) {
+        strPriceListCurrency = priceList.getCurrency().getId();
+    }
+    
+    // End DAL code
 
     resultado.append("var calloutName='SL_Project_PriceList';\n\n");
     resultado.append("var respuesta = new Array(");
@@ -73,7 +86,7 @@
       // resultado.append("new Array(\"inpistaxincluded\", \"" +
       // data[0].istaxincluded + "\"),\n"); C_Project table does not saves
       // IsTaxIncluded value
-      resultado.append("new Array(\"inpcCurrencyId\", \"" + data[0].cCurrencyId + "\")\n");
+      resultado.append("new Array(\"inpcCurrencyId\", \"" + strPriceListCurrency + "\")\n");
     }
     resultado.append(");\n");
 
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Openbravo-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-development

Reply via email to