dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42237
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21580: rename OrderOptions => OrderParams
------------------------------------------------------------
revno: 21580
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-01-05 14:53:54 +0700
message:
rename OrderOptions => OrderParams
removed:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderOptions.java
added:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java 2016-01-04 09:50:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Order.java 2016-01-05 07:53:54 +0000
@@ -128,12 +128,12 @@
return 0;
}
- public static Order asc( Property property )
+ public static Order iasc( Property property )
{
return new Order( property, true );
}
- public static Order desc( Property property )
+ public static Order idesc( Property property )
{
return new Order( property, false );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java 2016-01-04 06:04:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java 2016-01-05 07:53:54 +0000
@@ -184,11 +184,11 @@
if ( schema.havePersistedProperty( "name" ) )
{
- addOrder( Order.asc( schema.getPersistedProperty( "name" ) ) );
+ addOrder( Order.iasc( schema.getPersistedProperty( "name" ) ) );
}
if ( schema.havePersistedProperty( "created" ) )
{
- addOrder( Order.desc( schema.getPersistedProperty( "created" ) ) );
+ addOrder( Order.idesc( schema.getPersistedProperty( "created" ) ) );
}
return this;
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderOptions.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderOptions.java 2016-01-04 06:04:35 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderOptions.java 1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@
-package org.hisp.dhis.dxf2.common;
-
-/*
- * Copyright (c) 2004-2016, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.google.common.base.MoreObjects;
-import org.hisp.dhis.query.Order;
-import org.hisp.dhis.schema.Property;
-import org.hisp.dhis.schema.Schema;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class OrderOptions
-{
- private Set<String> order = new HashSet<>();
-
- public OrderOptions()
- {
- }
-
- public void setOrder( Set<String> order )
- {
- this.order = order;
- }
-
- public List<Order> getOrders( Schema schema )
- {
- Map<String, Order> orders = new HashMap<>();
-
- for ( String o : order )
- {
- String[] split = o.split( ":" );
-
- if ( split.length <= 1 )
- {
- continue;
- }
-
- if ( orders.containsKey( split[0] ) || !schema.haveProperty( split[0] )
- || !validProperty( schema.getProperty( split[0] ) ) || !validDirection( split[1] ) )
- {
- continue;
- }
-
- Order newOrder;
-
- if ( "asc".equals( split[1] ) )
- {
- newOrder = Order.asc( schema.getProperty( split[0] ) );
- }
- else
- {
- newOrder = Order.desc( schema.getProperty( split[0] ) );
- }
-
- orders.put( split[0], newOrder.ignoreCase() );
- }
-
- return new ArrayList<>( orders.values() );
- }
-
- private boolean validProperty( Property property )
- {
- return property.isSimple();
- }
-
- private boolean validDirection( String direction )
- {
- return "asc".equals( direction ) || "desc".equals( direction );
- }
-
- @Override
- public int hashCode()
- {
- return Objects.hash( order );
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
-
- if ( obj == null || getClass() != obj.getClass() )
- {
- return false;
- }
-
- final OrderOptions other = (OrderOptions) obj;
-
- return Objects.equals( this.order, other.order );
- }
-
-
- @Override
- public String toString()
- {
- return MoreObjects.toStringHelper( this )
- .add( "order", order )
- .toString();
- }
-}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/OrderParams.java 2016-01-05 07:53:54 +0000
@@ -0,0 +1,137 @@
+package org.hisp.dhis.dxf2.common;
+
+/*
+ * Copyright (c) 2004-2016, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.google.common.base.MoreObjects;
+import org.hisp.dhis.query.Order;
+import org.hisp.dhis.schema.Property;
+import org.hisp.dhis.schema.Schema;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OrderParams
+{
+ private Set<String> order = new HashSet<>();
+
+ public OrderParams()
+ {
+ }
+
+ public void setOrder( Set<String> order )
+ {
+ this.order = order;
+ }
+
+ public List<Order> getOrders( Schema schema )
+ {
+ Map<String, Order> orders = new HashMap<>();
+
+ for ( String o : order )
+ {
+ String[] split = o.split( ":" );
+
+ if ( split.length <= 1 )
+ {
+ continue;
+ }
+
+ if ( orders.containsKey( split[0] ) || !schema.haveProperty( split[0] )
+ || !validProperty( schema.getProperty( split[0] ) ) || !validDirection( split[1] ) )
+ {
+ continue;
+ }
+
+ Order newOrder;
+
+ if ( "asc".equals( split[1] ) )
+ {
+ newOrder = Order.iasc( schema.getProperty( split[0] ) );
+ }
+ else
+ {
+ newOrder = Order.idesc( schema.getProperty( split[0] ) );
+ }
+
+ orders.put( split[0], newOrder.ignoreCase() );
+ }
+
+ return new ArrayList<>( orders.values() );
+ }
+
+ private boolean validProperty( Property property )
+ {
+ return property.isSimple();
+ }
+
+ private boolean validDirection( String direction )
+ {
+ return "asc".equals( direction ) || "desc".equals( direction );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash( order );
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null || getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ final OrderParams other = (OrderParams) obj;
+
+ return Objects.equals( this.order, other.order );
+ }
+
+ @Override
+ public String toString()
+ {
+ return MoreObjects.toStringHelper( this )
+ .add( "order", order )
+ .toString();
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2016-01-05 07:53:54 +0000
@@ -42,7 +42,7 @@
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.dxf2.common.ImportOptions;
-import org.hisp.dhis.dxf2.common.OrderOptions;
+import org.hisp.dhis.dxf2.common.OrderParams;
import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.metadata.ImportService;
@@ -158,12 +158,12 @@
@RequestMapping( method = RequestMethod.GET )
public @ResponseBody RootNode getObjectList(
@RequestParam Map<String, String> rpParameters,
- TranslateParams translateParams, OrderOptions orderOptions,
+ TranslateParams translateParams, OrderParams orderParams,
HttpServletResponse response, HttpServletRequest request ) throws QueryParserException
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
- List<Order> orders = orderOptions.getOrders( getSchema() );
+ List<Order> orders = orderParams.getOrders( getSchema() );
WebOptions options = new WebOptions( rpParameters );
WebMetaData metaData = new WebMetaData();