CI: promote changesets from pi to main
authorRM packaging bot <staff.rm@openbravo.com>
Fri, 10 Dec 2010 06:35:55 +0000
changeset 9089 35c9b49515ef
parent 9086 16edb4853bf0 (current diff)
parent 9088 3322e18ae878 (diff)
child 9464 7d7e5eebcc62
CI: promote changesets from pi to main
src-db/database/sourcedata/AD_MODULE.xml
--- a/src-db/database/sourcedata/AD_MODULE.xml	Thu Dec 09 13:27:08 2010 +0000
+++ b/src-db/database/sourcedata/AD_MODULE.xml	Fri Dec 10 06:35:55 2010 +0000
@@ -6,7 +6,7 @@
 <!--0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0-->  <NAME><![CDATA[Core]]></NAME>
-<!--0-->  <VERSION><![CDATA[2.50.19085]]></VERSION>
+<!--0-->  <VERSION><![CDATA[2.50.19088]]></VERSION>
 <!--0-->  <DESCRIPTION><![CDATA[Core module is the base one]]></DESCRIPTION>
 <!--0-->  <HELP><![CDATA[Core module is the base one, all developments in core are included as part of the standard Openbravo ERP.]]></HELP>
 <!--0-->  <URL><![CDATA[www.openbravo.com]]></URL>
--- a/src/org/openbravo/dal/service/OBQuery.java	Thu Dec 09 13:27:08 2010 +0000
+++ b/src/org/openbravo/dal/service/OBQuery.java	Fri Dec 10 06:35:55 2010 +0000
@@ -151,6 +151,38 @@
     return ((Number) qry.uniqueResult()).intValue();
   }
 
+  /**
+   * Computes the row number of a record which has the id which is passed in as a parameter. The
+   * rownumber computation takes into account the filter and sorting settings of the the OBQuery
+   * object.
+   * 
+   * @param targetId
+   *          the record id
+   * @return the row number or -1 if not found
+   */
+  public int getRowNumber(String targetId) {
+    String qryStr = createQueryString();
+    if (qryStr.toLowerCase().contains(FROM_SPACED)) {
+      final int index = qryStr.indexOf(FROM_SPACED) + FROM_SPACED.length();
+      qryStr = qryStr.substring(index);
+    }
+    final Query qry = getSession().createQuery("select id " + FROM_SPACED + qryStr);
+    setParameters(qry);
+
+    final ScrollableResults results = qry.scroll(ScrollMode.FORWARD_ONLY);
+    try {
+      while (results.next()) {
+        final String id = results.getString(0);
+        if (id.equals(targetId)) {
+          return results.getRowNumber();
+        }
+      }
+    } finally {
+      results.close();
+    }
+    return -1;
+  }
+
   private String stripOrderBy(String qryStr) {
     if (qryStr.toLowerCase().indexOf(ORDERBY) != -1) {
       return qryStr.substring(0, qryStr.toLowerCase().indexOf(ORDERBY));