dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30742
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15622: minor fixes
------------------------------------------------------------
revno: 15622
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-06-11 14:04:45 +0200
message:
minor fixes
modified:
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
=== 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 2014-06-11 11:13:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java 2014-06-11 12:04:45 +0000
@@ -51,7 +51,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = OrganisationUnitSchemaDescriptor.API_ENDPOINT)
+@RequestMapping( value = OrganisationUnitSchemaDescriptor.API_ENDPOINT )
public class OrganisationUnitController
extends AbstractCrudController<OrganisationUnit>
{
@@ -94,11 +94,11 @@
if ( "true".equals( options.getOptions().get( "userOnly" ) ) )
{
- entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getOrganisationUnits() );
+ entityList = new ArrayList<>( currentUserService.getCurrentUser().getOrganisationUnits() );
}
else if ( "true".equals( options.getOptions().get( "userDataViewOnly" ) ) )
{
- entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getDataViewOrganisationUnits() );
+ entityList = new ArrayList<>( currentUserService.getCurrentUser().getDataViewOrganisationUnits() );
}
else if ( "true".equals( options.getOptions().get( "userDataViewFallback" ) ) )
{
@@ -106,16 +106,16 @@
if ( user != null && user.hasDataViewOrganisationUnit() )
{
- entityList = new ArrayList<OrganisationUnit>( user.getDataViewOrganisationUnits() );
+ entityList = new ArrayList<>( user.getDataViewOrganisationUnits() );
}
else
{
- entityList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
+ entityList = new ArrayList<>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
}
}
else if ( options.getOptions().containsKey( "query" ) )
{
- entityList = new ArrayList<OrganisationUnit>( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
+ entityList = new ArrayList<>( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
if ( levelSorted )
{
@@ -124,7 +124,7 @@
}
else if ( maxLevel != null || level != null )
{
- entityList = new ArrayList<OrganisationUnit>();
+ entityList = new ArrayList<>();
if ( maxLevel == null )
{
@@ -142,7 +142,7 @@
}
else if ( levelSorted )
{
- entityList = new ArrayList<OrganisationUnit>( manager.getAll( getEntityClass() ) );
+ entityList = new ArrayList<>( manager.getAll( getEntityClass() ) );
Collections.sort( entityList, OrganisationUnitByLevelComparator.INSTANCE );
}
else if ( options.hasPaging() )
@@ -152,11 +152,11 @@
Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
- entityList = new ArrayList<OrganisationUnit>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
+ entityList = new ArrayList<>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
}
else
{
- entityList = new ArrayList<OrganisationUnit>( manager.getAllSorted( getEntityClass() ) );
+ entityList = new ArrayList<>( manager.getAllSorted( getEntityClass() ) );
}
return entityList;
@@ -192,45 +192,4 @@
return organisationUnits;
}
-
- /* TODO can this be replaced by inclusion/filter?
- Integer maxLevel = null;
-
- if ( options.getOptions().containsKey( "maxLevel" ) )
- {
- try
- {
- maxLevel = Integer.parseInt( options.getOptions().get( "maxLevel" ) );
- }
- catch ( NumberFormatException ignored )
- {
- }
-
- if ( maxLevel != null && (organisationUnitService.getOrganisationUnitLevelByLevel( maxLevel ) == null
- || maxLevel > organisationUnitService.getNumberOfOrganisationalLevels()) )
- {
- maxLevel = organisationUnitService.getNumberOfOrganisationalLevels();
- }
- }
-
- if ( maxLevel != null )
- {
- List<OrganisationUnit> entities = new ArrayList<OrganisationUnit>();
- entities.add( entity );
-
- int level = entity.getOrganisationUnitLevel();
-
- while ( maxLevel > level )
- {
- entities.addAll( organisationUnitService.getOrganisationUnitsAtLevel( ++level, entity ) );
- }
-
- MetaData metaData = new MetaData();
- metaData.setOrganisationUnits( entities );
-
- model.addAttribute( "model", metaData );
-
- return StringUtils.uncapitalize( getEntitySimpleName() );
- }
- */
}