dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24215
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11828: add uuid view for (used for orgunit.uuid)
------------------------------------------------------------
revno: 11828
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-08-28 13:47:51 +0200
message:
add uuid view for (used for orgunit.uuid)
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/view/UuidView.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-08-28 11:47:51 +0000
@@ -28,10 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseAnalyticalObject;
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -46,22 +48,19 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.user.User;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
/**
* @author Lars Helge Overland
*/
-@JacksonXmlRootElement( localName = "chart", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement(localName = "chart", namespace = DxfNamespaces.DXF_2_0)
public class Chart
extends BaseAnalyticalObject
{
private static final long serialVersionUID = 2570074075484545534L;
-
+
public static final String SIZE_NORMAL = "normal";
public static final String SIZE_WIDE = "wide";
public static final String SIZE_TALL = "tall";
@@ -92,9 +91,9 @@
private boolean regression;
private boolean hideTitle;
-
+
private boolean hideSubtitle;
-
+
private String title;
private Double targetLineValue;
@@ -114,9 +113,9 @@
private transient I18nFormat format;
private transient List<Period> relativePeriods = new ArrayList<Period>();
-
+
private transient User user;
-
+
private transient List<OrganisationUnit> organisationUnitsAtLevel = new ArrayList<OrganisationUnit>();
private transient List<OrganisationUnit> organisationUnitsInGroups = new ArrayList<OrganisationUnit>();
@@ -139,7 +138,7 @@
// -------------------------------------------------------------------------
@Override
- public void init( User user, Date date, OrganisationUnit organisationUnit,
+ public void init( User user, Date date, OrganisationUnit organisationUnit,
List<OrganisationUnit> organisationUnitsAtLevel, List<OrganisationUnit> organisationUnitsInGroups, I18nFormat format )
{
this.user = user;
@@ -147,9 +146,9 @@
this.relativeOrganisationUnit = organisationUnit;
this.organisationUnitsAtLevel = organisationUnitsAtLevel;
this.organisationUnitsInGroups = organisationUnitsInGroups;
- this.format = format;
+ this.format = format;
}
-
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -157,34 +156,34 @@
public List<NameableObject> series()
{
DimensionalObject object = getDimensionalObject( series, relativePeriodDate, user, true, organisationUnitsAtLevel, organisationUnitsInGroups, format );
-
+
return object != null ? object.getItems() : null;
}
public List<NameableObject> category()
{
DimensionalObject object = getDimensionalObject( category, relativePeriodDate, user, true, organisationUnitsAtLevel, organisationUnitsInGroups, format );
-
+
return object != null ? object.getItems() : null;
}
public List<NameableObject> filters()
{
List<NameableObject> filterItems = new ArrayList<NameableObject>();
-
+
for ( String filter : filterDimensions )
{
DimensionalObject object = getDimensionalObject( filter, relativePeriodDate, user, true, organisationUnitsAtLevel, organisationUnitsInGroups, format );
-
+
if ( object != null )
{
filterItems.addAll( object.getItems() );
}
}
-
+
return filterItems;
}
-
+
public String generateTitle()
{
return IdentifiableObjectUtils.join( filters() );
@@ -195,7 +194,7 @@
{
columns.addAll( getDimensionalObjectList( series ) );
rows.addAll( getDimensionalObjectList( category ) );
-
+
for ( String filter : filterDimensions )
{
filters.addAll( getDimensionalObjectList( filter ) );
@@ -213,19 +212,19 @@
return organisationUnits;
}
}
-
+
public OrganisationUnit getFirstOrganisationUnit()
{
List<OrganisationUnit> units = getAllOrganisationUnits();
return units != null && !units.isEmpty() ? units.iterator().next() : null;
}
-
+
public List<Period> getAllPeriods()
{
List<Period> list = new ArrayList<Period>();
-
+
list.addAll( relativePeriods );
-
+
for ( Period period : periods )
{
if ( !list.contains( period ) )
@@ -233,7 +232,7 @@
list.add( period );
}
}
-
+
return list;
}
@@ -282,8 +281,8 @@
// -------------------------------------------------------------------------
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getDomainAxisLabel()
{
return domainAxisLabel;
@@ -295,8 +294,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getRangeAxisLabel()
{
return rangeAxisLabel;
@@ -308,8 +307,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getType()
{
return type;
@@ -321,8 +320,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getSeries()
{
return series;
@@ -334,8 +333,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getCategory()
{
return category;
@@ -347,9 +346,9 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlElementWrapper( localName = "filterDimensions", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "filterDimension", namespace = DxfNamespaces.DXF_2_0 )
+ @JsonView({ DetailedView.class, ExportView.class })
+ @JacksonXmlElementWrapper(localName = "filterDimensions", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty(localName = "filterDimension", namespace = DxfNamespaces.DXF_2_0)
public List<String> getFilterDimensions()
{
return filterDimensions;
@@ -361,8 +360,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isHideLegend()
{
return hideLegend;
@@ -374,8 +373,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isRegression()
{
return regression;
@@ -387,8 +386,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Double getTargetLineValue()
{
return targetLineValue;
@@ -400,8 +399,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getTargetLineLabel()
{
return targetLineLabel;
@@ -413,8 +412,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Double getBaseLineValue()
{
return baseLineValue;
@@ -426,8 +425,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getBaseLineLabel()
{
return baseLineLabel;
@@ -439,8 +438,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isHideTitle()
{
return hideTitle;
@@ -452,8 +451,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isHideSubtitle()
{
return hideSubtitle;
@@ -463,10 +462,10 @@
{
this.hideSubtitle = hideSubtitle;
}
-
+
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getTitle()
{
return this.title;
@@ -478,8 +477,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isShowData()
{
return showData;
@@ -491,8 +490,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView({ DetailedView.class, ExportView.class, DimensionalView.class })
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isRewindRelativePeriods()
{
return rewindRelativePeriods;
@@ -557,10 +556,10 @@
targetLineValue = chart.getTargetLineValue() == null ? targetLineValue : chart.getTargetLineValue();
targetLineLabel = chart.getTargetLineLabel() == null ? targetLineLabel : chart.getTargetLineLabel();
baseLineValue = chart.getBaseLineValue() == null ? baseLineValue : chart.getBaseLineValue();
- baseLineLabel = chart.getBaseLineLabel() == null ? baseLineLabel : chart.getBaseLineLabel();
+ baseLineLabel = chart.getBaseLineLabel() == null ? baseLineLabel : chart.getBaseLineLabel();
showData = chart.isShowData();
rewindRelativePeriods = chart.isRewindRelativePeriods();
-
+
filterDimensions.clear();
filterDimensions.addAll( chart.getFilterDimensions() );
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/view/UuidView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/view/UuidView.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/view/UuidView.java 2013-08-28 11:47:51 +0000
@@ -0,0 +1,36 @@
+package org.hisp.dhis.common.view;
+
+/*
+ * Copyright (c) 2004-2013, 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.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class UuidView extends DetailedView
+{
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-08-28 11:47:51 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.common.view.UuidView;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.user.User;
@@ -308,16 +309,16 @@
return grandChildren;
}
-
+
public List<OrganisationUnit> getSortedGrandChildren()
{
List<OrganisationUnit> grandChildren = new ArrayList<OrganisationUnit>();
-
+
for ( OrganisationUnit child : getSortedChildren() )
{
grandChildren.addAll( child.getSortedChildren() );
}
-
+
return grandChildren;
}
@@ -559,7 +560,7 @@
}
this.level = currentLevel;
-
+
return currentLevel;
}
@@ -636,6 +637,9 @@
return false;
}
+ @JsonProperty
+ @JsonView( UuidView.class )
+ @JacksonXmlProperty( isAttribute = true, namespace = DxfNamespaces.DXF_2_0 )
public String getUuid()
{
return uuid;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2013-08-28 11:29:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2013-08-28 11:47:51 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.common.view.DimensionalView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.common.view.ShortNameView;
+import org.hisp.dhis.common.view.UuidView;
import java.io.IOException;
import java.io.InputStream;
@@ -93,6 +94,7 @@
viewClasses.put( "basic", BasicView.class );
viewClasses.put( "shortName", ShortNameView.class );
viewClasses.put( "detailed", DetailedView.class );
+ viewClasses.put( "uuid", UuidView.class );
viewClasses.put( "export", ExportView.class );
viewClasses.put( "dimensional", DimensionalView.class );
}
@@ -145,7 +147,7 @@
return jsonMapper.writerWithView( viewClass ).writeValueAsString( value );
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public static <T> T fromJson( InputStream input, Class<?> clazz ) throws IOException
{
return (T) jsonMapper.readValue( input, clazz );
@@ -181,7 +183,7 @@
return xmlMapper.writerWithView( viewClass ).writeValueAsString( value );
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
public static <T> T fromXml( InputStream input, Class<?> clazz ) throws IOException
{
return (T) xmlMapper.readValue( input, clazz );