=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java' --- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2011-01-26 00:07:38 +0000 +++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2011-01-27 18:30:34 +0000 @@ -32,6 +32,7 @@ import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.mapping.MapLayer; import org.hisp.dhis.mapping.MapLegend; @@ -238,7 +239,9 @@ Criteria criteria = session.createCriteria( MapView.class ); - criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) ); + Criterion nullUser = Restrictions.isNull( "user" ); + + criteria.add( user != null ? Restrictions.or( Restrictions.eq( "user", user ), nullUser ) : nullUser ); return criteria.list(); } === modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java' --- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-26 00:07:38 +0000 +++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-27 18:30:34 +0000 @@ -52,7 +52,6 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.user.User; import org.junit.Test; /** @@ -335,7 +334,7 @@ @Test public void testAddGetMapView() { - MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, + MapView mapView = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 ); @@ -352,7 +351,7 @@ @Test public void testGetDeleteMapViewByName() { - MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, + MapView mapView = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 ); @@ -369,12 +368,12 @@ @Test public void testGetAllMapViews() { - MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, + MapView mapView1 = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 ); - MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON, + MapView mapView2 = new MapView( "MapViewB", null, OrganisationUnit.FEATURETYPE_POLYGON, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, @@ -389,18 +388,18 @@ @Test public void testGetMapViewsByFeatureType() { - MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, + MapView mapView1 = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 ); - MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON, + MapView mapView2 = new MapView( "MapViewB", null, OrganisationUnit.FEATURETYPE_POLYGON, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "2", "2", 1 ); - MapView mapView3 = new MapView( "MapViewC", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, + MapView mapView3 = new MapView( "MapViewC", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement, MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,