=== 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 2011-11-30 18:36:57 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-12-02 15:18:52 +0000 @@ -57,38 +57,38 @@ { private static final long serialVersionUID = 2570074075484545534L; - public static final String DIMENSION_PERIOD_INDICATOR = "period"; - public static final String DIMENSION_ORGANISATIONUNIT_INDICATOR = "organisationUnit"; - public static final String DIMENSION_INDICATOR_PERIOD = "indicator"; - public static final String DIMENSION_PERIOD_DATAELEMENT = "period_dataElement"; - public static final String DIMENSION_ORGANISATIONUNIT_DATAELEMENT = "organisationUnit_dataElement"; - public static final String DIMENSION_DATAELEMENT_PERIOD = "dataElement_period"; - public static final String DIMENSION_PERIOD_COMPLETENESS = "period_completeness"; - public static final String DIMENSION_ORGANISATIONUNIT_COMPLETENESS = "organisationUnit_completeness"; + public static final String DIMENSION_PERIOD_INDICATOR = "period"; + public static final String DIMENSION_ORGANISATIONUNIT_INDICATOR = "organisationUnit"; + public static final String DIMENSION_INDICATOR_PERIOD = "indicator"; + public static final String DIMENSION_PERIOD_DATAELEMENT = "period_dataElement"; + public static final String DIMENSION_ORGANISATIONUNIT_DATAELEMENT = "organisationUnit_dataElement"; + public static final String DIMENSION_DATAELEMENT_PERIOD = "dataElement_period"; + public static final String DIMENSION_PERIOD_COMPLETENESS = "period_completeness"; + public static final String DIMENSION_ORGANISATIONUNIT_COMPLETENESS = "organisationUnit_completeness"; public static final String DIMENSION_COMPLETENESS_PERIOD = "completeness_period"; - - public static final String TYPE_BAR3D = "bar3d"; - public static final String TYPE_STACKED_BAR3D = "stackedBar3d"; - public static final String TYPE_LINE3D = "line3d"; + + public static final String TYPE_BAR3D = "bar3d"; + public static final String TYPE_STACKED_BAR3D = "stackedBar3d"; + public static final String TYPE_LINE3D = "line3d"; public static final String TYPE_PIE3D = "pie3d"; - - public static final String SIZE_NORMAL = "normal"; - public static final String SIZE_WIDE = "wide"; + + public static final String SIZE_NORMAL = "normal"; + public static final String SIZE_WIDE = "wide"; public static final String SIZE_TALL = "tall"; - - public static final String TYPE = "tall"; - public static final String TYPE_COLUMN = "column"; - public static final String TYPE_STACKED_COLUMN = "stackedColumn"; - public static final String TYPE_BAR = "bar"; - public static final String TYPE_STACKED_BAR = "stackedBar"; - public static final String TYPE_LINE = "line"; - public static final String TYPE_AREA = "area"; + + public static final String TYPE = "tall"; + public static final String TYPE_COLUMN = "column"; + public static final String TYPE_STACKED_COLUMN = "stackedColumn"; + public static final String TYPE_BAR = "bar"; + public static final String TYPE_STACKED_BAR = "stackedBar"; + public static final String TYPE_LINE = "line"; + public static final String TYPE_AREA = "area"; public static final String TYPE_PIE = "pie"; - - public static final String DIMENSION_DATA = "data"; - public static final String DIMENSION_PERIOD = "period"; + + public static final String DIMENSION_DATA = "data"; + public static final String DIMENSION_PERIOD = "period"; public static final String DIMENSION_ORGANISATIONUNIT = "organisationUnit"; - + private String domainAxixLabel; private String rangeAxisLabel; @@ -98,27 +98,27 @@ private String size; private String dimension; - + private String series; - + private String category; - + private String filter; private boolean hideLegend; - + private boolean verticalLabels; private boolean horizontalPlotOrientation; private boolean regression; - + private boolean targetLine; - + private boolean hideSubtitle; private Double targetLineValue; - + private String targetLineLabel; private Set groups = new HashSet(); @@ -339,7 +339,7 @@ { this.dimension = dimension; } - + @XmlElement @JsonProperty public String getSeries() @@ -351,7 +351,7 @@ { this.series = series; } - + @XmlElement @JsonProperty public String getCategory() @@ -363,7 +363,7 @@ { this.category = category; } - + @XmlElement @JsonProperty public String getFilter() @@ -474,7 +474,7 @@ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) @XmlElementWrapper( name = "indicators" ) - @XmlElement + @XmlElement( name = "indicator" ) @JsonProperty @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getIndicators() @@ -489,7 +489,7 @@ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) @XmlElementWrapper( name = "dataElements" ) - @XmlElement + @XmlElement( name = "dataElement" ) @JsonProperty @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getDataElements() @@ -504,7 +504,7 @@ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) @XmlElementWrapper( name = "dataSets" ) - @XmlElement + @XmlElement( name = "dataSet" ) @JsonProperty @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getDataSets() @@ -529,7 +529,7 @@ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) @XmlElementWrapper( name = "organisationUnits" ) - @XmlElement + @XmlElement( name = "organisationUnit" ) @JsonProperty @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getOrganisationUnits() @@ -584,6 +584,11 @@ this.relativePeriods = relativePeriods; } + @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) + @XmlElementWrapper( name = "allPeriods" ) + @XmlElement( name = "allPeriod" ) + @JsonProperty + @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getAllPeriods() { return allPeriods; @@ -604,6 +609,11 @@ this.organisationUnit = organisationUnit; } + @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) + @XmlElementWrapper( name = "allOrganisationUnits" ) + @XmlElement( name = "allOrganisationUnit" ) + @JsonProperty + @JsonSerialize( using = JsonNameableObjectListSerializer.class ) public List getAllOrganisationUnits() { return allOrganisationUnits; === 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-12 18:43:35 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2011-11-25 14:03:14 +0000 @@ -70,6 +70,8 @@ Chart getChart( int id ); + Chart getChart( String uid ); + void deleteChart( Chart chart ); Collection getAllCharts(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2011-11-25 11:07:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2011-11-25 14:03:14 +0000 @@ -39,7 +39,7 @@ */ @XmlRootElement( name = "identifiableObject" ) @XmlAccessorType( value = XmlAccessType.NONE ) -@XmlType( propOrder = {"id", "uid", "name", "code", "lastUpdated"} ) +@XmlType( propOrder = {"uid", "name", "code", "lastUpdated"} ) public class BaseIdentifiableObject implements IdentifiableObject { @@ -89,8 +89,6 @@ this.name = name; } - @XmlAttribute - @JsonProperty public int getId() { return id; @@ -101,8 +99,9 @@ this.id = id; } - @XmlAttribute - @JsonProperty + @XmlID + @XmlAttribute(name = "id") + @JsonProperty(value = "id") public String getUid() { return uid; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java 2011-11-25 11:07:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java 2011-11-25 14:03:14 +0000 @@ -50,7 +50,6 @@ { BaseIdentifiableObject bio = new BaseIdentifiableObject(); - bio.setId( baseIdentifiableObject.getId() ); bio.setUid( baseIdentifiableObject.getUid() ); bio.setCode( baseIdentifiableObject.getCode() ); bio.setName( baseIdentifiableObject.getName() ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 2011-11-25 11:07:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 2011-11-25 14:03:14 +0000 @@ -50,7 +50,6 @@ { BaseNameableObject bno = new BaseNameableObject(); - bno.setId( baseNameableObject.getId() ); bno.setUid( baseNameableObject.getUid() ); bno.setCode( baseNameableObject.getCode() ); bno.setName( baseNameableObject.getName() ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2011-11-24 17:03:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2011-11-25 13:25:37 +0000 @@ -330,8 +330,6 @@ // Getters & setters // ------------------------------------------------------------------------- - @XmlAttribute - @JsonProperty public int getId() { return id; @@ -450,8 +448,6 @@ this.frequencyOrder = frequencyOrder; } - @XmlElement - @JsonProperty public String getOperandType() { return operandType; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-11-25 18:32:06 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-12-02 15:18:52 +0000 @@ -371,8 +371,9 @@ this.sortOrder = sortOrder; } -/* @XmlElementWrapper( name = "sections" ) - @XmlElement( name = "section" ) */ + @XmlElementWrapper( name = "sections" ) + @XmlElement( name = "section" ) + @JsonProperty public Set
getSections() { return sections; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2011-11-25 18:17:41 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2011-12-02 15:18:52 +0000 @@ -23,28 +23,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonSerialize; import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter; import org.hisp.dhis.common.adapter.JsonIdentifiableObjectListSerializer; +import org.hisp.dhis.common.adapter.JsonIdentifiableObjectSetSerializer; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementOperand; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + @XmlRootElement( name = "section" ) @XmlAccessorType( value = XmlAccessType.NONE ) public class Section @@ -194,6 +189,7 @@ @XmlElement @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonIdentifiableObjectSetSerializer.class ) public DataSet getDataSet() { return dataSet; @@ -235,8 +231,8 @@ this.sortOrder = sortOrder; } - @XmlElementWrapper(name = "greyedFields") - @XmlElement(name = "greyedField") + @XmlElementWrapper( name = "greyedFields" ) + @XmlElement( name = "greyedField" ) @JsonProperty public Set getGreyedFields() { === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-11-22 16:17:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-11-25 14:03:14 +0000 @@ -91,6 +91,8 @@ IndicatorType getIndicatorType( int id ); + IndicatorType getIndicatorType( String uid ); + Collection getIndicatorTypes( Collection identifiers ); Collection getAllIndicatorTypes(); === 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 2011-11-25 11:00:15 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2011-11-25 13:25:37 +0000 @@ -32,17 +32,13 @@ import org.codehaus.jackson.map.annotate.JsonSerialize; import org.hisp.dhis.attribute.AttributeValue; import org.hisp.dhis.common.BaseNameableObject; -import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter; -import org.hisp.dhis.common.adapter.JsonDateSerializer; +import org.hisp.dhis.common.adapter.*; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; import org.hisp.dhis.user.User; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.*; import java.util.regex.Matcher; @@ -502,7 +498,7 @@ @XmlElement @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) -/* @JsonSerialize( using = JsonNameableObjectSerializer.class ) */ + @JsonSerialize( using = JsonNameableObjectSerializer.class ) public OrganisationUnit getParent() { return parent; @@ -512,7 +508,7 @@ { this.parent = parent; } - + public String getAlternativeName() { return getShortName(); @@ -621,6 +617,10 @@ this.url = url; } + @XmlElementWrapper( name = "groups" ) + @XmlElement( name = "group" ) + @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonIdentifiableObjectSetSerializer.class ) public Set getGroups() { return groups; @@ -631,6 +631,10 @@ this.groups = groups; } + @XmlElementWrapper( name = "dataSets" ) + @XmlElement( name = "dataSet" ) + @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonNameableObjectSetSerializer.class ) public Set getDataSets() { return dataSets; @@ -641,6 +645,7 @@ this.dataSets = dataSets; } + // TODO expose this when marshalling? public Set getUsers() { return users; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-11-24 14:36:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-11-25 13:25:37 +0000 @@ -27,11 +27,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.codehaus.jackson.map.annotate.JsonSerialize; import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter; +import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter; +import org.hisp.dhis.common.adapter.JsonIdentifiableObjectSerializer; +import org.hisp.dhis.common.adapter.JsonNameableObjectSetSerializer; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.HashSet; import java.util.Set; @@ -139,6 +143,10 @@ // Getters and setters // ------------------------------------------------------------------------- + @XmlElementWrapper( name = "members" ) + @XmlElement( name = "member" ) + @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonNameableObjectSetSerializer.class ) public Set getMembers() { return members; @@ -149,6 +157,9 @@ this.members = members; } + @XmlElement + @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonIdentifiableObjectSerializer.class ) public OrganisationUnitGroupSet getGroupSet() { return groupSet; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-11-24 14:36:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-11-25 13:25:37 +0000 @@ -27,12 +27,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonSerialize; import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter; +import org.hisp.dhis.common.adapter.JsonIdentifiableObjectSetSerializer; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupNameComparator; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.*; /** @@ -169,6 +172,8 @@ // Getters and setters // ------------------------------------------------------------------------- + @XmlElement + @JsonProperty public String getDescription() { return description; @@ -179,6 +184,8 @@ this.description = description; } + @XmlElement + @JsonProperty public boolean isCompulsory() { return compulsory; @@ -189,6 +196,10 @@ this.compulsory = compulsory; } + @XmlElementWrapper( name = "organisationUnitGroups" ) + @XmlElement( name = "organisationUnitGroup" ) + @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class ) + @JsonSerialize( using = JsonIdentifiableObjectSetSerializer.class ) public Set getOrganisationUnitGroups() { return organisationUnitGroups; === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java 2011-11-25 13:25:37 +0000 @@ -0,0 +1,37 @@ +package org.hisp.dhis.organisationunit; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@XmlRootElement( name = "organisationUnitGroupSets" ) +@XmlAccessorType( value = XmlAccessType.NONE ) +public class OrganisationUnitGroupSets +{ + private List organisationUnitGroupSets = new ArrayList(); + + public OrganisationUnitGroupSets() + { + + } + + @XmlElement( name = "organisationUnitGroupSet" ) + @JsonProperty( value = "organisationUnitGroupSets" ) + public List getOrganisationUnitGroupSets() + { + return organisationUnitGroupSets; + } + + public void setOrganisationUnitGroupSets( List organisationUnitGroupSets ) + { + this.organisationUnitGroupSets = organisationUnitGroupSets; + } +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java 2011-11-25 13:25:37 +0000 @@ -0,0 +1,37 @@ +package org.hisp.dhis.organisationunit; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@XmlRootElement( name = "organisationUnitGroups" ) +@XmlAccessorType( value = XmlAccessType.NONE ) +public class OrganisationUnitGroups +{ + private List organisationUnitGroups = new ArrayList(); + + public OrganisationUnitGroups() + { + + } + + @XmlElement( name = "organisationUnitGroup" ) + @JsonProperty( value = "organisationUnitGroups" ) + public List getOrganisationUnitGroups() + { + return organisationUnitGroups; + } + + public void setOrganisationUnitGroups( List organisationUnitGroups ) + { + this.organisationUnitGroups = organisationUnitGroups; + } +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevel.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevel.java 2011-11-24 14:36:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevel.java 2011-11-25 15:12:06 +0000 @@ -27,10 +27,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.codehaus.jackson.annotate.JsonProperty; import org.hisp.dhis.common.BaseIdentifiableObject; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** @@ -105,6 +107,8 @@ // Getters and setters // ------------------------------------------------------------------------- + @XmlElement + @JsonProperty public int getLevel() { return level; === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java 2011-11-25 15:12:06 +0000 @@ -0,0 +1,36 @@ +package org.hisp.dhis.organisationunit; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@XmlRootElement( name = "organisationUnitLevels" ) +@XmlAccessorType( value = XmlAccessType.NONE ) +public class OrganisationUnitLevels +{ + private List organisationUnitLevels = new ArrayList(); + + public OrganisationUnitLevels() + { + } + + @XmlElement( name = "organisationUnitLevel" ) + @JsonProperty( value = "organisationUnitLevels" ) + public List getOrganisationUnitLevels() + { + return organisationUnitLevels; + } + + public void setOrganisationUnitLevels( List organisationUnitLevels ) + { + this.organisationUnitLevels = organisationUnitLevels; + } +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-11-22 15:48:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-11-25 15:12:06 +0000 @@ -27,16 +27,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.hierarchy.HierarchyViolationException; + import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; -import org.hisp.dhis.hierarchy.HierarchyViolationException; - /** * Defines methods for working with OrganisationUnits. - * + * * @author Torgeir Lorange Ostby * @version $Id: OrganisationUnitService.java 5951 2008-10-16 17:41:34Z larshelg $ */ @@ -45,14 +45,14 @@ String ID = OrganisationUnitService.class.getName(); final int MAX_LIMIT = 500; - + // ------------------------------------------------------------------------- // OrganisationUnit // ------------------------------------------------------------------------- /** * Adds an OrganisationUnit to the hierarchy. - * + * * @param organisationUnit the OrganisationUnit to add. * @return a generated unique id of the added OrganisationUnit. */ @@ -60,24 +60,24 @@ /** * Updates an OrganisationUnit. - * + * * @param organisationUnit the OrganisationUnit to update. */ void updateOrganisationUnit( OrganisationUnit organisationUnit ); /** * Updates an OrganisationUnit. - * + * * @param organisationUnit the organisationUnit to update. - * @param updateHierarchy indicate whether the OrganisationUnit hierarchy - * has been updated. + * @param updateHierarchy indicate whether the OrganisationUnit hierarchy + * has been updated. */ void updateOrganisationUnit( OrganisationUnit organisationUnit, boolean updateHierarchy ); - + /** * Deletes an OrganisationUnit. OrganisationUnits with children cannot be * deleted. - * + * * @param organisationUnit the OrganisationUnit to delete. * @throws HierarchyViolationException if the OrganisationUnit has children. */ @@ -86,15 +86,15 @@ /** * Returns an OrganisationUnit. - * + * * @param id the id of the OrganisationUnit to return. * @return the OrganisationUnit with the given id, or null if no match. */ OrganisationUnit getOrganisationUnit( int id ); - + /** * Returns the OrganisationUnit with the given UID. - * + * * @param uid the UID of the OrganisationUnit to return. * @return the OrganisationUnit with the given UID, or null if no match. */ @@ -110,32 +110,32 @@ /** * Returns all OrganisationUnits. - * + * * @return a collection of all OrganisationUnits, or an empty collection if * there are no OrganisationUnits. */ Collection getAllOrganisationUnits(); - + /** * Returns all OrganisationUnits with corresponding name key based on the given list. - * + * * @param orgUnits the collection of organization unit objects. - * @param key the name key. + * @param key the name key. * @return a collection of OrganisationUnits. */ void searchOrganisationUnitByName( List orgUnits, String key ); - + /** * Returns all OrganisationUnits with corresponding identifiers. - * + * * @param identifiers the collection of identifiers. * @return a collection of OrganisationUnits. */ Collection getOrganisationUnits( Collection identifiers ); - + /** * Returns an OrganisationUnit with a given name. - * + * * @param name the name of the OrganisationUnit to return. * @return the OrganisationUnit with the given name, or null if not match. */ @@ -143,7 +143,7 @@ /** * Returns an OrganisationUnit with a given name. Case is ignored. - * + * * @param name the name of the OrganisationUnit to return. * @return the OrganisationUnit with the given name, or null if not match. */ @@ -152,7 +152,7 @@ /** * Returns all root OrganisationUnits. A root OrganisationUnit is an * OrganisationUnit with no parent/the parent set to null. - * + * * @return a collection containing all root OrganisationUnits, or an empty * collection if there are no OrganisationUnits. */ @@ -161,15 +161,15 @@ /** * Returns all OrganisationUnits which are part of the subtree of the * OrganisationUnit with the given identifer and have no children. - * + * * @param id the identifier of the parent OrganisationUnit. * @return a collection of OrganisationUnits. */ Collection getLeafOrganisationUnits( int id ); - + /** * Returns an OrganisationUnit and all its children. - * + * * @param id the id of the parent OrganisationUnit in the subtree. * @return a collection containing the OrganisationUnit with the given id * and all its children, or an empty collection if no @@ -181,7 +181,7 @@ * Returns the branch of OrganisationUnits from a root to a given * OrganisationUnit. Both root and target OrganisationUnits are included in * the returned collection. - * + * * @param id the id of the OrganisationUnit to trace upwards from. * @return the list of OrganisationUnits from a root to the given * OrganisationUnit, or an empty list if the given OrganisationUnit @@ -192,19 +192,19 @@ /** * Returns all OrganisationUnits at a given hierarchical level. The root * OrganisationUnits are at level 1. - * + * * @param level the hierarchical level. * @return a collection of all OrganisationUnits at a given hierarchical * level, or an empty collection if the level is empty. * @throws IllegalArgumentException if the level is zero or negative. */ Collection getOrganisationUnitsAtLevel( int level ); - + /** * Returns all OrganisationUnits which are children of the given unit and are * at the given hierarchical level. The root OrganisationUnits are at level 1. - * - * @param level the hierarchical level. + * + * @param level the hierarchical level. * @param parent the parent unit. * @return all OrganisationUnits which are children of the given unit and are * at the given hierarchical level. @@ -215,16 +215,16 @@ /** * Returns the hierarchical level in which the given OrganisationUnit * resides. - * + * * @param id the identifier of the OrganisationUnit. * @return the hierarchical level of the given OrganisationUnit. */ int getLevelOfOrganisationUnit( int id ); - + /** * Returns the hierarchical level in which the given OrganisationUnit * resides. - * + * * @param organisationUnit the OrganisationUnit. * @return the hierarchical level of the given OrganisationUnit. */ @@ -232,24 +232,24 @@ /** * Returns the number of levels in the OrganisationUnit hierarchy. - * + * * @return the number of hierarchical levels. */ int getNumberOfOrganisationalLevels(); /** * Returns all OrganisationUnits which are not a member of any OrganisationUnitGroups. - * + * * @return all OrganisationUnits which are not a member of any OrganisationUnitGroups. */ Collection getOrganisationUnitsWithoutGroups(); - + /** * Get the units which name are like the given name and are members of the - * given groups. If name or groups are null or empty they are ignored in the - * search. If name and groups are null an empty collection is returned. - * - * @param name the name. + * given groups. If name or groups are null or empty they are ignored in the + * search. If name and groups are null an empty collection is returned. + * + * @param name the name. * @param groups the organisation unit groups. * @return a collection of organisation units. */ @@ -257,75 +257,77 @@ /** * Get the units which name are like the given name, are members of the - * given groups and children of the given parent organisation unit. If name - * or groups are null or empty they are ignored in the sarch. If name and - * groups are null an empty collection is returned. - * - * @param name the name. + * given groups and children of the given parent organisation unit. If name + * or groups are null or empty they are ignored in the sarch. If name and + * groups are null an empty collection is returned. + * + * @param name the name. * @param groups the organisation unit groups. * @return a collection of organisation units. */ Collection getOrganisationUnitsByNameAndGroups( String name, Collection groups, OrganisationUnit parent, boolean limit ); OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet(); - + void filterOrganisationUnitsWithoutData( Collection organisationUnits ); - + // ------------------------------------------------------------------------- // OrganisationUnitHierarchy // ------------------------------------------------------------------------- /** - * Get the OrganisationUnit hierarchy. - * + * Get the OrganisationUnit hierarchy. + * * @return a Collection with OrganisationUnitRelationship entries. */ OrganisationUnitHierarchy getOrganisationUnitHierarchy(); /** * Updates the parent id of the organisation unit with the given id. - * + * * @param organisationUnitId the child organisation unit identifier. - * @param parentId the parent organisation unit identifier. + * @param parentId the parent organisation unit identifier. */ void updateOrganisationUnitParent( int organisationUnitId, int parentId ); - + // ------------------------------------------------------------------------- // OrganisationUnitLevel // ------------------------------------------------------------------------- int addOrganisationUnitLevel( OrganisationUnitLevel level ); - + void updateOrganisationUnitLevel( OrganisationUnitLevel level ); - + void addOrUpdateOrganisationUnitLevel( OrganisationUnitLevel level ); - + void pruneOrganisationUnitLevels( Set currentLevels ); - + OrganisationUnitLevel getOrganisationUnitLevel( int id ); - + + OrganisationUnitLevel getOrganisationUnitLevel( String uid ); + Collection getOrganisationUnitLevels( Collection identifiers ); - + void deleteOrganisationUnitLevel( OrganisationUnitLevel level ); void deleteOrganisationUnitLevels(); - + List getOrganisationUnitLevels(); - + OrganisationUnitLevel getOrganisationUnitLevelByLevel( int level ); - + OrganisationUnitLevel getOrganisationUnitLevelByName( String name ); - + List getFilledOrganisationUnitLevels(); - + Map getOrganisationUnitLevelMap(); - + int getNumberOfOrganisationUnits(); - + int getMaxOfOrganisationUnitLevels(); - + void updateOrganisationUnits( Collection units ); - + Collection getOrganisationUnits( Boolean hasPatients ); // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java 2011-11-03 01:02:13 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java 2011-11-25 15:12:06 +0000 @@ -125,6 +125,14 @@ OrganisationUnitLevel getOrganisationUnitLevel( int id ); /** + * Gets an OrganisationUnitLevel. + * + * @param uid the identifier of the OrganisationUnitLevel. + * @return the OrganisationUnitLevel with the given identifier. + */ + OrganisationUnitLevel getOrganisationUnitLevel( String uid ); + + /** * Deletes an OrganisationUnitLevel. * * @param level the OrganisationUnitLevel to delete. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java 2011-11-23 14:49:40 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java 2011-11-25 13:25:37 +0000 @@ -20,6 +20,7 @@ public OrganisationUnits() { + } @XmlElement( name = "organisationUnit" ) === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-10-13 15:15:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-11-25 14:53:34 +0000 @@ -27,20 +27,27 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.apache.commons.collections.CollectionUtils; +import org.codehaus.jackson.annotate.JsonProperty; +import org.hisp.dhis.attribute.AttributeValue; +import org.hisp.dhis.common.IdentifiableObjectUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.apache.commons.collections.CollectionUtils; -import org.hisp.dhis.attribute.AttributeValue; -import org.hisp.dhis.common.IdentifiableObjectUtils; -import org.hisp.dhis.organisationunit.OrganisationUnit; - /** * @author Nguyen Hong Duc * @version $Id: User.java 5554 2008-08-20 09:18:38Z abyot $ */ +@XmlRootElement( name = "user" ) +@XmlAccessorType( value = XmlAccessType.NONE ) public class User implements Serializable { @@ -56,11 +63,11 @@ */ private String surname; - /** - * Required. - */ private String firstName; + /** + * Optional. + */ private String email; private String phoneNumber; @@ -69,13 +76,13 @@ /** * All OrgUnits where the user could belong - * + *

* TODO This should have been put in UserCredentials */ private Set organisationUnits = new HashSet(); /** - * Set of the dynamic attributes values that belong to this dataElement. + * Set of the dynamic attributes values that belong to this User. */ private Set attributeValues = new HashSet(); @@ -169,7 +176,7 @@ * Null is returned if the user has no organisation units. Which * organisation unit to return is undefined if the user has multiple * organisation units. - * + * * @return an organisation unit associated with the user. */ public OrganisationUnit getOrganisationUnit() @@ -206,6 +213,8 @@ this.id = id; } + @XmlElement + @JsonProperty public String getFirstName() { return firstName; @@ -216,6 +225,8 @@ this.firstName = firstName; } + @XmlElement + @JsonProperty public String getSurname() { return surname; @@ -226,6 +237,8 @@ this.surname = surname; } + @XmlElement + @JsonProperty public String getEmail() { return email; @@ -236,6 +249,8 @@ this.email = email; } + @XmlElement + @JsonProperty public String getPhoneNumber() { return phoneNumber; === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java 2011-11-25 14:53:34 +0000 @@ -0,0 +1,37 @@ +package org.hisp.dhis.user; + +import org.codehaus.jackson.annotate.JsonProperty; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@XmlRootElement( name = "users" ) +@XmlAccessorType( value = XmlAccessType.NONE ) +public class Users +{ + private List users = new ArrayList(); + + public Users() + { + + } + + @XmlElement( name = "user" ) + @JsonProperty( value = "users" ) + public List getUsers() + { + return users; + } + + public void setUsers( List users ) + { + this.users = users; + } +} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2011-11-03 01:02:13 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2011-11-25 14:03:14 +0000 @@ -100,12 +100,12 @@ return (DataSet) session.get( DataSet.class, id ); } - public DataSet getDataSet( String uuid ) + public DataSet getDataSet( String uid ) { Session session = sessionFactory.getCurrentSession(); Criteria criteria = session.createCriteria( DataSet.class ); - criteria.add( Restrictions.eq( "uuid", uuid ) ); + criteria.add( Restrictions.eq( "uid", uid ) ); return (DataSet) criteria.uniqueResult(); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-11-22 16:17:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-11-25 14:03:14 +0000 @@ -27,19 +27,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.i18n.I18nUtils.i18n; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; - import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; + +import static org.hisp.dhis.i18n.I18nUtils.i18n; + /** * @author Lars Helge Overland * @version $Id$ @@ -123,9 +123,9 @@ return i18n( i18nService, indicatorStore.getIndicator( id ) ); } - public Indicator getIndicator( String uuid ) + public Indicator getIndicator( String uid ) { - return i18n( i18nService, indicatorStore.getIndicator( uuid ) ); + return i18n( i18nService, indicatorStore.getIndicator( uid ) ); } public Collection getAllIndicators() @@ -238,6 +238,11 @@ return i18n( i18nService, indicatorTypeStore.get( id ) ); } + public IndicatorType getIndicatorType( String uid ) + { + return i18n( i18nService, indicatorTypeStore.getByUid( uid ) ); + } + public Collection getIndicatorTypes( final Collection identifiers ) { Collection types = getAllIndicatorTypes(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java 2011-11-11 13:25:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java 2011-11-25 14:03:14 +0000 @@ -75,12 +75,12 @@ return (Indicator) session.get( Indicator.class, id ); } - public Indicator getIndicator( String uuid ) + public Indicator getIndicator( String uid ) { Session session = sessionFactory.getCurrentSession(); Criteria criteria = session.createCriteria( Indicator.class ); - criteria.add( Restrictions.eq( "uuid", uuid ) ); + criteria.add( Restrictions.eq( "uid", uid ) ); return (Indicator) criteria.uniqueResult(); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-11-22 15:48:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-11-25 15:12:06 +0000 @@ -596,6 +596,11 @@ return organisationUnitStore.getOrganisationUnitLevel( id ); } + public OrganisationUnitLevel getOrganisationUnitLevel( String uid ) + { + return organisationUnitStore.getOrganisationUnitLevel( uid ); + } + public Collection getOrganisationUnitLevels( final Collection identifiers ) { Collection objects = getOrganisationUnitLevels(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2011-11-04 09:28:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2011-11-25 15:12:06 +0000 @@ -254,6 +254,11 @@ return orgLevelStore.get( id ); } + public OrganisationUnitLevel getOrganisationUnitLevel( String uid ) + { + return orgLevelStore.getByUid( uid ); + } + public void deleteOrganisationUnitLevel( OrganisationUnitLevel level ) { orgLevelStore.delete( level ); === modified file 'dhis-2/dhis-support/dhis-support-xml/src/main/java/org/amplecode/staxwax/transformer/LoggingErrorListener.java' --- dhis-2/dhis-support/dhis-support-xml/src/main/java/org/amplecode/staxwax/transformer/LoggingErrorListener.java 2010-02-22 09:37:31 +0000 +++ dhis-2/dhis-support/dhis-support-xml/src/main/java/org/amplecode/staxwax/transformer/LoggingErrorListener.java 2011-11-28 22:54:04 +0000 @@ -46,7 +46,7 @@ public void warning( TransformerException exception ) throws TransformerException { - log.warn( exception.getMessageAndLocation() ); + log.warn( "xslt: " + exception.getMessage() ); } @Override === modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml' --- dhis-2/dhis-web/dhis-web-api/pom.xml 2011-12-02 14:53:08 +0000 +++ dhis-2/dhis-web/dhis-web-api/pom.xml 2011-12-02 15:18:52 +0000 @@ -46,6 +46,10 @@ org.springframework spring-oxm + + org.apache.xmlgraphics + fop + === 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-11-24 17:50:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-01 13:44:45 +0000 @@ -32,12 +32,14 @@ import org.hisp.dhis.chart.Charts; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; /** * @author Morten Olav Hansen @@ -50,19 +52,23 @@ private ChartService chartService; @RequestMapping( method = RequestMethod.GET ) - public Charts getCharts() + public String getCharts( Model model ) { Charts charts = new Charts(); charts.setCharts( new ArrayList( chartService.getAllCharts() ) ); - return charts; + model.addAttribute( "model", charts ); + + return "charts"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public Chart getChart( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getChart( @PathVariable( "uid" ) String uid, Model model ) { Chart chart = chartService.getChart( uid ); - return chart; + model.addAttribute( "model", chart ); + + return "chart"; } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java 2011-11-24 17:50:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java 2011-12-01 19:14:36 +0000 @@ -1,17 +1,41 @@ package org.hisp.dhis.api.controller; -import org.hisp.dhis.chart.Chart; -import org.hisp.dhis.chart.Charts; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataset.CompleteDataSetRegistration; import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; import org.hisp.dhis.dataset.CompleteDataSetRegistrations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -30,17 +54,19 @@ } @RequestMapping( method = RequestMethod.GET ) - public CompleteDataSetRegistrations getCompleteDataSetRegistrations() + public String getCompleteDataSetRegistrations( Model model ) { CompleteDataSetRegistrations completeDataSetRegistrations = new CompleteDataSetRegistrations(); completeDataSetRegistrations.setCompleteDataSetRegistrations( new ArrayList( completeDataSetRegistrationService.getAllCompleteDataSetRegistrations() ) ); - return completeDataSetRegistrations; + model.addAttribute( "model", completeDataSetRegistrations ); + + return "completeDataSetRegistrations"; } /* @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public Chart getChart( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public Chart getChart( @PathVariable( "uid" ) String uid ) { CompleteDataSetRegistration completeDataSetRegistration = completeDataSetRegistrationService.getCompleteDataSetRegistration( ) Chart chart = chartService.getChart( uid ); === 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-11-23 14:00:28 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryComboController.java 2011-12-01 19:14:36 +0000 @@ -1,16 +1,45 @@ package org.hisp.dhis.api.controller; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementCategoryCombos; import org.hisp.dhis.dataelement.DataElementCategoryService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; /** * @author Morten Olav Hansen @@ -22,24 +51,24 @@ @Autowired private DataElementCategoryService dataElementCategoryService; - public DataElementCategoryComboController() - { - } - @RequestMapping( method = RequestMethod.GET ) - public DataElementCategoryCombos getDataElementCategoryCombos() + public String getDataElementCategoryCombos( Model model ) { DataElementCategoryCombos dataElementCategoryCombos = new DataElementCategoryCombos(); dataElementCategoryCombos.setDataElementCategoryCombos( new ArrayList( dataElementCategoryService.getAllDataElementCategoryCombos() ) ); - return dataElementCategoryCombos; + model.addAttribute( "model", dataElementCategoryCombos ); + + return "dataElementCategoryCombos"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementCategoryCombo getDataElementCategoryCombo( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, Model model ) { DataElementCategoryCombo dataElementCategoryCombo = dataElementCategoryService.getDataElementCategoryCombo( uid ); - return dataElementCategoryCombo; + model.addAttribute( "model", dataElementCategoryCombo ); + + return "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-11-23 14:00:28 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryController.java 2011-12-01 19:14:36 +0000 @@ -1,15 +1,42 @@ package org.hisp.dhis.api.controller; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataelement.DataElementCategories; import org.hisp.dhis.dataelement.DataElementCategory; import org.hisp.dhis.dataelement.DataElementCategoryService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -22,24 +49,24 @@ @Autowired private DataElementCategoryService dataElementCategoryService; - public DataElementCategoryController() - { - } - @RequestMapping( method = RequestMethod.GET ) - public DataElementCategories getDataElementCategories() + public String getDataElementCategories( Model model ) { DataElementCategories dataElementCategories = new DataElementCategories(); dataElementCategories.setDataElementCategories( new ArrayList( dataElementCategoryService.getAllDataElementCategories() ) ); - return dataElementCategories; + model.addAttribute( "model", dataElementCategories ); + + return "dataElementCategories"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementCategory getDataElementCategory( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementCategory( @PathVariable( "uid" ) String uid, Model model ) { DataElementCategory dataElementCategory = dataElementCategoryService.getDataElementCategory( uid ); - return dataElementCategory; + model.addAttribute( "model", dataElementCategory ); + + return "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-11-23 14:00:28 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionComboController.java 2011-12-01 19:14:36 +0000 @@ -1,15 +1,42 @@ package org.hisp.dhis.api.controller; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombos; import org.hisp.dhis.dataelement.DataElementCategoryService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -22,24 +49,24 @@ @Autowired private DataElementCategoryService dataElementCategoryService; - public DataElementCategoryOptionComboController() - { - } - @RequestMapping( method = RequestMethod.GET ) - public DataElementCategoryOptionCombos getDataElementCategoryOptionCombos() + public String getDataElementCategoryOptionCombos( Model model ) { DataElementCategoryOptionCombos dataElementCategoryOptionCombos = new DataElementCategoryOptionCombos(); dataElementCategoryOptionCombos.setDataElementCategoryOptionCombos( new ArrayList( dataElementCategoryService.getAllDataElementCategoryOptionCombos() ) ); - return dataElementCategoryOptionCombos; + model.addAttribute( "model", dataElementCategoryOptionCombos ); + + return "dataElementCategoryOptionCombos"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementCategoryOptionCombo getDataElementCategoryCombo( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementCategoryCombo( @PathVariable( "uid" ) String uid, Model model ) { DataElementCategoryOptionCombo dataElementCategoryOptionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( uid ); - return dataElementCategoryOptionCombo; + model.addAttribute( "model", dataElementCategoryOptionCombo ); + + return "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-11-23 14:00:28 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementCategoryOptionController.java 2011-12-01 19:14:36 +0000 @@ -1,15 +1,42 @@ package org.hisp.dhis.api.controller; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataelement.DataElementCategoryOption; import org.hisp.dhis.dataelement.DataElementCategoryOptions; import org.hisp.dhis.dataelement.DataElementCategoryService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -22,24 +49,24 @@ @Autowired private DataElementCategoryService dataElementCategoryService; - public DataElementCategoryOptionController() - { - } - @RequestMapping( method = RequestMethod.GET ) - public DataElementCategoryOptions getDataElementCategoryOptions() + public String getDataElementCategoryOptions( Model model ) { DataElementCategoryOptions dataElementCategoryOptions = new DataElementCategoryOptions(); dataElementCategoryOptions.setDataElementCategoryOptions( new ArrayList( dataElementCategoryService.getAllDataElementCategoryOptions() ) ); - return dataElementCategoryOptions; + model.addAttribute( "model", dataElementCategoryOptions ); + + return "dataElementCategoryOptions"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementCategoryOption getDataElementCategoryOption( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementCategoryOption( @PathVariable( "uid" ) String uid, Model model ) { DataElementCategoryOption dataElementCategoryOption = dataElementCategoryService.getDataElementCategoryOption( uid ); - return dataElementCategoryOption; + model.addAttribute( "model", dataElementCategoryOption ); + + return "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-11-21 12:41:53 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-02 17:22:15 +0000 @@ -31,14 +31,21 @@ import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataelement.DataElements; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; 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.ResponseStatus; -import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/dataElements" ) public class DataElementController @@ -47,19 +54,62 @@ private DataElementService dataElementService; @RequestMapping( method = RequestMethod.GET ) - public DataElements getDataElements() + public String getDataElements( Model model ) { DataElements dataElements = new DataElements(); dataElements.setDataElements( new ArrayList( dataElementService.getAllActiveDataElements() ) ); - return dataElements; + model.addAttribute( "model", dataElements ); + + return "dataElements"; + } + + @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} ) + @ResponseStatus( value = HttpStatus.CREATED ) + public void postDataElementXML( HttpServletResponse response, InputStream input ) throws Exception + { + System.err.println( "POST request on DataElement using XML." ); + + // response.setHeader("Location", "/spittles/" + spittle.getId()); + } + + @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} ) + @ResponseStatus( value = HttpStatus.CREATED ) + public void postDataElementJSON( HttpServletResponse response, InputStream input ) throws Exception + { + System.err.println( "POST request on DataElement using JSON." ); + + // response.setHeader("Location", "/spittles/" + spittle.getId()); } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElement getDataElement( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElement( @PathVariable( "uid" ) String uid, Model model ) { DataElement dataElement = dataElementService.getDataElement( uid ); - return dataElement; + model.addAttribute( "model", dataElement ); + + return "dataElement"; + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) + @ResponseStatus( value = HttpStatus.NO_CONTENT ) + public void deleteDataElement( @PathVariable( "uid" ) String uid ) + { + System.err.println( "DELETE request on DataElement with UID = " + uid ); + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} ) + @ResponseStatus( value = HttpStatus.NO_CONTENT ) + public void putDataElementXML( @PathVariable( "uid" ) String uid, InputStream input ) + { + System.err.println( "PUT request on DataElement with UID = " + uid + " using XML." ); + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} ) + @ResponseStatus( value = HttpStatus.NO_CONTENT ) + public void putDataElementJSON( @PathVariable( "uid" ) String uid, InputStream input ) + { + System.err.println( "PUT request on DataElement with UID = " + uid + " using JSON." ); } } === 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-11-23 12:21:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java 2011-12-01 19:14:36 +0000 @@ -32,11 +32,11 @@ import org.hisp.dhis.dataelement.DataElementService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; @Controller @@ -47,19 +47,23 @@ private DataElementService dataElementService; @RequestMapping( method = RequestMethod.GET ) - public DataElementGroups getDataElementGroups() + public String getDataElementGroups( Model model ) { DataElementGroups dataElementGroups = new DataElementGroups(); dataElementGroups.setDataElementGroups( new ArrayList( dataElementService.getAllDataElementGroups() ) ); - return dataElementGroups; + model.addAttribute( "model", dataElementGroups ); + + return "dataElementGroups"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementGroup getDataElementGroup( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementGroup( @PathVariable( "uid" ) String uid, Model model ) { DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( uid ); - return dataElementGroup; + model.addAttribute( "model", dataElementGroup ); + + return "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-11-23 12:21:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java 2011-12-01 19:14:36 +0000 @@ -32,13 +32,16 @@ import org.hisp.dhis.dataelement.DataElementService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/dataElementGroupSets" ) public class DataElementGroupSetController @@ -47,19 +50,23 @@ private DataElementService dataElementService; @RequestMapping( method = RequestMethod.GET ) - public DataElementGroupSets getDataElementGroupSets() + public String getDataElementGroupSets( Model model ) { DataElementGroupSets dataElementGroupSets = new DataElementGroupSets(); dataElementGroupSets.setDataElementGroupSets( new ArrayList( dataElementService.getAllDataElementGroupSets() ) ); - return dataElementGroupSets; + model.addAttribute( "model", dataElementGroupSets ); + + return "dataElementGroupSets"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataElementGroupSet getDataElementGroupSet( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getDataElementGroupSet( @PathVariable( "uid" ) String uid, Model model ) { DataElementGroupSet dataElementGroupSet = dataElementService.getDataElementGroupSet( uid ); - return dataElementGroupSet; + model.addAttribute( "model", dataElementGroupSet ); + + return "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-02 14:53:08 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-02 15:18:52 +0000 @@ -1,15 +1,42 @@ package org.hisp.dhis.api.controller; +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.dataset.DataSets; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -22,25 +49,24 @@ @Autowired private DataSetService dataSetService; - public DataSetController() - { - - } - @RequestMapping( method = RequestMethod.GET ) - public DataSets getDataSets() + public String getDataSets( Model model ) { DataSets dataSets = new DataSets(); dataSets.setDataSets( new ArrayList( dataSetService.getAllDataSets() ) ); - return dataSets; + model.addAttribute( "model", dataSets ); + + return "dataSets"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public DataSet getDataSet( @PathVariable( "uid" ) String uid, HttpServletRequest request ) + public String getDataSet( @PathVariable( "uid" ) String uid, Model model ) { DataSet dataSet = dataSetService.getDataSet( uid ); - return dataSet; + model.addAttribute( "model", dataSet ); + + return "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-11-22 14:05:18 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-01 19:14:36 +0000 @@ -32,13 +32,16 @@ import org.hisp.dhis.indicator.Indicators; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/indicators" ) public class IndicatorController @@ -47,19 +50,23 @@ private IndicatorService indicatorService; @RequestMapping( method = RequestMethod.GET ) - public Indicators getIndicators() + public String getIndicators( Model model ) { Indicators indicators = new Indicators(); indicators.setIndicators( new ArrayList( indicatorService.getAllIndicators() ) ); - return indicators; + model.addAttribute( "model", indicators ); + + return "indicators"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public Indicator getIndicator( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getIndicator( @PathVariable( "uid" ) String uid, Model model ) { Indicator indicator = indicatorService.getIndicator( uid ); - return indicator; + model.addAttribute( "model", indicator ); + + return "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-11-23 12:21:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java 2011-12-01 19:14:36 +0000 @@ -27,16 +27,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.indicator.*; +import org.hisp.dhis.indicator.IndicatorGroup; +import org.hisp.dhis.indicator.IndicatorGroups; +import org.hisp.dhis.indicator.IndicatorService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/indicatorGroups" ) public class IndicatorGroupController @@ -45,19 +50,23 @@ private IndicatorService indicatorService; @RequestMapping( method = RequestMethod.GET ) - public IndicatorGroups getIndicatorGroups() + public String getIndicatorGroups( Model model ) { IndicatorGroups indicatorGroups = new IndicatorGroups(); indicatorGroups.setIndicatorGroups( new ArrayList( indicatorService.getAllIndicatorGroups() ) ); - return indicatorGroups; + model.addAttribute( "model", indicatorGroups ); + + return "indicatorGroups"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public IndicatorGroup getIndicatorGroup( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getIndicatorGroup( @PathVariable( "uid" ) String uid, Model model ) { IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( uid ); - return indicatorGroup; + model.addAttribute( "model", indicatorGroup ); + + return "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-11-23 12:21:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java 2011-12-01 19:14:36 +0000 @@ -32,13 +32,16 @@ import org.hisp.dhis.indicator.IndicatorService; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/indicatorGroupSets" ) public class IndicatorGroupSetController @@ -47,19 +50,23 @@ private IndicatorService indicatorService; @RequestMapping( method = RequestMethod.GET ) - public IndicatorGroupSets getIndicatorGroupSets() + public String getIndicatorGroupSets( Model model ) { IndicatorGroupSets indicatorGroupSets = new IndicatorGroupSets(); indicatorGroupSets.setIndicatorGroupSets( new ArrayList( indicatorService.getAllIndicatorGroupSets() ) ); - return indicatorGroupSets; + model.addAttribute( "model", indicatorGroupSets ); + + return "indicatorGroupSets"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public IndicatorGroupSet getIndicatorGroupSet( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getIndicatorGroupSet( @PathVariable( "uid" ) String uid, Model model ) { IndicatorGroupSet indicatorGroupSet = indicatorService.getIndicatorGroupSet( uid ); - return indicatorGroupSet; + model.addAttribute( "model", indicatorGroupSet ); + + return "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-11-23 12:28:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java 2011-12-01 19:14:36 +0000 @@ -32,13 +32,16 @@ import org.hisp.dhis.indicator.IndicatorTypes; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +/** + * @author Morten Olav Hansen + */ @Controller @RequestMapping( value = "/indicatorTypes" ) public class IndicatorTypeController @@ -47,19 +50,23 @@ private IndicatorService indicatorService; @RequestMapping( method = RequestMethod.GET ) - public IndicatorTypes getIndicatorTypes() + public String getIndicatorTypes( Model model ) { IndicatorTypes indicatorTypes = new IndicatorTypes(); indicatorTypes.setIndicatorTypes( new ArrayList( indicatorService.getAllIndicatorTypes() ) ); - return indicatorTypes; + model.addAttribute( "model", indicatorTypes ); + + return "indicatorTypes"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public IndicatorType getIndicator( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getIndicator( @PathVariable( "uid" ) String uid, Model model ) { IndicatorType indicatorType = indicatorService.getIndicatorType( uid ); - return indicatorType; + model.addAttribute( "model", indicatorType ); + + return "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-11-23 14:49:40 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-01 19:14:36 +0000 @@ -5,11 +5,11 @@ import org.hisp.dhis.organisationunit.OrganisationUnits; 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 javax.servlet.http.HttpServletRequest; import java.util.ArrayList; /** @@ -22,25 +22,24 @@ @Autowired private OrganisationUnitService organisationUnitService; - public OrganisationUnitController() - { - - } - @RequestMapping( method = RequestMethod.GET ) - public OrganisationUnits getOrganisationUnits() + public String getOrganisationUnits( Model model ) { OrganisationUnits organisationUnits = new OrganisationUnits(); organisationUnits.setOrganisationUnits( new ArrayList( organisationUnitService.getAllOrganisationUnits() ) ); - return organisationUnits; + model.addAttribute( "model", organisationUnits ); + + return "organisationUnits"; } @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public OrganisationUnit getOrganisationUnit( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) + public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model ) { OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( uid ); - return organisationUnit; + model.addAttribute( "model", organisationUnit ); + + return "organisationUnit"; } } === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java 2011-12-01 19:14:36 +0000 @@ -0,0 +1,45 @@ +package org.hisp.dhis.api.controller; + +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroups; +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 java.util.ArrayList; + +/** + * @author Morten Olav Hansen + */ +@Controller +@RequestMapping( value = "/organisationUnitGroups" ) +public class OrganisationUnitGroupController +{ + @Autowired + private OrganisationUnitGroupService organisationUnitGroupService; + + @RequestMapping( method = RequestMethod.GET ) + public String getOrganisationUnits( Model model ) + { + OrganisationUnitGroups organisationUnitGroups = new OrganisationUnitGroups(); + organisationUnitGroups.setOrganisationUnitGroups( new ArrayList( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); + + model.addAttribute( "model", organisationUnitGroups ); + + return "organisationUnitGroups"; + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) + public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model ) + { + OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( uid ); + + model.addAttribute( "model", organisationUnitGroup ); + + return "organisationUnitGroup"; + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java 2011-12-01 19:14:36 +0000 @@ -0,0 +1,72 @@ +package org.hisp.dhis.api.controller; + +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets; +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 java.util.ArrayList; + +/** + * @author Morten Olav Hansen + */ +@Controller +@RequestMapping( value = "/organisationUnitGroupSets" ) +public class OrganisationUnitGroupSetController +{ + @Autowired + private OrganisationUnitGroupService organisationUnitGroupService; + + @RequestMapping( method = RequestMethod.GET ) + public String getOrganisationUnitGroupSets( Model model ) + { + OrganisationUnitGroupSets organisationUnitGroupSets = new OrganisationUnitGroupSets(); + organisationUnitGroupSets.setOrganisationUnitGroupSets( new ArrayList( organisationUnitGroupService.getAllOrganisationUnitGroupSets() ) ); + + model.addAttribute( "model", organisationUnitGroupSets ); + + return "organisationUnitGroupSets"; + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) + public String getOrganisationUnitGroupSet( @PathVariable( "uid" ) String uid, Model model ) + { + OrganisationUnitGroupSet organisationUnitGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( uid ); + + model.addAttribute( "model", organisationUnitGroupSet ); + + return "organisationUnitGroupSet"; + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2011-12-01 19:14:36 +0000 @@ -0,0 +1,72 @@ +package org.hisp.dhis.api.controller; + +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; +import org.hisp.dhis.organisationunit.OrganisationUnitLevels; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +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 java.util.ArrayList; + +/** + * @author Morten Olav Hansen + */ +@Controller +@RequestMapping( value = "/organisationUnitLevels" ) +public class OrganisationUnitLevelController +{ + @Autowired + private OrganisationUnitService organisationUnitService; + + @RequestMapping( method = RequestMethod.GET ) + public String getOrganisationUnitLevels( Model model ) + { + OrganisationUnitLevels organisationUnitLevels = new OrganisationUnitLevels(); + organisationUnitLevels.setOrganisationUnitLevels( new ArrayList( organisationUnitService.getOrganisationUnitLevels() ) ); + + model.addAttribute( "model", organisationUnitLevels ); + + return "organisationUnitLevels"; + } + + @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) + public String getOrganisationUnit( @PathVariable( "uid" ) String uid, Model model ) + { + OrganisationUnitLevel organisationUnitLevel = organisationUnitService.getOrganisationUnitLevel( uid ); + + model.addAttribute( "model", organisationUnitLevel ); + + return "organisationUnitLevel"; + } +} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SectionController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SectionController.java 2011-11-24 17:03:14 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SectionController.java 1970-01-01 00:00:00 +0000 @@ -1,46 +0,0 @@ -package org.hisp.dhis.api.controller; - -import org.hisp.dhis.dataset.Section; -import org.hisp.dhis.dataset.SectionService; -import org.hisp.dhis.dataset.Sections; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; - -/** - * @author Morten Olav Hansen - */ -@Controller -@RequestMapping( value = "/sections" ) -public class SectionController -{ - @Autowired - private SectionService sectionService; - - public SectionController() - { - - } - - @RequestMapping( method = RequestMethod.GET ) - public Sections getDataSets() - { - Sections sections = new Sections(); - sections.setSections( new ArrayList

( sectionService.getAllSections() ) ); - - return sections; - } - - @RequestMapping( value = "/{uid}", method = RequestMethod.GET ) - public Section getDataSet( @PathVariable( "uid" ) Integer uid, HttpServletRequest request ) - { - Section section = sectionService.getSection( uid ); - - return section; - } -} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java 2011-12-01 19:14:36 +0000 @@ -0,0 +1,72 @@ +package org.hisp.dhis.api.controller; + +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.user.User; +import org.hisp.dhis.user.UserService; +import org.hisp.dhis.user.Users; +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 java.util.ArrayList; + +/** + * @author Morten Olav Hansen + */ +@Controller +@RequestMapping( value = "/users" ) +public class UserController +{ + @Autowired + private UserService userService; + + @RequestMapping( method = RequestMethod.GET ) + public String getUsers( Model model ) + { + Users users = new Users(); + users.setUsers( new ArrayList( userService.getAllUsers() ) ); + + model.addAttribute( "model", users ); + + return "users"; + } + + @RequestMapping( value = "/{id}", method = RequestMethod.GET ) + public String getUser( @PathVariable( "id" ) Integer id, Model model ) + { + User user = userService.getUser( id ); + + model.addAttribute( "model", user ); + + return "user"; + } +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ClassPathUriResolver.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ClassPathUriResolver.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ClassPathUriResolver.java 2011-12-02 14:01:09 +0000 @@ -0,0 +1,62 @@ +package org.hisp.dhis.api.view; + +import org.springframework.core.io.ClassPathResource; + +import javax.xml.transform.Source; +import javax.xml.transform.TransformerException; +import javax.xml.transform.URIResolver; +import javax.xml.transform.stream.StreamSource; +import java.io.IOException; + +/** + * @author Morten Olav Hansen + */ +public class ClassPathUriResolver implements URIResolver +{ + private String templatePath = "/templates/"; + + public ClassPathUriResolver() + { + + } + + public ClassPathUriResolver( String templatePath ) + { + this.templatePath = templatePath; + } + + public String getTemplatePath() + { + return templatePath; + } + + public void setTemplatePath( String templatePath ) + { + this.templatePath = templatePath; + } + + @Override + public Source resolve( String href, String base ) throws TransformerException + { + String url = getTemplatePath() + href; + ClassPathResource classPathResource = new ClassPathResource( url ); + + if ( !classPathResource.exists() ) + { + throw (new TransformerException( "Resource " + url + " does not exist in classpath." )); + } + + Source source = null; + + try + { + source = new StreamSource( classPathResource.getInputStream() ); + } + catch ( IOException e ) + { + throw (new TransformerException( "IOException while reading " + url + "." )); + } + + return source; + } +} === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2View.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2View.java 2011-11-12 15:46:34 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2View.java 2011-11-30 12:12:57 +0000 @@ -1,6 +1,5 @@ package org.hisp.dhis.api.view; -import org.springframework.validation.BindingResult; import org.springframework.web.servlet.view.AbstractView; import javax.servlet.http.HttpServletRequest; @@ -8,62 +7,47 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import java.io.OutputStream; -import java.util.HashMap; import java.util.Map; /** * @author mortenoh */ -public class Jaxb2View extends AbstractView { +public class Jaxb2View extends AbstractView +{ public static final String DEFAULT_CONTENT_TYPE = "application/xml"; - public Jaxb2View() { - setContentType(DEFAULT_CONTENT_TYPE); + public Jaxb2View() + { + setContentType( DEFAULT_CONTENT_TYPE ); } @Override - protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { - response.setContentType(getContentType()); - - Object value = filterModel(model); - - if (value instanceof Map) { - Map map = (Map) value; - - if (map.size() == 1) { - value = map.values().toArray()[0]; - } + protected void renderMergedOutputModel( Map model, HttpServletRequest request, HttpServletResponse response ) throws Exception + { + response.setContentType( getContentType() ); + model = ViewUtils.filterModel( model ); + + Object domainModel = model.get( "model" ); + + if ( domainModel == null ) + { + // TODO throw exception } OutputStream outputStream = response.getOutputStream(); - JAXBContext context = JAXBContext.newInstance(value.getClass()); + JAXBContext context = JAXBContext.newInstance( domainModel.getClass() ); Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); - -// Marshaller.Listener listener = new IdentifiableObjectListener(request); -// marshaller.setListener(listener); - - /* TODO This will only work on JAXB RI (and crash on others!) please fixme.. */ - - /* + marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, false ); + marshaller.setProperty( Marshaller.JAXB_ENCODING, "UTF-8" ); + + marshaller.marshal( domainModel, outputStream ); + +/* + Marshaller.Listener listener = new IdentifiableObjectListener(request); + marshaller.setListener(listener); + marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders", "\n\n"); - */ - - marshaller.marshal(value, outputStream); - } - - protected Object filterModel(Map model) { - Map result = new HashMap(model.size()); - - for (Map.Entry entry : model.entrySet()) { - if (!(entry.getValue() instanceof BindingResult)) { - result.put(entry.getKey(), entry.getValue()); - } - } - - return result; - } - +*/ + } } === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java 2011-12-02 14:01:09 +0000 @@ -0,0 +1,57 @@ +package org.hisp.dhis.api.view; + + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; + +/* + * Copyright (c) 2004-2005, 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 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 bobj + * @version created 02-Dec-2011 + */ +public interface TransformCache +{ + /** + * A Transformer for processing lists of elements to html tables + * + * @return the transformer + * @throws TransformerConfigurationException + */ + Transformer getHtmlTransformer() + throws TransformerConfigurationException; + + /** + * A transformer for rendering elements to xsl-fop + * + * @return the transformer + * @throws TransformerConfigurationException + */ + Transformer getFopTransformer() + throws TransformerConfigurationException; +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java 2011-12-02 16:05:28 +0000 @@ -0,0 +1,114 @@ +package org.hisp.dhis.api.view; + + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.xml.transform.ErrorListener; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamSource; +import org.amplecode.staxwax.transformer.LoggingErrorListener; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Component; + +/* + * Copyright (c) 2004-2005, 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 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 bobj + * @version created 02-Dec-2011 + */ +@Component +public class TransformCacheImpl implements TransformCache +{ + static final String MODEL2HTML = "model2html.xsl"; + + static final String MODEL2FOP = "model2fop.xsl"; + + static final String HTMLXSLT_RESOURCE = "/templates/xslt/"; + + static final String FOPXSLT_RESOURCE = "/templates/xslfo/"; + + static private TransformCache instance; + + private Templates htmlCachedTransform; + + private Templates fopCachedTransform; + + private TransformCacheImpl() throws IOException, TransformerConfigurationException + { + ErrorListener errorListener = new LoggingErrorListener(); + + TransformerFactory factory = TransformerFactory.newInstance(); + factory.setErrorListener( errorListener ); + + Source model2html = + new StreamSource(new ClassPathResource( HTMLXSLT_RESOURCE + MODEL2HTML ).getInputStream()); + Source model2fop = + new StreamSource(new ClassPathResource( FOPXSLT_RESOURCE + MODEL2FOP ).getInputStream()); + + factory.setURIResolver( new ClassPathUriResolver(HTMLXSLT_RESOURCE)); + htmlCachedTransform = factory.newTemplates( model2html ); + factory.setURIResolver( new ClassPathUriResolver(FOPXSLT_RESOURCE)); + fopCachedTransform = factory.newTemplates( model2fop ); + } + + static TransformCache instance() { + if (instance == null) { + try + { + instance = new TransformCacheImpl(); + } catch ( Exception ex ) + { + Logger.getLogger( TransformCacheImpl.class.getName() ).log( Level.SEVERE, null, ex ); + } + } + return instance; + } + + + + @Override + public Transformer getHtmlTransformer() + throws TransformerConfigurationException + { + return htmlCachedTransform.newTransformer(); + } + + @Override + public Transformer getFopTransformer() + throws TransformerConfigurationException + { + return fopCachedTransform.newTransformer(); + } + +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java 2011-11-28 17:34:49 +0000 @@ -0,0 +1,28 @@ +package org.hisp.dhis.api.view; + +import org.springframework.validation.BindingResult; + +import java.lang.annotation.Annotation; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Morten Olav Hansen + */ +public class ViewUtils +{ + public static Map filterModel( Map model ) + { + Map result = new HashMap( model.size() ); + + for ( Map.Entry entry : model.entrySet() ) + { + if ( !(entry.getValue() instanceof BindingResult) ) + { + result.put( entry.getKey(), entry.getValue() ); + } + } + + return result; + } +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java 2011-12-02 15:28:37 +0000 @@ -0,0 +1,57 @@ +package org.hisp.dhis.api.view; + +import org.apache.fop.apps.Fop; +import org.apache.fop.apps.FopFactory; +import org.apache.xmlgraphics.util.MimeConstants; +import org.springframework.web.servlet.view.AbstractUrlBasedView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.util.JAXBSource; +import javax.xml.transform.*; +import javax.xml.transform.sax.SAXResult; +import java.util.Map; + +/** + * @author Morten Olav Hansen + */ +public class XslFoPdfView extends AbstractUrlBasedView +{ + public static final String PDF_CONTENT_TYPE = "application/pdf"; + + public XslFoPdfView() + { + setContentType( PDF_CONTENT_TYPE ); + } + + @Override + protected void renderMergedOutputModel( Map model, HttpServletRequest request, HttpServletResponse response ) throws Exception + { + response.setContentType( getContentType() ); + model = ViewUtils.filterModel( model ); + + Object domainModel = model.get( "model" ); + + if ( domainModel == null ) + { + // throw exception + } + + JAXBContext context = JAXBContext.newInstance( domainModel.getClass() ); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, false ); + marshaller.setProperty( Marshaller.JAXB_ENCODING, "UTF-8" ); + + Source xmlSource = new JAXBSource( context, domainModel ); + + Transformer transformer = TransformCacheImpl.instance().getFopTransformer(); + + FopFactory fopFactory = FopFactory.newInstance(); + Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, response.getOutputStream() ); + + Result result = new SAXResult( fop.getDefaultHandler() ); + transformer.transform( xmlSource, result ); + } +} === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java 2011-12-02 15:28:37 +0000 @@ -0,0 +1,66 @@ +package org.hisp.dhis.api.view; + +import org.springframework.web.servlet.view.AbstractUrlBasedView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.util.JAXBSource; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.stream.StreamResult; +import java.io.OutputStream; +import java.util.Map; + +/** + * @author Morten Olav Hansen + */ +public class XsltHtmlView extends AbstractUrlBasedView +{ + public static final String HTML_CONTENT_TYPE = "text/html"; + + public XsltHtmlView() + { + setContentType( HTML_CONTENT_TYPE ); + } + + @Override + protected void renderMergedOutputModel( Map model, HttpServletRequest request, HttpServletResponse response ) + throws Exception + { + response.setContentType( getContentType() ); + model = ViewUtils.filterModel( model ); + + Object domainModel = model.get( "model" ); + + if ( domainModel == null ) + { + // TODO throw exception + } + + JAXBContext context = JAXBContext.newInstance( domainModel.getClass() ); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, false ); + marshaller.setProperty( Marshaller.JAXB_ENCODING, "UTF-8" ); + + Source xmlSource = new JAXBSource( context, domainModel ); + + Transformer transformer = TransformCacheImpl.instance().getHtmlTransformer(); + + OutputStream output = response.getOutputStream(); + + // pass on any parameters set in xslt-params + Map params = (Map) model.get( "xslt-params" ); + if ( params != null ) + { + for ( Map.Entry entry : params.entrySet() ) + { + transformer.setParameter( entry.getKey(), entry.getValue() ); + } + } + + transformer.transform( xmlSource, new StreamResult( output ) ); + + } +} === 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-11-02 11:14:35 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-12-02 14:01:09 +0000 @@ -3,5 +3,5 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml 2011-11-16 09:00:32 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml 2011-11-28 18:15:52 +0000 @@ -18,6 +18,8 @@ + + @@ -30,10 +32,27 @@ - - - - + + + + + + + + + + + + + + + + + + + + + === added directory 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates' === added directory 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo' === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/list.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/list.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/list.xsl 2011-12-01 13:44:45 +0000 @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + DataElements + + + + + + + + + + + + + + + + + + ShortName + + + + LastUpdated + + + + Active + + + + AggregationOperator + + + + DomainType + + + + SortOrder + + + + Type + + + + ZeroIsSignificant + + + + + + + === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/model2fop.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/model2fop.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslfo/model2fop.xsl 2011-12-02 14:01:09 +0000 @@ -0,0 +1,9 @@ + + + + + Hello World + + + \ No newline at end of file === added directory 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt' === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/chart.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/chart.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/chart.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,122 @@ + + + + +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID + +
Last Updated + +
Dimension + +
Hide legend + +
Hide subtitle + +
Horizontal Pilot Orientation + +
Regression + +
Size + +
Target line + +
Target line label + +
Type + +
User organisation unit + +
Vertical labels + +
+ + + +
+
+ + + +

OrganisationUnits

+ + +
+
+
+ + + +

DataElements

+ + +
+
+
+ + + +

Indicators

+ + +
+
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataElement.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataElement.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataElement.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,96 @@ + + + + +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID + +
Last Updated + +
Short Name + +
Type + +
Zero is Significant + +
Sort Order + +
Active + +
Aggregation Operator + +
Domain Type + +
+ + +
+
+ + +

DataElementCategoryCombo

+ + +
+
+ + + +

DataElementGroups

+ + +
+
+
+ + + +

DataSets

+ + +
+
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataSet.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataSet.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/dataSet.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,75 @@ + + + + +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + +
ID + +
Last Updated + +
Short Name + +
Version + +
Mobile + +
+ + + +
+
+ + + +

DataElements

+ + +
+
+
+ + + +

Indicators

+ + +
+
+
+ + + +

OrganisationUnits

+ + +
+
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/html-wrapper.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/html-wrapper.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/html-wrapper.xsl 2011-12-02 14:01:09 +0000 @@ -0,0 +1,20 @@ + + + + + + + + DHIS Web-API + + + + +

Some CSS required!

+ + + + +
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/identifiable-row.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/identifiable-row.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/identifiable-row.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,49 @@ + + + + + Created on: Nov 28, 2011 + Author: bobj + Generic rendering of table rows of identifiable objects + + + + + + + + + + + html + + + + + + xml + + + + + + json + + + + + + jsonp + + + + + + pdf + + + + + + === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/indicator.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/indicator.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/indicator.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,90 @@ + + + + +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID + +
Last Updated + +
Short Name + +
Denominator + +
Denominator Description + +
Numerator + +
Numerator Description + +
Annualized + +
Sort Order + +
+ + + +
+
+ + + +

Indicator Groups

+ + +
+
+
+ + + +

DataSets

+ + +
+
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/list.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/list.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/list.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,18 @@ + + + + + + + + +

+ +

+ + + +
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/model2html.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/model2html.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/model2html.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/organisationUnit.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/organisationUnit.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/organisationUnit.xsl 2011-12-02 20:35:16 +0000 @@ -0,0 +1,90 @@ + + + +
+

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID + +
Last Updated + +
Short Name + +
Opening Date + +
Level + +
Active + +
Current Parent + +
Has Patients + +
+ + + +
+
+ + +

Parent OrganisationUnit

+ + +
+
+ + + +

OrganisationUnit Groups

+ + +
+
+
+ + + +

DataSets

+ + +
+
+
+ +
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/users.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/users.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/xslt/users.xsl 2011-12-01 19:14:36 +0000 @@ -0,0 +1,14 @@ + + + + + + + + Users + users + + + + + === modified file 'dhis-2/pom.xml' --- dhis-2/pom.xml 2011-11-24 17:03:14 +0000 +++ dhis-2/pom.xml 2011-11-28 17:34:49 +0000 @@ -785,6 +785,13 @@ 2.2.2 + + + org.apache.xmlgraphics + fop + 1.0 + +