dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10648
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2919: Lot's of refactoring, work-in-progress
------------------------------------------------------------
revno: 2919
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-02-25 09:46:18 +0530
message:
Lot's of refactoring, work-in-progress
- added "uri conneg", so you can ask for a specific content type by adding .xml/.json/.html to the url
- added generic link type (preparing for adding href's to entities)
- if client can accept html, choose that ahead of xml (browsers often prefer xml)
removed:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataElement.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetResource.java
added:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSetLinks.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Link.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnitLinks.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilder.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilderImpl.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/OrgUnitMapper.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/HtmlPromotingUriConnegFilter.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java
modified:
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSet.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Dxf.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnit.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataSetMapper.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataSetMappingTest.java
dhis-2/dhis-web/dhis-web-api/pom.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnits.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml
dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitTest.java
dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitsTest.java
dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2011-02-25 04:16:18 +0000
@@ -27,10 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertFalse;
+
+import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import org.junit.Ignore;
@@ -96,4 +98,24 @@
}
+ @Test
+ public void isoDates()
+ {
+ WeeklyPeriodType weekly = new WeeklyPeriodType();
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+
+ cal.set( 2010, 11, 27 );
+
+ Period period = weekly.createPeriod( "2011W1" );
+
+ assertEquals(cal.getTime(), period.getStartDate());
+
+ period = weekly.createPeriod( "2011W11" );
+
+ cal.set( 2011, 2, 7 );
+
+ assertEquals(cal.getTime(), period.getStartDate());
+
+ }
}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataElement.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataElement.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataElement.java 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.importexport.dxf2.model;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-public class DataElement
-{
- @XmlAttribute(name="id")
- private String uuid;
-
- @XmlAttribute
- private String name;
-
- public String getUuid()
- {
- return uuid;
- }
-
- public void setUuid( String uuid )
- {
- this.uuid = uuid;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
-
-}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSet.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSet.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSet.java 2011-02-25 04:16:18 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.importexport.dxf2.model;
+/*
+ * Copyright (c) 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 java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -11,14 +38,8 @@
@XmlRootElement
@XmlAccessorType( XmlAccessType.FIELD )
-public class DataSet
+public class DataSet extends Link
{
- @XmlAttribute(name="id")
- private String uuid;
-
- @XmlAttribute
- private String name;
-
@XmlAttribute
private String shortName;
@@ -28,29 +49,13 @@
@XmlAttribute
private String periodType;
- @XmlElementWrapper(name="members")
+ @XmlElementWrapper(name="dataElements")
@XmlElement(name="dataElement")
- private List<DataElement> members;
-
- public String getUuid()
- {
- return uuid;
- }
-
- public void setUuid( String uuid )
- {
- this.uuid = uuid;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
+ private List<Link> dataElementLinks;
+
+ @XmlElementWrapper(name="orgUnits")
+ @XmlElement(name="orgUnit")
+ private List<Link> orgUnitLinks;
public String getShortName()
{
@@ -82,15 +87,25 @@
this.periodType = periodType;
}
- public List<DataElement> getMembers()
- {
- return members;
- }
-
- public void setMembers( List<DataElement> members )
- {
- this.members = members;
- }
-
-
+ public List<Link> getDataElementLinks()
+ {
+ return dataElementLinks;
+ }
+
+ public void setDataElementLinks( List<Link> dataElementLinks )
+ {
+ this.dataElementLinks = dataElementLinks;
+ }
+
+ public List<Link> getOrgUnitLinks()
+ {
+ return orgUnitLinks;
+ }
+
+ public void setOrgUnitLinks( List<Link> orgUnitLinks )
+ {
+ this.orgUnitLinks = orgUnitLinks;
+ }
+
+
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSetLinks.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSetLinks.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataSetLinks.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,33 @@
+package org.hisp.dhis.importexport.dxf2.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+public class DataSetLinks
+{
+
+ List<Link> dataSet;
+
+ public DataSetLinks()
+ {
+ }
+
+ public DataSetLinks( List<Link> dataSet )
+ {
+ this.dataSet = dataSet;
+ }
+
+ public List<Link> getDataSet()
+ {
+ return dataSet;
+ }
+
+ public void setDataSet( List<Link> dataSet )
+ {
+ this.dataSet = dataSet;
+ }
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Dxf.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Dxf.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Dxf.java 2011-02-25 04:16:18 +0000
@@ -1,5 +1,32 @@
package org.hisp.dhis.importexport.dxf2.model;
+/*
+ * Copyright (c) 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 java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -22,6 +49,10 @@
@XmlElement( name="dataValueSet" )
private List<DataValueSet> dataValueSets;
+ @XmlElementWrapper( name="orgUnits" )
+ @XmlElement( name="orgUnit" )
+ private List<OrgUnit> orgUnits;
+
public void setDataValueSets( List<DataValueSet> dataValueSets )
{
this.dataValueSets = dataValueSets;
@@ -42,5 +73,15 @@
this.dataSets = dataSets;
}
+ public List<OrgUnit> getOrgUnits()
+ {
+ return orgUnits;
+ }
+
+ public void setOrgUnits( List<OrgUnit> orgUnits )
+ {
+ this.orgUnits = orgUnits;
+ }
+
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Link.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Link.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/Link.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.importexport.dxf2.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+@XmlAccessorType( XmlAccessType.FIELD )
+public class Link
+{
+
+ @XmlAttribute( name = "id", required = true )
+ private String id;
+
+ @XmlAttribute
+ private String href;
+
+ @XmlAttribute
+ private String name;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public String getHref()
+ {
+ return href;
+ }
+
+ public void setHref( String href )
+ {
+ this.href = href;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnit.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnit.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnit.java 2011-02-25 04:16:18 +0000
@@ -1,37 +1,55 @@
package org.hisp.dhis.importexport.dxf2.model;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-public class OrgUnit
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class OrgUnit extends Link
{
- @XmlAttribute(name="id")
- private String uuid;
-
- @XmlAttribute
- private String name;
-
- public String getUuid()
- {
- return uuid;
- }
-
- public void setUuid( String uuid )
- {
- this.uuid = uuid;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
+ private Link parent;
+
+ @XmlElementWrapper(name="children")
+ @XmlElement(name="orgUnit")
+ private List<Link> children;
+
+
+ @XmlElementWrapper(name="dataSets")
+ @XmlElement(name="dataSet")
+ private List<Link> dataSets;
+
+ public List<Link> getDataSets()
+ {
+ return dataSets;
+ }
+
+ public void setDataSets( List<Link> dataSets )
+ {
+ this.dataSets = dataSets;
+ }
+
+ public List<Link> getChildren()
+ {
+ return children;
+ }
+
+ public void setChildren( List<Link> children )
+ {
+ this.children = children;
+ }
+
+ public Link getParent()
+ {
+ return parent;
+ }
+
+ public void setParent( Link parent )
+ {
+ this.parent = parent;
+ }
+
+
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnitLinks.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/OrgUnitLinks.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,35 @@
+package org.hisp.dhis.importexport.dxf2.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+public class OrgUnitLinks
+{
+
+ List<Link> orgUnit;
+
+ public OrgUnitLinks()
+ {
+ }
+
+ public OrgUnitLinks( List<Link> orgUnit )
+ {
+ this.orgUnit = orgUnit;
+ }
+
+ public List<Link> getOrgUnit()
+ {
+ return orgUnit;
+ }
+
+ public void setOrgUnit( List<Link> orgUnit )
+ {
+ this.orgUnit = orgUnit;
+ }
+
+
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataSetMapper.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataSetMapper.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataSetMapper.java 2011-02-25 04:16:18 +0000
@@ -1,40 +1,24 @@
package org.hisp.dhis.importexport.dxf2.service;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.hisp.dhis.importexport.dxf2.model.DataElement;
import org.hisp.dhis.importexport.dxf2.model.DataSet;
public class DataSetMapper
{
-
- public static DataSet convert(org.hisp.dhis.dataset.DataSet dataSet) {
+ private LinkBuilder linkBuilder = new LinkBuilderImpl();
+
+ public DataSet convert(org.hisp.dhis.dataset.DataSet dataSet) {
DataSet dxfDataSet = new DataSet();
dxfDataSet.setCode( dataSet.getCode() );
- dxfDataSet.setMembers( getDataElements(dataSet.getDataElements()) );
dxfDataSet.setName( dataSet.getName() );
dxfDataSet.setPeriodType( dataSet.getPeriodType().getName() );
dxfDataSet.setShortName( dataSet.getShortName() );
- dxfDataSet.setUuid( dataSet.getUuid() );
+ dxfDataSet.setId( dataSet.getUuid() );
+
+ dxfDataSet.setDataElementLinks( linkBuilder.getLinks( dataSet.getDataElements()) );
+ dxfDataSet.setOrgUnitLinks( linkBuilder.getLinks(dataSet.getOrganisationUnits()) );
return dxfDataSet;
}
- public static List<DataElement> getDataElements( Collection<org.hisp.dhis.dataelement.DataElement> dataElements )
- {
- List<DataElement> dxfDataElements = new ArrayList<DataElement>();
-
- for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
- {
- DataElement dxfDataElement = new DataElement();
- dxfDataElement.setName( dataElement.getName() );
- dxfDataElement.setUuid( dataElement.getUuid() );
-
- dxfDataElements.add( dxfDataElement );
- }
- return dxfDataElements;
- }
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilder.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilder.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilder.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,16 @@
+package org.hisp.dhis.importexport.dxf2.service;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.importexport.dxf2.model.Link;
+
+public interface LinkBuilder
+{
+
+ public List<Link> getLinks( Collection<? extends IdentifiableObject> targets );
+
+ public Link get( IdentifiableObject target );
+
+}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilderImpl.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilderImpl.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/LinkBuilderImpl.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,32 @@
+package org.hisp.dhis.importexport.dxf2.service;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.importexport.dxf2.model.Link;
+
+public class LinkBuilderImpl implements LinkBuilder
+{
+ public List<Link> getLinks( Collection<? extends IdentifiableObject> targets )
+ {
+ List<Link> links = new ArrayList<Link>();
+
+ for ( IdentifiableObject target : targets )
+ {
+ links.add( get( target ) );
+ }
+ return links;
+ }
+
+ public Link get( IdentifiableObject target )
+ {
+ Link link = new Link();
+ link.setName( target.getName() );
+ link.setId( target.getUuid() );
+
+ return link;
+ }
+
+}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/OrgUnitMapper.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/OrgUnitMapper.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/OrgUnitMapper.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,33 @@
+package org.hisp.dhis.importexport.dxf2.service;
+
+import java.util.Set;
+
+import org.hisp.dhis.importexport.dxf2.model.OrgUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
+public class OrgUnitMapper
+{
+
+ private LinkBuilder linkBuilder = new LinkBuilderImpl();
+
+ public OrgUnit get( OrganisationUnit unit )
+ {
+ OrgUnit dxfUnit = new OrgUnit();
+
+ dxfUnit.setName( unit.getName() );
+ dxfUnit.setId( unit.getUuid() );
+
+ OrganisationUnit parent = unit.getParent();
+ if ( parent != null )
+ dxfUnit.setParent( linkBuilder.get( parent ) );
+
+ Set<OrganisationUnit> children = unit.getChildren();
+ if ( children != null && !children.isEmpty() )
+ dxfUnit.setChildren( linkBuilder.getLinks( children ) );
+
+ dxfUnit.setDataSets( linkBuilder.getLinks( unit.getDataSets() ) );
+
+ return dxfUnit;
+ }
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataSetMappingTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataSetMappingTest.java 2011-02-22 23:17:50 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataSetMappingTest.java 2011-02-25 04:16:18 +0000
@@ -97,7 +97,7 @@
StringWriter writer = new StringWriter();
org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( DATA_SET_UUID );
- DataSet dxfDataSet = DataSetMapper.convert( dataSet );
+ DataSet dxfDataSet = new DataSetMapper().convert( dataSet );
u.marshal( dxfDataSet, writer );
System.out.println( writer.toString() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml 2011-01-23 00:12:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml 2011-02-25 04:16:18 +0000
@@ -42,17 +42,17 @@
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
- <version>1.4</version>
+ <version>1.5</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
- <version>1.4</version>
+ <version>1.5</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
- <version>1.4</version>
+ <version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/HtmlPromotingUriConnegFilter.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/HtmlPromotingUriConnegFilter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/HtmlPromotingUriConnegFilter.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,96 @@
+package org.hisp.dhis.web.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import com.sun.jersey.api.container.filter.UriConnegFilter;
+import com.sun.jersey.spi.container.ContainerRequest;
+
+public class HtmlPromotingUriConnegFilter
+ extends UriConnegFilter
+{
+
+ private static final String ACCEPT = "Accept";
+
+ private static Map<String, MediaType> mediaExtentions;
+
+ static
+ {
+ mediaExtentions = new HashMap<String, MediaType>();
+ mediaExtentions.put( "xml", MediaType.APPLICATION_XML_TYPE );
+ mediaExtentions.put( "html", MediaType.TEXT_HTML_TYPE );
+ mediaExtentions.put( "json", MediaType.APPLICATION_JSON_TYPE );
+ }
+
+ public HtmlPromotingUriConnegFilter()
+ {
+ super( mediaExtentions );
+ }
+
+ @Override
+ public ContainerRequest filter( ContainerRequest request )
+ {
+ String accept = request.getHeaderValue( ACCEPT );
+
+ if ( accept == null || accept.trim().isEmpty())
+ {
+ request.getRequestHeaders().putSingle( ACCEPT, MediaType.TEXT_HTML );
+ }
+ else
+ {
+ accept = preferHtml(accept);
+ request.getRequestHeaders().putSingle( ACCEPT, accept );
+ }
+
+ request = super.filter( request );
+
+ return request;
+ }
+
+ public static String preferHtml( String accept )
+ {
+ int i = accept.indexOf( "text/html" );
+
+ if ( i == -1 )
+ {
+ if ( accept.trim().equals( "" ) )
+ {
+ return "text/html";
+ }
+ return "text/html," + accept;
+ }
+
+ int start = accept.substring( 0, i ).lastIndexOf( ',' );
+
+ String result = "";
+
+ if ( start != -1 )
+ {
+ result = accept.substring( 0, start );
+ }
+
+ int end = accept.indexOf( ',', i );
+ if ( end != -1 )
+ {
+ if ( result.equals( "" ) )
+ {
+ result = accept.substring( end + 1 );
+ }
+ else
+ {
+ result = result + accept.substring( end );
+ }
+ }
+
+ if ( result.trim().equals( "" ) )
+ {
+ return "text/html";
+ }
+
+ return "text/html," + result;
+
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,149 @@
+package org.hisp.dhis.web.api.model;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name="orgUnit")
+public class MobileOrgUnitLinks
+ implements DataStreamSerializable
+{
+ private int id;
+
+ private String name;
+
+ private String downloadAllUrl;
+
+ private String updateActivityPlanUrl;
+
+ private String uploadFacilityReportUrl;
+
+ private String uploadActivityReportUrl;
+
+ private String updateDataSetUrl;
+
+ @XmlAttribute
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ @XmlAttribute
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getDownloadAllUrl()
+ {
+ return downloadAllUrl;
+ }
+
+ public void setDownloadAllUrl( String downloadAllUrl )
+ {
+ this.downloadAllUrl = downloadAllUrl;
+ }
+
+ public String getUploadFacilityReportUrl()
+ {
+ return uploadFacilityReportUrl;
+ }
+
+ public void setUploadFacilityReportUrl( String uploadFacilityReportUrl )
+ {
+ this.uploadFacilityReportUrl = uploadFacilityReportUrl;
+ }
+
+ public String getUploadActivityReportUrl()
+ {
+ return uploadActivityReportUrl;
+ }
+
+ public void setUploadActivityReportUrl( String uploadActivityReportUrl )
+ {
+ this.uploadActivityReportUrl = uploadActivityReportUrl;
+ }
+
+ public String getUpdateDataSetUrl()
+ {
+ return updateDataSetUrl;
+ }
+
+ public void setUpdateDataSetUrl( String updateDataSetUrl )
+ {
+ this.updateDataSetUrl = updateDataSetUrl;
+ }
+
+ public String getUpdateActivityPlanUrl() {
+ return updateActivityPlanUrl;
+ }
+
+ public void setUpdateActivityPlanUrl(String updateActivityPlanUrl) {
+ this.updateActivityPlanUrl = updateActivityPlanUrl;
+ }
+
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.writeInt( this.id );
+ dataOutputStream.writeUTF( this.name );
+ dataOutputStream.writeUTF( this.downloadAllUrl );
+ dataOutputStream.writeUTF(this.updateActivityPlanUrl);
+ dataOutputStream.writeUTF( this.uploadFacilityReportUrl );
+ dataOutputStream.writeUTF( this.uploadActivityReportUrl );
+ dataOutputStream.writeUTF( this.updateDataSetUrl );
+ }
+
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ this.id = dataInputStream.readInt();
+ this.name = dataInputStream.readUTF();
+ this.downloadAllUrl = dataInputStream.readUTF();
+ this.updateActivityPlanUrl = dataInputStream.readUTF();
+ this.uploadFacilityReportUrl = dataInputStream.readUTF();
+ this.uploadActivityReportUrl = dataInputStream.readUTF();
+ this.updateDataSetUrl = dataInputStream.readUTF();
+ }
+
+}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java 2011-02-21 06:51:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java 1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
-package org.hisp.dhis.web.api.model;
-
-/*
- * Copyright (c) 2004-2010, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class OrgUnit
- implements DataStreamSerializable
-{
- private int id;
-
- private String name;
-
- private String downloadAllUrl;
-
- private String updateActivityPlanUrl;
-
- private String uploadFacilityReportUrl;
-
- private String uploadActivityReportUrl;
-
- private String updateDataSetUrl;
-
- @XmlAttribute
- public int getId()
- {
- return id;
- }
-
- public void setId( int id )
- {
- this.id = id;
- }
-
- @XmlAttribute
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public String getDownloadAllUrl()
- {
- return downloadAllUrl;
- }
-
- public void setDownloadAllUrl( String downloadAllUrl )
- {
- this.downloadAllUrl = downloadAllUrl;
- }
-
- public String getUploadFacilityReportUrl()
- {
- return uploadFacilityReportUrl;
- }
-
- public void setUploadFacilityReportUrl( String uploadFacilityReportUrl )
- {
- this.uploadFacilityReportUrl = uploadFacilityReportUrl;
- }
-
- public String getUploadActivityReportUrl()
- {
- return uploadActivityReportUrl;
- }
-
- public void setUploadActivityReportUrl( String uploadActivityReportUrl )
- {
- this.uploadActivityReportUrl = uploadActivityReportUrl;
- }
-
- public String getUpdateDataSetUrl()
- {
- return updateDataSetUrl;
- }
-
- public void setUpdateDataSetUrl( String updateDataSetUrl )
- {
- this.updateDataSetUrl = updateDataSetUrl;
- }
-
- public String getUpdateActivityPlanUrl() {
- return updateActivityPlanUrl;
- }
-
- public void setUpdateActivityPlanUrl(String updateActivityPlanUrl) {
- this.updateActivityPlanUrl = updateActivityPlanUrl;
- }
-
- public void serialize( DataOutputStream dataOutputStream )
- throws IOException
- {
- dataOutputStream.writeInt( this.id );
- dataOutputStream.writeUTF( this.name );
- dataOutputStream.writeUTF( this.downloadAllUrl );
- dataOutputStream.writeUTF(this.updateActivityPlanUrl);
- dataOutputStream.writeUTF( this.uploadFacilityReportUrl );
- dataOutputStream.writeUTF( this.uploadActivityReportUrl );
- dataOutputStream.writeUTF( this.updateDataSetUrl );
- }
-
- public void deSerialize( DataInputStream dataInputStream )
- throws IOException
- {
- this.id = dataInputStream.readInt();
- this.name = dataInputStream.readUTF();
- this.downloadAllUrl = dataInputStream.readUTF();
- this.updateActivityPlanUrl = dataInputStream.readUTF();
- this.uploadFacilityReportUrl = dataInputStream.readUTF();
- this.uploadActivityReportUrl = dataInputStream.readUTF();
- this.updateDataSetUrl = dataInputStream.readUTF();
- }
-
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnits.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnits.java 2010-12-08 05:45:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnits.java 2011-02-25 04:16:18 +0000
@@ -13,24 +13,24 @@
public class OrgUnits
implements DataStreamSerializable
{
- private List<OrgUnit> orgUnits = new ArrayList<OrgUnit>();
+ private List<MobileOrgUnitLinks> orgUnits = new ArrayList<MobileOrgUnitLinks>();
public OrgUnits()
{
}
- public OrgUnits( List<OrgUnit> unitList )
+ public OrgUnits( List<MobileOrgUnitLinks> unitList )
{
this.orgUnits = unitList;
}
@XmlElement( name = "orgUnit" )
- public List<OrgUnit> getOrgUnits()
+ public List<MobileOrgUnitLinks> getOrgUnits()
{
return orgUnits;
}
- public void setOrgUnits( List<OrgUnit> orgUnits )
+ public void setOrgUnits( List<MobileOrgUnitLinks> orgUnits )
{
this.orgUnits = orgUnits;
}
@@ -40,7 +40,7 @@
throws IOException
{
dataOutputStream.writeInt( orgUnits.size() );
- for ( OrgUnit unit : orgUnits )
+ for ( MobileOrgUnitLinks unit : orgUnits )
{
unit.serialize( dataOutputStream );
}
@@ -51,12 +51,12 @@
public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
- orgUnits = new ArrayList<OrgUnit>();
+ orgUnits = new ArrayList<MobileOrgUnitLinks>();
int size = dataInputStream.readInt();
for ( int i = 0; i < size; i++ )
{
- OrgUnit unit = new OrgUnit();
+ MobileOrgUnitLinks unit = new MobileOrgUnitLinks();
unit.deSerialize( dataInputStream );
orgUnits.add( unit );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-02-25 04:16:18 +0000
@@ -20,10 +20,7 @@
@Produces( MediaType.TEXT_HTML )
public String getDescription()
{
- StringBuilder sb = new StringBuilder();
-
- sb.append( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html>" );
- sb.append( "<head><title>DHIS2 Web API</title></head>\n<body>\n<h1>DHIS2 Web API</h1>\n" );
+ StringBuilder sb = Html.head( null );
sb.append( "<p><b>Warning: This API is in no way ready for public consumption. Radical changes must be expected at any time!</b></p>\n" );
@@ -31,10 +28,10 @@
sb.append( "<h2>Posting data value sets</h2>" );
sb.append( "<p>To find the needed information about the data sets you want to post data about, go to " );
- URI uri = uriInfo.getBaseUriBuilder().path( DataSetResource.class ).build();
- sb.append( "<a href=\"" ).append( uri ).append( "\">the data set list</a>.</p>" );
-
- DataValueSetResource.xmlTemplate( sb, uriInfo );
+ sb.append( "<a href=\"" ).append( "dataSets" ).append( "\">the data set list</a>.</p>" );
+ sb.append( "<p>If you don't want org units listed by data set, there is also the <a href=\"orgUnits\">full list of org units</a></p> " );
+
+ Html.xmlTemplate( sb, uriInfo );
sb.append( "<h2>Mobile GPRS API</h2>" );
sb.append( "<p>The <a href=\"mobile\">api/mobile</a> path will return a list of the currently logged in user's" );
@@ -43,7 +40,7 @@
sb.append( "<p>The url's, and their content is quite specifically tailored for the mobile client, and the serialization" );
sb.append( " format for the mobile solution is java's native data serialization, zipped. But it does send xml (and potentially json)" );
sb.append( " if you request that in your Accept header (xml would be chosen by browsers by default), so have a look if you like.</p>" );
- sb.append( "<p>If the user you are logged in as are not associated with any org unit, try going directly to one of the <a href=\"orgUnits/\">org units</a></p> " );
+ sb.append( "<p>If the user you are logged in as are not associated with any org unit, try going directly to one of the <a href=\"orgUnits\">org units</a></p> " );
sb.append( "</body>\n</html>\n" );
return sb.toString();
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-02-25 04:16:18 +0000
@@ -1,6 +1,5 @@
package org.hisp.dhis.web.api.resources;
-import java.net.URI;
import java.util.Set;
import javax.ws.rs.GET;
@@ -19,7 +18,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.springframework.beans.factory.annotation.Required;
-@Path( "dataSets" )
+@Path( "dataSets/{uuid}" )
public class DataSetResource
{
@@ -29,29 +28,7 @@
UriInfo uriInfo;
@GET
- @Produces( MediaType.TEXT_HTML )
- public String getDataSetList()
- {
- StringBuilder t = new StringBuilder();
- t.append( head( "Data sets available for reporting" ) );
-
- t.append( "<h2>Data sets available for reporting</h2>\n<ul>\n" );
- for ( DataSet dataSet : dataSetService.getAllDataSets() )
- {
- URI uri = uriInfo.getAbsolutePathBuilder().path( "{uuid}" ).build( dataSet.getUuid() );
- t.append( "<li>" ).append( "<a href=\"" ).append( uri ).append( "\">" ).append( dataSet.getName() )
- .append( "</a></li>\n" );
- }
- t.append( "</ul>" );
- DataValueSetResource.xmlTemplate( t, uriInfo );
- t.append( tail() );
-
- return t.toString();
- }
-
- @GET
- @Produces( { MediaType.APPLICATION_XML, DhisMediaType.DXF } )
- @Path( "{uuid}/dxf" )
+ @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
public org.hisp.dhis.importexport.dxf2.model.DataSet getDataSetXml( @PathParam( "uuid" ) String uuid )
{
DataSet dataSet = dataSetService.getDataSet( uuid );
@@ -60,11 +37,10 @@
{
throw new IllegalArgumentException( "No dataset with uuid " + uuid );
}
- return DataSetMapper.convert( dataSet );
+ return new DataSetMapper().convert( dataSet );
}
@GET
- @Path( "{uuid}" )
@Produces( MediaType.TEXT_HTML )
public String getDataSet( @PathParam( "uuid" ) String uuid )
{
@@ -76,12 +52,8 @@
throw new IllegalArgumentException( "No dataset with uuid " + uuid );
}
- StringBuilder t = new StringBuilder();
-
- t.append( head( "Data set " + dataSet.getName() ) );
- URI url = uriInfo.getAbsolutePathBuilder().path( "/dxf" ).build();
- t.append( "<p>(There is also a <a href=\"" ).append( url )
- .append( "\">prototype xml version</a> of this data set available)</p>\n" );
+ StringBuilder t = Html.head( "Data set " + dataSet.getName() );
+ t.append( "<p>See the <a href=\"" + uuid + ".xml\">xml version</a></p>\n" );
t.append( "<p>Uuid: " ).append( dataSet.getUuid() ).append( "<br>\n" );
t.append( "Period type: " ).append( dataSet.getPeriodType().getName() ).append( " - " )
.append( dataSet.getPeriodType().getIsoFormat() );
@@ -117,23 +89,15 @@
t.append( "</ul>" );
t.append( "<h2>Xml template</h2>\n" );
- DataValueSetResource.xmlTemplate( t, uriInfo );
- t.append( tail() );
+ Html.xmlTemplate( t, uriInfo );
+ t.append( Html.tail() );
return t.toString();
}
- private String head( String title )
- {
- return "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html><head><title>"
- + title + "</title></head>\n" + "<body>\n<h1>" + title + "</h1>\n";
- }
-
- private String tail()
- {
- return "</body>\n</html>\n";
- }
-
+
+
+
@Required
public void setDataSetService( DataSetService dataSetService )
{
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,69 @@
+package org.hisp.dhis.web.api.resources;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.importexport.dxf2.model.DataSetLinks;
+import org.hisp.dhis.importexport.dxf2.model.Link;
+import org.hisp.dhis.importexport.dxf2.model.OrgUnitLinks;
+import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
+import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
+import org.springframework.beans.factory.annotation.Required;
+
+@Path( "dataSets" )
+public class DataSetsResource
+{
+
+ private LinkBuilder linkBuilder = new LinkBuilderImpl();
+
+ private DataSetService dataSetService;
+
+ @Context
+ UriInfo uriInfo;
+
+ @GET
+ @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
+ public DataSetLinks getDataSetLinks() {
+ return new DataSetLinks( linkBuilder.getLinks( dataSetService.getAllDataSets() ) );
+ }
+
+ @GET
+ @Produces( MediaType.TEXT_HTML )
+ public String getDataSetList()
+ {
+ StringBuilder t = Html.head( "Data sets available for reporting" );
+
+ t.append( "<p>See the <a href=\"dataSets.xml\">xml version</a></p>\n" );
+ for ( DataSet dataSet : dataSetService.getAllDataSets() )
+ {
+ URI uri = uriInfo.getAbsolutePathBuilder().path( "{uuid}" ).build( dataSet.getUuid() );
+ t.append( "<li>" ).append( "<a href=\"" ).append( uri ).append( "\">" ).append( dataSet.getName() )
+ .append( "</a></li>\n" );
+ }
+ t.append( "</ul>" );
+ Html.xmlTemplate( t, uriInfo );
+ t.append( Html.tail() );
+
+ return t.toString();
+ }
+
+
+
+ @Required
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetResource.java 2011-02-18 20:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetResource.java 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import java.net.URI;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
-import org.hisp.dhis.importexport.dxf2.service.DataValueSetService;
-import org.springframework.beans.factory.annotation.Required;
-
-@Path( "dataValueSets" )
-public class DataValueSetResource
-{
-
- private DataValueSetService dataValueSetService;
-
- @Context UriInfo uriInfo;
-
- @GET
- @Produces( MediaType.TEXT_HTML )
- public String getDescription() {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html>");
- sb.append( "<head><title>DHIS2 Web API: Data value sets</title></head>\n<body>\n<h1>Data value sets</h1>\n");
- URI uri = uriInfo.getBaseUriBuilder().path( DataSetResource.class ).build( );
- sb.append( "<p>This resource is the place to post data value sets. Take a look at the <a href=\"" );
- sb.append( uri ).append( "\">data sets</a> to see what to post.." );
- xmlTemplate( sb, null );
-
- sb.append( "</body>\n</html>\n" );
-
- return sb.toString();
- }
-
- @POST
- @Consumes( MediaType.APPLICATION_XML )
- public void storeDataValueSet( DataValueSet dataValueSet )
- {
- dataValueSetService.saveDataValueSet( dataValueSet );
- }
-
- @Required
- public void setDataValueSetService( DataValueSetService dataValueSetService )
- {
- this.dataValueSetService = dataValueSetService;
- }
-
-
- public static void xmlTemplate( StringBuilder t, UriInfo uriInfo )
- {
-
- t.append( "<p>Post according to the following template" );
- if (uriInfo != null) {
- URI uri = uriInfo.getBaseUriBuilder().path( DataValueSetResource.class ).build();
- t.append( " to <a href=\"" ).append( uri ).append( "\">" ).append( uri ).append( "</a>");
- }
- t.append( ":</p>" );
-
- t.append( "<pre>" ).append( "<dataValueSet xmlns=\"http://dhis2.org/schema/dxf/2.0-SNAPSHOT\"\n" );
- t.append( " dataSet=\"dataSet UUID\" \n period=\"periodInIsoFormat\"\n orgUnit=\"unit UUID\">" );
-
- t.append( "\n <dataValue dataElement=\"data element UUID\" categoryOptionCombo=\"UUID, only specify if used\" storedBy=\"string\" value=\"value\"/>" );
- t.append( "\n</dataValueSet>" );
- t.append( "</pre>" );
- }
-
-}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,53 @@
+package org.hisp.dhis.web.api.resources;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
+import org.hisp.dhis.importexport.dxf2.service.DataValueSetService;
+import org.springframework.beans.factory.annotation.Required;
+
+@Path( "dataValueSets" )
+public class DataValueSetsResource
+{
+
+ private DataValueSetService dataValueSetService;
+
+ @Context UriInfo uriInfo;
+
+ @GET
+ @Produces( MediaType.TEXT_HTML )
+ public String getDescription() {
+ StringBuilder sb = Html.head( "Data value sets" );
+ URI uri = uriInfo.getBaseUriBuilder().path( DataSetsResource.class ).build( );
+ sb.append( "<p>This resource is the place to post data value sets. Take a look at the <a href=\"" );
+ sb.append( uri ).append( "\">data sets</a> to see what to post.." );
+ Html.xmlTemplate( sb, null );
+
+ sb.append( Html.tail() );
+
+ return sb.toString();
+ }
+
+ @POST
+ @Consumes( MediaType.APPLICATION_XML )
+ public void storeDataValueSet( DataValueSet dataValueSet )
+ {
+ dataValueSetService.saveDataValueSet( dataValueSet );
+ }
+
+ @Required
+ public void setDataValueSetService( DataValueSetService dataValueSetService )
+ {
+ this.dataValueSetService = dataValueSetService;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java 2011-02-25 04:16:18 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.web.api.resources;
+
+import java.net.URI;
+
+import javax.ws.rs.core.UriInfo;
+
+public class Html
+{
+
+ public static StringBuilder head( String title )
+ {
+ StringBuilder sb = new StringBuilder(
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html><head><title>DHIS2 Web API" );
+
+ if ( title != null )
+ {
+ sb.append( " - " ).append( title );
+ }
+
+ sb.append( "</title></head>\n<body>\n<h1>" );
+ if ( title == null )
+ {
+ sb.append( "DHIS2 Web API" );
+ }
+ else
+ {
+ sb.append( title );
+ }
+ sb.append( "</h1>\n" );
+
+ return sb;
+
+ }
+
+ public static String tail()
+ {
+ return "</body>\n</html>\n";
+ }
+
+ public static void xmlTemplate( StringBuilder t, UriInfo uriInfo )
+ {
+
+ t.append( "<p>Post according to the following template" );
+ if ( uriInfo != null )
+ {
+ URI uri = uriInfo.getBaseUriBuilder().path( DataValueSetsResource.class ).build();
+ t.append( " to <a href=\"" ).append( uri ).append( "\">" ).append( uri ).append( "</a>" );
+ }
+ t.append( ":</p>" );
+
+ t.append( "<pre>" ).append( "<dataValueSet xmlns=\"http://dhis2.org/schema/dxf/2.0-SNAPSHOT\"\n" );
+ t.append( " dataSet=\"dataSet UUID\" \n period=\"periodInIsoFormat\"\n orgUnit=\"unit UUID\">" );
+
+ t.append( "\n <dataValue dataElement=\"data element UUID\" categoryOptionCombo=\"UUID, only specify if used\" storedBy=\"string\" value=\"value\"/>" );
+ t.append( "\n</dataValueSet>" );
+ t.append( "</pre>" );
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java 2011-02-18 20:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java 2011-02-25 04:16:18 +0000
@@ -41,7 +41,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import org.hisp.dhis.web.api.model.OrgUnit;
+import org.hisp.dhis.web.api.model.MobileOrgUnitLinks;
import org.hisp.dhis.web.api.model.OrgUnits;
import org.hisp.dhis.web.api.service.NotAllowedException;
import org.springframework.beans.factory.annotation.Required;
@@ -76,7 +76,7 @@
Collection<OrganisationUnit> units = user.getOrganisationUnits();
- List<OrgUnit> unitList = new ArrayList<OrgUnit>();
+ List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
for ( OrganisationUnit unit : units )
{
unitList.add( OrgUnitResource.getOrgUnit( unit, uriInfo ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2011-02-22 23:17:50 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2011-02-25 04:16:18 +0000
@@ -45,6 +45,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.importexport.dxf2.model.OrgUnit;
+import org.hisp.dhis.importexport.dxf2.service.OrgUnitMapper;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.web.api.model.ActivityValue;
@@ -53,7 +55,7 @@
import org.hisp.dhis.web.api.model.DataSetValue;
import org.hisp.dhis.web.api.model.MobileModel;
import org.hisp.dhis.web.api.model.ModelList;
-import org.hisp.dhis.web.api.model.OrgUnit;
+import org.hisp.dhis.web.api.model.MobileOrgUnitLinks;
import org.hisp.dhis.web.api.service.ActivityReportingService;
import org.hisp.dhis.web.api.service.ActivityReportingServiceImpl;
import org.hisp.dhis.web.api.service.FacilityReportingService;
@@ -67,7 +69,7 @@
public class OrgUnitResource
{
private OrganisationUnitService organisationUnitService;
-
+
private static Log log = LogFactory.getLog( ActivityReportingServiceImpl.class );
private static final boolean DEBUG = log.isDebugEnabled();
@@ -78,19 +80,36 @@
private FacilityReportingService facilityReportingService;
- @PathParam( "id" ) private int id;
-
- @Context UriInfo uriInfo;
-
- private OrganisationUnit getUnit() {
- return organisationUnitService.getOrganisationUnit( id );
+ @PathParam( "id" )
+ private String id;
+
+ @Context
+ UriInfo uriInfo;
+
+ private OrganisationUnit getUnit()
+ {
+ try
+ {
+ return organisationUnitService.getOrganisationUnit( Integer.parseInt( id ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ return organisationUnitService.getOrganisationUnit( id );
+ }
}
-
+
@GET
- public OrgUnit getOrgUnit() {
- return OrgUnitResource.getOrgUnit( getUnit(), uriInfo );
+ @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
+ public OrgUnit getOrgUnit()
+ {
+ OrganisationUnit unit = getUnit();
+
+ if (unit == null)
+ return null;
+
+ return new OrgUnitMapper().get( unit );
}
-
+
/**
* Get activity plan, program forms and facility forms wrapped in a
* {@link MobileModel}
@@ -168,7 +187,7 @@
updatedDataSetList.getModifiedDataSets().add( dataSets.get( i ) );
}
}
-
+
if ( DEBUG )
log.debug( "Returning updated datasets for org unit " + getUnit().getName() );
@@ -210,37 +229,34 @@
{
MobileModel model = new MobileModel();
model.setPrograms( programService.updateProgram( programsFromClient, locale, getUnit() ) );
- model.setActivityPlan(activityReportingService.getCurrentActivityPlan( getUnit(), locale ));
+ model.setActivityPlan( activityReportingService.getCurrentActivityPlan( getUnit(), locale ) );
return model;
}
- public static OrgUnit getOrgUnit( OrganisationUnit unit, UriInfo uriInfo )
+ public static MobileOrgUnitLinks getOrgUnit( OrganisationUnit unit, UriInfo uriInfo )
{
- OrgUnit orgUnit = new OrgUnit();
+ MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
orgUnit.setId( unit.getId() );
orgUnit.setName( unit.getShortName() );
- orgUnit.setDownloadAllUrl( getOrgUnitUrlBuilder(uriInfo).path( "all" )
- .build( unit.getId() ).toString() );
- orgUnit.setUpdateActivityPlanUrl( getOrgUnitUrlBuilder(uriInfo).path( "activitiyplan" )
- .build( unit.getId() ).toString() );
- orgUnit.setUploadFacilityReportUrl( getOrgUnitUrlBuilder(uriInfo).path( "dataSets" )
- .build( unit.getId() ).toString() );
- orgUnit.setUploadActivityReportUrl( getOrgUnitUrlBuilder(uriInfo).path( "activities" )
- .build( unit.getId() ).toString() );
- orgUnit.setUpdateDataSetUrl( getOrgUnitUrlBuilder(uriInfo).path( "updateDataSets" )
- .build( unit.getId() ).toString() );
+ orgUnit.setDownloadAllUrl( getOrgUnitUrlBuilder( uriInfo ).path( "all" ).build( unit.getId() ).toString() );
+ orgUnit.setUpdateActivityPlanUrl( getOrgUnitUrlBuilder( uriInfo ).path( "activitiyplan" ).build( unit.getId() )
+ .toString() );
+ orgUnit.setUploadFacilityReportUrl( getOrgUnitUrlBuilder( uriInfo ).path( "dataSets" ).build( unit.getId() )
+ .toString() );
+ orgUnit.setUploadActivityReportUrl( getOrgUnitUrlBuilder( uriInfo ).path( "activities" ).build( unit.getId() )
+ .toString() );
+ orgUnit.setUpdateDataSetUrl( getOrgUnitUrlBuilder( uriInfo ).path( "updateDataSets" ).build( unit.getId() )
+ .toString() );
return orgUnit;
}
- private static UriBuilder getOrgUnitUrlBuilder(UriInfo uriInfo)
+ private static UriBuilder getOrgUnitUrlBuilder( UriInfo uriInfo )
{
return uriInfo.getBaseUriBuilder().path( "/orgUnits/{id}" );
}
-
-
@Required
public void setProgramService( IProgramService programService )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-02-18 20:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-02-25 04:16:18 +0000
@@ -5,6 +5,9 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import org.hisp.dhis.importexport.dxf2.model.OrgUnitLinks;
+import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
+import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.springframework.web.util.HtmlUtils;
@@ -14,20 +17,29 @@
{
private OrganisationUnitService organisationUnitService;
+ private LinkBuilder linkBuilder = new LinkBuilderImpl();
+
+ @GET
+ @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
+ public OrgUnitLinks getOrgUnits()
+ {
+ return new OrgUnitLinks( linkBuilder.getLinks( organisationUnitService.getAllOrganisationUnits() ) );
+ }
+
@GET
@Produces( MediaType.TEXT_HTML )
- public String getOrgUnits()
+ public String getOrgUnitsHtml()
{
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = Html.head( "Org units" );
- sb.append( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html>" );
- sb.append( "<head><title>DHIS2 Web API: Org units</title></head>\n<body>\n<h1>Data value sets</h1>\n<ul>" );
+ sb.append( "<p>See the <a href=\"orgUnits.xml\">xml version</a></p>\n" );
+ sb.append( "<ul>" );
for ( OrganisationUnit unit : organisationUnitService.getAllOrganisationUnits() )
{
- sb.append( "<li><a href=\"" ).append( unit.getId() ).append( "/\">" );
- sb.append( HtmlUtils.htmlEscape( unit.getName()) ).append( "</a></li>" );
+ sb.append( "<li><a href=\"orgUnits/" ).append( unit.getId() ).append( "\">" );
+ sb.append( HtmlUtils.htmlEscape( unit.getName() ) ).append( "</a></li>" );
}
sb.append( "</ul></body>\n</html>\n" );
@@ -39,6 +51,5 @@
{
this.organisationUnitService = organisationUnitService;
}
-
-
+
}
=== 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-02-21 10:32:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-02-25 04:16:18 +0000
@@ -7,12 +7,17 @@
<bean id="org.hisp.dhis.web.api.resources.ApiResource" class="org.hisp.dhis.web.api.resources.ApiResource" />
+ <bean id="org.hisp.dhis.web.api.resources.DataSetsResource" class="org.hisp.dhis.web.api.resources.DataSetsResource"
+ scope="prototype">
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ </bean>
+
<bean id="org.hisp.dhis.web.api.resources.DataSetResource" class="org.hisp.dhis.web.api.resources.DataSetResource"
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
- <bean id="org.hisp.dhis.web.api.resources.DataValueSetResource" class="org.hisp.dhis.web.api.resources.DataValueSetResource">
+ <bean id="org.hisp.dhis.web.api.resources.DataValueSetResource" class="org.hisp.dhis.web.api.resources.DataValueSetsResource">
<property name="dataValueSetService" ref="org.hisp.dhis.importexport.dxf2.service.DataValueSetService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml 2011-02-21 10:32:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml 2011-02-25 04:16:18 +0000
@@ -2,102 +2,100 @@
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
- <display-name>DHIS Case Entry</display-name>
-
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath*:/META-INF/dhis/beans.xml</param-value>
- </context-param>
- <context-param>
- <param-name>automaticAccessType</param-name>
- <param-value>ghostAdmin</param-value>
- </context-param>
-
- <filter>
- <filter-name>RedirectFilter</filter-name>
- <filter-class>
- org.hisp.dhis.servlet.filter.HttpRedirectFilter</filter-class>
- <init-param>
- <param-name>redirectPath</param-name>
- <param-value>api/</param-value>
- </init-param>
- </filter>
- <filter>
- <filter-name>OpenSessionInViewFilter</filter-name>
- <filter-class>
- org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
- </filter>
- <filter>
- <filter-name>filterChainProxy</filter-name>
- <filter-class>
- org.springframework.web.filter.DelegatingFilterProxy</filter-class>
- </filter>
-
- <filter>
- <filter-name>Struts</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>RedirectFilter</filter-name>
- <url-pattern>/</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>OpenSessionInViewFilter</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>OpenSessionInViewFilter</filter-name>
- <url-pattern>/api/*</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>filterChainProxy</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>Struts</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
-
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <listener>
- <listener-class>
- org.hisp.dhis.system.startup.StartupListener</listener-class>
- </listener>
-
- <servlet>
- <servlet-name>web-api</servlet-name>
- <servlet-class>
- com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
- <init-param>
- <param-name>
- com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
- <param-value>
- com.sun.jersey.api.container.filter.LoggingFilter</param-value>
- </init-param>
- <init-param>
- <param-name>
- com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
- <param-value>
- com.sun.jersey.api.container.filter.LoggingFilter</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.feature.Trace</param-name>
- <param-value>true</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>web-api</servlet-name>
- <url-pattern>/api/*</url-pattern>
- </servlet-mapping>
+ <display-name>DHIS Case Entry</display-name>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath*:/META-INF/dhis/beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>automaticAccessType</param-name>
+ <param-value>ghostAdmin</param-value>
+ </context-param>
+
+ <filter>
+ <filter-name>RedirectFilter</filter-name>
+ <filter-class>
+ org.hisp.dhis.servlet.filter.HttpRedirectFilter</filter-class>
+ <init-param>
+ <param-name>redirectPath</param-name>
+ <param-value>api/</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>OpenSessionInViewFilter</filter-name>
+ <filter-class>
+ org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
+ </filter>
+ <filter>
+ <filter-name>filterChainProxy</filter-name>
+ <filter-class>
+ org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+ </filter>
+
+ <filter>
+ <filter-name>Struts</filter-name>
+ <filter-class>
+ org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>RedirectFilter</filter-name>
+ <url-pattern>/</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>OpenSessionInViewFilter</filter-name>
+ <url-pattern>*.action</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>OpenSessionInViewFilter</filter-name>
+ <url-pattern>/api/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>filterChainProxy</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>Struts</filter-name>
+ <url-pattern>*.action</url-pattern>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <listener>
+ <listener-class>
+ org.hisp.dhis.system.startup.StartupListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>web-api</servlet-name>
+ <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.hisp.dhis.web.api.resources</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
+ <param-value>
+ com.sun.jersey.api.container.filter.LoggingFilter, org.hisp.dhis.web.api.HtmlPromotingUriConnegFilter</param-value>
+ </init-param>
+<!-- <init-param>-->
+<!-- <param-name>-->
+<!-- com.sun.jersey.spi.container.ContainerResponseFilters</param-name>-->
+<!-- <param-value>-->
+<!-- com.sun.jersey.api.container.filter.LoggingFilter</param-value>-->
+<!-- </init-param>-->
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>web-api</servlet-name>
+ <url-pattern>/api/*</url-pattern>
+ </servlet-mapping>
<servlet-mapping>
<servlet-name>web-api</servlet-name>
<url-pattern>/api</url-pattern>
</servlet-mapping>
-
+
</web-app>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitTest.java'
--- dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitTest.java 2011-02-21 06:51:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitTest.java 2011-02-25 04:16:18 +0000
@@ -44,7 +44,7 @@
public void testSerialization()
throws IOException
{
- OrgUnit unit = new OrgUnit();
+ MobileOrgUnitLinks unit = new MobileOrgUnitLinks();
unit.setId( 1 );
unit.setName( "name" );
unit.setUpdateActivityPlanUrl("updateActivityPlanUrl");
@@ -57,7 +57,7 @@
DataOutputStream dos = new DataOutputStream( baos );
unit.serialize( dos );
dos.flush();
- OrgUnit unit2 = new OrgUnit();
+ MobileOrgUnitLinks unit2 = new MobileOrgUnitLinks();
unit2.deSerialize( new DataInputStream( new ByteArrayInputStream( baos.toByteArray() ) ) );
assertEquals( unit.getName(), unit2.getName() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitsTest.java'
--- dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitsTest.java 2011-02-21 06:51:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/OrgUnitsTest.java 2011-02-25 04:16:18 +0000
@@ -37,7 +37,7 @@
import java.util.Arrays;
import java.util.List;
-import org.hisp.dhis.web.api.model.OrgUnit;
+import org.hisp.dhis.web.api.model.MobileOrgUnitLinks;
import org.hisp.dhis.web.api.model.OrgUnits;
import org.junit.Test;
@@ -48,29 +48,29 @@
public void testSerialization()
throws IOException
{
- OrgUnit unit = createOrgUnit();
+ MobileOrgUnitLinks unit = createOrgUnit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream( baos );
OrgUnits units = new OrgUnits();
- units.setOrgUnits( Arrays.asList( new OrgUnit[] { unit } ) );
+ units.setOrgUnits( Arrays.asList( new MobileOrgUnitLinks[] { unit } ) );
units.serialize( dos );
dos.flush();
OrgUnits units2 = new OrgUnits();
units2.deSerialize( new DataInputStream( new ByteArrayInputStream( baos.toByteArray() ) ) );
- List<OrgUnit> unitList = units2.getOrgUnits();
+ List<MobileOrgUnitLinks> unitList = units2.getOrgUnits();
assertEquals( 1, unitList.size() );
- OrgUnit unit2 = unitList.get( 0 );
+ MobileOrgUnitLinks unit2 = unitList.get( 0 );
assertEquals( unit.getName(), unit2.getName() );
assertEquals( unit.getId(), unit2.getId() );
}
- private OrgUnit createOrgUnit()
+ private MobileOrgUnitLinks createOrgUnit()
{
- OrgUnit unit = new OrgUnit();
+ MobileOrgUnitLinks unit = new MobileOrgUnitLinks();
unit.setId( 1 );
unit.setName( "name" );
unit.setUpdateActivityPlanUrl("updateActivityPlanUrl");
=== modified file 'dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml'
--- dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2011-02-18 20:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2011-02-25 04:16:18 +0000
@@ -67,6 +67,14 @@
<servlet>
<servlet-name>web-api</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.hisp.dhis.web.api.resources</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
+ <param-value>org.hisp.dhis.web.api.HtmlPromotingUriConnegFilter</param-value>
+ </init-param>
<load-on-startup>1</load-on-startup>
</servlet>