dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18082
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7475: Update new version for client using mobile
------------------------------------------------------------
revno: 7475
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-02 13:43:56 +0700
message:
Update new version for client using mobile
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/struts.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
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java 2012-06-22 02:59:28 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataStreamSerializable.java 2012-07-02 06:43:56 +0000
@@ -48,7 +48,7 @@
public void deSerialize( DataInputStream dataInputStream )
throws IOException;
-
+
public void serializeVerssion2_8( DataOutputStream dataOutputStream )
throws IOException;
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2012-07-02 06:43:56 +0000
@@ -28,6 +28,7 @@
*/
import java.io.DataInputStream;
+import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -58,6 +59,10 @@
private String searchUrl;
+ public static double currentVersion = 2.9;
+
+ private String updateNewVersionUrl;
+
@XmlAttribute
public int getId()
{
@@ -160,9 +165,21 @@
this.updateActivityPlanUrl = updateActivityPlanUrl;
}
+ public String getUpdateNewVersionUrl()
+ {
+ return updateNewVersionUrl;
+ }
+
+ public void setUpdateNewVersionUrl( String updateNewVersionUrl )
+ {
+ this.updateNewVersionUrl = updateNewVersionUrl;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
+
throws IOException
{
+ dataOutputStream.writeUTF( this.updateNewVersionUrl );
dataOutputStream.writeInt( this.id );
dataOutputStream.writeUTF( this.name );
dataOutputStream.writeUTF( this.downloadAllUrl );
@@ -177,6 +194,7 @@
public void deSerialize( DataInputStream dataInputStream )
throws IOException
{
+ this.updateNewVersionUrl = dataInputStream.readUTF();
this.id = dataInputStream.readInt();
this.name = dataInputStream.readUTF();
this.downloadAllUrl = dataInputStream.readUTF();
@@ -188,6 +206,13 @@
this.searchUrl = dataInputStream.readUTF();
}
+ public void sendVersion( DataOutputStream dataOutputStream )
+ throws IOException
+ {
+ dataOutputStream.writeDouble( this.currentVersion );
+ System.out.println("welcome send Version method");
+ }
+
@Override
public void serializeVerssion2_8( DataOutputStream dataOutputStream )
throws IOException
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2012-07-02 06:43:56 +0000
@@ -36,6 +36,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+
@XmlRootElement
public class OrgUnits
implements DataStreamSerializable
@@ -78,6 +79,9 @@
public void serialize( DataOutputStream dataOutputStream )
throws IOException
{
+ //send the current version to client for updating or not
+ dataOutputStream.writeDouble( MobileOrgUnitLinks.currentVersion );
+
dataOutputStream.writeInt( orgUnits.size() );
for ( MobileOrgUnitLinks unit : orgUnits )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2012-03-16 06:36:41 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2012-07-02 06:43:56 +0000
@@ -63,7 +63,12 @@
orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
-
+
+ //generate URL for download new version
+ String full = UrlUtils.buildFullRequestUrl( request );
+ String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length());
+ String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
+ orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );
return orgUnit;
}
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-06-26 07:43:35 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-07-02 06:43:56 +0000
@@ -70,7 +70,6 @@
@ResponseBody
public MobileModel getAllDataForOrgUnit2_9( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
{
- System.out.println("download all 2.9");
MobileModel mobileModel = new MobileModel();
mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
OrganisationUnit unit = getUnit( id );
@@ -79,6 +78,7 @@
mobileModel.setDatasets( facilityReportingService.getMobileDataSetsForUnit( unit, locale ) );
mobileModel.setServerCurrentDate( new Date() );
mobileModel.setLocales( getLocalStrings( i18nService.getAvailableLocales() ) );
+
return mobileModel;
}
@@ -167,5 +167,35 @@
{
return organisationUnitService.getOrganisationUnit( id );
}
+
+/* @RequestMapping( method = RequestMethod.GET, value = "updateClient" )
+ @ResponseBody
+ public InputStream updateClient()
+ {
+
+ File fileToDownload = new File( "DHISMobile-Aggregate.jar" );
+
+ InputStream inputStream = null;
+
+ if(fileToDownload == null)
+
+ System.out.println("sorry! can't find your shit");
+ else
+ System.out.println("shit shit shit! name is "+fileToDownload.getName());
+
+ try
+ {
+ inputStream = new BufferedInputStream( new FileInputStream( fileToDownload ));
+ System.out.println(inputStream.read());
+ }
+
+ catch (Exception e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return inputStream;
+
+ }*/
}
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-01-05 20:39:23 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-07-02 06:43:56 +0000
@@ -1,7 +1,10 @@
<?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="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+<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.1.xsd">
- <!-- Root Context: defines shared resources visible to all other web components -->
+ <!-- Root Context: defines shared resources visible to all other web components -->
+ <bean id="org.hisp.dhis.api.mobile.action.UpdateClientAction"
+ class="org.hisp.dhis.api.mobile.action.UpdateClientAction" scope="prototype" />
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/struts.xml 2011-11-29 12:06:35 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/resources/struts.xml 2012-07-02 06:43:56 +0000
@@ -3,9 +3,19 @@
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
- <include file="dhis-web-commons.xml" />
-
- <package name="dhis-web-api-mobile" extends="dhis-web-commons" namespace="/dhis-web-api-mobile">
- </package>
+ <include file="dhis-web-commons.xml" />
+
+ <package name="dhis-web-api-mobile" extends="dhis-web-commons"
+ namespace="/dhis-web-api-mobile">
+ <action name="updateClient" class="org.hisp.dhis.api.mobile.action.UpdateClientAction">
+ <result name="success" type="stream">
+ <param name="contentType">application/.jar</param>
+ <param name="inputName">inputStream</param>
+ <param name="contentDisposition">fileName</param>
+ <param name="bufferSize">1024</param>
+ </result>
+ </action>
+
+ </package>
</struts>