dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24262
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11856: Added new parameter to programController (type), added filtering on some new properties in Progra...
------------------------------------------------------------
revno: 11856
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-02 10:27:33 +0200
message:
Added new parameter to programController (type), added filtering on some new properties in Program. Minor fixes to even export UI.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-09-02 08:27:33 +0000
@@ -66,7 +66,7 @@
*/
private static final long serialVersionUID = -2581751965520009382L;
- public static final List<String> TYPE_LOOKUP = Arrays.asList("",
+ public static final List<String> TYPE_LOOKUP = Arrays.asList( "",
"MULTIPLE_EVENTS_WITH_REGISTRATION", "SINGLE_EVENT_WITH_REGISTRATION", "SINGLE_EVENT_WITHOUT_REGISTRATION" );
public static final int MULTIPLE_EVENTS_WITH_REGISTRATION = 1;
@@ -261,7 +261,7 @@
throw new RuntimeException( ex );
}
}
-
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -389,8 +389,14 @@
}
@JsonProperty
- @JsonView({ DetailedView.class, ExportView.class })
- @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getKind()
+ {
+ return TYPE_LOOKUP.get( type );
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Integer getType()
{
return type;
@@ -539,6 +545,7 @@
}
@JsonProperty
+ @JsonView({ DetailedView.class, ExportView.class })
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Boolean getOnlyEnrollOnce()
{
@@ -590,6 +597,7 @@
}
@JsonProperty
+ @JsonView({ DetailedView.class, ExportView.class })
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Boolean getUseBirthDateAsIncidentDate()
{
@@ -602,6 +610,7 @@
}
@JsonProperty
+ @JsonView({ DetailedView.class, ExportView.class })
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public Boolean getUseBirthDateAsEnrollmentDate()
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java 2013-09-02 08:27:33 +0000
@@ -29,17 +29,80 @@
*/
import org.hisp.dhis.api.controller.AbstractCrudController;
+import org.hisp.dhis.api.controller.WebMetaData;
+import org.hisp.dhis.api.controller.WebOptions;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = ProgramController.RESOURCE_PATH )
+@RequestMapping(value = ProgramController.RESOURCE_PATH)
public class ProgramController
extends AbstractCrudController<Program>
{
public static final String RESOURCE_PATH = "/programs";
+
+ @Autowired
+ private ProgramService programService;
+
+ protected List<Program> getEntityList( WebMetaData metaData, WebOptions options )
+ {
+ List<Program> entityList;
+
+ Date lastUpdated = options.getLastUpdated();
+
+ if ( lastUpdated != null )
+ {
+ entityList = new ArrayList<Program>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );
+ }
+ else if ( options.hasPaging() )
+ {
+ int count = manager.getCount( getEntityClass() );
+
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
+ metaData.setPager( pager );
+
+ entityList = new ArrayList<Program>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
+ }
+ else
+ {
+ entityList = new ArrayList<Program>( manager.getAllSorted( getEntityClass() ) );
+ }
+
+ if ( options.getOptions().get( "type" ) != null )
+ {
+ try
+ {
+ int type = Integer.parseInt( options.getOptions().get( "type" ) );
+
+ Iterator<Program> iterator = entityList.iterator();
+
+ while ( iterator.hasNext() )
+ {
+ Program program = iterator.next();
+
+ if ( program.getType() != type )
+ {
+ iterator.remove();
+ }
+ }
+ }
+ catch ( NumberFormatException ignored )
+ {
+ }
+ }
+
+ return entityList;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2013-08-29 11:59:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2013-09-02 08:27:33 +0000
@@ -297,6 +297,13 @@
pdf_data_import=PDF Data Import
event_data_import=Event Data Import
event_data_export=Event Data Export
+programs=Programs
+format=Format
+compression=Compression
+compression_gzip=Gzip
+compression_zip=Zip
+uncompressed=Uncompressed
+no_programs_available=No programs available
no_data_values_found=No data values found
create_new_route=Create new route
integration=Integration
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm 2013-08-29 11:59:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/eventExportForm.vm 2013-09-02 08:27:33 +0000
@@ -1,2 +1,79 @@
+<script>
+$( function() {
+ $( '#submit' ).on( 'click', function() {
+ var format = $( '#format' ).val();
+ var program = $( '#programs' ).val();
+ var url = '../api/events' + format + "?program=" + program;
+
+ window.location = url;
+ console.log(url);
+ });
+
+ $.ajax({
+ url: '../api/programs.json',
+ data: {
+ type: 3
+ }
+ } ).done(function(data) {
+ var options = [];
+
+ $.each(data.programs, function(idx, item) {
+ var option = $( '<option/>' ).html( item.name ).val(item.id);
+ options.push( option );
+ });
+
+ if(options.length > 0) {
+ $( '#programs' ).removeAttr('disabled');
+ } else {
+ var option = $( '<option/>' ).html('$i18n.getString( "no_programs_available" )');
+ $( '#programs' ).attr('disabled', true);
+ }
+
+ $( '#programs' ).html( options );
+ });
+});
+</script>
<h3>$i18n.getString( "event_data_export" )</h3>
+
+<div id="inputCriteria" class="inputCriteria" style="width: 480px;">
+<form id="importForm" name="importForm" method="post" enctype="multipart/form-data" action="importMetaData.action">
+<table>
+<col width="140">
+<col>
+<tr>
+ <td>$i18n.getString( "programs" )</td>
+ <td><select disabled="disabled" style="width: 300px;" id="programs" name="programs">
+ <option>$i18n.getString( "no_programs_available" )</option>
+ </select>
+ </td>
+</tr>
+
+<tr>
+ <td>$i18n.getString( "compression" )</td>
+ <td>
+ <select disabled="disabled" id="compression" style="width: 300px;">
+ <option value="">$i18n.getString( "uncompressed" )</option>
+ <option value=".zip">$i18n.getString( "compression_zip" )</option>
+ <option value=".gz">$i18n.getString( "compression_gzip" )</option>
+ </select>
+ </td>
+</tr>
+
+<tr>
+ <td>$i18n.getString( "format" )</td>
+ <td>
+ <select id="format" style="width: 300px;">
+ <option value=".xml">XML</option>
+ <option value=".json">Json</option>
+ </select>
+ </td>
+</tr>
+
+<tr>
+ <td></td>
+ <td><input type="button" id="submit" value="$i18n.getString( 'export' )" style="width:120px" /></td>
+</tr>
+</table>
+</form>
+</div>