dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08565
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2079: Cleaned up, hopefully not broken too much..
------------------------------------------------------------
revno: 2079
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-16 21:58:41 +0530
message:
Cleaned up, hopefully not broken too much..
removed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/ActivityValueConsumer.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/DataSetValueConsumer.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModel.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityWrapper.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Form.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ISerializable.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Link.java
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/provider/AbstractModelListProvider.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/MobileWrapperProvider.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ActivityPlanResource.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/OrgUnitResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ProgramStageService.java
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileSerializable.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSerializableProvider.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java
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/ActivityValue.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java
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/DataSetValue.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.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/model/PatientAttribute.java
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/ProgramStage.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.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/service/DefaultActivityPlanService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java
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/IDataSetService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.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
=== removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer'
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/ActivityValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/ActivityValueConsumer.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/ActivityValueConsumer.java 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
-package org.hisp.dhis.web.api.consumer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.ActivityValue;
-
-import com.sun.jersey.spi.resource.Singleton;
-
-@Provider
-@Singleton
-@Consumes( "application/vnd.org.dhis2.activityvaluelist+serialized" )
-public class ActivityValueConsumer implements MessageBodyReader<ActivityValue>{
-
- @Override
- public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2,
- MediaType arg3) {
- return true;
- }
-
- @Override
- public ActivityValue readFrom(Class<ActivityValue> arg0, Type arg1,
- Annotation[] arg2, MediaType arg3,
- MultivaluedMap<String, String> arg4, InputStream stream )
- throws IOException, WebApplicationException {
-
- ActivityValue activityValue = new ActivityValue();
- arg0.cast(activityValue);
-
- return activityValue.deSerialize( stream );
-
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/DataSetValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/DataSetValueConsumer.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/consumer/DataSetValueConsumer.java 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-package org.hisp.dhis.web.api.consumer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.DataSetValue;
-
-import com.sun.jersey.spi.resource.Singleton;
-
-@Provider
-@Singleton
-@Consumes( "application/vnd.org.dhis2.datasetvalue+serialized" )
-public class DataSetValueConsumer implements MessageBodyReader<DataSetValue>{
-
- @Override
- public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2,
- MediaType arg3) {
- return true;
- }
-
- @Override
- public DataSetValue readFrom(Class<DataSetValue> arg0, Type arg1,
- Annotation[] arg2, MediaType arg3,
- MultivaluedMap<String, String> arg4, InputStream stream )
- throws IOException, WebApplicationException {
-
- DataSetValue dsValue = new DataSetValue();
- arg0.cast(dsValue);
-
- return dsValue.deSerialize( stream );
-
- }
-
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModel.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModel.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModel.java 1970-01-01 00:00:00 +0000
@@ -1,91 +0,0 @@
-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;
-
-/**
- *
- * @author abyotag_adm
- */
-public class AbstractModel implements ISerializable {
-
- private int id;
-
- private String name;
-
- public AbstractModel(){}
-
- /**
- * @return the id
- */
- public int getId() {
- return id;
- }
-
- /**
- * @param id the id to set
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- public static AbstractModel recordToAbstractModel( byte[] rec)
- {
- ByteArrayInputStream bin = new ByteArrayInputStream(rec);
- DataInputStream din = new DataInputStream(bin);
-
- AbstractModel model = new AbstractModel();
-
- try{
- model.setId( din.readInt() );
- model.setName( din.readUTF());
- }catch(IOException ioe){}
-
- return model;
-
- }
-
- public byte[] serialize() throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getId());
- dout.writeUTF(this.getName());
-
- return bout.toByteArray();
- }
-
- public void deSerialize(byte[] data) throws IOException
- {
- ByteArrayInputStream bin = new ByteArrayInputStream(data);
- DataInputStream din = new DataInputStream(bin);
-
- this.setId( din.readInt() );
- this.setName( din.readUTF() );
- }
-
- public void deSerialize( DataInputStream din ) throws IOException
- {
- this.setId( din.readInt() );
- this.setName( din.readUTF() );
- }
-}
-
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java 2010-11-09 02:53:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java 1970-01-01 00:00:00 +0000
@@ -1,90 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-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;
-
-/**
- *
- * @author abyotag_adm
- */
-public class AbstractModelList
- implements ISerializable
-{
-
- private List<AbstractModel> abstractModels;
-
- public List<AbstractModel> getAbstractModels()
- {
- return abstractModels;
- }
-
- public void setAbstractModels( List<AbstractModel> abstractModels )
- {
- this.abstractModels = abstractModels;
- }
-
- public byte[] serialize()
- throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- dout.writeInt( abstractModels.size() );
-
- for ( int i = 0; i < abstractModels.size(); i++ )
- {
- AbstractModel abstractModel = (AbstractModel) abstractModels.get( i );
- dout.writeInt( abstractModel.getId() );
- dout.writeUTF( abstractModel.getName() );
- }
-
- return bout.toByteArray();
- }
-
- public void deSerialize( byte[] data )
- throws IOException
- {
- ByteArrayInputStream bin = new ByteArrayInputStream( data );
- DataInputStream din = new DataInputStream( bin );
-
- int size = din.readInt();
-
- for ( int i = 0; i < size; i++ )
- {
- AbstractModel abstractModel = new AbstractModel();
- abstractModel.setId( din.readInt() );
- abstractModel.setName( din.readUTF() );
- this.abstractModels.add( abstractModel );
- }
- }
-
- public void serialize( OutputStream out )
- throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- dout.writeInt( abstractModels.size() );
-
- for ( int i = 0; i < abstractModels.size(); i++ )
- {
- AbstractModel abstractModel = (AbstractModel) abstractModels.get( i );
- dout.writeInt( abstractModel.getId() );
- dout.writeUTF( abstractModel.getName() );
- }
-
- // bout.flush();
- bout.writeTo( out );
-
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java 2010-10-20 11:54:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java 2010-11-16 16:28:41 +0000
@@ -1,15 +1,39 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.Date;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class Activity implements ISerializable
+public class Activity
+ implements MobileSerializable
{
private Beneficiary beneficiary;
@@ -18,7 +42,7 @@
private Task task;
- private Date dueDate;
+ private Date dueDate;
public Beneficiary getBeneficiary()
{
@@ -50,51 +74,33 @@
this.dueDate = dueDate;
}
-
-
- public boolean isLate() {
- return late;
- }
-
- public void setLate(boolean late) {
- this.late = late;
- }
-
- @Override
- public byte[] serialize() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void serialize( DataOutputStream dout ) throws IOException
- {
- this.getBeneficiary().serialize(dout);
- this.getTask().serialize(dout);
-
- dout.writeLong(this.getDueDate().getTime());
-
- dout.flush();
- }
-
- public void serialize( OutputStream out ) throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- this.getBeneficiary().serialize(dout);
- dout.writeBoolean(late);
- this.getTask().serialize(dout);
- dout.writeLong(this.getDueDate().getTime());
-
- bout.flush();
- bout.writeTo(out);
-
- }
-
- @Override
- public void deSerialize(byte[] data) throws IOException {
- // TODO Auto-generated method stub
-
- }
+ public boolean isLate()
+ {
+ return late;
+ }
+
+ public void setLate( boolean late )
+ {
+ this.late = late;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ this.getBeneficiary().serialize( dout );
+ dout.writeBoolean( late );
+ this.getTask().serialize( dout );
+ dout.writeLong( this.getDueDate().getTime() );
+
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
+
+ }
}
=== 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-11-12 10:28:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java 2010-11-16 16:28:41 +0000
@@ -1,23 +1,43 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.List;
-import java.util.Set;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
+
public class ActivityPlan
- implements ISerializable
+ implements MobileSerializable
{
private List<Activity> activitiesList;
- @XmlElement( name = "activity" )
public List<Activity> getActivitiesList()
{
return activitiesList;
@@ -29,29 +49,9 @@
}
@Override
- public byte[] serialize()
- throws IOException
- {
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- dout.writeInt( this.getActivitiesList().size() );
-
- for ( int i = 0; i < activitiesList.size(); i++ )
- {
- Activity activity = (Activity) activitiesList.get( i );
- activity.serialize( dout );
- }
-
- return bout.toByteArray();
- }
-
- public void serialize( OutputStream out )
- throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
if ( activitiesList == null )
{
@@ -68,23 +68,21 @@
Beneficiary b = activity.getBeneficiary();
b.serialize( dout );
-
+
Task t = activity.getTask();
dout.writeInt( t.getId() );
dout.writeInt( t.getProgramStageId() );
dout.writeBoolean( t.isCompleted() );
}
}
- bout.flush();
- bout.writeTo( out );
}
@Override
- public void deSerialize( byte[] data )
+ public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
- // TODO Auto-generated method stub
+ // FIXME: Get implementation from client
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityValue.java 2010-11-13 17:48:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityValue.java 2010-11-16 16:28:41 +0000
@@ -1,101 +1,95 @@
-/**
- *
- */
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-/**
- * @author abyotag_adm
- *
- */
-public class ActivityValue implements ISerializable {
-
- private int programInstanceId;
-
- private List<DataValue> dataValues = new ArrayList<DataValue>();
-
- public ActivityValue() {
- }
-
- public void setProgramInstanceId(int programInstanceId) {
- this.programInstanceId = programInstanceId;
- }
-
- public int getProgramInstanceId() {
- return programInstanceId;
- }
-
- public void setDataValues(List<DataValue> dataValues) {
- this.dataValues = dataValues;
- }
-
- public List<DataValue> getDataValues() {
- return dataValues;
- }
-
- public byte[] serialize() throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getProgramInstanceId());
- dout.writeInt(dataValues.size());
-
- for(int i=0; i<dataValues.size(); i++)
- {
- DataValue dv = (DataValue)dataValues.get(i);
- dout.writeInt( dv.getId() );
- dout.writeInt( dv.getCategoryOptComboID() );
- dout.writeUTF( dv.getVal() );
- }
-
- return bout.toByteArray();
- }
-
- public void deSerialize(byte[] data) throws IOException
- {
- ByteArrayInputStream bin = new ByteArrayInputStream(data);
- DataInputStream din = new DataInputStream(bin);
-
- this.setProgramInstanceId( din.readInt() ) ;
-
- int size = din.readInt();
-
- for(int i=0; i<size; i++)
- {
- DataValue dv = new DataValue();
- dv.setId( din.readInt() );
- dv.setCategoryOptComboID( din.readInt() );
- dv.setVal( din.readUTF() );
- this.dataValues.add(dv);
- }
- }
-
- public ActivityValue deSerialize(InputStream stream) throws IOException
- {
- DataInputStream din = new DataInputStream(stream);
-
- this.setProgramInstanceId( din.readInt() ) ;
-
- int size = din.readInt();
-
- for(int i=0; i<size; i++)
- {
- DataValue dv = new DataValue();
- dv.setId( din.readInt() );
- dv.setCategoryOptComboID( din.readInt() );
- dv.setVal( din.readUTF() );
- this.dataValues.add(dv);
- }
-
- return this;
- }
+public class ActivityValue
+ implements MobileSerializable
+{
+
+ private int programInstanceId;
+
+ private List<DataValue> dataValues = new ArrayList<DataValue>();
+
+ public ActivityValue()
+ {
+ }
+
+ public void setProgramInstanceId( int programInstanceId )
+ {
+ this.programInstanceId = programInstanceId;
+ }
+
+ public int getProgramInstanceId()
+ {
+ return programInstanceId;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
+
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ DataInputStream din = new DataInputStream( dataInputStream );
+
+ this.setProgramInstanceId( din.readInt() );
+
+ int size = din.readInt();
+
+ for ( int i = 0; i < size; i++ )
+ {
+ DataValue dv = new DataValue();
+ dv.deSerialize( dataInputStream );
+ this.dataValues.add( dv );
+ }
+
+ }
+
}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityWrapper.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityWrapper.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityWrapper.java 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
-package org.hisp.dhis.web.api.model;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-
-/**
- * @author Tran Ng Minh Luan
- *
- */
-public class ActivityWrapper implements ISerializable
-{
- private ActivityPlan activityPlan;
- private List<Program> programs;
-
- public ActivityPlan getActivityPlan()
- {
- return activityPlan;
- }
-
- public void setActivityPlan( ActivityPlan activityPlan )
- {
- this.activityPlan = activityPlan;
- }
-
- public List<Program> getPrograms()
- {
- return programs;
- }
-
- public void setPrograms( List<Program> programs )
- {
- this.programs = programs;
- }
-
- public ActivityWrapper()
- {
-
- }
-
- public void serialize(OutputStream out) throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(programs.size());
-
- this.activityPlan.serialize( dout );
-
- for(Program each : programs){
- each.serialize( dout );
- }
- bout.flush();
- bout.writeTo(out);
- }
-
- @Override
- public byte[] serialize()
- throws IOException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void deSerialize( byte[] data )
- throws IOException
- {
- // TODO Auto-generated method stub
-
- }
-
-
-
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java 2010-11-12 10:28:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java 2010-11-16 16:28:41 +0000
@@ -1,17 +1,40 @@
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.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.util.Set;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
public class Beneficiary
- implements ISerializable
+ implements MobileSerializable
{
private int id;
@@ -45,7 +68,6 @@
this.patientAttValues = patientAttValues;
}
- @XmlAttribute
public int getId()
{
return id;
@@ -56,7 +78,6 @@
this.id = id;
}
- @XmlAttribute
public String getFirstName()
{
return firstName;
@@ -67,7 +88,6 @@
this.firstName = firstName;
}
- @XmlAttribute
public String getMiddleName()
{
return middleName;
@@ -78,7 +98,6 @@
this.middleName = middleName;
}
- @XmlAttribute
public String getLastName()
{
return lastName;
@@ -89,13 +108,7 @@
this.lastName = lastName;
}
- public byte[] serialize()
- throws IOException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
+ @Override
public void serialize( DataOutputStream out )
throws IOException
{
@@ -131,10 +144,13 @@
bout.writeTo( out );
}
- public void deSerialize( byte[] data )
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
- // TODO Auto-generated method stub
+ // FIXME: Get implementation from client
+
}
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java 2010-11-08 03:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java 2010-11-16 16:28:41 +0000
@@ -1,13 +1,37 @@
package org.hisp.dhis.web.api.model;
-import javax.xml.bind.annotation.XmlRootElement;
+/*
+ * 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.
+ */
-@XmlRootElement
-public class DataElement extends AbstractModel {
+public class DataElement extends Model {
private String type;
- private AbstractModelList categoryOptionCombos;
+ private ModelList categoryOptionCombos;
public DataElement() {
@@ -21,16 +45,14 @@
this.type = type;
}
- public AbstractModelList getCategoryOptionCombos()
+ public ModelList getCategoryOptionCombos()
{
return categoryOptionCombos;
}
- public void setCategoryOptionCombos( AbstractModelList categoryOptionCombos )
+ public void setCategoryOptionCombos( ModelList categoryOptionCombos )
{
this.categoryOptionCombos = categoryOptionCombos;
}
-
-
}
=== 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-11-02 03:53:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSet.java 2010-11-16 16:28:41 +0000
@@ -1,131 +1,93 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlAccessType;
-
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(propOrder= {"id", "name", "periodType", "dataElements"})
-public class DataSet extends AbstractModel {
-
- private String periodType;
-
-// @XmlElementWrapper( name = "des" )
-// @XmlElement(name = "de")
- private List<Section> sections;
-// private List<DataElement> dataElements;
-
- public void setPeriodType(String periodType) {
- this.periodType = periodType;
- }
-
- public String getPeriodType() {
- return periodType;
- }
-
-
-// public List<DataElement> getDataElements() {
-// return dataElements;
-// }
-//
-// public void setDataElements(List<DataElement> dataElements) {
-// this.dataElements = dataElements;
-// }
-
- public List<Section> getSections() {
- return sections;
- }
-
- public void setSections(List<Section> sections) {
- this.sections = sections;
- }
-
-// public byte[] serialize() throws IOException
-// {
-// ByteArrayOutputStream bout = new ByteArrayOutputStream();
-// DataOutputStream dout = new DataOutputStream(bout);
-//
-// dout.writeInt(this.getId());
-// dout.writeUTF(this.getName());
-// dout.writeUTF(this.getPeriodType());
-// dout.writeInt(dataElements.size());
-//
-// for(int i=0; i<dataElements.size(); i++)
-// {
-// DataElement de = (DataElement)dataElements.get(i);
-// dout.writeInt( de.getId() );
-// dout.writeUTF( de.getName() );
-// dout.writeUTF( de.getType() );
-// }
-//
-// return bout.toByteArray();
-// }
-
-// public void deSerialize(byte[] data) throws IOException
-// {
-// ByteArrayInputStream bin = new ByteArrayInputStream(data);
-// DataInputStream din = new DataInputStream(bin);
-//
-// this.setId( din.readInt() ) ;
-// this.setName( din.readUTF() );
-// this.setPeriodType( din.readUTF() ) ;
-//
-// int size = din.readInt();
-//
-// for(int i=0; i<size; i++)
-// {
-// DataElement de = new DataElement();
-// de.setId( din.readInt() );
-// de.setName( din.readUTF() );
-// de.setType( din.readUTF() );
-// this.dataElements.add(de);
-// }
-// }
-
- public void serialize( OutputStream out ) throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getId());
- dout.writeUTF(this.getName());
- dout.writeUTF(this.getPeriodType());
-
- if(this.sections == null){
- dout.writeInt(0);
- }else{
- dout.writeInt(this.sections.size());
- for(Section section : this.sections){
- section.serialize(dout);
+public class DataSet
+ extends Model
+{
+
+ private String periodType;
+
+ private List<Section> sections;
+
+ public String getPeriodType()
+ {
+ return periodType;
+ }
+
+ public void setPeriodType( String periodType )
+ {
+ this.periodType = periodType;
+ }
+
+ public List<Section> getSections()
+ {
+ return sections;
+ }
+
+ public void setSections( List<Section> sections )
+ {
+ this.sections = sections;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+ dout.writeUTF( this.getPeriodType() );
+
+ if ( this.sections == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( this.sections.size() );
+ for ( Section section : this.sections )
+ {
+ section.serialize( dout );
}
}
- bout.flush();
- bout.writeTo(out);
-
-
-// dout.writeInt(dataElements.size());
-
-// for(int i=0; i<dataElements.size(); i++)
-// {
-// DataElement de = (DataElement)dataElements.get(i);
-// dout.writeInt( de.getId() );
-// dout.writeUTF( de.getName() );
-// dout.writeUTF( de.getType() );
-// }
-
-
-
- }
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
+
+ }
+
}
-
-
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java 2010-11-09 02:53:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java 2010-11-16 16:28:41 +0000
@@ -1,33 +1,52 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.InputStream;
import java.util.ArrayList;
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.XmlRootElement;
-
-
-@XmlRootElement(name = "DSV")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class DataSetValue extends AbstractModel {
-
+public class DataSetValue
+ extends Model
+{
+
private String pName;
-
+
private boolean completed;
-
- @XmlElement(name = "dv")
- private List<DataValue> dataValues = new ArrayList<DataValue>();
-
- public DataSetValue(){}
-
+
+ private List<DataValue> dataValues = new ArrayList<DataValue>();
+
+ public DataSetValue()
+ {
+ }
+
public boolean isCompleted()
{
return completed;
@@ -38,85 +57,53 @@
this.completed = completed;
}
- public String getpName() {
- return pName;
- }
-
- public void setpName(String pName) {
- this.pName = pName;
- }
-
- public void setDataValues(List<DataValue> dataValues) {
- this.dataValues = dataValues;
- }
-
- public List<DataValue> getDataValues() {
- return dataValues;
- }
-
- public byte[] serialize() throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getId());
- dout.writeUTF(this.getName());
- dout.writeUTF(this.getpName());
- dout.writeBoolean( this.isCompleted() );
- dout.writeInt(dataValues.size());
-
- for(int i=0; i<dataValues.size(); i++)
- {
- DataValue dv = (DataValue)dataValues.get(i);
- dout.writeInt( dv.getId() );
- dout.writeInt( dv.getCategoryOptComboID() );
- dout.writeUTF( dv.getVal() );
- }
-
- return bout.toByteArray();
- }
-
- public void deSerialize(byte[] data) throws IOException
- {
- ByteArrayInputStream bin = new ByteArrayInputStream(data);
- DataInputStream din = new DataInputStream(bin);
-
- this.setId( din.readInt() ) ;
- this.setName( din.readUTF() );
- this.setpName( din.readUTF() ) ;
- this.setCompleted( din.readBoolean() );
- int size = din.readInt();
-
- for(int i=0; i<size; i++)
- {
- DataValue dv = new DataValue();
- dv.setId( din.readInt() );
- dv.setCategoryOptComboID( din.readInt() );
- dv.setVal( din.readUTF() );
- this.dataValues.add(dv);
- }
- }
-
- public DataSetValue deSerialize(InputStream stream) throws IOException
- {
- DataInputStream din = new DataInputStream(stream);
-
- this.setId( din.readInt() ) ;
- this.setName( din.readUTF() );
- this.setpName( din.readUTF() ) ;
- this.setCompleted( din.readBoolean() );
- int size = din.readInt();
-
- for(int i=0; i<size; i++)
- {
- DataValue dv = new DataValue();
- dv.setId( din.readInt() );
- dv.setCategoryOptComboID( din.readInt() );
- dv.setVal( din.readUTF() );
- this.dataValues.add(dv);
- }
-
- return this;
- }
-
+ public String getpName()
+ {
+ return pName;
+ }
+
+ public void setpName( String pName )
+ {
+ this.pName = pName;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
+ }
+
+ @Override
+ public void deSerialize( DataInputStream din )
+ throws IOException
+ {
+
+ this.setId( din.readInt() );
+ this.setName( din.readUTF() );
+ this.setpName( din.readUTF() );
+ this.setCompleted( din.readBoolean() );
+ int size = din.readInt();
+
+ for ( int i = 0; i < size; i++ )
+ {
+ DataValue dv = new DataValue();
+ dv.setId( din.readInt() );
+ dv.setCategoryOptComboID( din.readInt() );
+ dv.setVal( din.readUTF() );
+ this.dataValues.add( dv );
+ }
+
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java 2010-11-09 02:53:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java 2010-11-16 16:28:41 +0000
@@ -1,15 +1,38 @@
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.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlType( name = "dv" )
-@XmlAccessorType( XmlAccessType.FIELD )
public class DataValue
- implements ISerializable
+ implements MobileSerializable
{
private int id;
@@ -49,18 +72,20 @@
}
@Override
- public byte[] serialize()
+ public void serialize( DataOutputStream dataOutputStream )
throws IOException
{
// TODO Auto-generated method stub
- return null;
+
}
@Override
- public void deSerialize( byte[] data )
+ public void deSerialize( DataInputStream din )
throws IOException
{
- // TODO Auto-generated method stub
+ setId( din.readInt() );
+ setCategoryOptComboID( din.readInt() );
+ setVal( din.readUTF() );
+ }
- }
}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Form.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Form.java 2010-08-25 17:40:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Form.java 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-package org.hisp.dhis.web.api.model;
-
-import java.util.List;
-
-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;
-
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(propOrder= {"id", "name", "dataElements"})
-public class Form {
-
- private int id;
-
- private String name;
-
- @XmlElementWrapper( name = "des" )
- @XmlElement(name = "de")
- private List<DataElement> dataElements;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<DataElement> getDataElements() {
- return dataElements;
- }
-
- public void setDataElements(List<DataElement> dataElements) {
- this.dataElements = dataElements;
- }
-}
-
-
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ISerializable.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ISerializable.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ISerializable.java 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-/**
- *
- */
-package org.hisp.dhis.web.api.model;
-
-import java.io.IOException;
-
-/**
- * @author abyotag_adm
- *
- */
-public interface ISerializable {
- byte[] serialize() throws IOException;
- void deSerialize(byte[] data)throws IOException;
-}
\ No newline at end of file
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Link.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Link.java 2010-08-25 17:40:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Link.java 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
-package org.hisp.dhis.web.api.model;
-
-import javax.xml.bind.annotation.XmlAttribute;
-
-public class Link
-{
-
- private String url;
-
- public Link()
- {
- }
-
- public Link( String url )
- {
- this.url = url;
- }
-
- @XmlAttribute
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-
-
-}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,130 @@
+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 java.util.List;
+
+public class MobileModel
+ implements MobileSerializable
+{
+ private ActivityPlan activityPlan;
+
+ private List<Program> programs;
+
+ private List<DataSet> datasets;
+
+ public ActivityPlan getActivityPlan()
+ {
+ return activityPlan;
+ }
+
+ public void setActivityPlan( ActivityPlan activityPlan )
+ {
+ this.activityPlan = activityPlan;
+ }
+
+ public List<Program> getPrograms()
+ {
+ return programs;
+ }
+
+ public void setPrograms( List<Program> programs )
+ {
+ this.programs = programs;
+ }
+
+ public List<DataSet> getDatasets()
+ {
+ return datasets;
+ }
+
+ public void setDatasets( List<DataSet> datasets )
+ {
+ this.datasets = datasets;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+
+ if ( programs != null )
+ {
+ dout.writeInt( programs.size() );
+ }
+ else
+ {
+ dout.writeInt( 0 );
+ }
+
+ // Write ActivityPlans
+ if ( this.activityPlan == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ this.activityPlan.serialize( dout );
+ }
+
+ // Write Programs
+ if ( programs != null || programs.size() > 0 )
+ {
+ for ( Program prog : programs )
+ {
+ prog.serialize( dout );
+ }
+ }
+
+ // Write DataSets
+ if ( datasets == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( datasets.size() );
+ for ( DataSet ds : datasets )
+ {
+ ds.serialize( dout );
+ }
+ }
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
+
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileSerializable.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileSerializable.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileSerializable.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,47 @@
+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;
+
+/**
+ * Interface for entities that needs to be serialized/deserialized for
+ * communication with low-bandwith mobile phones
+ */
+public interface MobileSerializable
+{
+
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException;
+
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException;
+
+}
\ No newline at end of file
=== removed 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-11-13 17:48:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileWrapper.java 1970-01-01 00:00:00 +0000
@@ -1,126 +0,0 @@
-package org.hisp.dhis.web.api.model;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-
-/**
- * @author Tran Ng Minh Luan
- *
- */
-public class MobileWrapper
- implements ISerializable
-{
- private ActivityPlan activityPlan;
-
- private List<Program> programs;
-
- private List<DataSet> datasets;
-
- public MobileWrapper()
- {
- }
-
- public ActivityPlan getActivityPlan()
- {
- return activityPlan;
- }
-
- public void setActivityPlan( ActivityPlan activityPlan )
- {
- this.activityPlan = activityPlan;
- }
-
- public List<Program> getPrograms()
- {
- return programs;
- }
-
- public void setPrograms( List<Program> programs )
- {
- this.programs = programs;
- }
-
- public List<DataSet> getDatasets()
- {
- return datasets;
- }
-
- public void setDatasets( List<DataSet> datasets )
- {
- this.datasets = datasets;
- }
-
- public void serialize( OutputStream out )
- throws IOException
- {
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- if ( programs != null )
- {
- dout.writeInt( programs.size() );
- }
- else
- {
- dout.writeInt( 0 );
- }
-
- // Write ActivityPlans
- if ( this.activityPlan == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- this.activityPlan.serialize( dout );
- }
-
- // Write Programs
- if ( programs != null || programs.size() > 0 )
- {
- for ( Program prog : programs )
- {
- prog.serialize( dout );
- }
- }
-
- // Write DataSets
- if ( datasets == null )
- {
- dout.writeInt( 0 );
- }
- else
- {
- dout.writeInt( datasets.size() );
- for ( DataSet ds : datasets )
- {
- ds.serialize( dout );
- }
- }
-
- bout.flush();
- bout.writeTo( out );
-
- }
-
- @Override
- public byte[] serialize()
- throws IOException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void deSerialize( byte[] data )
- throws IOException
- {
- // TODO Auto-generated method stub
-
- }
-
-}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,78 @@
+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;
+
+public class Model
+ implements MobileSerializable
+{
+
+ private int id;
+
+ private String name;
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.id );
+ dout.writeUTF( this.name );
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ this.id = dataInputStream.readInt();
+ this.name = dataInputStream.readUTF();
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,81 @@
+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 java.util.ArrayList;
+import java.util.List;
+
+public class ModelList
+ implements MobileSerializable
+{
+
+ private List<Model> models;
+
+ public List<Model> getAbstractModels()
+ {
+ return models;
+ }
+
+ public void setModels( List<Model> models )
+ {
+ this.models = models;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.writeInt( models.size() );
+
+ for ( int i = 0; i < models.size(); i++ )
+ {
+ models.get( i ).serialize( dataOutputStream );
+ }
+
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ int size = dataInputStream.readInt();
+ models = new ArrayList<Model>( size );
+
+ for ( int i = 0; i < size; i++ )
+ {
+ Model m = new Model();
+ m.deSerialize( dataInputStream );
+ models.add( m );
+ }
+
+ }
+
+}
=== modified 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 2010-08-25 17:40:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java 2010-11-16 16:28:41 +0000
@@ -1,43 +1,105 @@
package org.hisp.dhis.web.api.model;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name="orgUnit")
-public class OrgUnit {
-
- @XmlAttribute
+/*
+ * 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;
+
+
+public class OrgUnit implements MobileSerializable {
+
private int id;
- @XmlAttribute
private String name;
- @XmlElement(name="allProgramForms")
- private Link programFormsLink;
+ private String programFormsLink;
- @XmlElement(name="currentActivities")
- private Link activitiesLink;
+ private String activitiesLink;
+
+ public int getId()
+ {
+ return id;
+ }
public void setId( int id )
{
this.id = id;
}
+ public String getName()
+ {
+ return name;
+ }
+
public void setName( String name )
{
this.name = name;
}
- public void setProgramFormsLink( Link programFormsLink )
+ public String getProgramFormsLink()
+ {
+ return programFormsLink;
+ }
+
+ public void setProgramFormsLink( String programFormsLink )
{
this.programFormsLink = programFormsLink;
}
- public void setActivitiesLink( Link activitiesLink )
+ public String getActivitiesLink()
+ {
+ return activitiesLink;
+ }
+
+ public void setActivitiesLink( String activitiesLink )
{
this.activitiesLink = activitiesLink;
}
-
-
+
+ @Override
+ public void serialize( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.write( this.id );
+ dataOutputStream.writeUTF( this.name );
+ dataOutputStream.writeUTF( this.activitiesLink );
+ dataOutputStream.writeUTF( this.programFormsLink );
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ this.id = dataInputStream.readInt();
+ this.name = dataInputStream.readUTF();
+ this.activitiesLink = dataInputStream.readUTF();
+ this.programFormsLink = dataInputStream.readUTF();
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java 2010-11-12 10:28:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java 2010-11-16 16:28:41 +0000
@@ -1,5 +1,7 @@
+package org.hisp.dhis.web.api.model;
+
/*
- * Copyright (c) 2004-2009, University of Oslo
+ * Copyright (c) 2004-2010, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,29 +26,18 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-public class PatientAttribute
+public class PatientAttribute implements MobileSerializable
{
private String name;
private String value;
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
- public PatientAttribute()
- {
- }
-
- // -------------------------------------------------------------------------
- // Getter & Setter
- // -------------------------------------------------------------------------
public String getName()
{
return name;
@@ -67,17 +58,20 @@
this.value = value;
}
- public void serialize( DataOutputStream out )
+ @Override
+ public void serialize( DataOutputStream dout )
throws IOException
{
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
dout.writeUTF( this.name );
dout.writeUTF( this.value );
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // FIXME: Get implementation from client
- 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-11-01 06:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java 2010-11-16 16:28:41 +0000
@@ -1,62 +1,72 @@
-/**
- *
- */
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.List;
-/**
- * @author abyotag_adm
- *
- */
-public class Program extends AbstractModel {
-
- private List<ProgramStage> programStages;
-
- public List<ProgramStage> getProgramStages() {
- return programStages;
- }
-
- public void setProgramStages(List<ProgramStage> programStages) {
- this.programStages = programStages;
- }
-
- public byte[] serialize() throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getId());
- dout.writeUTF(this.getName());
- dout.writeInt(programStages.size());
-
- for(int i=0; i<programStages.size(); i++)
+public class Program
+ extends Model
+{
+
+ private List<ProgramStage> programStages;
+
+ public List<ProgramStage> getProgramStages()
+ {
+ return programStages;
+ }
+
+ public void setProgramStages( List<ProgramStage> programStages )
+ {
+ this.programStages = programStages;
+ }
+
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+ dout.writeInt( programStages.size() );
+ for ( int i = 0; i < programStages.size(); i++ )
{
- ProgramStage prorgamStage = (ProgramStage)programStages.get(i);
- prorgamStage.serialize(dout);
+ ProgramStage programStage = (ProgramStage) programStages.get( i );
+ programStage.serialize( dout );
}
+ }
- return bout.toByteArray();
- }
-
- public void serialize( OutputStream out ) throws IOException
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
{
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
- dout.writeInt(this.getId());
- dout.writeUTF(this.getName());
- dout.writeInt(programStages.size());
- for(int i=0; i<programStages.size(); i++)
- {
- ProgramStage programStage = (ProgramStage)programStages.get(i);
- programStage.serialize(dout);
- }
-
- bout.flush();
- bout.writeTo(out);
- }
+ // FIXME: Get implementation from client
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java 2010-11-13 17:48:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java 2010-11-16 16:28:41 +0000
@@ -1,15 +1,39 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.List;
public class ProgramStage
- extends AbstractModel
+ extends Model
{
private List<DataElement> dataElements;
@@ -24,46 +48,24 @@
this.dataElements = dataElements;
}
- public byte[] serialize()
- throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
- dout.writeInt( dataElements.size() );
-
- for ( int i = 0; i < dataElements.size(); i++ )
- {
- DataElement de = (DataElement) dataElements.get( i );
- dout.writeInt( de.getId() );
- dout.writeUTF( de.getName() );
- dout.writeUTF( de.getType() );
- }
-
- return bout.toByteArray();
- }
-
- public void serialize( OutputStream out )
- throws IOException
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
- dout.writeInt( this.getId() );
- dout.writeUTF( this.getName() );
-
- dout.writeInt( dataElements.size() );
-
- for ( int i = 0; i < dataElements.size(); i++ )
- {
- DataElement de = (DataElement) dataElements.get( i );
- dout.writeInt( de.getId() );
- dout.writeUTF( de.getName() );
- dout.writeUTF( de.getType() );
-
- List<AbstractModel> cateOptCombos = de.getCategoryOptionCombos().getAbstractModels();
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ // FIXME: Children should serialize themselves
+ dout.writeInt( this.getId() );
+ dout.writeUTF( this.getName() );
+
+ dout.writeInt( dataElements.size() );
+
+ for ( int i = 0; i < dataElements.size(); i++ )
+ {
+ DataElement de = (DataElement) dataElements.get( i );
+ dout.writeInt( de.getId() );
+ dout.writeUTF( de.getName() );
+ dout.writeUTF( de.getType() );
+
+ List<Model> cateOptCombos = de.getCategoryOptionCombos().getAbstractModels();
if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
{
dout.writeInt( 0 );
@@ -71,53 +73,20 @@
else
{
dout.writeInt( cateOptCombos.size() );
- for ( AbstractModel each : cateOptCombos )
+ for ( Model each : cateOptCombos )
{
dout.writeInt( each.getId() );
dout.writeUTF( each.getName() );
}
}
}
-
- bout.flush();
- bout.writeTo( out );
}
- // public void serialize( DataOutputStream dout ) throws IOException
- // {
- // dout.writeInt(this.getId());
- // dout.writeUTF(this.getName());
- // dout.writeInt(dataElements.size());
- // System.out.println("add dataelement");
- // for(int i=0; i<dataElements.size(); i++)
- // {
- // DataElement de = (DataElement)dataElements.get(i);
- // dout.writeInt( de.getId() );
- // dout.writeUTF( de.getName() );
- // dout.writeUTF( de.getType() );
- // }
- //
- // dout.flush();
- // }
-
- public void deSerialize( byte[] data )
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
- ByteArrayInputStream bin = new ByteArrayInputStream( data );
- DataInputStream din = new DataInputStream( bin );
-
- this.setId( din.readInt() );
- this.setName( din.readUTF() );
-
- int size = din.readInt();
-
- for ( int i = 0; i < size; i++ )
- {
- DataElement de = new DataElement();
- de.setId( din.readInt() );
- de.setName( din.readUTF() );
- de.setType( din.readUTF() );
- this.dataElements.add( de );
- }
+ // FIXME: Get implementation from client
}
+
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java 2010-11-08 03:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java 2010-11-16 16:28:41 +0000
@@ -1,41 +1,52 @@
package org.hisp.dhis.web.api.model;
-import java.io.ByteArrayOutputStream;
+/*
+ * 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 java.io.OutputStream;
import java.util.List;
-/**
- * @author Tran Ng Minh Luan
- *
- */
public class Section
- extends AbstractModel
+ extends Model
{
private List<DataElement> dataElements;
- public Section()
- {
- }
-
- public List<DataElement> getDes()
- {
- return dataElements;
- }
-
- public void setDes( List<DataElement> des )
+ public void setDataElements( List<DataElement> des )
{
this.dataElements = des;
}
- public void serialize( OutputStream out )
+ @Override
+ public void serialize( DataOutputStream dout )
throws IOException
{
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream( bout );
-
dout.writeInt( this.getId() );
dout.writeUTF( getName() );
@@ -52,7 +63,7 @@
dout.writeInt( de.getId() );
dout.writeUTF( de.getName() );
dout.writeUTF( de.getType() );
- List<AbstractModel> cateOptCombos = de.getCategoryOptionCombos().getAbstractModels();
+ List<Model> cateOptCombos = de.getCategoryOptionCombos().getAbstractModels();
if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
{
dout.writeInt( 0 );
@@ -60,7 +71,7 @@
else
{
dout.writeInt( cateOptCombos.size() );
- for ( AbstractModel each : cateOptCombos )
+ for ( Model each : cateOptCombos )
{
dout.writeInt( each.getId() );
dout.writeUTF( each.getName() );
@@ -69,8 +80,14 @@
}
}
- bout.flush();
- bout.writeTo( out );
- }
+ }
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
+ {
+ // FIXME
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java 2010-11-16 16:28:41 +0000
@@ -1,6 +1,34 @@
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.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -8,8 +36,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
-@XmlRootElement
-public class Task implements ISerializable
+public class Task implements MobileSerializable
{
private int id;
@@ -17,7 +44,6 @@
private boolean completed;
- @XmlAttribute
public int getId()
{
return id;
@@ -28,7 +54,6 @@
this.id = id;
}
- @XmlAttribute
public int getProgramStageId()
{
return programStageId;
@@ -39,7 +64,6 @@
this.programStageId = programStageId;
}
- @XmlAttribute
public boolean isCompleted()
{
return completed;
@@ -50,39 +74,22 @@
this.completed = completed;
}
- @Override
- public byte[] serialize() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void serialize( DataOutputStream dout ) throws IOException
- {
- dout.writeInt(this.getId());
+ @Override
+ public void serialize( DataOutputStream dout )
+ throws IOException
+ {
+ dout.writeInt(this.getId());
dout.writeInt(this.getProgramStageId());
dout.writeBoolean(this.isCompleted());
-
- dout.flush();
}
-
- public void serialize( OutputStream out ) throws IOException
+
+ @Override
+ public void deSerialize( DataInputStream dataInputStream )
+ throws IOException
{
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(bout);
-
- dout.writeInt(this.getId());
- dout.writeInt(this.getProgramStageId());
- dout.writeBoolean(this.isCompleted());
-
- bout.flush();
- bout.writeTo(out);
-
- }
+ // Fixme
+
+ }
- @Override
- public void deSerialize(byte[] data) throws IOException {
- // TODO Auto-generated method stub
-
- }
}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractModelListProvider.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractModelListProvider.java 2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractModelListProvider.java 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-
-import com.jcraft.jzlib.JZlib;
-import com.jcraft.jzlib.ZOutputStream;
-import com.sun.jersey.spi.resource.Singleton;
-
-import org.hisp.dhis.web.api.model.AbstractModelList;
-
-@Provider
-@Singleton
-@Produces( "application/vnd.org.dhis2.abstractmodellist+serialized" )
-public class AbstractModelListProvider implements MessageBodyWriter<AbstractModelList>{
-
- @Override
- public long getSize(AbstractModelList arg0, Class<?> arg1, Type arg2,
- Annotation[] arg3, MediaType arg4) {
- return -1;
- }
-
- @Override
- public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2,
- MediaType arg3) {
- return true;
- }
-
- @Override
- public void writeTo(AbstractModelList abstractModelList, Class<?> arg1, Type arg2,
- Annotation[] arg3, MediaType arg4,
- MultivaluedMap<String, Object> arg5, OutputStream stream)
- throws IOException, WebApplicationException {
-
- serializeZipped(abstractModelList, stream);
- }
-
- public void serializeZipped( AbstractModelList abstractModelList, OutputStream os ) throws IOException
- {
- ByteArrayOutputStream baos = serializePersistent( abstractModelList );
- ZOutputStream gzip = new ZOutputStream( os, JZlib.Z_BEST_COMPRESSION );
- DataOutputStream dos = new DataOutputStream( gzip );
-
- try
- {
- //dos.writeByte( 1 );
- byte[] res = baos.toByteArray();
- dos.write( res );
- }
- finally
- {
- dos.flush();
- gzip.finish();
- }
- }
-
- public ByteArrayOutputStream serializePersistent( AbstractModelList abstractModelList ) throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream( baos );
- abstractModelList.serialize(out);
- out.flush();
- return baos;
- }
-}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,69 @@
+package org.hisp.dhis.web.api.provider;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.ActivityValue;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Consumes( "application/vnd.org.dhis2.activityvaluelist+serialized" )
+public class ActivityValueConsumer
+ implements MessageBodyReader<ActivityValue>
+{
+
+ @Override
+ public boolean isReadable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
+ {
+ return true;
+ }
+
+ @Override
+ public ActivityValue readFrom( Class<ActivityValue> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream )
+ throws IOException, WebApplicationException
+ {
+ ActivityValue activityValue = new ActivityValue();
+ activityValue.deSerialize( new DataInputStream( entityStream ) );
+ return activityValue;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSerializableProvider.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSerializableProvider.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSerializableProvider.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,106 @@
+package org.hisp.dhis.web.api.provider;
+
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.MobileSerializable;
+
+import com.jcraft.jzlib.JZlib;
+import com.jcraft.jzlib.ZOutputStream;
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Produces( "application/vnd.org.dhis2.mobile+serialized" )
+public class DataSerializableProvider
+ implements MessageBodyWriter<MobileSerializable>
+{
+
+ @Override
+ public boolean isWriteable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
+ {
+ return true;
+ }
+
+ @Override
+ public long getSize( MobileSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType )
+ {
+ return -1;
+ }
+
+ @Override
+ public void writeTo( MobileSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream )
+ throws IOException, WebApplicationException
+ {
+ ByteArrayOutputStream baos = serializePersistent( t );
+ ZOutputStream gzip = new ZOutputStream( entityStream, JZlib.Z_BEST_COMPRESSION );
+ DataOutputStream dos = new DataOutputStream( gzip );
+
+ try
+ {
+ byte[] res = baos.toByteArray();
+ dos.write( res );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ dos.flush();
+ gzip.finish();
+ }
+
+ }
+
+ public ByteArrayOutputStream serializePersistent( MobileSerializable entity )
+ throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream( baos );
+ entity.serialize( out );
+ out.flush();
+ return baos;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java 2010-11-16 16:28:41 +0000
@@ -0,0 +1,70 @@
+package org.hisp.dhis.web.api.provider;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.DataSetValue;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Consumes( "application/vnd.org.dhis2.datasetvalue+serialized" )
+public class DataSetValueConsumer
+ implements MessageBodyReader<DataSetValue>
+{
+
+ @Override
+ public boolean isReadable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
+ {
+ return true;
+ }
+
+ @Override
+ public DataSetValue readFrom( Class<DataSetValue> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream )
+ throws IOException, WebApplicationException
+ {
+ DataSetValue dsValue = new DataSetValue();
+ dsValue.deSerialize( new DataInputStream( entityStream ) );
+ return dsValue;
+ }
+
+}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/MobileWrapperProvider.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/MobileWrapperProvider.java 2010-10-28 09:25:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/MobileWrapperProvider.java 1970-01-01 00:00:00 +0000
@@ -1,84 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.ActivityWrapper;
-import org.hisp.dhis.web.api.model.MobileWrapper;
-
-import com.jcraft.jzlib.JZlib;
-import com.jcraft.jzlib.ZOutputStream;
-import com.sun.jersey.spi.resource.Singleton;
-
-/**
- * @author Tran Ng Minh Luan
- *
- */
-@Provider
-@Singleton
-@Produces( "application/vnd.org.dhis2.mobileresource+serialized" )
-public class MobileWrapperProvider implements MessageBodyWriter<MobileWrapper>{
- @Override
- public long getSize(MobileWrapper arg0, Class<?> arg1, Type arg2,
- Annotation[] arg3, MediaType arg4) {
- return -1;
- }
-
- @Override
- public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2,
- MediaType arg3) {
- return true;
- }
-
- @Override
- public void writeTo(MobileWrapper mobileWrapper, Class<?> arg1, Type arg2,
- Annotation[] arg3, MediaType arg4,
- MultivaluedMap<String, Object> arg5, OutputStream stream)
- throws IOException, WebApplicationException {
-
- //activityPlan.serialize( stream );
- serializeZipped(mobileWrapper, stream);
- }
-
-
- public void serializeZipped( MobileWrapper mobileWrapper, OutputStream os ) throws IOException
- {
- ByteArrayOutputStream baos = serializePersistent( mobileWrapper );
- ZOutputStream gzip = new ZOutputStream( os, JZlib.Z_BEST_COMPRESSION );
- DataOutputStream dos = new DataOutputStream( gzip );
-
- try
- {
- byte[] res = baos.toByteArray();
- dos.write( res );
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally
- {
- dos.flush();
- gzip.finish();
- }
- }
-
- public ByteArrayOutputStream serializePersistent( MobileWrapper mobileWrapper ) throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream( baos );
- mobileWrapper.serialize(out);
- out.flush();
- return baos;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ActivityPlanResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ActivityPlanResource.java 2010-11-13 17:48:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ActivityPlanResource.java 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Produces;
-
-import org.hisp.dhis.web.api.model.ActivityPlan;
-import org.hisp.dhis.web.api.model.ActivityValue;
-import org.hisp.dhis.web.api.service.IActivityPlanService;
-import org.hisp.dhis.web.api.service.IActivityValueService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Path( "/activityplan" )
-public class ActivityPlanResource
-{
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private IActivityPlanService activityPlanService;
-
- @Autowired
- private IActivityValueService iactivityValueService;
-
- // -------------------------------------------------------------------------
- // Resources
- // -------------------------------------------------------------------------
-
- @GET
- @Path( "current" )
- @Produces( "application/vnd.org.dhis2.activityplan+serialized" )
- public ActivityPlan getCurrentActivityPlan( @HeaderParam( "accept-language" ) String locale )
- {
- return activityPlanService.getCurrentActivityPlan( locale );
- }
-
- @POST
- @Path( "values" )
- @Consumes( "application/vnd.org.dhis2.activityvaluelist+serialized" )
- @Produces( "application/xml" )
- public String getValues( ActivityValue activityValue )
- {
- return iactivityValueService.saveValues( activityValue );
- }
-}
=== removed 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 2010-11-01 06:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Produces;
-
-import org.hisp.dhis.web.api.model.AbstractModelList;
-import org.hisp.dhis.web.api.model.DataSet;
-import org.hisp.dhis.web.api.model.DataSetValue;
-import org.hisp.dhis.web.api.service.IDataSetService;
-import org.hisp.dhis.web.api.service.IDataValueService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Path("/mobile-datasets")
-public class DataSetResource {
-
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private IDataSetService idataSetService;
-
- @Autowired
- private IDataValueService idataValueService;
-
-
- // -------------------------------------------------------------------------
- // Resources
- // -------------------------------------------------------------------------
-
- @GET
- @Produces( "application/vnd.org.dhis2.abstractmodellist+serialized" )
- public AbstractModelList getAllMobileDataSets(@HeaderParam("accept-language") String locale)
- {
- return null;
-// return idataSetService.getAllMobileDataSetsForLocale( locale );
- }
-
- @GET
- @Path("{datasetid}")
- @Produces( "application/vnd.org.dhis2.dataset+serialized" )
- public DataSet getSelectedDataSet(
- @PathParam("datasetid") int datasetid,
- @HeaderParam("accept-language") String locale
- )
- {
- return null;
-// return idataSetService.getDataSetForLocale( datasetid, locale );
- }
-
- @POST
- @Path( "values" )
- @Consumes( "application/vnd.org.dhis2.datasetvalue+serialized" )
- @Produces("application/xml")
- public String getValues(DataSetValue dataSetValue)
- {
- return idataValueService.saveValues(dataSetValue);
- }
-}
=== 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 2010-11-15 18:00:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java 2010-11-16 16:28:41 +0000
@@ -1,9 +1,38 @@
package org.hisp.dhis.web.api.resources;
+/*
+ * 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.util.Collection;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
@@ -15,70 +44,81 @@
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.Link;
-import org.hisp.dhis.web.api.model.MobileWrapper;
+import org.hisp.dhis.web.api.model.ActivityPlan;
+import org.hisp.dhis.web.api.model.ActivityValue;
+import org.hisp.dhis.web.api.model.DataSetValue;
+import org.hisp.dhis.web.api.model.MobileModel;
import org.hisp.dhis.web.api.model.OrgUnit;
import org.hisp.dhis.web.api.service.IActivityPlanService;
+import org.hisp.dhis.web.api.service.IActivityValueService;
import org.hisp.dhis.web.api.service.IDataSetService;
+import org.hisp.dhis.web.api.service.IDataValueService;
import org.hisp.dhis.web.api.service.IProgramService;
+import org.springframework.beans.factory.annotation.Required;
@Path( "/mobile" )
public class MobileResource
{
+ private static final String MEDIA_TYPE_MOBILE_SERIALIZED = "application/vnd.org.dhis2.mobile+serialized";
+
+ // Dependencies
+
+ private IDataValueService idataValueService;
+
+ private IActivityValueService iactivityValueService;
+
private IProgramService programService;
- public IProgramService getProgramService()
+ private IActivityPlanService activityPlanService;
+
+ private IDataSetService idataSetService;
+
+ private CurrentUserService currentUserService;
+
+ @Required
+ public void setIdataValueService( IDataValueService idataValueService )
{
- return programService;
+ this.idataValueService = idataValueService;
}
+ @Required
public void setProgramService( IProgramService programService )
{
this.programService = programService;
}
- private IActivityPlanService activityPlanService;
-
- public IActivityPlanService getActivityPlanService()
- {
- return activityPlanService;
- }
-
+ @Required
public void setActivityPlanService( IActivityPlanService activityPlanService )
{
this.activityPlanService = activityPlanService;
}
- private IDataSetService idataSetService;
-
- public IDataSetService getIdataSetService()
+ @Required
+ public void setIactivityValueService( IActivityValueService iactivityValueService )
{
- return idataSetService;
+ this.iactivityValueService = iactivityValueService;
}
+ @Required
public void setIdataSetService( IDataSetService idataSetService )
{
this.idataSetService = idataSetService;
}
- private CurrentUserService currentUserService;
-
- public CurrentUserService getCurrentUserService()
- {
- return currentUserService;
- }
-
+ @Required
public void setCurrentUserService( CurrentUserService currentUserService )
{
this.currentUserService = currentUserService;
}
+ // Resource methods
+
@Context
private UriInfo uriInfo;
@GET
- @Produces( MediaType.APPLICATION_XML )
+ @Produces( MEDIA_TYPE_MOBILE_SERIALIZED )
public Response getOrgUnitForUser()
{
User user = currentUserService.getCurrentUser();
@@ -110,10 +150,10 @@
@GET
@Path( "all" )
- @Produces( "application/vnd.org.dhis2.mobileresource+serialized" )
- public MobileWrapper getAllDataForUser( @HeaderParam( "accept-language" ) String locale )
+ @Produces( MEDIA_TYPE_MOBILE_SERIALIZED )
+ public MobileModel getAllDataForUser( @HeaderParam( "accept-language" ) String locale )
{
- MobileWrapper mobileWrapper = new MobileWrapper();
+ MobileModel mobileWrapper = new MobileModel();
mobileWrapper.setActivityPlan( activityPlanService.getCurrentActivityPlan( locale ) );
mobileWrapper.setPrograms( programService.getAllProgramsForLocale( locale ) );
@@ -123,14 +163,40 @@
return mobileWrapper;
}
+ @POST
+ @Path( "dataSets" )
+ @Consumes( "application/vnd.org.dhis2.datasetvalue+serialized" )
+ @Produces( "application/xml" )
+ public String getValues( DataSetValue dataSetValue )
+ {
+ return idataValueService.saveValues( dataSetValue );
+ }
+
+ @GET
+ @Path( "activities/currentplan" )
+ @Produces( "application/vnd.org.dhis2.activityplan+serialized" )
+ public ActivityPlan getCurrentActivityPlan( @HeaderParam( "accept-language" ) String locale )
+ {
+ return activityPlanService.getCurrentActivityPlan( locale );
+ }
+
+ @POST
+ @Path( "activities" )
+ @Consumes( "application/vnd.org.dhis2.activityvaluelist+serialized" )
+ @Produces( "application/xml" )
+ public String getValues( ActivityValue activityValue )
+ {
+ return iactivityValueService.saveValues( activityValue );
+ }
+
private OrgUnit getOrgUnit( OrganisationUnit unit )
{
OrgUnit m = new OrgUnit();
m.setId( unit.getId() );
m.setName( unit.getShortName() );
- m.setProgramFormsLink( new Link( uriInfo.getRequestUriBuilder().path( "programforms" ).build().toString() ) );
- m.setActivitiesLink( new Link( uriInfo.getRequestUriBuilder().path( "activityplan/current" ).build().toString() ) );
+ m.setProgramFormsLink( uriInfo.getRequestUriBuilder().path( "programforms" ).build().toString() );
+ m.setActivitiesLink( uriInfo.getRequestUriBuilder().path( "activityplan/current" ).build().toString() );
return m;
}
=== removed 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 2010-11-15 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.web.api.model.ActivityPlan;
-import org.hisp.dhis.web.api.model.Form;
-import org.hisp.dhis.web.api.service.ActivityPlanModelService;
-import org.hisp.dhis.web.api.service.ProgramStageService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Path( "/orgUnits/{id}" )
-public class OrgUnitResource
-{
- private OrganisationUnitService organisationUnitService;
-
- public OrganisationUnitService getOrganisationUnitService()
- {
- return organisationUnitService;
- }
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- private ActivityPlanModelService service;
-
- public ActivityPlanModelService getService()
- {
- return service;
- }
-
- public void setService( ActivityPlanModelService service )
- {
- this.service = service;
- }
-
- private ProgramStageService programStageService;
-
- public ProgramStageService getProgramStageService()
- {
- return programStageService;
- }
-
- public void setProgramStageService( ProgramStageService programStageService )
- {
- this.programStageService = programStageService;
- }
-
- @PathParam( "id" )
- private int unitId;
-
- @GET
- @Path( "activityplan/current" )
- @Produces( MediaType.APPLICATION_XML )
- public ActivityPlan getCurrentActivityPlan()
- {
- return service.getCurrentActivityPlan( organisationUnitService.getOrganisationUnit( unitId ) );
- }
-
- @GET
- @Path( "programforms" )
- @Produces( MediaType.APPLICATION_XML )
- public List<Form> getAllForms()
- {
- return programStageService.getAllForms();
- }
-
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java 2010-11-01 06:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Produces;
-
-import org.hisp.dhis.web.api.model.AbstractModelList;
-import org.hisp.dhis.web.api.model.Program;
-import org.hisp.dhis.web.api.service.IProgramService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Path("/programs")
-public class ProgramResource {
-
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private IProgramService iprogramService;
-
- // -------------------------------------------------------------------------
- // Resources
- // -------------------------------------------------------------------------
-
- @GET
- @Produces( "application/vnd.org.dhis2.abstractmodellist+serialized" )
- public AbstractModelList getAllMobileDataSets(@HeaderParam("accept-language") String locale)
- {
-// return iprogramService.getAllProgramsForLocale( locale );
- return null;
- }
-
- @GET
- @Path("{programid}")
- @Produces( "application/vnd.org.dhis2.program+serialized" )
- public Program getSelectedProgram(
- @PathParam("programid") int programid,
- @HeaderParam("accept-language") String locale
- )
- {
- return iprogramService.getProgramForLocale( programid, locale );
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java 2010-11-15 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java 2010-11-16 16:28:41 +0000
@@ -1,6 +1,3 @@
-/**
- *
- */
package org.hisp.dhis.web.api.service;
import java.util.ArrayList;
@@ -24,10 +21,6 @@
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
-/**
- * @author abyotag_adm
- *
- */
public class DefaultActivityPlanService
implements IActivityPlanService
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java 2010-11-15 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java 2010-11-16 16:28:41 +0000
@@ -5,7 +5,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -14,10 +13,10 @@
import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.web.api.model.AbstractModel;
-import org.hisp.dhis.web.api.model.AbstractModelList;
import org.hisp.dhis.web.api.model.DataElement;
import org.hisp.dhis.web.api.model.DataSet;
+import org.hisp.dhis.web.api.model.Model;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.Section;
import org.hisp.dhis.web.api.utils.LocaleUtil;
@@ -146,7 +145,7 @@
section.setName( "" );
List<DataElement> dataElementList = new ArrayList<DataElement>();
- section.setDes( dataElementList );
+ section.setDataElements( dataElementList );
for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
{
@@ -154,13 +153,13 @@
dataElement = i18n( i18nService, locale, dataElement );
Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
// Client DataElement
- AbstractModelList deCateOptCombo = new AbstractModelList();
- List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
- deCateOptCombo.setAbstractModels( listCateOptCombo );
+ ModelList deCateOptCombo = new ModelList();
+ List<Model> listCateOptCombo = new ArrayList<Model>();
+ deCateOptCombo.setModels( listCateOptCombo );
for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
{
- AbstractModel oneCateOptCombo = new AbstractModel();
+ Model oneCateOptCombo = new Model();
oneCateOptCombo.setId( oneCatOptCombo.getId() );
oneCateOptCombo.setName( oneCatOptCombo.getName() );
listCateOptCombo.add( oneCateOptCombo );
@@ -185,7 +184,7 @@
section.setName( each.getName() );
// Mobile
List<DataElement> dataElementList = new ArrayList<DataElement>();
- section.setDes( dataElementList );
+ section.setDataElements( dataElementList );
for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
{
@@ -195,13 +194,13 @@
.getOptionCombos();
// Client DataElement
- AbstractModelList deCateOptCombo = new AbstractModelList();
- List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
- deCateOptCombo.setAbstractModels( listCateOptCombo );
+ ModelList deCateOptCombo = new ModelList();
+ List<Model> listCateOptCombo = new ArrayList<Model>();
+ deCateOptCombo.setModels( listCateOptCombo );
for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
{
- AbstractModel oneCateOptCombo = new AbstractModel();
+ Model oneCateOptCombo = new Model();
oneCateOptCombo.setId( oneCatOptCombo.getId() );
oneCateOptCombo.setName( oneCatOptCombo.getName() );
listCateOptCombo.add( oneCateOptCombo );
=== 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-11-15 15:24:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-11-16 16:28:41 +0000
@@ -14,8 +14,8 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.web.api.model.AbstractModel;
-import org.hisp.dhis.web.api.model.AbstractModelList;
+import org.hisp.dhis.web.api.model.Model;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.DataElement;
import org.hisp.dhis.web.api.model.Program;
import org.hisp.dhis.web.api.model.ProgramStage;
@@ -117,15 +117,15 @@
for ( org.hisp.dhis.program.ProgramStageDataElement programStagedataElement : programStage
.getProgramStageDataElements() )
{
- AbstractModelList mobileCategpryOptCombos = new AbstractModelList();
- mobileCategpryOptCombos.setAbstractModels( new ArrayList<AbstractModel>() );
+ ModelList mobileCategpryOptCombos = new ModelList();
+ mobileCategpryOptCombos.setModels( new ArrayList<Model>() );
programStagedataElement = i18n( i18nService, locale, programStagedataElement );
Set<DataElementCategoryOptionCombo> deCatOptCombs = programStagedataElement.getDataElement()
.getCategoryCombo().getOptionCombos();
for ( DataElementCategoryOptionCombo categoryOptCombo : deCatOptCombs )
{
- AbstractModel mobileCategpryOptCombo = new AbstractModel();
+ Model mobileCategpryOptCombo = new Model();
mobileCategpryOptCombo.setId( categoryOptCombo.getId() );
mobileCategpryOptCombo.setName( categoryOptCombo.getName() );
mobileCategpryOptCombos.getAbstractModels().add( mobileCategpryOptCombo );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IDataSetService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IDataSetService.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IDataSetService.java 2010-11-16 16:28:41 +0000
@@ -3,7 +3,7 @@
import java.util.List;
import java.util.Locale;
-import org.hisp.dhis.web.api.model.AbstractModelList;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.DataSet;
public interface IDataSetService {
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java 2010-10-20 15:56:07 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java 2010-11-16 16:28:41 +0000
@@ -5,7 +5,7 @@
import java.util.List;
-import org.hisp.dhis.web.api.model.AbstractModelList;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.Program;
/**
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ProgramStageService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ProgramStageService.java 2010-11-15 08:35:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ProgramStageService.java 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
-package org.hisp.dhis.web.api.service;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.web.api.model.Form;
-import org.hisp.dhis.web.api.model.DataElement;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class ProgramStageService
-{
-
- private org.hisp.dhis.program.ProgramStageService programStageService;
-
- public org.hisp.dhis.program.ProgramStageService getProgramStageService()
- {
- return programStageService;
- }
-
- public void setProgramStageService( org.hisp.dhis.program.ProgramStageService programStageService )
- {
- this.programStageService = programStageService;
- }
-
- public List<Form> getAllForms()
- {
-
- List<Form> forms = new ArrayList<Form>();
-
- for ( org.hisp.dhis.program.ProgramStage programStage : programStageService.getAllProgramStages() )
- {
-
- Form modelProgramStage = new Form();
-
- modelProgramStage.setId( programStage.getId() );
- modelProgramStage.setName( programStage.getName() );
-
- forms.add( modelProgramStage );
-
- }
-
- return forms;
- }
-
- public Form getForm( int programStageId )
- {
- org.hisp.dhis.program.ProgramStage programStage = programStageService.getProgramStage( programStageId );
-
- Collection<ProgramStageDataElement> dataElements = programStage.getProgramStageDataElements();
-
- Form modelProgramStage = new Form();
- List<DataElement> des = new ArrayList<DataElement>();
- modelProgramStage.setId( programStage.getId() );
- modelProgramStage.setName( programStage.getName() );
-
- for ( ProgramStageDataElement programStageDataElement : dataElements )
- {
- DataElement de = new DataElement();
- de.setId( programStageDataElement.getDataElement().getId() );
- de.setName( programStageDataElement.getDataElement().getName() );
- de.setType( programStageDataElement.getDataElement().getType() );
- des.add( de );
- }
-
- modelProgramStage.setDataElements( des );
-
- return modelProgramStage;
- }
-}
=== 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 2010-11-15 18:00:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2010-11-16 16:28:41 +0000
@@ -1,187 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
- <!-- Providers -->
-
- <bean id="org.hisp.dhis.web.api.provider.AbstractModelListProvider"
- class="org.hisp.dhis.web.api.provider.AbstractModelListProvider" scope="singleton"/>
-
- <bean id="org.hisp.dhis.web.api.provider.MobileWrapperProvider"
- class="org.hisp.dhis.web.api.provider.MobileWrapperProvider" scope="singleton"/>
-
- <!-- Consumers -->
-
- <bean id="org.hisp.dhis.web.api.consumer.DataSetValueConsumer"
- class="org.hisp.dhis.web.api.consumer.DataSetValueConsumer" scope="singleton"/>
-
- <bean id="org.hisp.dhis.web.api.consumer.ActivityValueConsumer"
- class="org.hisp.dhis.web.api.consumer.ActivityValueConsumer" scope="singleton"/>
-
- <!-- Resources -->
-
- <bean id="org.hisp.dhis.web.api.resources.MobileResource"
- class="org.hisp.dhis.web.api.resources.MobileResource" scope="prototype">
- <property name="programService">
- <ref bean="org.hisp.dhis.web.api.service.IProgramService"/>
- </property>
- <property name="activityPlanService">
- <ref bean="org.hisp.dhis.web.api.service.IActivityPlanService"/>
- </property>
- <property name="idataSetService">
- <ref bean="org.hisp.dhis.web.api.service.IDataSetService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.resources.OrgUnitResource"
- class="org.hisp.dhis.web.api.resources.OrgUnitResource"
- scope="prototype">
- <property name="service">
- <ref bean="org.hisp.dhis.web.api.service.ActivityPlanModelService"/>
- </property>
- <property name="programStageService">
- <ref bean="org.hisp.dhis.web.api.service.ProgramStageService"/>
- </property>
- <property name="organisationUnitService">
- <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.resources.DataSetResource"
- class="org.hisp.dhis.web.api.resources.DataSetResource" scope="prototype"/>
-
- <bean id="org.hisp.dhis.web.api.resources.ActivityPlanResource"
- class="org.hisp.dhis.web.api.resources.ActivityPlanResource" scope="prototype"/>
-
- <!-- Services -->
-
- <bean id="org.hisp.dhis.web.api.service.ActivityPlanModelService"
- class="org.hisp.dhis.web.api.service.ActivityPlanModelService">
- <property name="activityPlanService">
- <ref bean="org.hisp.dhis.activityplan.ActivityPlanService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IActivityPlanService"
- class="org.hisp.dhis.web.api.service.DefaultActivityPlanService">
- <property name="activityPlanService">
- <ref bean="org.hisp.dhis.activityplan.ActivityPlanService"/>
- </property>
- <property name="patientAttValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService"/>
- </property>
- <property name="patientAttService">
- <ref bean="org.hisp.dhis.patient.PatientAttributeService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.ProgramStageService"
- class="org.hisp.dhis.web.api.service.ProgramStageService">
- <property name="programStageService">
- <ref bean="org.hisp.dhis.program.ProgramStageService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IProgramService"
- class="org.hisp.dhis.web.api.service.DefaultProgramService">
- <property name="programService">
- <ref bean="org.hisp.dhis.program.ProgramService"/>
- </property>
- <property name="i18nService">
- <ref bean="org.hisp.dhis.i18n.I18nService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IDataSetService"
- class="org.hisp.dhis.web.api.service.DefaultDataSetService">
- <property name="dataSetService">
- <ref bean="org.hisp.dhis.dataset.DataSetService"/>
- </property>
- <property name="i18nService">
- <ref bean="org.hisp.dhis.i18n.I18nService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IDataValueService"
- class="org.hisp.dhis.web.api.service.DefaultDataValueService">
- <property name="dataSetService">
- <ref bean="org.hisp.dhis.dataset.DataSetService"/>
- </property>
- <property name="periodService">
- <ref bean="org.hisp.dhis.web.api.service.IPeriodService"/>
- </property>
- <property name="categoryService">
- <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
- </property>
- <property name="dataValueService">
- <ref bean="org.hisp.dhis.datavalue.DataValueService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IActivityValueService"
- class="org.hisp.dhis.web.api.service.DefaultActivityValueService">
- <property name="programStageInstanceService">
- <ref bean="org.hisp.dhis.program.ProgramStageInstanceService"/>
- </property>
- <property name="categoryService">
- <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
- </property>
- <property name="dataValueService">
- <ref bean="org.hisp.dhis.patientdatavalue.PatientDataValueService"/>
- </property>
- <property name="currentUserService">
- <ref bean="org.hisp.dhis.user.CurrentUserService"/>
- </property>
- </bean>
-
- <bean id="org.hisp.dhis.web.api.service.IPeriodService"
- class="org.hisp.dhis.web.api.service.DefaultPeriodService">
- <property name="periodService">
- <ref bean="org.hisp.dhis.period.PeriodService"/>
- </property>
- </bean>
-
- <!-- Response writers -->
-
- <!-- ImportDataValue beans -->
-
- <bean id="org.hisp.dhis.web.api.action.ImportDataValueAction"
- class="org.hisp.dhis.web.api.action.ImportDataValueAction">
-
- <property name="programStageInstanceService">
- <ref bean="org.hisp.dhis.program.ProgramStageInstanceService"/>
- </property>
- <property name="patientDataValueService">
- <ref bean="org.hisp.dhis.patientdatavalue.PatientDataValueService"/>
- </property>
- <property name="dataElementService">
- <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
- </property>
- <property name="orgUnitService">
- <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
- </property>
- <property name="dataElementCategoryService">
- <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
- </property>
-
- </bean>
+ <!-- Resource -->
+
+ <bean id="org.hisp.dhis.web.api.resources.MobileResource" class="org.hisp.dhis.web.api.resources.MobileResource"
+ scope="prototype">
+ <property name="idataValueService" ref="org.hisp.dhis.web.api.service.IDataValueService" />
+ <property name="iactivityValueService" ref="org.hisp.dhis.web.api.service.IActivityValueService" />
+ <property name="programService" ref="org.hisp.dhis.web.api.service.IProgramService" />
+ <property name="activityPlanService" ref="org.hisp.dhis.web.api.service.IActivityPlanService" />
+ <property name="idataSetService" ref="org.hisp.dhis.web.api.service.IDataSetService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+ <!-- Services -->
+
+ <bean id="org.hisp.dhis.web.api.service.ActivityPlanModelService" class="org.hisp.dhis.web.api.service.ActivityPlanModelService">
+ <property name="activityPlanService" ref="org.hisp.dhis.activityplan.ActivityPlanService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IActivityPlanService" class="org.hisp.dhis.web.api.service.DefaultActivityPlanService">
+ <property name="activityPlanService" ref="org.hisp.dhis.activityplan.ActivityPlanService" />
+ <property name="patientAttValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <property name="patientAttService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IProgramService" class="org.hisp.dhis.web.api.service.DefaultProgramService">
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+ <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IDataSetService" class="org.hisp.dhis.web.api.service.DefaultDataSetService">
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IDataValueService" class="org.hisp.dhis.web.api.service.DefaultDataValueService">
+ <property name="dataSetService">
+ <ref bean="org.hisp.dhis.dataset.DataSetService" />
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.web.api.service.IPeriodService" />
+ </property>
+ <property name="categoryService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ </property>
+ <property name="dataValueService">
+ <ref bean="org.hisp.dhis.datavalue.DataValueService" />
+ </property>
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService" />
+ </property>
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IActivityValueService" class="org.hisp.dhis.web.api.service.DefaultActivityValueService">
+ <property name="programStageInstanceService">
+ <ref bean="org.hisp.dhis.program.ProgramStageInstanceService" />
+ </property>
+ <property name="categoryService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ </property>
+ <property name="dataValueService">
+ <ref bean="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+ </property>
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService" />
+ </property>
+ </bean>
+
+ <bean id="org.hisp.dhis.web.api.service.IPeriodService" class="org.hisp.dhis.web.api.service.DefaultPeriodService">
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService" />
+ </property>
+ </bean>
+
+ <!-- Serialization writers and readers -->
+
+ <bean id="org.hisp.dhis.web.api.provider.DataSerializableProvider" class="org.hisp.dhis.web.api.provider.DataSerializableProvider"
+ scope="singleton" />
+
+ <bean id="org.hisp.dhis.web.api.consumer.DataSetValueConsumer" class="org.hisp.dhis.web.api.provider.DataSetValueConsumer"
+ scope="singleton" />
+
+ <bean id="org.hisp.dhis.web.api.consumer.ActivityValueConsumer" class="org.hisp.dhis.web.api.provider.ActivityValueConsumer"
+ scope="singleton" />
+
+ <!-- ImportDataValue beans -->
+
+ <bean id="org.hisp.dhis.web.api.action.ImportDataValueAction" class="org.hisp.dhis.web.api.action.ImportDataValueAction">
+
+ <property name="programStageInstanceService">
+ <ref bean="org.hisp.dhis.program.ProgramStageInstanceService" />
+ </property>
+ <property name="patientDataValueService">
+ <ref bean="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+ </property>
+ <property name="dataElementService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementService" />
+ </property>
+ <property name="orgUnitService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </property>
+ <property name="dataElementCategoryService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ </property>
+
+ </bean>
</beans>