dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38522
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19629: renamed TranslateOptions => TranslateParams
------------------------------------------------------------
revno: 19629
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-07-13 16:52:25 +0700
message:
renamed TranslateOptions => TranslateParams
removed:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateOptions.java
added:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateParams.java
modified:
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/DimensionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.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
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateOptions.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateOptions.java 2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateOptions.java 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
-package org.hisp.dhis.dxf2.common;
-
-/*
- * Copyright (c) 2004-2015, 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 org.springframework.util.StringUtils;
-
-import java.util.Locale;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class TranslateOptions
-{
- private boolean translate;
-
- private String locale;
-
- public TranslateOptions()
- {
- }
-
- public boolean isTranslate()
- {
- return translate || !StringUtils.isEmpty( locale );
- }
-
- public void setTranslate( boolean translate )
- {
- this.translate = translate;
- }
-
- public Locale getLocale()
- {
- return Locale.forLanguageTag( locale );
- }
-
- public void setLocale( String locale )
- {
- this.locale = locale;
- }
-
- public boolean defaultLocale()
- {
- return StringUtils.isEmpty( locale );
- }
-}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateParams.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/TranslateParams.java 2015-07-13 09:52:25 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.dxf2.common;
+
+/*
+ * Copyright (c) 2004-2015, 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 org.springframework.util.StringUtils;
+
+import java.util.Locale;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class TranslateParams
+{
+ private boolean translate;
+
+ private String locale;
+
+ public TranslateParams()
+ {
+ }
+
+ public boolean isTranslate()
+ {
+ return translate || !StringUtils.isEmpty( locale );
+ }
+
+ public void setTranslate( boolean translate )
+ {
+ this.translate = translate;
+ }
+
+ public Locale getLocale()
+ {
+ return Locale.forLanguageTag( locale );
+ }
+
+ public void setLocale( String locale )
+ {
+ this.locale = locale;
+ }
+
+ public boolean defaultLocale()
+ {
+ return StringUtils.isEmpty( locale );
+ }
+}
=== 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 2015-07-10 02:55:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-07-13 09:52:25 +0000
@@ -44,7 +44,7 @@
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.TranslateOptions;
+import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.fieldfilter.FieldFilterService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.metadata.ImportService;
@@ -157,7 +157,7 @@
@RequestMapping( method = RequestMethod.GET )
public @ResponseBody RootNode getObjectList(
@RequestParam Map<String, String> rpParameters,
- TranslateOptions translateOptions, OrderOptions orderOptions,
+ TranslateParams translateParams, OrderOptions orderOptions,
HttpServletResponse response, HttpServletRequest request )
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
@@ -181,7 +181,7 @@
Pager pager = metaData.getPager();
entities = objectFilterService.filter( entities, filters );
- translate( entities, translateOptions );
+ translate( entities, translateParams );
if ( options.hasPaging() && pager == null )
{
@@ -218,7 +218,7 @@
public @ResponseBody RootNode getObject(
@PathVariable( "uid" ) String pvUid,
@RequestParam Map<String, String> rpParameters,
- TranslateOptions translateOptions,
+ TranslateParams translateParams,
HttpServletRequest request, HttpServletResponse response ) throws Exception
{
if ( !aclService.canRead( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -234,14 +234,14 @@
fields.add( ":all" );
}
- return getObjectInternal( pvUid, rpParameters, filters, fields, translateOptions );
+ return getObjectInternal( pvUid, rpParameters, filters, fields, translateParams );
}
@RequestMapping( value = "/{uid}/{property}", method = RequestMethod.GET )
public @ResponseBody RootNode getObjectProperty(
@PathVariable( "uid" ) String pvUid, @PathVariable( "property" ) String pvProperty,
@RequestParam Map<String, String> rpParameters,
- TranslateOptions translateOptions,
+ TranslateParams translateParams,
HttpServletRequest request, HttpServletResponse response ) throws Exception
{
if ( !aclService.canRead( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -258,7 +258,7 @@
String fieldFilter = "[" + Joiner.on( ',' ).join( fields ) + "]";
- return getObjectInternal( pvUid, rpParameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + fieldFilter ), translateOptions );
+ return getObjectInternal( pvUid, rpParameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + fieldFilter ), translateParams );
}
@RequestMapping( value = "/{uid}", method = RequestMethod.PATCH )
@@ -401,30 +401,30 @@
webMessageService.send( WebMessageUtils.importTypeSummary( importTypeSummary ), response, request );
}
- protected void translate( List<?> entities, TranslateOptions translateOptions )
+ protected void translate( List<?> entities, TranslateParams translateParams )
{
- if ( translateOptions.isTranslate() )
+ if ( translateParams.isTranslate() )
{
- if ( translateOptions.defaultLocale() )
+ if ( translateParams.defaultLocale() )
{
i18nService.internationalise( entities );
}
else
{
- i18nService.internationalise( entities, translateOptions.getLocale() );
+ i18nService.internationalise( entities, translateParams.getLocale() );
}
}
}
private RootNode getObjectInternal( String uid, Map<String, String> parameters,
- List<String> filters, List<String> fields, TranslateOptions translateOptions ) throws Exception
+ List<String> filters, List<String> fields, TranslateParams translateParams ) throws Exception
{
WebOptions options = new WebOptions( parameters );
List<T> entities = getEntity( uid, options );
- if ( translateOptions != null )
+ if ( translateParams != null )
{
- translate( entities, translateOptions );
+ translate( entities, translateParams );
}
if ( entities.isEmpty() )
@@ -645,7 +645,7 @@
@PathVariable( "property" ) String pvProperty,
@PathVariable( "itemId" ) String pvItemId,
@RequestParam Map<String, String> parameters,
- TranslateOptions translateOptions,
+ TranslateParams translateParams,
HttpServletRequest request, HttpServletResponse response ) throws Exception
{
if ( !aclService.canRead( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -653,7 +653,7 @@
throw new ReadAccessDeniedException( "You don't have the proper permissions to read objects of this type." );
}
- RootNode rootNode = getObjectInternal( pvUid, parameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ), translateOptions );
+ RootNode rootNode = getObjectInternal( pvUid, parameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ), translateParams );
// TODO optimize this using field filter (collection filtering)
if ( !rootNode.getChildren().isEmpty() && rootNode.getChildren().get( 0 ).isCollection() )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-07-09 06:44:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-07-13 09:52:25 +0000
@@ -35,7 +35,7 @@
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dxf2.common.TranslateOptions;
+import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.node.AbstractNode;
import org.hisp.dhis.node.Node;
@@ -100,7 +100,7 @@
@RequestMapping( value = "/{uid}/items", method = RequestMethod.GET )
public @ResponseBody RootNode getItems( @PathVariable String uid, @RequestParam Map<String, String> parameters,
- TranslateOptions translateOptions, Model model, HttpServletRequest request, HttpServletResponse response )
+ TranslateParams translateParams, Model model, HttpServletRequest request, HttpServletResponse response )
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
@@ -114,7 +114,7 @@
items = objectFilterService.filter( items, filters );
Collections.sort( items, IdentifiableObjectNameComparator.INSTANCE );
- translate( items, translateOptions );
+ translate( items, translateParams );
RootNode rootNode = NodeUtils.createMetadata();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2015-07-09 07:12:16 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2015-07-13 09:52:25 +0000
@@ -32,7 +32,7 @@
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.common.JacksonUtils;
-import org.hisp.dhis.dxf2.common.TranslateOptions;
+import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
@@ -109,7 +109,7 @@
}
@Override
- public RootNode getObject( @PathVariable String uid, Map<String, String> rpParameters, TranslateOptions translateOptions, HttpServletRequest request, HttpServletResponse response )
+ public RootNode getObject( @PathVariable String uid, Map<String, String> rpParameters, TranslateParams translateParams, HttpServletRequest request, HttpServletResponse response )
throws Exception
{
org.hisp.dhis.message.MessageConversation messageConversation = messageService.getMessageConversation( uid );
@@ -127,7 +127,7 @@
throw new AccessDeniedException( "Not authorized to access this conversation." );
}
- return super.getObject( uid, rpParameters, translateOptions, request, response );
+ return super.getObject( uid, rpParameters, translateParams, request, response );
}
@Override
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java 2015-07-08 08:17:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java 2015-07-13 09:52:25 +0000
@@ -35,7 +35,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementOperand;
-import org.hisp.dhis.dxf2.common.TranslateOptions;
+import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.schema.descriptors.DataElementGroupSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
@@ -71,12 +71,12 @@
@RequestMapping( value = "/{uid}/operands", method = RequestMethod.GET )
public String getOperands( @PathVariable( "uid" ) String uid,
@RequestParam Map<String, String> parameters,
- TranslateOptions translateOptions,
+ TranslateParams translateParams,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
WebOptions options = new WebOptions( parameters );
List<DataElementGroup> dataElementGroups = getEntity( uid );
- translate( dataElementGroups, translateOptions );
+ translate( dataElementGroups, translateParams );
if ( dataElementGroups.isEmpty() )
{
@@ -116,13 +116,13 @@
public String getOperandsByQuery( @PathVariable( "uid" ) String uid,
@PathVariable( "q" ) String q,
@RequestParam Map<String, String> parameters,
- TranslateOptions translateOptions,
+ TranslateParams translateParams,
Model model, HttpServletRequest request,
HttpServletResponse response ) throws Exception
{
WebOptions options = new WebOptions( parameters );
List<DataElementGroup> dataElementGroups = getEntity( uid );
- translate( dataElementGroups, translateOptions );
+ translate( dataElementGroups, translateParams );
if ( dataElementGroups.isEmpty() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java 2015-06-15 05:06:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java 2015-07-13 09:52:25 +0000
@@ -32,7 +32,7 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.collect.Lists;
import org.hisp.dhis.common.Pager;
-import org.hisp.dhis.dxf2.common.TranslateOptions;
+import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
@@ -226,12 +226,12 @@
@RequestMapping( value = "/{uid}/parents", method = RequestMethod.GET )
public List<OrganisationUnit> getEntityList( @PathVariable( "uid" ) String uid,
- @RequestParam Map<String, String> parameters, Model model, TranslateOptions translateOptions,
+ @RequestParam Map<String, String> parameters, Model model, TranslateParams translateParams,
HttpServletRequest request, HttpServletResponse response ) throws Exception
{
OrganisationUnit organisationUnit = manager.get( getEntityClass(), uid );
List<OrganisationUnit> organisationUnits = Lists.newArrayList();
- translate( organisationUnits, translateOptions );
+ translate( organisationUnits, translateParams );
if ( organisationUnit != null )
{