dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15135
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5347: Replaced boilerplate code in store layer with HibernateGenericStore
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 5347 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-09 21:05:20 +0100
message:
Replaced boilerplate code in store layer with HibernateGenericStore
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardContentStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardContentStore.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/hibernate/HibernateVersionStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/chart/ChartStoreTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.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-api/src/main/java/org/hisp/dhis/chart/ChartStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 2011-11-22 16:17:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
-package org.hisp.dhis.chart;
-
-/*
- * Copyright (c) 2004-2010, 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.Collection;
-
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public interface ChartStore
- extends GenericIdentifiableObjectStore<Chart>
-{
- String ID = ChartStore.class.getName();
-
- /**
- * Retrieves the Chart with the given title.
- *
- * @param title the title of the Chart.
- * @return the Chart.
- */
- Chart getByTitle( String title );
-
- Collection<Chart> getChartsBetween( int first, int max );
-
- Collection<Chart> getChartsBetweenByName( String name, int first, int max );
-
- int getChartCount();
-
- int getChartCountByName( String name );
-
-}
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardContentStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardContentStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardContentStore.java 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-package org.hisp.dhis.dashboard;
-
-/*
- * Copyright (c) 2004-2010, 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.GenericStore;
-import org.hisp.dhis.user.User;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public interface DashboardContentStore
- extends GenericStore<DashboardContent>
-{
- final String ID = DashboardContentStore.class.getName();
-
- DashboardContent get( User user );
-}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/hibernate/HibernateVersionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/hibernate/HibernateVersionStore.java 2011-08-11 11:31:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/version/hibernate/HibernateVersionStore.java 2011-12-09 19:48:13 +0000
@@ -23,8 +23,6 @@
* 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.hibernate.HibernateGenericStore;
import org.hisp.dhis.version.Version;
@@ -37,11 +35,6 @@
@Override
public Version getVersionByKey( String key )
{
- Session session = sessionFactory.getCurrentSession();
- Criteria criteria = session.createCriteria( Version.class );
- criteria.add( Restrictions.eq( "key", key ) );
- criteria.setCacheable( true );
- return (Version) criteria.uniqueResult();
+ return (Version) getCriteria( Restrictions.eq( "key", key ) ).uniqueResult();
}
-
}
=== 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 2011-12-09 19:44:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-12-09 19:48:13 +0000
@@ -238,6 +238,7 @@
<bean id="org.hisp.dhis.version.VersionStore" class="org.hisp.dhis.version.hibernate.HibernateVersionStore">
<property name="sessionFactory" ref="sessionFactory" />
<property name="clazz" value="org.hisp.dhis.version.Version" />
+ <property name="cacheable" value="true" />
</bean>
<bean id="org.hisp.dhis.attribute.AttributeStore" class="org.hisp.dhis.attribute.hibernate.HibernateAttributeStore">
=== 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-12-05 12:21:38 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2011-12-09 20:04:48 +0000
@@ -173,37 +173,27 @@
public int addMapView( MapView view )
{
- return save( view );
+ return super.save( view );
}
public void updateMapView( MapView view )
{
- update( view );
+ super.update( view );
}
public void deleteMapView( MapView view )
{
- Session session = sessionFactory.getCurrentSession();
-
- session.delete( view );
+ super.delete( view );
}
public MapView getMapView( int id )
{
- Session session = sessionFactory.getCurrentSession();
-
- return (MapView) session.get( MapView.class, id );
+ return super.get( id );
}
public MapView getMapViewByName( String name )
{
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( MapView.class );
-
- criteria.add( Restrictions.eq( "name", name ) );
-
- return (MapView) criteria.uniqueResult();
+ return super.getByName( name );
}
@SuppressWarnings( "unchecked" )
=== removed directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate'
=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2011-11-23 18:07:35 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.chart.hibernate;
-
-/*
- * Copyright (c) 2004-2010, 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.Collection;
-
-import org.hibernate.Criteria;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.chart.Chart;
-import org.hisp.dhis.chart.ChartStore;
-import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class HibernateChartStore
- extends HibernateIdentifiableObjectStore<Chart> implements ChartStore
-{
- public Chart getByTitle( String title )
- {
- return getObject( Restrictions.eq( "name", title ) );
- }
-
- public int getChartCount()
- {
- return getCount();
- }
-
- @SuppressWarnings("unchecked")
- public Collection<Chart> getChartsBetween( int first, int max )
- {
- Criteria criteria = getCriteria();
- criteria.addOrder( Order.asc( "name" ) );
- criteria.setFirstResult( first );
- criteria.setMaxResults( max );
- return criteria.list();
- }
-
- @SuppressWarnings("unchecked")
- public Collection<Chart> getChartsBetweenByName( String name, int first, int max )
- {
- Criteria criteria = getCriteria();
- criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );
- criteria.addOrder( Order.asc( "name" ) );
- criteria.setFirstResult( first );
- criteria.setMaxResults( max );
- return criteria.list();
- }
-
- public int getChartCountByName( String name )
- {
- Criteria criteria = getCriteria();
- criteria.setProjection( Projections.rowCount() );
- criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );
- return ((Number) criteria.uniqueResult()).intValue();
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-12-06 17:41:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-12-09 20:04:48 +0000
@@ -27,6 +27,40 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.chart.Chart.DIMENSION_COMPLETENESS_PERIOD;
+import static org.hisp.dhis.chart.Chart.DIMENSION_DATAELEMENT_PERIOD;
+import static org.hisp.dhis.chart.Chart.DIMENSION_INDICATOR_PERIOD;
+import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_COMPLETENESS;
+import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_DATAELEMENT;
+import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_INDICATOR;
+import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_COMPLETENESS;
+import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_DATAELEMENT;
+import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_INDICATOR;
+import static org.hisp.dhis.chart.Chart.SIZE_NORMAL;
+import static org.hisp.dhis.chart.Chart.TYPE_BAR;
+import static org.hisp.dhis.chart.Chart.TYPE_BAR3D;
+import static org.hisp.dhis.chart.Chart.TYPE_LINE;
+import static org.hisp.dhis.chart.Chart.TYPE_LINE3D;
+import static org.hisp.dhis.chart.Chart.TYPE_PIE;
+import static org.hisp.dhis.chart.Chart.TYPE_PIE3D;
+import static org.hisp.dhis.chart.Chart.TYPE_STACKED_BAR;
+import static org.hisp.dhis.chart.Chart.TYPE_STACKED_BAR3D;
+import static org.hisp.dhis.options.SystemSettingManager.AGGREGATION_STRATEGY_REAL_TIME;
+import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_AGGREGATION_STRATEGY;
+import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY;
+import static org.hisp.dhis.system.util.ConversionUtils.getArray;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
import org.apache.commons.math.MathException;
import org.apache.commons.math.analysis.SplineInterpolator;
import org.apache.commons.math.analysis.UnivariateRealFunction;
@@ -37,7 +71,6 @@
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartGroup;
import org.hisp.dhis.chart.ChartService;
-import org.hisp.dhis.chart.ChartStore;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
@@ -68,8 +101,18 @@
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
-import org.jfree.chart.plot.*;
-import org.jfree.chart.renderer.category.*;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.DatasetRenderingOrder;
+import org.jfree.chart.plot.Marker;
+import org.jfree.chart.plot.MultiplePiePlot;
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.plot.ValueMarker;
+import org.jfree.chart.renderer.category.BarRenderer;
+import org.jfree.chart.renderer.category.BarRenderer3D;
+import org.jfree.chart.renderer.category.CategoryItemRenderer;
+import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.chart.renderer.category.LineRenderer3D;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
@@ -77,15 +120,6 @@
import org.jfree.util.TableOrder;
import org.springframework.transaction.annotation.Transactional;
-import java.awt.*;
-import java.util.*;
-import java.util.List;
-import java.util.Map.Entry;
-
-import static org.hisp.dhis.chart.Chart.*;
-import static org.hisp.dhis.options.SystemSettingManager.*;
-import static org.hisp.dhis.system.util.ConversionUtils.getArray;
-
/**
* @author Lars Helge Overland
* @version $Id$
@@ -115,9 +149,9 @@
// Dependencies
// -------------------------------------------------------------------------
- private ChartStore chartStore;
+ private GenericIdentifiableObjectStore<Chart> chartStore;
- public void setChartStore( ChartStore chartStore )
+ public void setChartStore( GenericIdentifiableObjectStore<Chart> chartStore )
{
this.chartStore = chartStore;
}
@@ -1129,7 +1163,7 @@
public Chart getChartByName( String name )
{
- return chartStore.getByTitle( name );
+ return chartStore.getByName( name );
}
public Collection<Chart> getCharts( final Collection<Integer> identifiers )
@@ -1147,21 +1181,21 @@
public int getChartCount()
{
- return chartStore.getChartCount();
+ return chartStore.getCount();
}
public int getChartCountByName( String name )
{
- return chartStore.getChartCountByName( name );
+ return chartStore.getCountByName( name );
}
public Collection<Chart> getChartsBetween( int first, int max )
{
- return chartStore.getChartsBetween( first, max );
+ return chartStore.getBetween( first, max );
}
public Collection<Chart> getChartsBetweenByName( String name, int first, int max )
{
- return chartStore.getChartsBetweenByName( name, first, max );
+ return chartStore.getBetweenByName( name, first, max );
}
}
=== removed directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate'
=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardContentStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardContentStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardContentStore.java 1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-package org.hisp.dhis.dashboard.hibernate;
-
-/*
- * Copyright (c) 2004-2010, 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.dashboard.DashboardContent;
-import org.hisp.dhis.dashboard.DashboardContentStore;
-import org.hisp.dhis.hibernate.HibernateGenericStore;
-import org.hisp.dhis.user.User;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class HibernateDashboardContentStore
- extends HibernateGenericStore<DashboardContent> implements DashboardContentStore
-{
- public DashboardContent get( User user )
- {
- return (DashboardContent) sessionFactory.getCurrentSession().get( DashboardContent.class, user.getId() );
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java 2011-12-09 20:04:48 +0000
@@ -29,8 +29,8 @@
import java.util.Collection;
+import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.dashboard.DashboardContent;
-import org.hisp.dhis.dashboard.DashboardContentStore;
import org.hisp.dhis.dashboard.DashboardService;
import org.hisp.dhis.user.User;
import org.springframework.transaction.annotation.Transactional;
@@ -47,9 +47,9 @@
// Dependencies
// -------------------------------------------------------------------------
- private DashboardContentStore dashboardContentStore;
+ private GenericStore<DashboardContent> dashboardContentStore;
- public void setDashboardContentStore( DashboardContentStore dashboardContentStore )
+ public void setDashboardContentStore( GenericStore<DashboardContent> dashboardContentStore )
{
this.dashboardContentStore = dashboardContentStore;
}
@@ -65,7 +65,7 @@
public DashboardContent getDashboardContent( User user )
{
- DashboardContent content = dashboardContentStore.get( user );
+ DashboardContent content = dashboardContentStore.get( user.getId() );
return content != null ? content : new DashboardContent( user );
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-11-25 10:09:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-12-09 20:04:48 +0000
@@ -17,7 +17,7 @@
<property name="statementManager" ref="statementManager" />
</bean>
- <bean id="org.hisp.dhis.reporttable.ReportTableStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
+ <bean id="org.hisp.dhis.reporttable.ReportTableStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.reporttable.ReportTable" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
@@ -42,7 +42,7 @@
<!-- Report -->
- <bean id="org.hisp.dhis.report.ReportStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
+ <bean id="org.hisp.dhis.report.ReportStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.report.Report" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
@@ -65,13 +65,13 @@
<!-- Chart -->
- <bean id="org.hisp.dhis.chart.ChartStore" class="org.hisp.dhis.chart.hibernate.HibernateChartStore">
+ <bean id="org.hisp.dhis.chart.ChartStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.chart.Chart" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
</bean>
- <bean id="org.hisp.dhis.chart.ChartGroupStore" class="org.hisp.dhis.chart.hibernate.HibernateChartStore">
+ <bean id="org.hisp.dhis.chart.ChartGroupStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
<property name="clazz" value="org.hisp.dhis.chart.ChartGroup" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
@@ -171,7 +171,7 @@
<!-- Dashboard -->
- <bean id="org.hisp.dhis.dashboard.DashboardContentStore" class="org.hisp.dhis.dashboard.hibernate.HibernateDashboardContentStore">
+ <bean id="org.hisp.dhis.dashboard.DashboardContentStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
<property name="clazz" value="org.hisp.dhis.dashboard.DashboardContent" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/chart/ChartStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/chart/ChartStoreTest.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/chart/ChartStoreTest.java 2011-12-09 20:04:48 +0000
@@ -36,6 +36,7 @@
import java.util.List;
import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
@@ -54,7 +55,7 @@
public class ChartStoreTest
extends DhisSpringTest
{
- private ChartStore chartStore;
+ private GenericIdentifiableObjectStore<Chart> chartStore;
private Indicator indicatorA;
private Indicator indicatorB;
@@ -77,9 +78,10 @@
// -------------------------------------------------------------------------
@Override
+ @SuppressWarnings("unchecked")
public void setUpTest()
{
- chartStore = (ChartStore) getBean( ChartStore.ID );
+ chartStore = (GenericIdentifiableObjectStore<Chart>) getBean( "org.hisp.dhis.chart.ChartStore" );
indicatorService = (IndicatorService) getBean( IndicatorService.ID );
@@ -209,6 +211,6 @@
chartStore.save( chartB );
chartStore.save( chartC );
- assertEquals( chartB, chartStore.getByTitle( "ChartB" ) );
+ assertEquals( chartB, chartStore.getByName( "ChartB" ) );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java 2011-04-24 12:47:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java 2011-12-09 20:04:48 +0000
@@ -33,6 +33,7 @@
import org.hibernate.NonUniqueObjectException;
import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.GenericStore;
import org.hisp.dhis.report.Report;
import org.hisp.dhis.report.ReportService;
import org.hisp.dhis.user.User;
@@ -51,7 +52,7 @@
private ReportService reportService;
- private DashboardContentStore dashboardContentStore;
+ private GenericStore<DashboardContent> dashboardContentStore;
private User userA;
@@ -61,13 +62,14 @@
private DashboardContent contentB;
@Override
+ @SuppressWarnings("unchecked")
public void setUpTest()
{
userStore = (UserStore) getBean( UserStore.ID );
reportService = (ReportService) getBean( ReportService.ID );
- dashboardContentStore = (DashboardContentStore) getBean( DashboardContentStore.ID );
+ dashboardContentStore = (GenericStore<DashboardContent>) getBean( "org.hisp.dhis.dashboard.DashboardContentStore" );
userA = createUser( 'A' );
userStore.addUser( userA );
@@ -87,9 +89,9 @@
dashboardContentStore.save( contentA );
- assertEquals( contentA, dashboardContentStore.get( userA ) );
- assertEquals( userA, dashboardContentStore.get( userA ).getUser() );
- assertEquals( reportA, dashboardContentStore.get( userA ).getReports().iterator().next() );
+ assertEquals( contentA, dashboardContentStore.get( userA.getId() ) );
+ assertEquals( userA, dashboardContentStore.get( userA.getId() ).getUser() );
+ assertEquals( reportA, dashboardContentStore.get( userA.getId() ).getReports().iterator().next() );
}
@Test
@@ -111,10 +113,10 @@
dashboardContentStore.save( contentA );
- assertNotNull( dashboardContentStore.get( userA ) );
+ assertNotNull( dashboardContentStore.get( userA.getId() ) );
dashboardContentStore.delete( contentA );
- assertNull( dashboardContentStore.get( userA ) );
+ assertNull( dashboardContentStore.get( userA.getId() ) );
}
}