=== 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 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 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 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 getAllTrackedEntityAttributeGroups(); /** - * Get {@link TrackedEntityAttribute} by a {@link TrackedEntityAttributeGroup} + * Get {@link TrackedEntityAttribute} by a + * {@link TrackedEntityAttributeGroup} * * @param TrackedEntityAttributeGroup {@link TrackedEntityAttributeGroup} * * @return TrackedEntityAttribute list */ - List getTrackedEntityAttributes( TrackedEntityAttributeGroup TrackedEntityAttributeGroup ); + List 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 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 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 getRelationshipTypesBetweenByName( String name, int min, int max ) + { + return relationshipTypeStore.getAllLikeNameOrderedName( name, min, max ); + } + + @Override + public Integer getRelationshipTypeCount() + { + return relationshipTypeStore.getCount(); + } + + @Override + public Collection 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( i18n( i18nService, attributeGroup.getAttributes() ) ); } + @Override + public Integer getTrackedEntityAttributeGroupCountByName( String name ) + { + return attributeGroupStore.getCountLikeName( name ); + } + + @Override + public Collection getTrackedEntityAttributeGroupsBetweenByName( String name, + int min, int max ) + { + return attributeGroupStore.getAllLikeNameOrderedName( name, min, max ); + } + + @Override + public Integer getTrackedEntityAttributeGroupCount() + { + return attributeGroupStore.getCount(); + } + + @Override + public Collection 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 { // ------------------------------------------------------------------------- // Dependencies @@ -58,13 +61,24 @@ // Input/Output // ------------------------------------------------------------------------- - private Collection relationshipTypes = new ArrayList(); + private List relationshipTypes = new ArrayList(); - public Collection getRelationshipTypes() + public List 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( + relationshipTypeService.getRelationshipTypesBetweenByName( key, paging.getStartPos(), + paging.getPageSize() ) ); + } + else + { + this.paging = createPaging( relationshipTypeService.getRelationshipTypeCount() ); + + relationshipTypes = new ArrayList( + 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 { // ------------------------------------------------------------------------- // Dependency @@ -59,7 +60,7 @@ // ------------------------------------------------------------------------- // Getter && Setter // ------------------------------------------------------------------------- - + private List attributeGroups = new ArrayList(); public List 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( - attributeGroupService.getAllTrackedEntityAttributeGroups() ); - - Collections.sort( attributeGroups, new TrackedEntityAttributeGroupSortOrderComparator() ); + if ( isNotBlank( key ) ) + { + this.paging = createPaging( attributeGroupService.getTrackedEntityAttributeGroupCountByName( key ) ); + + attributeGroups = new ArrayList( + attributeGroupService.getTrackedEntityAttributeGroupsBetweenByName( key, paging.getStartPos(), + paging.getPageSize() ) ); + } + else + { + this.paging = createPaging( attributeGroupService.getTrackedEntityAttributeGroupCount() ); + + attributeGroups = new ArrayList( + 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 @@ - + - +
- $i18n.getString( "filter_by_name" ): + #filterDiv( "attributeGroup" ) - -
-
@@ -33,7 +30,9 @@ #foreach( $attributeGroup in $attributeGroups ) - @@ -42,9 +41,8 @@ #end - + #parse( "/dhis-web-commons/paging/paging.vm" ) -
=== 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 @@
- $i18n.getString( "filter_by_name" ): + #filterDiv( "relationshipType" ) @@ -24,14 +24,20 @@
- +
+ + + + #foreach( $relationshipType in $relationshipTypes ) - @@ -41,6 +47,7 @@ #end
$i18n.getString( "relationship_type" ) $i18n.getString( "name" )
+ #parse( "/dhis-web-commons/paging/paging.vm" )