Saturday, July 19, 2014

Saturday, May 31, 2014

GSoC community bonding and Coding phase:

I had couple of skype calls with Jim and Saptarshi during the community bonding period. They have been very kind to discuss the goals and objectives of the project and define the initial tasks. I will now summarize my work here:

I set up maven plugin in eclipse as:
Eclipse Help -> Install New Software and use http://download.eclipse.org/technology/m2e/releases as update site.
and install bazaar

I then downloaded bazaar client for windows and downloaded the source trunk from bazaar branch:

bzr branch lp:dhis2

I imported above code as Maven project in eclipse. My eclipse environment looks like following:




I haven't been able to compile and launch dhis in eclipse but I am trying to do so.

With Jim and Saptarshi we decided to make following contributions in the project:

Implement a smartphone mobile web-api controller in DHIS2. The controller will be written in java. The controller willl provide a list of available forms to the mobile device. The controller will generate XFORMs for the data sets in dhis. Mobiles can get list of forms using ODK collect. Mobiles will fill up the form and send the data back to server. The controller should be able to collect the data, parse it and store it into the database.

Controller will be part of dhis-web-api module at
http://bazaar.launchpad.net/~dhis2-devs-core/dhis2/trunk/files/head:/dhis-2/dhis-web/dhis-web-api-mobile/

The end point of web service will be:

dhis_url/mobile/xforms 

The basic template of mobile controller class is:

http://bazaar.launchpad.net/~dhis2-devs-core/dhis2/trunk/view/head:/dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java

I will extend the new controller from AbstractMobileController class

The data exchange through XForms will have:

IDs for dataset
IDs for orgunit
IDs for period
Ids for attribute
.. so on

The ODKCollect in mobile device will display the menu with the list of XFORMS. The users can choose certain form and submit the data back to the server

I am working on authentication implementation between ODKCollecct and DHIS mobile controller at the moment.

Sunday, March 2, 2014


Dear all,

I will describe my work on the design and implementation of GSoC project 'Allow data entry from OpenDataKit' here in detail. Thank you for taking time to look at this blog.

Installation:

Created Launchpad account: https://launchpad.net
Added SSH key: https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair
Installed bzr on ubuntu: apt-get install bzr
Installed maven on ubuntu: apt-get install maven
Installed JDK on ubuntu

Code:
Login bzr: bzr lp-login anumnaveed1989
Download source: bzr branch lp:dhis2
root@ubuntu:/home/anum/dhis2# bzr branch lp:dhis2
The authenticity of host 'bazaar.launchpad.net (91.189.95.84)' can't be established.
RSA key fingerprint is 9d:38:3a:63:b1:d5:6f:c4:44:67:53:49:2e:ee:fc:89.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bazaar.launchpad.net,91.189.95.84' (RSA) to the list of known hosts.

  1197kB   210kB/s / Fetching revisions:Inserting stream:Estimating.. 9983    

cd dhis-2
mvn install 
cd /dhis-2/dhis-web
mvn install   

//////////////////////
Android Xform Development 

Opendatakit ODK

Install Notepad++
Install XML Tools for NOTEPAD++
Download tool from  http://sourceforge.net/projects/npp-plugins/files/XML%20Tools/
Copy ext_libs fils into root repo of Notepad++
Copy XMLTools.dll into plugin directory of Notepad++
Tidy up XMLTools settings like XML syntax auto-check, Tag auto-close etc
Restart Notepad ++

Create a sample xform as:
//////////////////////////////////
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
        <h:head>
<!-- Anum Naveed: This form is my first example of GSoC xform project for Google -->
                <h:title>Anum Naveed GSoC example</h:title>
                <model>
                        <instance>
                                <data id="firstelement">
                                        <StringData/>
                                </data>
                        </instance>
                        <bind nodeset="/data/StringData" type="string" />
                </model>
        </h:head>
        <h:body>

                <input ref="StringData">
                        <label>Enter Full Name of GSoC student</label>
                </input>
        </h:body>
</h:html>
////////////////////////////////////////////
Follow instructions to set up development environment for xforms and validation using javarosa https://bitbucket.org/javarosa/javarosa/wiki/buildxforms
Download javarosa form validater from https://bitbucket.org/javarosa/javarosa/wiki/JavaRosa-XForm-Validator

Download the jar files
 javarosa-xform-validator.jar
JavaRosaFormTest.jad
JavaRosaFormTest.jar

Download and Install JAVA WTK from http://www.oracle.com/technetwork/java/download-135801.html

Test the form:
Install Android SDK Emulator: http://developer.android.com/sdk/index.html
Run the executable to start the installation of packages after selecting the packages

Download ODK Collect tool from: http://opendatakit.org/downloads/download-info/odk-collect-apk/
Install ODK Tool:
Go to: sdk\platform-tools
Run adb.exe install ODK Collect v1.4 rev 1038.apk
That will install the collection tool for opendata kit. Success!

Start the Emulator, Now you will see the ODKCollect application in the emulator.
Copy form from disk to emulator as

adb.exe push anum.xml sdcard/odk/forms
106 KB/s (1363 bytes in 0.012s)

Go to android Menu:

Run ODTCollect as


Open XML Form named Anum.xml as:



Fill up the form with dummy data about my project:



My Anum.xml form looks like the following:

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
  <h:head>
    <!-- This is my first XFORM for GSoC 2014 project for DHIS2. I am excited-->
    <h:title>Anum Naveed - GSoC 2014 DHIS2</h:title>
    <model>
      <instance>
        <data id="myform">
          <meta>
            <instanceID/>
          </meta>
          <Anum/>
        </data>
      </instance>
      <itext>
        <translation lang="eng">
          <text id="/data/Anum:label">
            <value>Anum Naveed - XFORM Success!

</value>
          </text>
        </translation>
      </itext>
      <bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
      <bind nodeset="/data/Anum" type="string"/>
    </model>
  </h:head>
  <h:body>
    <input ref="/data/Anum">
      <label ref="jr:itext('/data/Anum:label')"/>
    </input>
  </h:body>
</h:html>


I have successfully managed to write a basic xform and deploy it on the emulator. Next step I am working on is to deep down into advanced xforms and work on DHIS codebase.

Really Excited about the project