=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2010-09-24 11:12:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2010-11-01 06:32:22 +0000 @@ -197,7 +197,7 @@ /** * Returns all DataSets that can be collected through mobile. */ - Collection getDataSetsForMobile(); + Collection getDataSetsForMobile(Source source); // ------------------------------------------------------------------------- // FrequencyOverrideAssociation === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2010-10-22 06:50:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2010-11-01 06:32:22 +0000 @@ -118,7 +118,7 @@ /** * Returns all DataSets that can be collected through mobile. */ - Collection getDataSetsForMobile(); + Collection getDataSetsForMobile(Source source); Collection getDataSetsBySources( Collection sources ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2010-10-22 06:52:16 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2010-11-01 06:32:22 +0000 @@ -275,9 +275,9 @@ return i18n( i18nService, dataSet.getDataElements() ); } - public Collection getDataSetsForMobile() + public Collection getDataSetsForMobile(Source source) { - return i18n( i18nService, dataSetStore.getDataSetsForMobile() ); + return i18n( i18nService, dataSetStore.getDataSetsForMobile(source) ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2010-10-29 12:19:15 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2010-11-01 06:32:22 +0000 @@ -41,6 +41,7 @@ import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.source.Source; import org.hisp.dhis.system.util.ConversionUtils; +import org.springframework.beans.factory.annotation.Autowired; /** * @author Kristian Nordal @@ -178,14 +179,14 @@ } @SuppressWarnings( "unchecked" ) - public Collection getDataSetsForMobile() { - - Session session = sessionFactory.getCurrentSession(); - - Criteria criteria = session.createCriteria( DataSet.class ); - criteria.add( Restrictions.eq( "mobile", true ) ); - - return criteria.list(); + public Collection getDataSetsForMobile(Source source) { + System.out.println("received Source: "+source.getName()); + String hql = "from DataSet d where :source in elements(d.sources) and d.mobile = true"; + Query query = sessionFactory.getCurrentSession().createQuery( hql ); + query.setEntity( "source", source ); + + return query.list(); + } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java 2010-10-28 09:17:13 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java 2010-11-01 06:32:22 +0000 @@ -56,28 +56,22 @@ for(int i=0; i atts = b.getPatientAttValues(); dout.writeInt( atts.size() ); for(String att : atts){ dout.writeUTF( att ); } - System.out.println("add task"); Task t = activity.getTask(); dout.writeInt(t.getId()); dout.writeInt(t.getProgramStageId()); dout.writeBoolean(t.isCompleted()); } } - bout.flush(); bout.writeTo(out); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSet.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSet.java 2010-10-29 12:19:15 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSet.java 2010-11-01 06:32:22 +0000 @@ -1,15 +1,19 @@ package org.hisp.dhis.web.api.model; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlAccessType; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileWrapper.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileWrapper.java 2010-10-28 09:25:22 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileWrapper.java 2010-11-01 06:32:22 +0000 @@ -60,7 +60,6 @@ }else{ this.activityPlan.serialize( dout ); } - System.out.println("finish serialize ActivityPlan"); //Write Programs if(programs != null || programs.size() > 0){ @@ -68,7 +67,6 @@ prog.serialize( dout ); } } - System.out.println("finish serialize Programs"); //Write DataSets if(datasets == null){ @@ -80,7 +78,6 @@ } } - System.out.println("finish serialize Datasets"); bout.flush(); bout.writeTo(out); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java 2010-10-20 15:56:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java 2010-11-01 06:32:22 +0000 @@ -47,11 +47,9 @@ { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream dout = new DataOutputStream(bout); - System.out.println("add program info"); dout.writeInt(this.getId()); dout.writeUTF(this.getName()); dout.writeInt(programStages.size()); - System.out.println("add program stages"); for(int i=0; i getAllMobileDataSetsForLocale(String localeString) { - + Collection units = currentUserService.getCurrentUser().getOrganisationUnits(); + OrganisationUnit unit = null; + + if( units.size() > 0 ) + { + unit = units.iterator().next(); + } + else + { + return null; + } + + + List datasets = new ArrayList(); Locale locale = LocaleUtil.getLocale(localeString); // AbstractModelList abstractModelList = new AbstractModelList(); // // List abstractModels = new ArrayList(); // - for (org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile()) + for (org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile(unit)) { if( dataSet.getPeriodType().getName().equals( "Daily") || dataSet.getPeriodType().getName().equals( "Weekly") || @@ -54,7 +76,6 @@ } public DataSet getDataSetForLocale(int dataSetId, Locale locale) { - System.out.println("DefaultDataSetService: transform dataset"); org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetId ); dataSet = i18n( i18nService, locale, dataSet ); Set sections = dataSet.getSections(); @@ -66,40 +87,64 @@ ds.setId( dataSet.getId() ); ds.setName( dataSet.getName() ); - System.out.println("DefaultDataSetService: create DataSet "+ ds.getName()); ds.setPeriodType( dataSet.getPeriodType().getName() ); //Mobile List
sectionList = new ArrayList
(); ds.setSections(sectionList); - for(org.hisp.dhis.dataset.Section each : sections){ - List dataElements = each.getDataElements(); - - Section section = new Section(); - section.setId(each.getId()); - section.setName(each.getName()); - //Mobile - List dataElementList = new ArrayList(); - section.setDes(dataElementList); - - - for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements ) - { - dataElement = i18n( i18nService, locale, dataElement ); - - DataElement de = new DataElement(); - de.setId( dataElement.getId() ); - de.setName( dataElement.getName() ); - de.setType( dataElement.getType() ); - dataElementList.add( de ); - System.out.println("add dataelement:"+de.getName()); + if(sections.size() == 0 || sections == null){ + Collection dataElements = new ArrayList(); + try { + dataElements = dataElementOrderManager.getOrderedDataElements(dataSet); + } catch (DataElementOrderManagerException e) { + e.printStackTrace(); + } + //Fake Section to store Data Elements + Section section = new Section(); + + sectionList.add(section); + section.setId(0); + section.setName(""); + + List dataElementList = new ArrayList(); + section.setDes(dataElementList); + + for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements ) + { + dataElement = i18n( i18nService, locale, dataElement ); + + DataElement de = new DataElement(); + de.setId( dataElement.getId() ); + de.setName( dataElement.getName() ); + de.setType( dataElement.getType() ); + dataElementList.add( de ); + } + }else{ + for(org.hisp.dhis.dataset.Section each : sections){ + List dataElements = each.getDataElements(); + + Section section = new Section(); + section.setId(each.getId()); + section.setName(each.getName()); + //Mobile + List dataElementList = new ArrayList(); + section.setDes(dataElementList); + + + for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements ) + { + dataElement = i18n( i18nService, locale, dataElement ); + + DataElement de = new DataElement(); + de.setId( dataElement.getId() ); + de.setName( dataElement.getName() ); + de.setType( dataElement.getType() ); + dataElementList.add( de ); + } + sectionList.add(section); } - - sectionList.add(section); - System.out.println("add section:"+section.getName()); - } -// ds.setDataElements(des); + } return ds; } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-10-20 15:56:07 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-11-01 06:32:22 +0000 @@ -106,14 +106,10 @@ public Program getProgramForLocale(int programId, String localeString) { - - System.out.println("The id is: " + programId + " and locale is: " + localeString); Locale locale = LocaleUtil.getLocale(localeString); org.hisp.dhis.program.Program program = programService.getProgram( programId ); - System.out.println("Fetched .... " + program.getId() ); - program = i18n( i18nService, locale, program ); Program pr = new Program();