dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29412
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14855: Add filter-by-name and pagging for Relationship type ( tracker module ).
------------------------------------------------------------
revno: 14855
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-14 23:59:05 +0800
message:
Add filter-by-name and pagging for Relationship type ( tracker module ).
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipTypeService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipTypeService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/relationship/GetRelationshipTypeListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/GetAttributeGroupListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeGroup.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/relationshipType.vm
--
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/relationship/RelationshipTypeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipTypeService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipTypeService.java 2014-04-14 15:59:05 +0000
@@ -30,6 +30,8 @@
import java.util.Collection;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+
/**
* @author Abyot Asalefew
* @version $Id$
@@ -72,9 +74,9 @@
/**
* Returns a {@link RelationshipType}.
- *
+ *
* @param uid the uid of the RelationshipType to return.
- *
+ *
* @return the RelationshipType with the given id
*/
RelationshipType getRelationshipType( String uid );
@@ -97,4 +99,41 @@
*/
Collection<RelationshipType> getAllRelationshipTypes();
+ /**
+ * Returns The number of RelationshipTypes with the key searched
+ *
+ * @param name Keyword for searching by name
+ *
+ * @return A number
+ *
+ */
+ Integer getRelationshipTypeCountByName( String name );
+
+ /**
+ * Returns {@link TrackedEntityAttribute} list with paging
+ *
+ * @param name Keyword for searching by name
+ * @param min
+ * @param max
+ * @return a collection of all TrackedEntityAttribute, or an empty
+ * collection if there are no TrackedEntityAttributes.
+ */
+ Collection<? extends RelationshipType> getRelationshipTypesBetweenByName( String name,
+ int min, int max );
+
+ /**
+ * Returns The number of all TrackedEntityAttribute available
+ *
+ */
+ Integer getRelationshipTypeCount();
+
+ /**
+ * Returns {@link TrackedEntityAttribute} list with paging
+ *
+ * @param min
+ * @param max
+ * @return a collection of all TrackedEntityAttribute, or an empty
+ * collection if there are no TrackedEntityAttributes.
+ */
+ Collection<RelationshipType> getRelationshipTypesBetween( int min, int max );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeGroupService.java 2014-04-14 15:59:05 +0000
@@ -42,23 +42,27 @@
/**
* Adds an {@link TrackedEntityAttributeGroup}
*
- * @param TrackedEntityAttributeGroup The to TrackedEntityAttributeGroup add.
+ * @param TrackedEntityAttributeGroup The to TrackedEntityAttributeGroup
+ * add.
*
- * @return A generated unique id of the added {@link TrackedEntityAttributeGroup}.
+ * @return A generated unique id of the added
+ * {@link TrackedEntityAttributeGroup}.
*/
int addTrackedEntityAttributeGroup( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
/**
* Deletes a {@link TrackedEntityAttributeGroup}.
*
- * @param TrackedEntityAttributeGroup the TrackedEntityAttributeGroup to delete.
+ * @param TrackedEntityAttributeGroup the TrackedEntityAttributeGroup to
+ * delete.
*/
void deleteTrackedEntityAttributeGroup( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
/**
* Updates a {@link TrackedEntityAttributeGroup}.
*
- * @param TrackedEntityAttributeGroup the TrackedEntityAttributeGroup to update.
+ * @param TrackedEntityAttributeGroup the TrackedEntityAttributeGroup to
+ * update.
*/
void updateTrackedEntityAttributeGroup( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
@@ -73,9 +77,9 @@
/**
* Returns a {@link TrackedEntityAttributeGroup}.
- *
+ *
* @param uid the id of the TrackedEntityAttributeGroup to return.
- *
+ *
* @return the TrackedEntityAttributeGroup with the given id
*/
TrackedEntityAttributeGroup getTrackedEntityAttributeGroup( String uid );
@@ -85,24 +89,65 @@
*
* @param name the name of the TrackedEntityAttributeGroup to return.
*
- * @return the TrackedEntityAttributeGroup with the given name, or null if no match.
+ * @return the TrackedEntityAttributeGroup with the given name, or null if
+ * no match.
*/
TrackedEntityAttributeGroup getTrackedEntityAttributeGroupByName( String name );
/**
* Returns all {@link TrackedEntityAttributeGroup}
*
- * @return a collection of all TrackedEntityAttributeGroup, or an empty collection if there are
- * no TrackedEntityAttributeGroups.
+ * @return a collection of all TrackedEntityAttributeGroup, or an empty
+ * collection if there are no TrackedEntityAttributeGroups.
*/
Collection<TrackedEntityAttributeGroup> getAllTrackedEntityAttributeGroups();
/**
- * Get {@link TrackedEntityAttribute} by a {@link TrackedEntityAttributeGroup}
+ * Get {@link TrackedEntityAttribute} by a
+ * {@link TrackedEntityAttributeGroup}
*
* @param TrackedEntityAttributeGroup {@link TrackedEntityAttributeGroup}
*
* @return TrackedEntityAttribute list
*/
- List<TrackedEntityAttribute> getTrackedEntityAttributes( TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
+ List<TrackedEntityAttribute> getTrackedEntityAttributes(
+ TrackedEntityAttributeGroup TrackedEntityAttributeGroup );
+
+ /**
+ * Returns The number of TrackedEntityAttributeGroups with the key searched
+ *
+ * @param name Keyword for searching by name
+ *
+ * @return A number
+ *
+ */
+ Integer getTrackedEntityAttributeGroupCountByName( String name );
+
+ /**
+ * Returns {@link TrackedEntityAttribute} list with paging
+ *
+ * @param name Keyword for searching by name
+ * @param min
+ * @param max
+ * @return a collection of all TrackedEntityAttribute, or an empty
+ * collection if there are no TrackedEntityAttributes.
+ */
+ Collection<? extends TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetweenByName( String name,
+ int min, int max );
+
+ /**
+ * Returns The number of all TrackedEntityAttribute available
+ *
+ */
+ Integer getTrackedEntityAttributeGroupCount();
+
+ /**
+ * Returns {@link TrackedEntityAttribute} list with paging
+ *
+ * @param min
+ * @param max
+ * @return a collection of all TrackedEntityAttribute, or an empty
+ * collection if there are no TrackedEntityAttributes.
+ */
+ Collection<TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetween( int min, int max );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipTypeService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipTypeService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipTypeService.java 2014-04-14 15:59:05 +0000
@@ -28,13 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
+import java.util.Collection;
+
import org.hisp.dhis.i18n.I18nService;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Collection;
-
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
/**
* @author Abyot Asalefew
* @version $Id$
@@ -100,4 +100,28 @@
{
return i18n( i18nService, relationshipTypeStore.getRelationshipType( aIsToB, bIsToA ) );
}
+
+ @Override
+ public Integer getRelationshipTypeCountByName( String name )
+ {
+ return relationshipTypeStore.getCountLikeName( name );
+ }
+
+ @Override
+ public Collection<? extends RelationshipType> getRelationshipTypesBetweenByName( String name, int min, int max )
+ {
+ return relationshipTypeStore.getAllLikeNameOrderedName( name, min, max );
+ }
+
+ @Override
+ public Integer getRelationshipTypeCount()
+ {
+ return relationshipTypeStore.getCount();
+ }
+
+ @Override
+ public Collection<RelationshipType> getRelationshipTypesBetween( int min, int max )
+ {
+ return relationshipTypeStore.getAllOrderedName( min, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java 2014-04-14 15:59:05 +0000
@@ -116,4 +116,29 @@
return new ArrayList<TrackedEntityAttribute>( i18n( i18nService, attributeGroup.getAttributes() ) );
}
+ @Override
+ public Integer getTrackedEntityAttributeGroupCountByName( String name )
+ {
+ return attributeGroupStore.getCountLikeName( name );
+ }
+
+ @Override
+ public Collection<? extends TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetweenByName( String name,
+ int min, int max )
+ {
+ return attributeGroupStore.getAllLikeNameOrderedName( name, min, max );
+ }
+
+ @Override
+ public Integer getTrackedEntityAttributeGroupCount()
+ {
+ return attributeGroupStore.getCount();
+ }
+
+ @Override
+ public Collection<TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetween( int min, int max )
+ {
+ return attributeGroupStore.getAllOrderedName( min, max );
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/relationship/GetRelationshipTypeListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/relationship/GetRelationshipTypeListAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/relationship/GetRelationshipTypeListAction.java 2014-04-14 15:59:05 +0000
@@ -28,20 +28,23 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
import java.util.ArrayList;
-import java.util.Collection;
+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.relationship.RelationshipType;
import org.hisp.dhis.relationship.RelationshipTypeService;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Abyot Asalefew Gizaw
* @version $Id$
*/
public class GetRelationshipTypeListAction
- implements Action
+extends ActionPagingSupport<RelationshipType>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -58,13 +61,24 @@
// Input/Output
// -------------------------------------------------------------------------
- private Collection<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>();
+ private List<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>();
- public Collection<RelationshipType> getRelationshipTypes()
+ public List<RelationshipType> getRelationshipTypes()
{
return relationshipTypes;
}
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -72,7 +86,24 @@
public String execute()
throws Exception
{
- relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
+ if ( isNotBlank( key ) )
+ {
+ this.paging = createPaging( relationshipTypeService.getRelationshipTypeCountByName( key ) );
+
+ relationshipTypes = new ArrayList<RelationshipType>(
+ relationshipTypeService.getRelationshipTypesBetweenByName( key, paging.getStartPos(),
+ paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( relationshipTypeService.getRelationshipTypeCount() );
+
+ relationshipTypes = new ArrayList<RelationshipType>(
+ relationshipTypeService.getRelationshipTypesBetween( paging.getStartPos(),
+ paging.getPageSize() ) );
+ }
+
+ Collections.sort( relationshipTypes, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/GetAttributeGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/GetAttributeGroupListAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattributegroup/GetAttributeGroupListAction.java 2014-04-14 15:59:05 +0000
@@ -28,22 +28,23 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+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.trackedentity.TrackedEntityAttributeGroup;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService;
-import org.hisp.dhis.trackedentity.comparator.TrackedEntityAttributeGroupSortOrderComparator;
-
-import com.opensymphony.xwork2.Action;
/**
* @author Chau Thu Tran
* @version $Id$
*/
public class GetAttributeGroupListAction
- implements Action
+ extends ActionPagingSupport<TrackedEntityAttributeGroup>
{
// -------------------------------------------------------------------------
// Dependency
@@ -59,7 +60,7 @@
// -------------------------------------------------------------------------
// Getter && Setter
// -------------------------------------------------------------------------
-
+
private List<TrackedEntityAttributeGroup> attributeGroups = new ArrayList<TrackedEntityAttributeGroup>();
public List<TrackedEntityAttributeGroup> getAttributeGroups()
@@ -67,6 +68,18 @@
return attributeGroups;
}
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -74,10 +87,24 @@
public String execute()
throws Exception
{
- attributeGroups = new ArrayList<TrackedEntityAttributeGroup>(
- attributeGroupService.getAllTrackedEntityAttributeGroups() );
-
- Collections.sort( attributeGroups, new TrackedEntityAttributeGroupSortOrderComparator() );
+ if ( isNotBlank( key ) )
+ {
+ this.paging = createPaging( attributeGroupService.getTrackedEntityAttributeGroupCountByName( key ) );
+
+ attributeGroups = new ArrayList<TrackedEntityAttributeGroup>(
+ attributeGroupService.getTrackedEntityAttributeGroupsBetweenByName( key, paging.getStartPos(),
+ paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( attributeGroupService.getTrackedEntityAttributeGroupCount() );
+
+ attributeGroups = new ArrayList<TrackedEntityAttributeGroup>(
+ attributeGroupService.getTrackedEntityAttributeGroupsBetween( paging.getStartPos(),
+ paging.getPageSize() ) );
+ }
+
+ Collections.sort( attributeGroups, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeGroup.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeGroup.vm 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeGroup.vm 2014-04-14 15:59:05 +0000
@@ -13,14 +13,11 @@
<tr>
<td style="vertical-align:top">
<table width="100%">
- <tr>
+ <tr valign="bottom">
<td>
- $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+ #filterDiv( "attributeGroup" )
</td>
- <td colspan="3" style="text-align:right">
- <input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddAttributeGroupForm.action'" style="width:75px">
- <input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortAttributeGroup.action'" style="width:75px"><br>
- </td>
+ <td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddAttributeForm.action'" style="width:70px"></td>
</tr>
</table>
@@ -33,7 +30,9 @@
</thead>
<tbody id="list">
#foreach( $attributeGroup in $attributeGroups )
- <tr id="tr${attributeGroup.id}" data-id="$!attributeGroup.id" data-uid="$!attributeGroup.uid" data-type="TrackedEntityAttributeGroup" data-name="$encoder.htmlEncode( $!attributeGroup.displayName )"
+ <tr id="tr${attributeGroup.id}" data-id="$!attributeGroup.id"
+ data-uid="$!attributeGroup.uid" data-type="TrackedEntityAttributeGroup"
+ data-name="$encoder.htmlEncode( $!attributeGroup.displayName )"
data-can-manage="$security.canManage( $attributeGroup )"
data-can-update="$security.canUpdate( $attributeGroup )"
data-can-delete="$security.canDelete( $attributeGroup )">
@@ -42,9 +41,8 @@
#end
</tbody>
</table>
-
+ #parse( "/dhis-web-commons/paging/paging.vm" )
</td>
-
<td id="detailsData">
<div id="detailsArea">
<div id="hideDetailsArea">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/relationshipType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/relationshipType.vm 2013-12-17 01:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/relationshipType.vm 2014-04-14 15:59:05 +0000
@@ -16,7 +16,7 @@
<table width="100%">
<tr>
<td>
- $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+ #filterDiv( "relationshipType" )
</td>
<td colspan="3" style="text-align:right">
<input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddRelationshipTypeForm.action'" style="width:70px">
@@ -24,14 +24,20 @@
</tr>
</table>
- <table class="listTable">
+ <table class="listTable">
+ <col>
+ <col>
+ <thead>
<tr>
<th>$i18n.getString( "relationship_type" )</th>
<th>$i18n.getString( "name" )</th>
</tr>
+ </thead>
<tbody id="list">
#foreach( $relationshipType in $relationshipTypes )
- <tr id="tr${relationshipType.id}" data-id="$!relationshipType.id" data-uid="$!relationshipType.uid" data-type="RelationshipType" data-name="$encoder.htmlEncode( $relationshipType.aIsToB )/$encoder.htmlEncode( $relationshipType.bIsToA )"
+ <tr id="tr${relationshipType.id}" data-id="$!relationshipType.id"
+ data-uid="$!relationshipType.uid" data-type="RelationshipType"
+ data-name="$encoder.htmlEncode( $relationshipType.aIsToB )/$encoder.htmlEncode( $relationshipType.bIsToA )"
data-can-manage="$security.canManage( $relationshipType )"
data-can-update="$security.canUpdate( $relationshipType )"
data-can-delete="$security.canDelete( $relationshipType )">
@@ -41,6 +47,7 @@
#end
</tbody>
</table>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
</td>
<td id="detailsData">