From abef172dd0be399986d275672cf5fc74b8916885 Mon Sep 17 00:00:00 2001 From: sauljabin Date: Fri, 15 May 2015 12:52:37 -0500 Subject: [PATCH] IDEMPIERE-2623 Limit and offset in queryData WebService --- .../Notes/HowToAddNewWebService.txt | 18 ++++++++++++++++++ .../adinterface/ModelADServiceImpl.java | 14 ++++++++++---- .../WEB-INF/xsd/idempiere-schema.xsd | 2 ++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/org.idempiere.webservices/Notes/HowToAddNewWebService.txt b/org.idempiere.webservices/Notes/HowToAddNewWebService.txt index 045bd2ce31..341baf5b71 100644 --- a/org.idempiere.webservices/Notes/HowToAddNewWebService.txt +++ b/org.idempiere.webservices/Notes/HowToAddNewWebService.txt @@ -11,9 +11,27 @@ the new webservice will have the following parameters: Note, if you need to define new datatypes you need to define them in WEB-INF/xsd/idempiere-schema.xsd and generate the idempiere-xmlbeans.jar again with this command: + scomp -out ./WEB-INF/lib/idempiere-xmlbeans.jar ./WEB-INF/xsd/idempiere-schema.xsd + scomp will generate the corresponding classes to manipulate the xml objects from the messages +To install xmlbeans Git Clone URL: git://git.apache.org/xmlbeans.git +cd xmlbeans/ +./xbeanenv.sh +ant + +Environment example: +export XMLBEANS_HOME=/opt/xmlbeans +export PATH=$PATH:$XMLBEANS_HOME/bin +export XMLBEANS_LIB=$XMLBEANS_HOME/build/lib +export JAVA_HOME=/usr/lib/jvm/java-1.7.0...(your path) + +Apps: +ant +svn +git + The method will be called modelSetDocAction - the model in name indicates that the web service is going to be based on model classes, current web services are based in UI instead of model. diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java index 7e370c3ff0..4b73fc370e 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java @@ -1478,6 +1478,9 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID()); int cnt = 0; + int rowCnt = 0; + int offset = modelCRUD.getOffset(); + int limit = modelCRUD.getLimit(); PreparedStatement pstmtquery = null; ResultSet rsquery = null; @@ -1539,6 +1542,9 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic DataSet ds = resp.addNewDataSet(); while (rsquery.next ()) { cnt++; + if ((offset >= cnt) || (limit > 0 && offset+limit < cnt)) + continue; + rowCnt++; DataRow dr = ds.addNewDataRow(); for (int i = 0; i < poinfo.getColumnCount(); i++) { String columnName = poinfo.getColumnName(i); @@ -1560,11 +1566,11 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic rsquery = null; pstmtquery = null; } - resp.setSuccess(true); - resp.setRowCount(cnt); - resp.setNumRows(cnt); + resp.setSuccess(true); + resp.setRowCount(rowCnt); + resp.setNumRows(rowCnt); resp.setTotalRows(cnt); - resp.setStartRow(1); + resp.setStartRow(offset); return ret; } finally { diff --git a/org.idempiere.webservices/WEB-INF/xsd/idempiere-schema.xsd b/org.idempiere.webservices/WEB-INF/xsd/idempiere-schema.xsd index 3ec31594ac..0ab0ec392f 100644 --- a/org.idempiere.webservices/WEB-INF/xsd/idempiere-schema.xsd +++ b/org.idempiere.webservices/WEB-INF/xsd/idempiere-schema.xsd @@ -263,6 +263,8 @@ + +