=== 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-25 04:16:18 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2011-02-25 07:08:59 +0000 @@ -136,62 +136,7 @@ @Path( "updateDataSets" ) public DataSetList checkUpdatedDataSet( DataSetList dataSetList, @HeaderParam( "accept-language" ) String locale ) { - if ( DEBUG ) - log.debug( "Checking updated datasets for org unit " + getUnit().getName() ); - DataSetList updatedDataSetList = new DataSetList(); - List dataSets = facilityReportingService.getMobileDataSetsForUnit( getUnit(), locale ); - List currentDataSets = dataSetList.getCurrentDataSets(); - // List copyCurrentDataSets = new - // ArrayList(currentDataSets.size()); - // Collections.copy( copyCurrentDataSets, currentDataSets ); - // check added dataset - for ( DataSet dataSet : dataSets ) - { - if ( !currentDataSets.contains( dataSet ) ) - { - if ( updatedDataSetList.getAddedDataSets() == null ) - updatedDataSetList.setAddedDataSets( new ArrayList() ); - updatedDataSetList.getAddedDataSets().add( dataSet ); - currentDataSets.add( dataSet ); - } - } - - // check deleted dataset - for ( DataSet dataSet : currentDataSets ) - { - if ( !dataSets.contains( dataSet ) ) - { - if ( updatedDataSetList.getDeletedDataSets() == null ) - updatedDataSetList.setDeletedDataSets( new ArrayList() ); - updatedDataSetList.getDeletedDataSets().add( new DataSet( dataSet ) ); - } - } - if ( updatedDataSetList.getDeletedDataSets() != null ) - { - for ( DataSet dataSet : updatedDataSetList.getDeletedDataSets() ) - { - currentDataSets.remove( dataSet ); - } - } - - // check modified dataset - Collections.sort( dataSets ); - Collections.sort( currentDataSets ); - - for ( int i = 0; i < dataSets.size(); i++ ) - { - if ( dataSets.get( i ).getVersion() != currentDataSets.get( i ).getVersion() ) - { - if ( updatedDataSetList.getModifiedDataSets() == null ) - updatedDataSetList.setModifiedDataSets( new ArrayList() ); - updatedDataSetList.getModifiedDataSets().add( dataSets.get( i ) ); - } - } - - if ( DEBUG ) - log.debug( "Returning updated datasets for org unit " + getUnit().getName() ); - - return updatedDataSetList; + return facilityReportingService.getUpdatedDataSet( dataSetList, getUnit(), locale ); } /** === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java 2011-01-17 06:28:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java 2011-02-25 07:08:59 +0000 @@ -32,6 +32,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.web.api.model.DataSet; +import org.hisp.dhis.web.api.model.DataSetList; import org.hisp.dhis.web.api.model.DataSetValue; public interface FacilityReportingService @@ -48,5 +49,7 @@ */ public void saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue ) throws NotAllowedException; + + public DataSetList getUpdatedDataSet(DataSetList dataSetList, OrganisationUnit unit, String locale); } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java 2011-01-19 11:38:59 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java 2011-02-25 07:08:59 +0000 @@ -55,6 +55,7 @@ import org.hisp.dhis.period.YearlyPeriodType; import org.hisp.dhis.web.api.model.DataElement; import org.hisp.dhis.web.api.model.DataSet; +import org.hisp.dhis.web.api.model.DataSetList; import org.hisp.dhis.web.api.model.DataSetValue; import org.hisp.dhis.web.api.model.DataValue; import org.hisp.dhis.web.api.model.Section; @@ -126,6 +127,64 @@ return datasets; } + public DataSetList getUpdatedDataSet( DataSetList dataSetList, OrganisationUnit unit, String locale ) + { + if ( DEBUG ) + log.debug( "Checking updated datasets for org unit " + unit.getName() ); + DataSetList updatedDataSetList = new DataSetList(); + List dataSets = this.getMobileDataSetsForUnit( unit, locale ); + List currentDataSets = dataSetList.getCurrentDataSets(); + + // check added dataset + for ( DataSet dataSet : dataSets ) + { + if ( !currentDataSets.contains( dataSet ) ) + { + if ( updatedDataSetList.getAddedDataSets() == null ) + updatedDataSetList.setAddedDataSets( new ArrayList() ); + updatedDataSetList.getAddedDataSets().add( dataSet ); + currentDataSets.add( dataSet ); + } + } + + // check deleted dataset + for ( DataSet dataSet : currentDataSets ) + { + if ( !dataSets.contains( dataSet ) ) + { + if ( updatedDataSetList.getDeletedDataSets() == null ) + updatedDataSetList.setDeletedDataSets( new ArrayList() ); + updatedDataSetList.getDeletedDataSets().add( new DataSet( dataSet ) ); + } + } + if ( updatedDataSetList.getDeletedDataSets() != null ) + { + for ( DataSet dataSet : updatedDataSetList.getDeletedDataSets() ) + { + currentDataSets.remove( dataSet ); + } + } + + // check modified dataset + Collections.sort( dataSets ); + Collections.sort( currentDataSets ); + + for ( int i = 0; i < dataSets.size(); i++ ) + { + if ( dataSets.get( i ).getVersion() != currentDataSets.get( i ).getVersion() ) + { + if ( updatedDataSetList.getModifiedDataSets() == null ) + updatedDataSetList.setModifiedDataSets( new ArrayList() ); + updatedDataSetList.getModifiedDataSets().add( dataSets.get( i ) ); + } + } + + if ( DEBUG ) + log.debug( "Returning updated datasets for org unit " + unit.getName() ); + + return updatedDataSetList; + } + public DataSet getDataSetForLocale( int dataSetId, Locale locale ) { org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetId ); @@ -242,19 +301,20 @@ continue; } - saveValue(unit, period, dataElement, dataValue); + saveValue( unit, period, dataElement, dataValue ); } - - CompleteDataSetRegistration registration = - registrationService.getCompleteDataSetRegistration( dataSet, period, unit ); - - if (registration != null) { + + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, + unit ); + + if ( registration != null ) + { registrationService.deleteCompleteDataSetRegistration( registration ); } - + registration = new CompleteDataSetRegistration(); - + registration.setDataSet( dataSet ); registration.setPeriod( period ); registration.setSource( unit ); @@ -281,20 +341,22 @@ return dataSetService.getDataSetsBySource( unit ).contains( dataSet ); } - private void saveValue(OrganisationUnit unit, Period period, org.hisp.dhis.dataelement.DataElement dataElement, DataValue dv) { + private void saveValue( OrganisationUnit unit, Period period, org.hisp.dhis.dataelement.DataElement dataElement, + DataValue dv ) + { String value = dv.getValue().trim(); DataElementCategoryOptionCombo cateOptCombo = categoryService.getDataElementCategoryOptionCombo( dv .getCategoryOptComboID() ); - org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( unit, dataElement, - period, cateOptCombo ); + org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, + cateOptCombo ); if ( dataValue == null ) { - dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, unit, value, "", - new Date(), "", cateOptCombo ); + dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, unit, value, "", new Date(), "", + cateOptCombo ); dataValueService.addDataValue( dataValue ); } else @@ -305,7 +367,7 @@ } } - + // ------------------------------------------------------------------------- // Supportive method // ------------------------------------------------------------------------- @@ -394,5 +456,4 @@ this.registrationService = registrationService; } - } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java 2011-02-25 07:08:59 +0000 @@ -0,0 +1,72 @@ +package org.hisp.dhis.dataset.action; + +import java.util.Collection; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; + +import com.opensymphony.xwork2.Action; + +public class MobileDataSetListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Getters and Setters + // ------------------------------------------------------------------------- + private Collection dataSets; + + public void setDataSets( Collection dataSets ) + { + this.dataSets = dataSets; + } + + public Collection getDataSets() + { + return dataSets; + } + + private Collection mobileDatasets; + + public Collection getMobileDatasets() + { + return mobileDatasets; + } + + public void setMobileDatasets( Collection mobileDatasets ) + { + this.mobileDatasets = mobileDatasets; + } + + @Override + public String execute() + throws Exception + { + OrganisationUnit selectedUnits = selectionManager.getSelectedOrganisationUnit(); + dataSets = dataSetService.getDataSetsBySource( selectedUnits ); + mobileDatasets = dataSetService.getDataSetsForMobile( selectedUnits ); + dataSets.removeAll( mobileDatasets ); + System.out.println("Number of datasets:"+ dataSets.size()); + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java 2011-02-25 07:08:59 +0000 @@ -0,0 +1,70 @@ +package org.hisp.dhis.dataset.action; + +import java.util.Collection; +import java.util.HashSet; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; + +import com.opensymphony.xwork2.Action; + +public class UpdateMobileDataSetAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + private Collection selectedList = new HashSet(); + + public void setSelectedList( Collection selectedList ) + { + this.selectedList = selectedList; + } + + private Collection availableList = new HashSet(); + + public void setAvailableList( Collection availableList ) + { + this.availableList = availableList; + } + + @Override + public String execute() + throws Exception + { + try{ + DataSet dataset = null; + for(String id : selectedList){ + dataset = dataSetService.getDataSet( Integer.parseInt( id ) ); + if(!dataset.isMobile()){ + System.out.println("set dataset "+ dataset.getName()+" to true"); + dataset.setMobile( true ); + dataSetService.updateDataSet( dataset ); + } + } + for(String id : availableList){ + dataset = dataSetService.getDataSet( Integer.parseInt( id ) ); + if(dataset.isMobile()){ + System.out.println("set dataset "+ dataset.getName()+" to false"); + dataset.setMobile( false ); + dataSetService.updateDataSet( dataset ); + } + } + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-01-25 22:15:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-02-25 07:08:59 +0000 @@ -136,7 +136,26 @@ - + + + + + + + + + + + + + + + + + + /main.vm + /dhis-web-maintenance-dataset/mobileDatasetList.vm + /dhis-web-maintenance-dataset/menuWithTree.vm + 300 + + ../dhis-web-commons/ouwt/ouwt.js,javascript/organisationUnit.js,javascript/mobiledataset.js + + + + + + showMobileDataSet.action + + /main.vm /dhis-web-maintenance-dataset/dataSetList.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/index.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/index.vm 2011-01-11 17:14:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/index.vm 2011-02-25 07:08:59 +0000 @@ -5,4 +5,5 @@ #introListImgItem( "dataSet.action" "dataset" "dataset" ) #introListImgItem( "section.action" "dataset_section" "dataset" ) #introListImgItem( "showAssignMultiDataSetForOrgunitForm.action" "dataset_assignment_editor" "dataset" ) + #introListImgItem( "showMobileDataSet.action" "mobile_dataset" "dataset" ) \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/mobiledataset.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/mobiledataset.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/mobiledataset.js 2011-02-25 07:08:59 +0000 @@ -0,0 +1,3 @@ +function orgunitselected(){ + window.location.reload(true) +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menu.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menu.vm 2011-01-11 17:04:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menu.vm 2011-02-25 07:08:59 +0000 @@ -4,4 +4,5 @@
  • $i18n.getString( "dataset" ) 
  • $i18n.getString( "dataset_section" ) 
  • $i18n.getString( "dataset_assignment_editor" ) 
  • +
  • $i18n.getString( "mobile_dataset" ) 
  • \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menuWithTree.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menuWithTree.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/menuWithTree.vm 2011-02-25 07:08:59 +0000 @@ -0,0 +1,5 @@ +#parse( "/dhis-web-maintenance-dataset/menu.vm" ) +#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" ) + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm 2011-02-25 07:08:59 +0000 @@ -0,0 +1,49 @@ +
    + + ## Available DataSet of selected Organisation Unit + ## Filter + ## Mobile DataSet of selected Organisation Unit + + + + + + + + + + + + + + + + + + + +
    $i18n.getString( "available_datasets" )$i18n.getString( "filter" )$i18n.getString( "mobile_dataset" )
    + + +
    +
    +
    + +
    + + + +

    +

    +
    + +
    +
    \ No newline at end of file