dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19737
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8740: Removed name uniqueness constraint on MapLegend. Impl support for pageSize parameter on web api l...
------------------------------------------------------------
revno: 8740
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-26 19:22:12 +0200
message:
Removed name uniqueness constraint on MapLegend. Impl support for pageSize parameter on web api listing of objects.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractAccessControlController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java
--
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/common/Pager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java 2012-10-17 12:39:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java 2012-10-26 17:22:12 +0000
@@ -92,6 +92,11 @@
return "[Page: " + page + " total: " + total + " size: " + pageSize + " offset: " + getOffset() + "]";
}
+ public boolean pageSizeIsDefault()
+ {
+ return pageSize == Pager.DEFAULT_PAGE_SIZE;
+ }
+
@JsonProperty
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public int getPage()
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java 2012-09-12 10:21:27 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Options.java 2012-10-26 17:22:12 +0000
@@ -128,7 +128,8 @@
try
{
return Integer.parseInt( str );
- } catch ( NumberFormatException ignored )
+ }
+ catch ( NumberFormatException ignored )
{
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-10-25 11:02:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-10-26 17:22:12 +0000
@@ -144,6 +144,7 @@
executeSql( "ALTER TABLE mapview RENAME COLUMN mapvaluetype TO valuetype" );
executeSql( "ALTER TABLE mapview RENAME COLUMN maplegendtype TO legendtype" );
executeSql( "ALTER TABLE mapview RENAME COLUMN maplegendsetid TO legendsetid" );
+ executeSql( "ALTER TABLE maplegend DROP CONSTRAINT maplegend_name_key" );
executeSql( "UPDATE mapview SET layer = 'thematic1' WHERE layer IS NULL" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml 2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml 2012-10-26 17:22:12 +0000
@@ -10,8 +10,12 @@
<id name="id" column="maplegendid">
<generator class="native" />
- </id>
- &identifiableProperties;
+ </id>
+
+ <property name="name" column="name" not-null="true" length="230" />
+ <property name="uid" column="uid" length="11" />
+ <property name="code" column="code" not-null="false" unique="true" length="50" />
+ <property name="lastUpdated" type="timestamp"/>
<property name="startValue" column="startvalue" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractAccessControlController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractAccessControlController.java 2012-10-26 15:53:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractAccessControlController.java 2012-10-26 17:22:12 +0000
@@ -55,7 +55,7 @@
{
int count = manager.getCount( getEntityClass() );
- Pager pager = new Pager( options.getPage(), count );
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
entityList = new ArrayList<T>( manager.getAccessibleBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
@@ -77,7 +77,7 @@
{
int count = manager.getCount( getEntityClass() );
- Pager pager = new Pager( options.getPage(), count );
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
entityList = new ArrayList<T>( manager.getAccessibleBetweenLikeName( getEntityClass(), query, pager.getOffset(), pager.getPageSize() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-26 14:18:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-26 17:22:12 +0000
@@ -246,7 +246,7 @@
{
int count = manager.getCount( getEntityClass() );
- Pager pager = new Pager( options.getPage(), count );
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
entityList = new ArrayList<T>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
@@ -267,7 +267,7 @@
{
int count = manager.getCount( getEntityClass() );
- Pager pager = new Pager( options.getPage(), count );
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
entityList = new ArrayList<T>( manager.getBetweenByName( getEntityClass(), query, pager.getOffset(), pager.getPageSize() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java 2012-07-06 08:37:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java 2012-10-26 17:22:12 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dxf2.metadata.Options;
import java.util.Map;
@@ -55,7 +56,7 @@
{
return stringAsBoolean( options.get( "paging" ), true );
}
-
+
public int getPage()
{
return stringAsInt( options.get( "page" ), 1 );
@@ -65,4 +66,9 @@
{
return stringAsString( options.get( "viewClass" ), defaultValue );
}
+
+ public int getPageSize()
+ {
+ return stringAsInt( options.get( "pageSize" ), Pager.DEFAULT_PAGE_SIZE );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2012-10-17 17:04:50 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2012-10-26 17:22:12 +0000
@@ -64,7 +64,7 @@
{
if ( baseType != null )
{
- log.warn( "baseType already set, overwriting.." );
+ log.warn( "baseType already set, overwriting" );
}
baseType = objects.get( 0 ).getClass();
@@ -84,20 +84,26 @@
if ( pager.getPage() < pager.getPageCount() )
{
- pager.setNextPage( basePath + "?page=" + (pager.getPage() + 1) );
+ String nextPath = basePath + "?page=" + ( pager.getPage() + 1 );
+ nextPath += pager.pageSizeIsDefault() ? "" : "&pageSize=" + pager.getPageSize();
+
+ pager.setNextPage( nextPath );
}
if ( pager.getPage() > 1 )
{
if ( (pager.getPage() - 1) == 1 )
{
- pager.setPrevPage( basePath );
+ String prevPath = pager.pageSizeIsDefault() ? basePath : basePath + "?pageSize=" + pager.getPageSize();
+ pager.setPrevPage( prevPath );
}
else
{
- pager.setPrevPage( basePath + "?page=" + (pager.getPage() - 1) );
+ String prevPath = basePath + "?page=" + ( pager.getPage() - 1 );
+ prevPath += pager.pageSizeIsDefault() ? "" : "&pageSize=" + pager.getPageSize();
+
+ pager.setPrevPage( prevPath );
}
-
}
}
}