dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04975
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1664: added dataset selector to dhis-web-mobile
------------------------------------------------------------
revno: 1664
committer: Saptarshi <sunbiz@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-03-18 01:21:22 +0100
message:
added dataset selector to dhis-web-mobile
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/add.png
dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/GetDataElementsAction.java
dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/dataElementsResponse.vm
modified:
dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/CreateMobileAppAction.java
dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/JarGeneratorAction.java
dhis-mobile/dhis-web-mobile/src/main/resources/META-INF/dhis/beans.xml
dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml
dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/create.html
dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/createMobileApp.vm
--
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.
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/add.png'
Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/add.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/add.png 2010-03-18 00:21:22 +0000 differ
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/CreateMobileAppAction.java'
--- dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/CreateMobileAppAction.java 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/CreateMobileAppAction.java 2010-03-18 00:21:22 +0000
@@ -26,27 +26,42 @@
* (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 com.opensymphony.xwork2.Action;
import java.io.File;
+import java.util.Collection;
import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.period.PeriodService;
-public class CreateMobileAppAction implements Action {
+public class CreateMobileAppAction implements Action
+{
private String mvnPath;
+
private String mvnStatus;
+
private String[] splashImg;
- public String[] getSplashImg() {
- String webappPath = ServletActionContext.getServletContext().getRealPath("/");
+ private String[] availableDatasets;
+
+ public String[] getSplashImg()
+ {
+ String webappPath = ServletActionContext.getServletContext().getRealPath( "/" );
String imgPath = webappPath + "/dhis-web-mobile/javame_src/src/main/resources/splash";
- File imgFolder = new File(imgPath);
+ File imgFolder = new File( imgPath );
File[] images;
- if (imgFolder.exists()) {
- if (imgFolder.isDirectory()) {
+ if ( imgFolder.exists() )
+ {
+ if ( imgFolder.isDirectory() )
+ {
images = imgFolder.listFiles();
String[] imageNames = new String[images.length];
- for (int i = 0; i < images.length; i++) {
- if (images[i].getName().contains(".png")) {
+ for ( int i = 0; i < images.length; i++ )
+ {
+ if ( images[i].getName().contains( ".png" ) )
+ {
imageNames[i] = images[i].getName();
}
}
@@ -56,19 +71,24 @@
return splashImg;
}
- public String getMvnPath() {
+ public String getMvnPath()
+ {
//long startTime = System.currentTimeMillis();
- String PATH = System.getenv("PATH");
+ String PATH = System.getenv( "PATH" );
String[] locations;
- if (getOSName().equals("win")) {
- locations = PATH.split(";");
- } else {
- locations = PATH.split(":");
+ if ( getOSName().equals( "win" ) )
+ {
+ locations = PATH.split( ";" );
+ } else
+ {
+ locations = PATH.split( ":" );
}
- for (String location : locations) {
- File folder = new File(location);
- String filePath = scanPath(getOSName(), folder);
- if (!filePath.equals("")) {
+ for ( String location : locations )
+ {
+ File folder = new File( location );
+ String filePath = scanPath( getOSName(), folder );
+ if ( !filePath.equals( "" ) )
+ {
mvnPath = filePath;
break;
}
@@ -78,49 +98,68 @@
return mvnPath;
}
- public void setMvnPath(String path) {
- File mvnFolder = new File(path);
- String filePath = scanPath(getOSName(), mvnFolder);
- if (!filePath.equals("")) {
+ public void setMvnPath( String path )
+ {
+ File mvnFolder = new File( path );
+ String filePath = scanPath( getOSName(), mvnFolder );
+ if ( !filePath.equals( "" ) )
+ {
this.mvnPath = filePath;
- } else {
+ } else
+ {
mvnStatus = "Could not find mvn.bat at the location you entered";
}
}
- public String getMvnStatus() {
+ public String getMvnStatus()
+ {
return mvnStatus;
}
- public void setMvnStatus(String status) {
+ public void setMvnStatus( String status )
+ {
this.mvnStatus = status;
}
- private String getOSName() {
+ private String getOSName()
+ {
String osName;
- if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+ if ( System.getProperty( "os.name" ).toLowerCase().contains( "windows" ) )
+ {
osName = "win";
- } else {
+ } else
+ {
osName = "nix";
}
return osName;
}
- private String scanPath(String osName, File folder) {
+ private String scanPath( String osName, File folder )
+ {
String filePath = new String();
- if (folder.exists()) {
- if (folder.isDirectory()) {
+ if ( folder.exists() )
+ {
+ if ( folder.isDirectory() )
+ {
File[] files = folder.listFiles();
- for (File file : files) {
- if (osName.equals("win")) {
- if (file.getName().equals("mvn.bat")) {
+ for ( File file : files )
+ {
+ if ( osName.equals( "win" ) )
+ {
+ if ( file.getName().equals( "mvn.bat" ) )
+ {
filePath = file.getAbsolutePath();
break;
}
- } else if (osName.equals("nix")) {
- if (file.getName().equals("mvn")) {
- filePath = file.getAbsolutePath();
- break;
+ } else
+ {
+ if ( osName.equals( "nix" ) )
+ {
+ if ( file.getName().equals( "mvn" ) )
+ {
+ filePath = file.getAbsolutePath();
+ break;
+ }
}
}
}
@@ -129,10 +168,37 @@
return filePath;
}
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ public String[] getAvailableDatasets()
+ {
+ int i = 0;
+ Collection<DataSet> allDataSets = dataSetService.getAllDataSets();
+ availableDatasets = new String[allDataSets.size()];
+ for ( DataSet dataSet : allDataSets )
+ {
+ availableDatasets[i] = dataSet.getName();
+ i++;
+ }
+ return availableDatasets;
+ }
+
@Override
public String execute()
- throws Exception {
-
+ throws Exception
+ {
return SUCCESS;
}
}
=== added file 'dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/GetDataElementsAction.java'
--- dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/GetDataElementsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/GetDataElementsAction.java 2010-03-18 00:21:22 +0000
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+package org.hisp.dhis.mobile.app.action;
+
+
+import com.opensymphony.xwork2.Action;
+import java.util.Collection;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+
+public class GetDataElementsAction implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+ private String dataSetName;
+
+ public void setDataSetName( String dataSetName )
+ {
+ this.dataSetName = dataSetName;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+ private Collection<DataElement> dataElements;
+
+ public Collection<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+ @Override
+ public String execute()
+ throws Exception
+ {
+ DataSet dataSet = dataSetService.getDataSetByName( dataSetName );
+ dataElements = dataSet.getDataElements();
+ for ( DataElement de : dataElements )
+ {
+ System.out.println( "DataElement = " + de.getName() );
+ }
+ System.out.println( "===================================" );
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/JarGeneratorAction.java'
--- dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/JarGeneratorAction.java 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/app/action/JarGeneratorAction.java 2010-03-18 00:21:22 +0000
@@ -94,12 +94,19 @@
public String execute() throws Exception {
String webappPath = ServletActionContext.getServletContext().getRealPath("/");
String javameSrc = webappPath + "/dhis-web-mobile/javame_src/src/main/java/org/hisp/dhis/mobile";
-
File dir = new File(javameSrc);
+
+ //For splash screen
replaceStringInFile(dir, "DHISMobile.java", "\\w*.png", splash);
- System.out.println("MVN BIN = " + mvnBin);
- System.out.println("Full Exec: " + mvnBin + " install " + "-f " + ServletActionContext.getServletContext().getRealPath("/") + "/dhis-web-mobile/javame_src/pom.xml");
+ //For dataset
+ //replaceStringInFile(dir, "DHISMobile.java", "", dataset);
+
+ //For language
+ //replaceStringInFile(dir, "DHISMobile.java", "", language);
+
+ //For patient-program stage
+ //replaceStringInFile(dir, "DHISMobile.java", "", patient_program);
ProcessBuilder pb = new ProcessBuilder(mvnBin, "install", "-f", ServletActionContext.getServletContext().getRealPath("/") + "/dhis-web-mobile/javame_src/pom.xml");
pb.redirectErrorStream(true);
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-mobile/dhis-web-mobile/src/main/resources/META-INF/dhis/beans.xml 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/resources/META-INF/dhis/beans.xml 2010-03-18 00:21:22 +0000
@@ -12,6 +12,14 @@
<bean id="org.hisp.dhis.mobile.app.action.CreateMobileAppAction"
class="org.hisp.dhis.mobile.app.action.CreateMobileAppAction"
scope="prototype">
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.mobile.app.action.GetDataElementsAction"
+ class="org.hisp.dhis.mobile.app.action.GetDataElementsAction"
+ scope="prototype">
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
<bean id="org.hisp.dhis.mobile.app.action.SplashUploadAction"
@@ -30,13 +38,13 @@
</bean>
<!-- Mobile Importing -->
- <bean id="org.hisp.dhis.mobileimport.api.MobileImportService"
+ <bean id="org.hisp.dhis.mobileimport.api.MobileImportService"
class="org.hisp.dhis.mobileimport.api.DefaultMobileImportService"
scope="prototype">
- </bean>
+ </bean>
- <bean id="org.hisp.dhis.mobileimport.action.MobileImportProcessAction"
+ <bean id="org.hisp.dhis.mobileimport.action.MobileImportProcessAction"
class="org.hisp.dhis.mobileimport.action.MobileImportProcessAction"
scope="prototype">
- </bean>
+ </bean>
</beans>
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml'
--- dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml 2010-03-18 00:21:22 +0000
@@ -19,6 +19,11 @@
<param name="menu">/dhis-web-mobile/menu.vm</param>
</action>
+ <action name="getDataElements" class="org.hisp.dhis.mobile.app.action.GetDataElementsAction">
+ <result name="success" type="velocity"> /dhis-web-mobile/dataElementsResponse.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<action name="splashUpload" class="org.hisp.dhis.mobile.app.action.SplashUploadAction">
<result name="success" type="velocity">/dhis-web-mobile/splashUploadResponse.vm</result>
<param name="onExceptionReturn">plainTextError</param>
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/create.html'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/create.html 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/create.html 2010-03-18 00:21:22 +0000
@@ -8,14 +8,23 @@
collapsible: true
});
$("#splashUpdate input:radio:first").attr("checked","checked");
- var options = {
+ var splashOptions = {
url: 'splashUpload.action',
target: '#splashUpdate',
success: function(){
$("#splashUpdate input:radio:first").attr("checked","checked");
}
}
- $("#splashForm").ajaxForm(options);
+ $("#splashForm").ajaxForm(splashOptions);
+
+ var dataElementsOptions = {
+ url: 'getDataElements.action',
+ type: 'POST',
+ success: function(responseXML){
+ $("#dataElementsListDiv").append(responseXML);
+ }
+ }
+ $("#dataSetForm").ajaxForm(dataElementsOptions);
});
function showPathField(){
@@ -48,6 +57,10 @@
form.submit();
}
+ function addDataSet(){
+ $("#dataSetForm").submit();
+ }
+
</script>
<h1>Create Mobile Application</h1>
@@ -105,11 +118,23 @@
</div>
<h3><a href="#">Step 2: Dataset Selection</a></h3>
<div id="dataSetSelector">
+ <form id="dataSetForm">
+ <select name="dataSetName" style="vertical-align: top" >
+ #foreach($var in $availableDatasets)
+ <option>$var</option>
+ #end
+ </select>
+ <a href="#" onclick="addDataSet()"><img src="../images/add.png" alt="" align="top" width="16" /></a>
+ <span id="dataElementsListDiv"></span>
+ </form>
+ </div>
+ <h3><a href="#">Step 3: Set Pages</a></h3>
+ <div id="pageSelector">
<p>
</p>
</div>
- <h3><a href="#">Step 3: Select Language Or Translate Data Elements</a></h3>
+ <h3><a href="#">Step 4: Select Language Or Translate Data Elements</a></h3>
<div id="languageSelector">
<table>
<tr>
@@ -119,8 +144,8 @@
</tr>
</table>
</div>
- <h3><a href="#">Step 4: Generate Application</a></h3>
- <div id="jarGenerator">
- <input type="button" value="Generate Mobile Application" onclick="submitJarGenerator()" />
- </div>
+ <h3><a href="#">Step 5: Generate Application</a></h3>
+ <div id="jarGenerator">
+ <input type="button" value="Generate Mobile Application" onclick="submitJarGenerator()" />
+ </div>
</div>
\ No newline at end of file
=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/createMobileApp.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/createMobileApp.vm 2010-03-09 17:32:56 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/createMobileApp.vm 2010-03-18 00:21:22 +0000
@@ -8,14 +8,23 @@
collapsible: true
});
$("#splashUpdate input:radio:first").attr("checked","checked");
- var options = {
+ var splashOptions = {
url: 'splashUpload.action',
target: '#splashUpdate',
success: function(){
$("#splashUpdate input:radio:first").attr("checked","checked");
}
}
- $("#splashForm").ajaxForm(options);
+ $("#splashForm").ajaxForm(splashOptions);
+
+ var dataElementsOptions = {
+ url: 'getDataElements.action',
+ type: 'POST',
+ success: function(responseXML){
+ $("#dataElementsListDiv").append(responseXML);
+ }
+ }
+ $("#dataSetForm").ajaxForm(dataElementsOptions);
});
function showPathField(){
@@ -48,6 +57,10 @@
form.submit();
}
+ function addDataSet(){
+ $("#dataSetForm").submit();
+ }
+
</script>
<h1>Create Mobile Application</h1>
@@ -105,11 +118,23 @@
</div>
<h3><a href="#">Step 2: Dataset Selection</a></h3>
<div id="dataSetSelector">
+ <form id="dataSetForm">
+ <select name="dataSetName" style="vertical-align: top" >
+ #foreach($var in $availableDatasets)
+ <option>$var</option>
+ #end
+ </select>
+ <a href="#" onclick="addDataSet()"><img src="../images/add.png" alt="" align="top" width="16" /></a>
+ <span id="dataElementsListDiv"></span>
+ </form>
+ </div>
+ <h3><a href="#">Step 3: Set Pages</a></h3>
+ <div id="pageSelector">
<p>
</p>
</div>
- <h3><a href="#">Step 3: Select Language Or Translate Data Elements</a></h3>
+ <h3><a href="#">Step 4: Select Language Or Translate Data Elements</a></h3>
<div id="languageSelector">
<table>
<tr>
@@ -119,8 +144,8 @@
</tr>
</table>
</div>
- <h3><a href="#">Step 4: Generate Application</a></h3>
- <div id="jarGenerator">
- <input type="button" value="Generate Mobile Application" onclick="submitJarGenerator()" />
- </div>
+ <h3><a href="#">Step 5: Generate Application</a></h3>
+ <div id="jarGenerator">
+ <input type="button" value="Generate Mobile Application" onclick="submitJarGenerator()" />
+ </div>
</div>
\ No newline at end of file
=== added file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/dataElementsResponse.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/dataElementsResponse.vm 1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/dataElementsResponse.vm 2010-03-18 00:21:22 +0000
@@ -0,0 +1,5 @@
+<select multiple="false" style="width: 250px; height: 180px;">
+#foreach( $dataElement in $dataElements )
+ <option value="$dataElement.id">$dataElement.name</option>
+#end
+</select>
\ No newline at end of file