dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15070
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5295: merged with dhis2-dxf. API now generates all links correctly, added support for rendering chart a...
Merge authors:
Morten Olav Hansen (mortenoh)
------------------------------------------------------------
revno: 5295 [merge]
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-06 06:26:02 +0100
message:
merged with dhis2-dxf. API now generates all links correctly, added support for rendering chart as png/jpg
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml
--
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-api/src/main/java/org/hisp/dhis/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2011-12-03 10:35:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2011-12-06 04:28:54 +0000
@@ -159,8 +159,6 @@
this.attributeValues = attributeValues;
}
- @XmlElement
- @JsonProperty
public Integer getSortOrder()
{
return sortOrder;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2011-11-25 14:03:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2011-12-06 05:14:01 +0000
@@ -49,7 +49,11 @@
{
String ID = ChartService.class.getName();
+ JFreeChart getJFreeChart( String uid, I18nFormat format );
+
JFreeChart getJFreeChart( int id, I18nFormat format );
+
+ JFreeChart getJFreeChart( Chart chart, I18nFormat format );
JFreeChart getJFreePeriodChart( Indicator indicator, OrganisationUnit unit, boolean title, I18nFormat format );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java 2011-12-03 16:31:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseLinkableObject.java 2011-12-05 15:02:23 +0000
@@ -40,7 +40,7 @@
* As part of the marshalling process, this field can be set to indicate a link to this
* identifiable object (will be used on the web layer for navigating the REST API)
*/
- private String link;
+ private transient String link;
@XmlAttribute
@JsonProperty
=== 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-11-23 18:07:35 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-12-06 05:14:01 +0000
@@ -27,40 +27,6 @@
* 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;
@@ -102,18 +68,8 @@
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
-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.plot.*;
+import org.jfree.chart.renderer.category.*;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
@@ -121,6 +77,15 @@
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$
@@ -141,10 +106,10 @@
private static final String DEFAULT_TITLE_PIVOT_CHART = "Pivot Chart";
- private static final Color[] colors = { Color.decode( "#d54a4a" ), Color.decode( "#2e4e83" ),
+ private static final Color[] colors = {Color.decode( "#d54a4a" ), Color.decode( "#2e4e83" ),
Color.decode( "#75e077" ), Color.decode( "#e3e274" ), Color.decode( "#e58c6d" ), Color.decode( "#df6ff3" ),
Color.decode( "#88878e" ), Color.decode( "#6ff3e8" ), Color.decode( "#6fc3f3" ), Color.decode( "#aaf36f" ),
- Color.decode( "#9d6ff3" ), Color.decode( "#474747" ) };
+ Color.decode( "#9d6ff3" ), Color.decode( "#474747" )};
// -------------------------------------------------------------------------
// Dependencies
@@ -228,10 +193,22 @@
// Logic
// -------------------------------------------------------------------------
+ public JFreeChart getJFreeChart( String uid, I18nFormat format )
+ {
+ Chart chart = getChart( uid );
+
+ return getJFreeChart( chart, format );
+ }
+
public JFreeChart getJFreeChart( int id, I18nFormat format )
{
Chart chart = getChart( id );
+ return getJFreeChart( chart, format );
+ }
+
+ public JFreeChart getJFreeChart( Chart chart, I18nFormat format )
+ {
if ( chart.getRelatives() != null )
{
chart.setRelativePeriods( periodService.reloadPeriods( chart.getRelatives().getRelativePeriods( format,
@@ -280,7 +257,7 @@
}
public JFreeChart getJFreeOrganisationUnitChart( Indicator indicator, OrganisationUnit parent, boolean title,
- I18nFormat format )
+ I18nFormat format )
{
RelativePeriods relatives = new RelativePeriods();
relatives.setThisYear( true );
@@ -309,8 +286,8 @@
}
public JFreeChart getJFreeChart( List<Indicator> indicators, List<DataElement> dataElements,
- List<DataSet> dataSets, List<Period> periods, List<OrganisationUnit> organisationUnits, String dimension,
- boolean regression, I18nFormat format )
+ List<DataSet> dataSets, List<Period> periods, List<OrganisationUnit> organisationUnits, String dimension,
+ boolean regression, I18nFormat format )
{
Chart chart = new Chart();
@@ -347,7 +324,7 @@
}
public JFreeChart getJFreeChart( String name, PlotOrientation orientation, CategoryLabelPositions labelPositions,
- Map<String, Double> categoryValues )
+ Map<String, Double> categoryValues )
{
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
@@ -365,8 +342,8 @@
}
public JFreeChart getJFreeChartHistory( DataElement dataElement,
- DataElementCategoryOptionCombo categoryOptionCombo, Period lastPeriod, OrganisationUnit organisationUnit,
- int historyLength, I18nFormat format )
+ DataElementCategoryOptionCombo categoryOptionCombo, Period lastPeriod, OrganisationUnit organisationUnit,
+ int historyLength, I18nFormat format )
{
lastPeriod = periodService.reloadPeriod( lastPeriod );
@@ -440,8 +417,7 @@
metaDataSet.addValue( function.value( periodCount ), "Regression value", period.getName() );
}
}
- }
- catch ( MathException ex )
+ } catch ( MathException ex )
{
throw new RuntimeException( "Failed to interpolate", ex );
}
@@ -569,7 +545,7 @@
* Returns a CategoryPlot.
*/
private CategoryPlot getCategoryPlot( CategoryDataset dataSet, CategoryItemRenderer renderer,
- PlotOrientation orientation, CategoryLabelPositions labelPositions )
+ PlotOrientation orientation, CategoryLabelPositions labelPositions )
{
CategoryPlot plot = new CategoryPlot( dataSet, new CategoryAxis(), new NumberAxis(), renderer );
@@ -827,7 +803,7 @@
{
String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY,
DEFAULT_AGGREGATION_STRATEGY );
-
+
final DefaultCategoryDataset regularDataSet = new DefaultCategoryDataset();
final DefaultCategoryDataset regressionDataSet = new DefaultCategoryDataset();
@@ -884,7 +860,7 @@
shortName = dataSets.get( i ).getShortName();
}
- if ( chart.isDimension( DIMENSION_PERIOD_INDICATOR )
+ if ( chart.isDimension( DIMENSION_PERIOD_INDICATOR )
|| chart.isDimension( DIMENSION_INDICATOR_PERIOD )
|| chart.isDimension( DIMENSION_PERIOD_DATAELEMENT )
|| chart.isDimension( DIMENSION_DATAELEMENT_PERIOD )
@@ -1030,14 +1006,14 @@
}
}
- return new CategoryDataset[] { regularDataSet, regressionDataSet };
+ return new CategoryDataset[]{regularDataSet, regressionDataSet};
}
/**
* Returns a title based on the chart meta data.
*/
private String getTitle( NameableObject nameableObject, List<Period> periods,
- List<OrganisationUnit> organisationUnits, I18nFormat format )
+ List<OrganisationUnit> organisationUnits, I18nFormat format )
{
String title = "";
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java 2011-12-03 14:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.attribute.Attributes;
@@ -51,21 +53,33 @@
private AttributeService attributeService;
@RequestMapping( method = RequestMethod.GET )
- public String getAttributes( Model model, HttpServletRequest request )
+ public String getAttributes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Attributes attributes = new Attributes();
attributes.setAttributes( new ArrayList<Attribute>( attributeService.getAllAttributes() ) );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( attributes );
+ }
+
model.addAttribute( "model", attributes );
return "attributes";
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getAttribute( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getAttribute( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Attribute attribute = attributeService.getAttribute( uid );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( attribute );
+ }
+
model.addAttribute( "model", attribute );
return "attribute";
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-05 12:21:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-06 05:19:57 +0000
@@ -27,19 +27,26 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.chart.Charts;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.period.Period;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -71,4 +78,53 @@
return "chart";
}
+
+ private class MockI18nFormat
+ extends I18nFormat
+ {
+ public MockI18nFormat()
+ {
+ super( null );
+ }
+
+ @Override
+ public String formatPeriod( Period period )
+ {
+ String name = period.getStartDate() + "-" + period.getEndDate();
+
+ return name.toLowerCase().trim();
+ }
+
+ @Override
+ public String formatDate( Date date )
+ {
+ return date.toString().toLowerCase().trim();
+ }
+ }
+
+ @RequestMapping( value = "/{uid}.png", method = RequestMethod.GET )
+ public void getChartPNG( @PathVariable( "uid" ) String uid, @RequestParam( value = "width", defaultValue = "700", required = false ) int width,
+ @RequestParam( value = "height", defaultValue = "500", required = false ) Integer height,
+ HttpServletResponse response ) throws IOException
+ {
+ I18nFormat i18nFormat = new MockI18nFormat();
+
+ JFreeChart chart = chartService.getJFreeChart( uid, i18nFormat );
+
+ response.setContentType( "image/png" );
+ ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
+ }
+
+ @RequestMapping( value = "/{uid}.jpg", method = RequestMethod.GET )
+ public void getChartJPG( @PathVariable( "uid" ) String uid, @RequestParam( value = "width", defaultValue = "700", required = false ) int width,
+ @RequestParam( value = "height", defaultValue = "500", required = false ) Integer height,
+ HttpServletResponse response ) throws IOException
+ {
+ I18nFormat i18nFormat = new MockI18nFormat();
+
+ JFreeChart chart = chartService.getJFreeChart( uid, i18nFormat );
+
+ response.setContentType( "image/jpg" );
+ ChartUtilities.writeChartAsJPEG( response.getOutputStream(), chart, width, height );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryComboController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryComboController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryCombos;
@@ -52,13 +53,16 @@
private DataElementCategoryService dataElementCategoryService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementCategoryCombos( Model model, HttpServletRequest request )
+ public String getDataElementCategoryCombos( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryCombos dataElementCategoryCombos = new DataElementCategoryCombos();
dataElementCategoryCombos.setDataElementCategoryCombos( new ArrayList<DataElementCategoryCombo>( dataElementCategoryService.getAllDataElementCategoryCombos() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryCombos );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryCombos );
+ }
model.addAttribute( "model", dataElementCategoryCombos );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryCombo dataElementCategoryCombo = dataElementCategoryService.getDataElementCategoryCombo( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryCombo );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryCombo );
+ }
model.addAttribute( "model", dataElementCategoryCombo );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementCategories;
import org.hisp.dhis.dataelement.DataElementCategory;
@@ -52,13 +53,16 @@
private DataElementCategoryService dataElementCategoryService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementCategories( Model model, HttpServletRequest request )
+ public String getDataElementCategories( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategories dataElementCategories = new DataElementCategories();
dataElementCategories.setDataElementCategories( new ArrayList<DataElementCategory>( dataElementCategoryService.getAllDataElementCategories() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategories );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategories );
+ }
model.addAttribute( "model", dataElementCategories );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementCategory( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementCategory( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategory dataElementCategory = dataElementCategoryService.getDataElementCategory( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategory );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategory );
+ }
model.addAttribute( "model", dataElementCategory );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionComboController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionComboController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombos;
@@ -52,13 +53,16 @@
private DataElementCategoryService dataElementCategoryService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementCategoryOptionCombos( Model model, HttpServletRequest request )
+ public String getDataElementCategoryOptionCombos( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOptionCombos dataElementCategoryOptionCombos = new DataElementCategoryOptionCombos();
dataElementCategoryOptionCombos.setDataElementCategoryOptionCombos( new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryService.getAllDataElementCategoryOptionCombos() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryOptionCombos );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryOptionCombos );
+ }
model.addAttribute( "model", dataElementCategoryOptionCombos );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOptionCombo dataElementCategoryOptionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryOptionCombo );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryOptionCombo );
+ }
model.addAttribute( "model", dataElementCategoryOptionCombo );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptions;
@@ -52,13 +53,16 @@
private DataElementCategoryService dataElementCategoryService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementCategoryOptions( Model model, HttpServletRequest request )
+ public String getDataElementCategoryOptions( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOptions dataElementCategoryOptions = new DataElementCategoryOptions();
dataElementCategoryOptions.setDataElementCategoryOptions( new ArrayList<DataElementCategoryOption>( dataElementCategoryService.getAllDataElementCategoryOptions() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryOptions );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryOptions );
+ }
model.addAttribute( "model", dataElementCategoryOptions );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementCategoryOption( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementCategoryOption( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOption dataElementCategoryOption = dataElementCategoryService.getDataElementCategoryOption( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementCategoryOption );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementCategoryOption );
+ }
model.addAttribute( "model", dataElementCategoryOption );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
@@ -56,13 +57,16 @@
private DataElementService dataElementService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElements( Model model, HttpServletRequest request )
+ public String getDataElements( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElements dataElements = new DataElements();
dataElements.setDataElements( new ArrayList<DataElement>( dataElementService.getAllActiveDataElements() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElements );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElements );
+ }
model.addAttribute( "model", dataElements );
@@ -88,12 +92,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElement( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElement( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElement dataElement = dataElementService.getDataElement( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElement );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElement );
+ }
model.addAttribute( "model", dataElement );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroups;
@@ -49,13 +50,16 @@
private DataElementService dataElementService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementGroups( Model model, HttpServletRequest request )
+ public String getDataElementGroups( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementGroups dataElementGroups = new DataElementGroups();
dataElementGroups.setDataElementGroups( new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementGroups );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementGroups );
+ }
model.addAttribute( "model", dataElementGroups );
@@ -63,12 +67,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementGroup( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementGroup( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementGroup );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementGroup );
+ }
model.addAttribute( "model", dataElementGroup );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementGroupSets;
@@ -52,13 +53,16 @@
private DataElementService dataElementService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementGroupSets( Model model, HttpServletRequest request )
+ public String getDataElementGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementGroupSets dataElementGroupSets = new DataElementGroupSets();
dataElementGroupSets.setDataElementGroupSets( new ArrayList<DataElementGroupSet>( dataElementService.getAllDataElementGroupSets() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementGroupSets );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementGroupSets );
+ }
model.addAttribute( "model", dataElementGroupSets );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementGroupSet( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataElementGroupSet( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementGroupSet dataElementGroupSet = dataElementService.getDataElementGroupSet( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataElementGroupSet );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataElementGroupSet );
+ }
model.addAttribute( "model", dataElementGroupSet );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -52,13 +53,16 @@
private DataSetService dataSetService;
@RequestMapping( method = RequestMethod.GET )
- public String getDataSets( Model model, HttpServletRequest request )
+ public String getDataSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataSets dataSets = new DataSets();
dataSets.setDataSets( new ArrayList<DataSet>( dataSetService.getAllDataSets() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataSets );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataSets );
+ }
model.addAttribute( "model", dataSets );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataSet( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getDataSet( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataSet dataSet = dataSetService.getDataSet( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( dataSet );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( dataSet );
+ }
model.addAttribute( "model", dataSet );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
@@ -52,13 +53,16 @@
private IndicatorService indicatorService;
@RequestMapping( method = RequestMethod.GET )
- public String getIndicators( Model model, HttpServletRequest request )
+ public String getIndicators( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Indicators indicators = new Indicators();
indicators.setIndicators( new ArrayList<Indicator>( indicatorService.getAllIndicators() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicators );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicators );
+ }
model.addAttribute( "model", indicators );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getIndicator( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getIndicator( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Indicator indicator = indicatorService.getIndicator( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicator );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicator );
+ }
model.addAttribute( "model", indicator );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorGroups;
@@ -52,13 +53,16 @@
private IndicatorService indicatorService;
@RequestMapping( method = RequestMethod.GET )
- public String getIndicatorGroups( Model model, HttpServletRequest request )
+ public String getIndicatorGroups( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorGroups indicatorGroups = new IndicatorGroups();
indicatorGroups.setIndicatorGroups( new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorGroups );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorGroups );
+ }
model.addAttribute( "model", indicatorGroups );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getIndicatorGroup( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getIndicatorGroup( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorGroup );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorGroup );
+ }
model.addAttribute( "model", indicatorGroup );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.indicator.IndicatorGroupSets;
@@ -52,13 +53,16 @@
private IndicatorService indicatorService;
@RequestMapping( method = RequestMethod.GET )
- public String getIndicatorGroupSets( Model model, HttpServletRequest request )
+ public String getIndicatorGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorGroupSets indicatorGroupSets = new IndicatorGroupSets();
indicatorGroupSets.setIndicatorGroupSets( new ArrayList<IndicatorGroupSet>( indicatorService.getAllIndicatorGroupSets() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorGroupSets );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorGroupSets );
+ }
model.addAttribute( "model", indicatorGroupSets );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getIndicatorGroupSet( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getIndicatorGroupSet( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorGroupSet indicatorGroupSet = indicatorService.getIndicatorGroupSet( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorGroupSet );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorGroupSet );
+ }
model.addAttribute( "model", indicatorGroupSet );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
@@ -52,13 +53,16 @@
private IndicatorService indicatorService;
@RequestMapping( method = RequestMethod.GET )
- public String getIndicatorTypes( Model model, HttpServletRequest request )
+ public String getIndicatorTypes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorTypes indicatorTypes = new IndicatorTypes();
indicatorTypes.setIndicatorTypes( new ArrayList<IndicatorType>( indicatorService.getAllIndicatorTypes() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorTypes );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorTypes );
+ }
model.addAttribute( "model", indicatorTypes );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getIndicator( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getIndicator( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
IndicatorType indicatorType = indicatorService.getIndicatorType( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( indicatorType );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( indicatorType );
+ }
model.addAttribute( "model", indicatorType );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-06 04:28:54 +0000
@@ -1,5 +1,6 @@
package org.hisp.dhis.api.controller;
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -25,13 +26,16 @@
private OrganisationUnitService organisationUnitService;
@RequestMapping( method = RequestMethod.GET )
- public String getOrganisationUnits( Model model, HttpServletRequest request )
+ public String getOrganisationUnits( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnits organisationUnits = new OrganisationUnits();
organisationUnits.setOrganisationUnits( new ArrayList<OrganisationUnit>( organisationUnitService.getAllOrganisationUnits() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnits );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnits );
+ }
model.addAttribute( "model", organisationUnits );
@@ -39,12 +43,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getOrganisationUnit( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnit );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnit );
+ }
model.addAttribute( "model", organisationUnit );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java 2011-12-06 04:28:54 +0000
@@ -1,5 +1,6 @@
package org.hisp.dhis.api.controller;
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -25,13 +26,16 @@
private OrganisationUnitGroupService organisationUnitGroupService;
@RequestMapping( method = RequestMethod.GET )
- public String getOrganisationUnits( Model model, HttpServletRequest request )
+ public String getOrganisationUnits( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitGroups organisationUnitGroups = new OrganisationUnitGroups();
organisationUnitGroups.setOrganisationUnitGroups( new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getAllOrganisationUnitGroups() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitGroups );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitGroups );
+ }
model.addAttribute( "model", organisationUnitGroups );
@@ -39,13 +43,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getOrganisationUnit( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitGroup );
-
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitGroup );
+ }
model.addAttribute( "model", organisationUnitGroup );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
@@ -52,13 +53,16 @@
private OrganisationUnitGroupService organisationUnitGroupService;
@RequestMapping( method = RequestMethod.GET )
- public String getOrganisationUnitGroupSets( Model model, HttpServletRequest request )
+ public String getOrganisationUnitGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitGroupSets organisationUnitGroupSets = new OrganisationUnitGroupSets();
organisationUnitGroupSets.setOrganisationUnitGroupSets( new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitGroupSets );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitGroupSets );
+ }
model.addAttribute( "model", organisationUnitGroupSets );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getOrganisationUnitGroupSet( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getOrganisationUnitGroupSet( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitGroupSet organisationUnitGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitGroupSet );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitGroupSet );
+ }
model.addAttribute( "model", organisationUnitGroupSet );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.organisationunit.OrganisationUnitLevels;
@@ -52,13 +53,16 @@
private OrganisationUnitService organisationUnitService;
@RequestMapping( method = RequestMethod.GET )
- public String getOrganisationUnitLevels( Model model, HttpServletRequest request )
+ public String getOrganisationUnitLevels( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitLevels organisationUnitLevels = new OrganisationUnitLevels();
organisationUnitLevels.setOrganisationUnitLevels( new ArrayList<OrganisationUnitLevel>( organisationUnitService.getOrganisationUnitLevels() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitLevels );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitLevels );
+ }
model.addAttribute( "model", organisationUnitLevels );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getOrganisationUnit( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
OrganisationUnitLevel organisationUnitLevel = organisationUnitService.getOrganisationUnitLevel( uid );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( organisationUnitLevel );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( organisationUnitLevel );
+ }
model.addAttribute( "model", organisationUnitLevel );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java 2011-12-03 18:00:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java 2011-12-06 04:28:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
@@ -52,13 +53,16 @@
private UserService userService;
@RequestMapping( method = RequestMethod.GET )
- public String getUsers( Model model, HttpServletRequest request )
+ public String getUsers( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Users users = new Users();
users.setUsers( new ArrayList<User>( userService.getAllUsers() ) );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( users );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( users );
+ }
model.addAttribute( "model", users );
@@ -66,12 +70,15 @@
}
@RequestMapping( value = "/{id}", method = RequestMethod.GET )
- public String getUser( @PathVariable( "id" ) Integer id, Model model, HttpServletRequest request )
+ public String getUser( @PathVariable( "id" ) Integer id, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
User user = userService.getUser( id );
- WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
- listener.beforeMarshal( user );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( user );
+ }
model.addAttribute( "model", user );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java 2011-12-05 12:21:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java 2011-12-06 05:26:02 +0000
@@ -27,55 +27,30 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.bind.Marshaller;
-
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.Attributes;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.Charts;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategories;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryCombos;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombos;
-import org.hisp.dhis.dataelement.DataElementCategoryOptions;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
-import org.hisp.dhis.dataelement.DataElementGroupSets;
-import org.hisp.dhis.dataelement.DataElementGroups;
-import org.hisp.dhis.dataelement.DataElements;
+import org.hisp.dhis.dataelement.*;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrations;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSets;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-import org.hisp.dhis.indicator.IndicatorGroupSets;
-import org.hisp.dhis.indicator.IndicatorGroups;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.indicator.IndicatorTypes;
-import org.hisp.dhis.indicator.Indicators;
+import org.hisp.dhis.indicator.*;
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.mapping.Maps;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroups;
-import org.hisp.dhis.organisationunit.OrganisationUnits;
+import org.hisp.dhis.organisationunit.*;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.Users;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.bind.Marshaller;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -149,17 +124,534 @@
@Override
public void beforeMarshal( Object source )
{
- if ( source instanceof BaseIdentifiableObject )
- {
- BaseIdentifiableObject entity = (BaseIdentifiableObject) source;
- entity.setLink( getPathWithUid( entity ) );
- }
- else if ( source instanceof BaseLinkableObject )
- {
- BaseLinkableObject linkable = (BaseLinkableObject) source;
- linkable.setLink( getBasePath( linkable.getClass() ) );
- }
-
+ if ( source instanceof Charts )
+ {
+ populateCharts( (Charts) source, true );
+ }
+ else if ( source instanceof Chart )
+ {
+ populateChart( (Chart) source, true );
+ }
+ else if ( source instanceof DataSets )
+ {
+ populateDataSets( (DataSets) source, true );
+ }
+ else if ( source instanceof DataSet )
+ {
+ populateDataSet( (DataSet) source, true );
+ }
+ else if ( source instanceof OrganisationUnits )
+ {
+ populateOrganisationUnits( (OrganisationUnits) source, true );
+ }
+ else if ( source instanceof OrganisationUnit )
+ {
+ populateOrganisationUnit( (OrganisationUnit) source, true );
+ }
+ else if ( source instanceof OrganisationUnitGroups )
+ {
+ populateOrganisationUnitGroups( (OrganisationUnitGroups) source, true );
+ }
+ else if ( source instanceof OrganisationUnitGroup )
+ {
+ populateOrganisationUnitGroup( (OrganisationUnitGroup) source, true );
+ }
+ else if ( source instanceof OrganisationUnitGroupSets )
+ {
+ populateOrganisationUnitGroupSets( (OrganisationUnitGroupSets) source, true );
+ }
+ else if ( source instanceof OrganisationUnitGroupSet )
+ {
+ populateOrganisationUnitGroupSet( (OrganisationUnitGroupSet) source, true );
+ }
+ else if ( source instanceof Indicators )
+ {
+ populateIndicators( (Indicators) source, true );
+ }
+ else if ( source instanceof Indicator )
+ {
+ populateIndicator( (Indicator) source, true );
+ }
+ else if ( source instanceof IndicatorGroups )
+ {
+ populateIndicatorGroups( (IndicatorGroups) source, true );
+ }
+ else if ( source instanceof IndicatorGroup )
+ {
+ populateIndicatorGroup( (IndicatorGroup) source, true );
+ }
+ else if ( source instanceof IndicatorGroupSets )
+ {
+ populateIndicatorGroupSets( (IndicatorGroupSets) source, true );
+ }
+ else if ( source instanceof IndicatorGroupSet )
+ {
+ populateIndicatorGroupSet( (IndicatorGroupSet) source, true );
+ }
+ else if ( source instanceof DataElements )
+ {
+ populateDataElements( (DataElements) source, true );
+ }
+ else if ( source instanceof DataElement )
+ {
+ populateDataElement( (DataElement) source, true );
+ }
+ else if ( source instanceof DataElementGroups )
+ {
+ populateDataElementGroups( (DataElementGroups) source, true );
+ }
+ else if ( source instanceof DataElementGroup )
+ {
+ populateDataElementGroup( (DataElementGroup) source, true );
+ }
+ else if ( source instanceof DataElementGroupSets )
+ {
+ populateDataElementGroupSets( (DataElementGroupSets) source, true );
+ }
+ else if ( source instanceof DataElementGroupSet )
+ {
+ populateDataElementGroupSet( (DataElementGroupSet) source, true );
+ }
+ else if ( source instanceof DataElementCategories )
+ {
+ populateDataElementCategories( (DataElementCategories) source, true );
+ }
+ else if ( source instanceof DataElementCategory )
+ {
+ populateDataElementCategory( (DataElementCategory) source, true );
+ }
+ else if ( source instanceof DataElementCategoryCombos )
+ {
+ populateDataElementCategoryCombos( (DataElementCategoryCombos) source, true );
+ }
+ else if ( source instanceof DataElementCategoryCombo )
+ {
+ populateDataElementCategoryCombo( (DataElementCategoryCombo) source, true );
+ }
+ else if ( source instanceof DataElementCategoryOptions )
+ {
+ populateDataElementCategoryOptions( (DataElementCategoryOptions) source, true );
+ }
+ else if ( source instanceof DataElementCategoryOption )
+ {
+ populateDataElementCategoryOption( (DataElementCategoryOption) source, true );
+ }
+ else if ( source instanceof DataElementCategoryOptionCombos )
+ {
+ populateDataElementCategoryOptionCombos( (DataElementCategoryOptionCombos) source, true );
+ }
+ else if ( source instanceof DataElementCategoryOptionCombo )
+ {
+ populateDataElementCategoryOptionCombo( (DataElementCategoryOptionCombo) source, true );
+ }
+ else if ( source instanceof Attributes )
+ {
+ populateAttributes( (Attributes) source, true );
+ }
+ else if ( source instanceof Attribute )
+ {
+ populateAttribute( (Attribute) source, true );
+ }
+ }
+
+ private void populateAttributes( Attributes attributes, boolean root )
+ {
+ attributes.setLink( getBasePath( Attributes.class ) );
+
+ if ( root )
+ {
+ for ( Attribute attribute : attributes.getAttributes() )
+ {
+ populateAttribute( attribute, false );
+ }
+ }
+ }
+
+ private void populateAttribute( Attribute attribute, boolean root )
+ {
+ attribute.setLink( getPathWithUid( attribute ) );
+
+ if ( root )
+ {
+
+ }
+ }
+
+ private void populateDataElementCategories( DataElementCategories dataElementCategories, boolean root )
+ {
+ dataElementCategories.setLink( getBasePath( DataElementCategories.class ) );
+
+ if ( root )
+ {
+ for ( DataElementCategory dataElementCategory : dataElementCategories.getDataElementCategories() )
+ {
+ populateDataElementCategory( dataElementCategory, false );
+ }
+ }
+ }
+
+ private void populateDataElementCategory( DataElementCategory dataElementCategory, boolean root )
+ {
+ dataElementCategory.setLink( getPathWithUid( dataElementCategory ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementCategory.getCategoryOptions() );
+ }
+ }
+
+ private void populateDataElementCategoryCombos( DataElementCategoryCombos dataElementCategoryCombos, boolean root )
+ {
+ dataElementCategoryCombos.setLink( getBasePath( DataElementCategoryCombos.class ) );
+
+ if ( root )
+ {
+ for ( DataElementCategoryCombo dataElementCategoryCombo : dataElementCategoryCombos.getDataElementCategoryCombos() )
+ {
+ populateDataElementCategoryCombo( dataElementCategoryCombo, false );
+ }
+ }
+ }
+
+ private void populateDataElementCategoryCombo( DataElementCategoryCombo dataElementCategoryCombo, boolean root )
+ {
+ dataElementCategoryCombo.setLink( getPathWithUid( dataElementCategoryCombo ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementCategoryCombo.getOptionCombos() );
+ handleIdentifiableObjectCollection( dataElementCategoryCombo.getCategories() );
+ }
+ }
+
+ private void populateDataElementCategoryOptions( DataElementCategoryOptions dataElementCategoryOptions, boolean root )
+ {
+ dataElementCategoryOptions.setLink( getBasePath( DataElementCategoryOptions.class ) );
+
+ if ( root )
+ {
+ for ( DataElementCategoryOption dataElementCategoryOption : dataElementCategoryOptions.getDataElementCategoryOptions() )
+ {
+ populateDataElementCategoryOption( dataElementCategoryOption, false );
+ }
+ }
+ }
+
+ private void populateDataElementCategoryOption( DataElementCategoryOption dataElementCategoryOption, boolean root )
+ {
+ dataElementCategoryOption.setLink( getPathWithUid( dataElementCategoryOption ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementCategoryOption.getCategoryOptionCombos() );
+ populateIdentifiableObject( dataElementCategoryOption.getCategory() );
+ }
+ }
+
+ private void populateDataElementCategoryOptionCombos( DataElementCategoryOptionCombos dataElementCategoryOptionCombos, boolean root )
+ {
+ dataElementCategoryOptionCombos.setLink( getBasePath( DataElementCategoryOptionCombos.class ) );
+
+ if ( root )
+ {
+ for ( DataElementCategoryOptionCombo dataElementCategoryOptionCombo : dataElementCategoryOptionCombos.getDataElementCategoryOptionCombos() )
+ {
+ populateDataElementCategoryOptionCombo( dataElementCategoryOptionCombo, false );
+ }
+ }
+ }
+
+ private void populateDataElementCategoryOptionCombo( DataElementCategoryOptionCombo dataElementCategoryOptionCombo, boolean root )
+ {
+ dataElementCategoryOptionCombo.setLink( getPathWithUid( dataElementCategoryOptionCombo ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementCategoryOptionCombo.getCategoryOptions() );
+ populateIdentifiableObject( dataElementCategoryOptionCombo.getCategoryCombo() );
+ }
+ }
+
+ private void populateDataElements( DataElements dataElements, boolean root )
+ {
+ dataElements.setLink( getBasePath( DataElements.class ) );
+
+ if ( root )
+ {
+ for ( DataElement dataElement : dataElements.getDataElements() )
+ {
+ populateDataElement( dataElement, false );
+ }
+ }
+ }
+
+ private void populateDataElement( DataElement dataElement, boolean root )
+ {
+ dataElement.setLink( getPathWithUid( dataElement ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElement.getGroups() );
+ handleIdentifiableObjectCollection( dataElement.getDataSets() );
+ populateIdentifiableObject( dataElement.getCategoryCombo() );
+ }
+ }
+
+ private void populateDataElementGroups( DataElementGroups dataElementGroups, boolean root )
+ {
+ dataElementGroups.setLink( getBasePath( DataElementGroups.class ) );
+
+ if ( root )
+ {
+ for ( DataElementGroup dataElementGroup : dataElementGroups.getDataElementGroups() )
+ {
+ populateDataElementGroup( dataElementGroup, false );
+ }
+ }
+ }
+
+ private void populateDataElementGroup( DataElementGroup dataElementGroup, boolean root )
+ {
+ dataElementGroup.setLink( getPathWithUid( dataElementGroup ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementGroup.getMembers() );
+ populateIdentifiableObject( dataElementGroup.getGroupSet() );
+ }
+ }
+
+ private void populateDataElementGroupSets( DataElementGroupSets dataElementGroupSets, boolean root )
+ {
+ dataElementGroupSets.setLink( getBasePath( DataElementGroupSets.class ) );
+
+ if ( root )
+ {
+ for ( DataElementGroupSet dataElementGroupSet : dataElementGroupSets.getDataElementGroupSets() )
+ {
+ populateDataElementGroupSet( dataElementGroupSet, false );
+ }
+ }
+ }
+
+ private void populateDataElementGroupSet( DataElementGroupSet dataElementGroupSet, boolean root )
+ {
+ dataElementGroupSet.setLink( getPathWithUid( dataElementGroupSet ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataElementGroupSet.getMembers() );
+ }
+ }
+
+ private void populateIndicators( Indicators indicators, boolean root )
+ {
+ indicators.setLink( getBasePath( Indicators.class ) );
+
+ if ( root )
+ {
+ for ( Indicator indicator : indicators.getIndicators() )
+ {
+ populateIndicator( indicator, false );
+ }
+ }
+ }
+
+ private void populateIndicator( Indicator indicator, boolean root )
+ {
+ indicator.setLink( getPathWithUid( indicator ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( indicator.getGroups() );
+ handleIdentifiableObjectCollection( indicator.getDataSets() );
+ }
+ }
+
+ private void populateIndicatorGroups( IndicatorGroups indicatorGroups, boolean root )
+ {
+ indicatorGroups.setLink( getBasePath( IndicatorGroups.class ) );
+
+ if ( root )
+ {
+ for ( IndicatorGroup indicatorGroup : indicatorGroups.getIndicatorGroups() )
+ {
+ populateIndicatorGroup( indicatorGroup, false );
+ }
+ }
+ }
+
+ private void populateIndicatorGroup( IndicatorGroup indicatorGroup, boolean root )
+ {
+ indicatorGroup.setLink( getPathWithUid( indicatorGroup ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( indicatorGroup.getMembers() );
+ populateIdentifiableObject( indicatorGroup.getGroupSet() );
+ }
+ }
+
+ private void populateIndicatorGroupSets( IndicatorGroupSets indicatorGroupSets, boolean root )
+ {
+ indicatorGroupSets.setLink( getBasePath( IndicatorGroupSets.class ) );
+
+ if ( root )
+ {
+ for ( IndicatorGroupSet indicatorGroupSet : indicatorGroupSets.getIndicatorGroupSets() )
+ {
+ populateIndicatorGroupSet( indicatorGroupSet, false );
+ }
+ }
+ }
+
+ private void populateIndicatorGroupSet( IndicatorGroupSet indicatorGroupSet, boolean root )
+ {
+ indicatorGroupSet.setLink( getPathWithUid( indicatorGroupSet ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( indicatorGroupSet.getMembers() );
+ }
+ }
+
+ private void populateOrganisationUnitGroups( OrganisationUnitGroups organisationUnitGroups, boolean root )
+ {
+ organisationUnitGroups.setLink( getBasePath( OrganisationUnitGroups.class ) );
+
+ if ( root )
+ {
+ for ( OrganisationUnitGroup organisationUnitGroup : organisationUnitGroups.getOrganisationUnitGroups() )
+ {
+ populateOrganisationUnitGroup( organisationUnitGroup, false );
+ }
+ }
+ }
+
+ private void populateOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup, boolean root )
+ {
+ organisationUnitGroup.setLink( getPathWithUid( organisationUnitGroup ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( organisationUnitGroup.getMembers() );
+ populateIdentifiableObject( organisationUnitGroup.getGroupSet() );
+ }
+ }
+
+ private void populateOrganisationUnitGroupSets( OrganisationUnitGroupSets organisationUnitGroupSets, boolean root )
+ {
+ organisationUnitGroupSets.setLink( getBasePath( OrganisationUnitGroupSets.class ) );
+
+ if ( root )
+ {
+ for ( OrganisationUnitGroupSet organisationUnitGroupSet : organisationUnitGroupSets.getOrganisationUnitGroupSets() )
+ {
+ populateOrganisationUnitGroupSet( organisationUnitGroupSet, false );
+ }
+ }
+ }
+
+ private void populateOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet, boolean root )
+ {
+ organisationUnitGroupSet.setLink( getPathWithUid( organisationUnitGroupSet ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( organisationUnitGroupSet.getOrganisationUnitGroups() );
+ }
+ }
+
+ private void populateOrganisationUnits( OrganisationUnits organisationUnits, boolean root )
+ {
+ organisationUnits.setLink( getBasePath( OrganisationUnits.class ) );
+
+ if ( root )
+ {
+ for ( OrganisationUnit organisationUnit : organisationUnits.getOrganisationUnits() )
+ {
+ populateOrganisationUnit( organisationUnit, false );
+ }
+ }
+ }
+
+ private void populateOrganisationUnit( OrganisationUnit organisationUnit, boolean root )
+ {
+ organisationUnit.setLink( getPathWithUid( organisationUnit ) );
+
+ if ( root )
+ {
+ populateIdentifiableObject( organisationUnit.getParent() );
+ handleIdentifiableObjectCollection( organisationUnit.getDataSets() );
+ handleIdentifiableObjectCollection( organisationUnit.getGroups() );
+ }
+ }
+
+ private void populateDataSets( DataSets dataSets, boolean root )
+ {
+ dataSets.setLink( getBasePath( DataSets.class ) );
+
+ if ( root )
+ {
+ for ( DataSet dataSet : dataSets.getDataSets() )
+ {
+ populateDataSet( dataSet, false );
+ }
+ }
+ }
+
+ private void populateDataSet( DataSet dataSet, boolean root )
+ {
+ dataSet.setLink( getPathWithUid( dataSet ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( dataSet.getDataElements() );
+ handleIdentifiableObjectCollection( dataSet.getIndicators() );
+ handleIdentifiableObjectCollection( dataSet.getSources() );
+ }
+ }
+
+ private void populateCharts( Charts charts, boolean root )
+ {
+ charts.setLink( getBasePath( Chart.class ) );
+
+ if ( root )
+ {
+ for ( Chart chart : charts.getCharts() )
+ {
+ populateChart( chart, false );
+ }
+ }
+ }
+
+ private void populateChart( Chart chart, boolean root )
+ {
+ chart.setLink( getPathWithUid( chart ) );
+
+ if ( root )
+ {
+ handleIdentifiableObjectCollection( chart.getIndicators() );
+ handleIdentifiableObjectCollection( chart.getDataElements() );
+ handleIdentifiableObjectCollection( chart.getOrganisationUnits() );
+ handleIdentifiableObjectCollection( chart.getAllOrganisationUnits() );
+ handleIdentifiableObjectCollection( chart.getDataSets() );
+ handleIdentifiableObjectCollection( chart.getPeriods() );
+ handleIdentifiableObjectCollection( chart.getAllPeriods() );
+ }
+ }
+
+ public void handleIdentifiableObjectCollection( Collection<? extends BaseIdentifiableObject> identifiableObjects )
+ {
+ for ( BaseIdentifiableObject baseIdentifiableObject : identifiableObjects )
+ {
+ populateIdentifiableObject( baseIdentifiableObject );
+ }
+ }
+
+ private void populateIdentifiableObject( BaseIdentifiableObject baseIdentifiableObject )
+ {
+ baseIdentifiableObject.setLink( getPathWithUid( baseIdentifiableObject ) );
}
private String getPathWithUid( BaseIdentifiableObject baseIdentifiableObject )
@@ -171,20 +663,20 @@
{
if ( rootPath == null )
{
- StringBuffer buffer = new StringBuffer();
- buffer.append( request.getScheme() );
+ StringBuilder builder = new StringBuilder();
- buffer.append( "://" + request.getServerName() );
+ builder.append( request.getScheme() );
+ builder.append( "://" ).append( request.getServerName() );
if ( request.getServerPort() != 80 && request.getServerPort() != 443 )
{
- buffer.append( ":" + request.getServerPort() );
+ builder.append( ":" ).append( request.getServerPort() );
}
- buffer.append( request.getContextPath() );
- buffer.append( request.getServletPath() );
+ builder.append( request.getContextPath() );
+ builder.append( request.getServletPath() );
- rootPath = buffer.toString();
+ rootPath = builder.toString();
}
String resourcePath = resourcePaths.get( clazz );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-12-02 14:01:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-12-06 05:14:01 +0000
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
-
+
</beans>