dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32316
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16488: Web api, dataValueSets, optimized how org units are being retrieved
------------------------------------------------------------
revno: 16488
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-08-24 17:45:25 +0200
message:
Web api, dataValueSets, optimized how org units are being retrieved
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java 2014-08-24 15:38:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java 2014-08-24 15:45:25 +0000
@@ -28,10 +28,27 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_CSV;
+import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_JSON;
+import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_XML;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.IdentifiableObjectUtils;
-import org.hisp.dhis.dxf2.datavalueset.DataValueSet;
import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
@@ -39,7 +56,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.view.ClassPathUriResolver;
-import org.hisp.dhis.webapi.webdomain.DataValueSets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.format.annotation.DateTimeFormat;
@@ -51,23 +67,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hisp.dhis.webapi.utils.ContextUtils.*;
-
@Controller
@RequestMapping( value = DataValueSetController.RESOURCE_PATH )
public class DataValueSetController
@@ -113,10 +112,8 @@
else
{
log.info( "Get XML bulk data value set for start date: " + startDate + ", end date: " + endDate );
-
- Set<String> ous = getOrganisationUnits( orgUnit, children );
- dataValueSetService.writeDataValueSetXml( dataSet, startDate, endDate, ous, false, response.getOutputStream() );
+ dataValueSetService.writeDataValueSetXml( dataSet, startDate, endDate, orgUnit, children, response.getOutputStream() );
}
}
@@ -146,10 +143,8 @@
else
{
log.info( "Get JSON bulk data value set for start date: " + startDate + ", end date: " + endDate );
-
- Set<String> ous = getOrganisationUnits( orgUnit, children );
- dataValueSetService.writeDataValueSetJson( dataSet, startDate, endDate, ous, false, response.getOutputStream() );
+ dataValueSetService.writeDataValueSetJson( dataSet, startDate, endDate, orgUnit, children, response.getOutputStream() );
}
}
@@ -164,27 +159,9 @@
{
log.info( "Get CSV bulk data value set for start date: " + startDate + ", end date: " + endDate );
- Set<String> ous = getOrganisationUnits( orgUnit, children );
-
response.setContentType( CONTENT_TYPE_CSV );
- dataValueSetService.writeDataValueSetCsv( dataSet, startDate, endDate, ous, false, response.getWriter() );
- }
-
- private Set<String> getOrganisationUnits( Set<String> orgUnits, boolean children )
- {
- Set<String> ous = new HashSet<>();
-
- if ( children )
- {
- for ( String ou : orgUnits )
- {
- ous.addAll( IdentifiableObjectUtils.getUids( organisationUnitService.getOrganisationUnitsWithChildren( ou ) ) );
- }
- }
-
- ous.addAll( orgUnits );
-
- return ous;
+
+ dataValueSetService.writeDataValueSetCsv( dataSet, startDate, endDate, orgUnit, children, response.getWriter() );
}
// -------------------------------------------------------------------------