dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19703
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8706: Added new object/entity NMap with store and service impl. A Map has a set of MapViews.
------------------------------------------------------------
revno: 8706
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-25 14:38:20 +0200
message:
Added new object/entity NMap with store and service impl. A Map has a set of MapViews.
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Map.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/Map.hbm.xml
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Map.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Map.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Map.java 2012-10-25 12:38:20 +0000
@@ -0,0 +1,122 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2012, 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 java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.user.User;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class Map
+ extends BaseIdentifiableObject
+{
+ private User user;
+
+ private String longitude;
+
+ private String latitude;
+
+ private Integer zoom;
+
+ private Set<MapView> views = new HashSet<MapView>();
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public Map()
+ {
+ }
+
+ public Map( String name, User user, String longitude, String latitude, Integer zoom )
+ {
+ this.name = name;
+ this.user = user;
+ this.longitude = longitude;
+ this.latitude = latitude;
+ this.zoom = zoom;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public void setUser( User user )
+ {
+ this.user = user;
+ }
+
+ public String getLongitude()
+ {
+ return longitude;
+ }
+
+ public void setLongitude( String longitude )
+ {
+ this.longitude = longitude;
+ }
+
+ public String getLatitude()
+ {
+ return latitude;
+ }
+
+ public void setLatitude( String latitude )
+ {
+ this.latitude = latitude;
+ }
+
+ public Integer getZoom()
+ {
+ return zoom;
+ }
+
+ public void setZoom( Integer zoom )
+ {
+ this.zoom = zoom;
+ }
+
+ public Set<MapView> getViews()
+ {
+ return views;
+ }
+
+ public void setViews( Set<MapView> views )
+ {
+ this.views = views;
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java 2012-10-25 12:38:20 +0000
@@ -0,0 +1,12 @@
+package org.hisp.dhis.mapping;
+
+import java.util.Collection;
+
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.user.User;
+
+public interface MapStore
+ extends GenericIdentifiableObjectStore<Map>
+{
+ Collection<Map> getSystemAndUserMaps( User user );
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-25 11:02:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-25 12:38:20 +0000
@@ -27,12 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
@@ -51,7 +45,13 @@
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.user.User;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
/**
* @author Jan Henrik Overland
@@ -70,8 +70,6 @@
private String layer;
- private User user;
-
private String valueType;
private IndicatorGroup indicatorGroup;
@@ -106,12 +104,6 @@
private Integer radiusHigh;
- private String longitude;
-
- private String latitude;
-
- private Integer zoom;
-
private Integer opacity;
private OrganisationUnitGroupSet organisationUnitGroupSet;
@@ -120,15 +112,14 @@
{
}
- public MapView( String layer, String name, User user, String valueType, IndicatorGroup indicatorGroup, Indicator indicator,
+ public MapView( String layer, String name, String valueType, IndicatorGroup indicatorGroup, Indicator indicator,
DataElementGroup dataElementGroup, DataElement dataElement, PeriodType periodType,
Period period, OrganisationUnit parentOrganisationUnit, OrganisationUnitLevel organisationUnitLevel,
String legendType, Integer method, Integer classes, String colorLow, String colorHigh,
- MapLegendSet legendSet, Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom, int opacity )
+ MapLegendSet legendSet, Integer radiusLow, Integer radiusHigh, int opacity )
{
this.layer = layer;
this.name = name;
- this.user = user;
this.valueType = valueType;
this.indicatorGroup = indicatorGroup;
this.indicator = indicator;
@@ -146,9 +137,6 @@
this.legendSet = legendSet;
this.radiusLow = radiusLow;
this.radiusHigh = radiusHigh;
- this.longitude = longitude;
- this.latitude = latitude;
- this.zoom = zoom;
this.opacity = opacity;
}
@@ -210,20 +198,6 @@
}
@JsonProperty
- @JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public User getUser()
- {
- return user;
- }
-
- public void setUser( User user )
- {
- this.user = user;
- }
-
- @JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getValueType()
@@ -458,45 +432,6 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public String getLongitude()
- {
- return longitude;
- }
-
- public void setLongitude( String longitude )
- {
- this.longitude = longitude;
- }
-
- @JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public String getLatitude()
- {
- return latitude;
- }
-
- public void setLatitude( String latitude )
- {
- this.latitude = latitude;
- }
-
- @JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
- public Integer getZoom()
- {
- return zoom;
- }
-
- public void setZoom( Integer zoom )
- {
- this.zoom = zoom;
- }
-
- @JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public Integer getOpacity()
{
return opacity;
@@ -530,7 +465,6 @@
{
MapView mapView = (MapView) other;
- user = mapView.getUser() == null ? user : mapView.getUser();
valueType = mapView.getValueType() == null ? valueType : mapView.getValueType();
indicatorGroup = mapView.getIndicatorGroup() == null ? indicatorGroup : mapView.getIndicatorGroup();
indicator = mapView.getIndicator() == null ? indicator : mapView.getIndicator();
@@ -548,9 +482,6 @@
legendSet = mapView.getLegendSet() == null ? legendSet : mapView.getLegendSet();
radiusLow = mapView.getRadiusLow() == null ? radiusLow : mapView.getRadiusLow();
radiusHigh = mapView.getRadiusHigh() == null ? radiusHigh : mapView.getRadiusHigh();
- longitude = mapView.getLongitude() == null ? longitude : mapView.getLongitude();
- latitude = mapView.getLatitude() == null ? latitude : mapView.getLatitude();
- zoom = mapView.getZoom() == null ? zoom : mapView.getZoom();
}
}
}
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java 2012-04-29 18:04:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-package org.hisp.dhis.mapping;
-
-/*
- * Copyright (c) 2004-2012, 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.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.user.User;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- */
-public interface MapViewStore
- extends GenericIdentifiableObjectStore<MapView>
-{
- String ID = MapViewStore.class.getName();
-
- Collection<MapView> getSystemAndUserMapViews( User user );
-
- Collection<MapView> getMapViewsByMapSourceType( String mapSourceType );
-
- Collection<MapView> getMapViewsByFeatureType( String featureType, User user );
-}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2012-10-25 09:03:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2012-10-25 12:38:20 +0000
@@ -123,6 +123,22 @@
Collection<MapLegendSet> getAllMapLegendSets();
// -------------------------------------------------------------------------
+ // Map
+ // -------------------------------------------------------------------------
+
+ int addMap( Map map );
+
+ void updateMap( Map map );
+
+ Map getMap( int id );
+
+ Map getMap( String uid );
+
+ void deleteMap( Map map );
+
+ Collection<Map> getSystemAndUserMaps();
+
+ // -------------------------------------------------------------------------
// MapView
// -------------------------------------------------------------------------
@@ -147,11 +163,7 @@
MapView getIndicatorLastYearMapView( String indicatorUid, String organisationUnitUid, int level );
Collection<MapView> getAllMapViews();
-
- Collection<MapView> getSystemAndUserMapViews();
-
- Collection<MapView> getMapViewsByFeatureType( String featureType );
-
+
Collection<MapView> getMapViewsByUser( User user );
Collection<MapView> getMapViewsBetweenByName( String name, int first, int max );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2012-10-25 11:02:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2012-10-25 12:38:20 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.aggregation.AggregatedMapValue;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.configuration.ConfigurationService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
@@ -64,29 +65,36 @@
// Dependencies
// -------------------------------------------------------------------------
- private MapViewStore mapViewStore;
+ private MapStore mapStore;
+
+ public void setMapStore( MapStore mapStore )
+ {
+ this.mapStore = mapStore;
+ }
+
+ private GenericIdentifiableObjectStore<MapView> mapViewStore;
+
+ public void setMapViewStore( GenericIdentifiableObjectStore<MapView> mapViewStore )
+ {
+ this.mapViewStore = mapViewStore;
+ }
private MapLayerStore mapLayerStore;
- private MapLegendStore mapLegendStore;
-
- private MapLegendSetStore mapLegendSetStore;
-
- public void setMapViewStore( MapViewStore mapViewStore )
- {
- this.mapViewStore = mapViewStore;
- }
-
public void setMapLayerStore( MapLayerStore mapLayerStore )
{
this.mapLayerStore = mapLayerStore;
}
+ private MapLegendStore mapLegendStore;
+
public void setMapLegendStore( MapLegendStore mapLegendStore )
{
this.mapLegendStore = mapLegendStore;
}
+ private MapLegendSetStore mapLegendSetStore;
+
public void setMapLegendSetStore( MapLegendSetStore mapLegendSetStore )
{
this.mapLegendSetStore = mapLegendSetStore;
@@ -394,6 +402,42 @@
}
// -------------------------------------------------------------------------
+ // Map
+ // -------------------------------------------------------------------------
+
+ public int addMap( Map map )
+ {
+ return mapStore.save( map );
+ }
+
+ public void updateMap( Map map )
+ {
+ mapStore.update( map );
+ }
+
+ public Map getMap( int id )
+ {
+ return mapStore.get( id );
+ }
+
+ public Map getMap( String uid )
+ {
+ return mapStore.getByCode( uid );
+ }
+
+ public void deleteMap( Map map )
+ {
+ mapStore.delete( map );
+ }
+
+ public Collection<Map> getSystemAndUserMaps()
+ {
+ User user = currentUserService.getCurrentUser();
+
+ return mapStore.getSystemAndUserMaps( user );
+ }
+
+ // -------------------------------------------------------------------------
// MapView
// -------------------------------------------------------------------------
@@ -408,8 +452,6 @@
Integer method, Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId,
Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom )
{
- User user = system ? null : currentUserService.getCurrentUser();
-
IndicatorGroup indicatorGroup = null;
Indicator indicator = null;
@@ -440,9 +482,9 @@
MapLegendSet mapLegendSet = mapLegendSetId != null ? getMapLegendSet( mapLegendSetId ) : null;
- addMapView( new MapView( MapView.LAYER_THEMATIC1, name, user, mapValueType, indicatorGroup, indicator, dataElementGroup, dataElement,
+ addMapView( new MapView( MapView.LAYER_THEMATIC1, name, mapValueType, indicatorGroup, indicator, dataElementGroup, dataElement,
periodType, period, parent, level, mapLegendType, method, classes, colorLow, colorHigh,
- mapLegendSet, radiusLow, radiusHigh, longitude, latitude, zoom, 1 ) );
+ mapLegendSet, radiusLow, radiusHigh, 1 ) );
}
public void updateMapView( MapView mapView )
@@ -507,13 +549,6 @@
return mapView;
}
- public Collection<MapView> getSystemAndUserMapViews()
- {
- User user = currentUserService.getCurrentUser();
-
- return mapViewStore.getSystemAndUserMapViews( user );
- }
-
public Collection<MapView> getAllMapViews()
{
Collection<MapView> mapViews = mapViewStore.getAll();
@@ -530,21 +565,6 @@
return mapViews;
}
- public Collection<MapView> getMapViewsByFeatureType( String featureType )
- {
- User user = currentUserService.getCurrentUser();
-
- Collection<MapView> mapViews = mapViewStore.getMapViewsByFeatureType( featureType, user );
-
- for ( MapView mapView : mapViews )
- {
- mapView.getParentOrganisationUnit().setLevel(
- organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
- }
-
- return mapViews;
- }
-
public Collection<MapView> getMapViewsByUser( User user )
{
return mapViewStore.getByUser( user );
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java 2012-10-25 12:38:20 +0000
@@ -0,0 +1,21 @@
+package org.hisp.dhis.mapping.hibernate;
+
+import java.util.Collection;
+
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.mapping.MapStore;
+import org.hisp.dhis.user.User;
+
+public class HibernateMapStore
+ extends HibernateIdentifiableObjectStore<Map> implements MapStore
+{
+ @SuppressWarnings("unchecked")
+ public Collection<Map> getSystemAndUserMaps( User user )
+ {
+ return getCriteria( Restrictions.or(
+ Restrictions.eq( "user", user ),
+ Restrictions.isNull( "user" ) ) ).list();
+ }
+}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java 2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java 1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-package org.hisp.dhis.mapping.hibernate;
-
-/*
- * Copyright (c) 2004-2012, 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.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.mapping.MapView;
-import org.hisp.dhis.mapping.MapViewStore;
-import org.hisp.dhis.user.User;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- */
-public class HibernateMapViewStore
- extends HibernateIdentifiableObjectStore<MapView>
- implements MapViewStore
-{
- @SuppressWarnings( "unchecked" )
- public Collection<MapView> getSystemAndUserMapViews( User user )
- {
- return getCriteria(
- Restrictions.or( Restrictions.isNull( "user" ),
- Restrictions.eq( "user", user ) ) ).list();
- }
-
- @SuppressWarnings( "unchecked" )
- public Collection<MapView> getMapViewsByMapSourceType( String mapSourceType )
- {
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( MapView.class );
-
- criteria.add( Restrictions.eq( "mapSourceType", mapSourceType ) );
-
- return criteria.list();
- }
-
- @SuppressWarnings( "unchecked" )
- public Collection<MapView> getMapViewsByFeatureType( String featureType, User user )
- {
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( MapView.class );
-
- criteria.add( Restrictions.eq( "featureType", featureType ) );
-
- criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
-
- return criteria.list();
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-10-25 12:38:20 +0000
@@ -287,10 +287,17 @@
<property name="sessionFactory" ref="sessionFactory" />
</bean>
+ <bean id="org.hisp.dhis.mapping.MapStore" class="org.hisp.dhis.mapping.hibernate.HibernateMapStore">
+ <property name="clazz" value="org.hisp.dhis.mapping.Map" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="cacheable" value="true" />
+ </bean>
+
<bean id="org.hisp.dhis.mapping.MapViewStore"
- class="org.hisp.dhis.mapping.hibernate.HibernateMapViewStore">
+ class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.mapping.MapView" />
<property name="sessionFactory" ref="sessionFactory" />
+ <property name="cacheable" value="true" />
</bean>
<bean id="org.hisp.dhis.mapping.MapLayerStore"
@@ -529,6 +536,7 @@
</bean>
<bean id="org.hisp.dhis.mapping.MappingService" class="org.hisp.dhis.mapping.DefaultMappingService">
+ <property name="mapStore" ref="org.hisp.dhis.mapping.MapStore" />
<property name="mapViewStore" ref="org.hisp.dhis.mapping.MapViewStore" />
<property name="mapLayerStore" ref="org.hisp.dhis.mapping.MapLayerStore" />
<property name="mapLegendStore" ref="org.hisp.dhis.mapping.MapLegendStore" />
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/Map.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/Map.hbm.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/Map.hbm.xml 2012-10-25 12:38:20 +0000
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
+
+<hibernate-mapping>
+ <class name="org.hisp.dhis.mapping.Map" table="map">
+
+ <id name="id" column="mapid">
+ <generator class="native" />
+ </id>
+ &identifiableProperties;
+
+ <many-to-one name="user" class="org.hisp.dhis.user.User"
+ column="userid" foreign-key="fk_mapview_userid" />
+
+ <property name="longitude" />
+
+ <property name="latitude" />
+
+ <property name="zoom" />
+
+ <set name="views" table="mapmapviews">
+ <key column="mapid" foreign-key="fk_mapmapview_mapid" />
+ <many-to-many column="mapviewid" class="org.hisp.dhis.mapping.MapView" foreign-key="fk_mapmapview_mapviewid" />
+ </set>
+
+ </class>
+</hibernate-mapping>
\ No newline at end of file
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2012-10-25 11:02:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2012-10-25 12:38:20 +0000
@@ -15,8 +15,6 @@
<property name="layer" />
- <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_mapview_userid" />
-
<property name="valueType" />
<many-to-one name="indicatorGroup" class="org.hisp.dhis.indicator.IndicatorGroup" column="indicatorgroupid"
@@ -58,12 +56,6 @@
<property name="radiusLow" />
<property name="radiusHigh" />
-
- <property name="longitude" />
-
- <property name="latitude" />
-
- <property name="zoom" />
<property name="opacity" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2012-10-25 11:02:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2012-10-25 12:38:20 +0000
@@ -266,10 +266,10 @@
@Test
public void testAddGetMapView()
{
- MapView mapView = new MapView( LAYER_THEMATIC1, "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
+ MapView mapView = new MapView( LAYER_THEMATIC1, "MapViewA", MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
indicator, dataElementGroup, dataElement, periodType, period,
organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "1", "1", 1, 1 );
+ mapLegendSet, 5, 20, 1 );
int idA = mappingService.addMapView( mapView );
@@ -283,10 +283,10 @@
@Test
public void testGetDeleteMapViewByName()
{
- MapView mapView = new MapView( LAYER_THEMATIC1, "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
+ MapView mapView = new MapView( LAYER_THEMATIC1, "MapViewA", MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
indicator, dataElementGroup, dataElement, periodType, period,
organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "1", "1", 1, 1 );
+ mapLegendSet, 5, 20, 1 );
int id = mappingService.addMapView( mapView );
@@ -300,15 +300,15 @@
@Test
public void testGetAllMapViews()
{
- MapView mapView1 = new MapView( LAYER_THEMATIC1, "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
+ MapView mapView1 = new MapView( LAYER_THEMATIC1, "MapViewA", MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
indicator, dataElementGroup, dataElement, periodType, period,
organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "1", "1", 1, 1 );
+ mapLegendSet, 5, 20, 1 );
- MapView mapView2 = new MapView( LAYER_THEMATIC1, "MapViewB", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
+ MapView mapView2 = new MapView( LAYER_THEMATIC1, "MapViewB", MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
indicator, dataElementGroup, dataElement, periodType, period,
organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "2", "2", 1, 1 );
+ mapLegendSet, 5, 20, 1 );
mappingService.addMapView( mapView1 );
mappingService.addMapView( mapView2 );
@@ -321,20 +321,20 @@
// TODO
public void testGetMapViewsByFeatureType()
{
- MapView mapView1 = new MapView( LAYER_THEMATIC1, "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
- indicator, dataElementGroup, dataElement, periodType, period,
- organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "1", "1", 1, 1 );
-
- MapView mapView2 = new MapView( LAYER_THEMATIC1, "MapViewB", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
- indicator, dataElementGroup, dataElement, periodType, period,
- organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "2", "2", 1, 1 );
-
- MapView mapView3 = new MapView( LAYER_THEMATIC1, "MapViewC", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
- indicator, dataElementGroup, dataElement, periodType, period,
- organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
- mapLegendSet, 5, 20, "3", "3", 1, 1 );
+ MapView mapView1 = new MapView( LAYER_THEMATIC1, "MapViewA", MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
+ indicator, dataElementGroup, dataElement, periodType, period,
+ organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
+ mapLegendSet, 5, 20, 1 );
+
+ MapView mapView2 = new MapView( LAYER_THEMATIC1, "MapViewB", MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
+ indicator, dataElementGroup, dataElement, periodType, period,
+ organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
+ mapLegendSet, 5, 20, 1 );
+
+ MapView mapView3 = new MapView( LAYER_THEMATIC1, "MapViewC", MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
+ indicator, dataElementGroup, dataElement, periodType, period,
+ organisationUnit, organisationUnitLevel, MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B",
+ mapLegendSet, 5, 20, 1 );
mappingService.addMapView( mapView1 );
mappingService.addMapView( mapView2 );
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2012-10-23 08:01:42 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2012-10-25 12:38:20 +0000
@@ -80,7 +80,11 @@
<cache name="org.hisp.dhis.message.UserMessage" maxElementsInMemory="50000" />
- <cache name="org.hisp.dhis.chart.Chart" maxElementsInMemory="100" />
+ <cache name="org.hisp.dhis.chart.Chart" maxElementsInMemory="1000" />
+
+ <cache name="org.hisp.dhis.mapping.MapView" maxElementsInMemory="1000" />
+
+ <cache name="org.hisp.dhis.mapping.Map" maxElementsInMemory="1000" />
<cache name="org.hisp.dhis.reporttable.ReportTable" maxElementsInMemory="100" />
@@ -172,9 +176,9 @@
<cache name="org.hisp.dhis.reporttable.ReportTable.organisationUnitGroups" maxElementsInMemory="500" />
- <cache name="org.hisp.dhis.chart.Chart.dataElements" maxElementsInMemory="1500" />
+ <cache name="org.hisp.dhis.chart.Chart.dataElements" maxElementsInMemory="2000" />
- <cache name="org.hisp.dhis.chart.Chart.indicators" maxElementsInMemory="500" />
+ <cache name="org.hisp.dhis.chart.Chart.indicators" maxElementsInMemory="2000" />
<cache name="org.hisp.dhis.chart.Chart.periods" maxElementsInMemory="200" />
@@ -182,6 +186,8 @@
<cache name="org.hisp.dhis.chart.Chart.dataSets" maxElementsInMemory="200" />
+ <cache name="org.hisp.dhis.mapping.Map.views" maxElementsInMemory="1000" />
+
<cache name="org.hisp.dhis.user.User.organisationUnits" maxElementsInMemory="20000" />
<cache name="org.hisp.dhis.attribute.Attribute.attributeValues" maxElementsInMemory="5000" />
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java 2012-04-29 18:04:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java 2012-10-25 12:38:20 +0000
@@ -72,7 +72,7 @@
public String execute()
{
- object = new ArrayList<MapView>( mappingService.getSystemAndUserMapViews() );
+ object = new ArrayList<MapView>( mappingService.getAllMapViews() );
Collections.sort( object, new MapViewNameComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java 2012-03-05 16:37:17 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java 2012-10-25 12:38:20 +0000
@@ -27,13 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import org.apache.commons.lang.NotImplementedException;
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.mapping.MappingService;
-import org.hisp.dhis.mapping.comparator.MapViewNameComparator;
import com.opensymphony.xwork2.Action;
@@ -83,10 +81,6 @@
public String execute()
{
- object = new ArrayList<MapView>( mappingService.getMapViewsByFeatureType( featureType ) );
-
- Collections.sort( object, new MapViewNameComparator() );
-
- return SUCCESS;
+ throw new NotImplementedException();
}
}