dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32397
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16540: Add pagination and standard filter box for SQL Views list.
------------------------------------------------------------
revno: 16540
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-08-27 19:50:13 +0700
message:
Add pagination and standard filter box for SQL Views list.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/GetSqlViewListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java 2014-08-27 12:50:13 +0000
@@ -67,6 +67,8 @@
String makeUpForQueryStatement( String query );
+ int getSqlViewCountByName( String name );
+
// -------------------------------------------------------------------------
// SqlView Expanded
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java 2014-08-27 12:50:13 +0000
@@ -134,6 +134,12 @@
return query.replaceAll( "\\s*;\\s+", ";" ).replaceAll( ";+", ";" ).replaceAll( "\\s+", " " ).trim();
}
+ @Override
+ public int getSqlViewCountByName( String name )
+ {
+ return sqlViewStore.getCountLikeName( name );
+ }
+
// -------------------------------------------------------------------------
// SqlView expanded
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/GetSqlViewListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/GetSqlViewListAction.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/GetSqlViewListAction.java 2014-08-27 12:50:13 +0000
@@ -28,18 +28,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.sqlview.SqlViewService;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Dang Duy Hieu
*/
public class GetSqlViewListAction
- implements Action
+ extends ActionPagingSupport<SqlView>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -63,6 +67,18 @@
return sqlViewObjectList;
}
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -70,8 +86,23 @@
public String execute()
throws Exception
{
- sqlViewObjectList = new ArrayList<>( sqlViewService.getAllSqlViews() );
+ if ( isNotBlank( key ) )
+ {
+ this.paging = createPaging( sqlViewService.getSqlViewCountByName( key ) );
+ sqlViewObjectList = new ArrayList<>(
+ sqlViewService.getSqlViewsBetweenByName( key, paging.getStartPos(),
+ paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( sqlViewService.getSqlViewCount() );
+
+ sqlViewObjectList = new ArrayList<>( sqlViewService.getSqlViewsBetween(
+ paging.getStartPos(), paging.getPageSize() ) );
+ }
+ Collections.sort( sqlViewObjectList, IdentifiableObjectNameComparator.INSTANCE );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2014-08-04 15:15:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2014-08-27 12:50:13 +0000
@@ -287,7 +287,7 @@
<param name="requiredAuthorities">F_SQLVIEW_MANAGEMENT</param>
</action>
- <action name="showSqlViewListForm" class="org.hisp.dhis.dataadmin.action.sqlview.GetSqlViewListAction">
+ <action name="sqlView" class="org.hisp.dhis.dataadmin.action.sqlview.GetSqlViewListAction">
<result name="success" type="velocity">/main.vm</result>
<param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
<param name="page">/dhis-web-maintenance-dataadmin/sqlView.vm</param>