dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20840
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9697: db translation support for dhis-web-mobile
------------------------------------------------------------
revno: 9697
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-02-03 16:53:30 +0700
message:
db translation support for dhis-web-mobile
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionMultiDimensionalDataElement.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortSectionForm.vm
dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache
--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2012-10-29 13:52:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2013-02-03 09:53:30 +0000
@@ -27,33 +27,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.api.utils.FormUtils;
import org.hisp.dhis.api.view.ClassPathUriResolver;
import org.hisp.dhis.api.webdomain.form.Form;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.dxf2.metadata.ExportService;
import org.hisp.dhis.dxf2.metadata.MetaData;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.i18n.I18nService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
@@ -65,6 +51,21 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -75,7 +76,7 @@
{
public static final String RESOURCE_PATH = "/dataSets";
public static final String DSD_TRANSFORM = "/templates/metadata2dsd.xsl";
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -86,26 +87,29 @@
@Autowired
private DataValueService dataValueService;
+ @Autowired
+ private I18nService i18nService;
+
// -------------------------------------------------------------------------
// Controller
// -------------------------------------------------------------------------
@RequestMapping( produces = "application/dsd+xml" )
- public void getStructureDefinition( @RequestParam Map<String, String> parameters, HttpServletResponse response )
+ public void getStructureDefinition( @RequestParam Map<String, String> parameters, HttpServletResponse response )
throws IOException, TransformerConfigurationException, TransformerException
{
WebOptions options = filterMetadataOptions();
-
+
MetaData metaData = exportService.getMetaData( options );
- InputStream input = new ByteArrayInputStream(JacksonUtils.toXmlWithViewAsString( metaData, ExportView.class ).getBytes("UTF-8"));
-
+ InputStream input = new ByteArrayInputStream( JacksonUtils.toXmlWithViewAsString( metaData, ExportView.class ).getBytes( "UTF-8" ) );
+
TransformerFactory tf = TransformerFactory.newInstance();
- tf.setURIResolver( new ClassPathUriResolver());
-
- Transformer transformer = tf.newTransformer( new StreamSource( new ClassPathResource(DSD_TRANSFORM).getInputStream()) );
-
- transformer.transform( new StreamSource(input), new StreamResult( response.getOutputStream() ) );
+ tf.setURIResolver( new ClassPathUriResolver() );
+
+ Transformer transformer = tf.newTransformer( new StreamSource( new ClassPathResource( DSD_TRANSFORM ).getInputStream() ) );
+
+ transformer.transform( new StreamSource( input ), new StreamResult( response.getOutputStream() ) );
}
@RequestMapping( value = "/{uid}/form", method = RequestMethod.GET, produces = "application/json" )
@@ -120,6 +124,10 @@
return;
}
+ i18nService.internationalise( dataSet );
+ i18nService.internationalise( dataSet.getDataElements() );
+ i18nService.internationalise( dataSet.getSections() );
+
Form form = FormUtils.fromDataSet( dataSet );
if ( orgUnit != null && !orgUnit.isEmpty() && period != null && !period.isEmpty() )
@@ -129,13 +137,13 @@
Collection<DataValue> dataValues = dataValueService.getDataValues( ou, p, dataSet.getDataElements() );
- FormUtils.fillWithDataValues(form, dataValues);
+ FormUtils.fillWithDataValues( form, dataValues );
}
JacksonUtils.toJson( response.getOutputStream(), form );
}
- @RequestMapping( value = "/{uid}/form", method = RequestMethod.GET, produces = {"application/xml", "text/xml"} )
+ @RequestMapping( value = "/{uid}/form", method = RequestMethod.GET, produces = { "application/xml", "text/xml" } )
public void getFormXml( @PathVariable( "uid" ) String uid, @RequestParam( value = "ou", required = false ) String orgUnit,
@RequestParam( value = "pe", required = false ) String period, HttpServletResponse response ) throws IOException
{
@@ -147,16 +155,22 @@
return;
}
+ i18nService.internationalise( dataSet );
+ i18nService.internationalise( dataSet.getDataElements() );
+ i18nService.internationalise( dataSet.getSections() );
+
Form form = FormUtils.fromDataSet( dataSet );
if ( orgUnit != null && !orgUnit.isEmpty() && period != null && !period.isEmpty() )
{
OrganisationUnit ou = manager.get( OrganisationUnit.class, orgUnit );
+ i18nService.internationalise( ou );
+
Period p = PeriodType.getPeriodFromIsoString( period );
Collection<DataValue> dataValues = dataValueService.getDataValues( ou, p, dataSet.getDataElements() );
- FormUtils.fillWithDataValues(form, dataValues);
+ FormUtils.fillWithDataValues( form, dataValues );
}
JacksonUtils.toXml( response.getOutputStream(), form );
@@ -167,23 +181,23 @@
{
}
- @RequestMapping( value = "/{uid}/form", method = RequestMethod.POST, consumes = {"application/xml", "text/xml"} )
+ @RequestMapping( value = "/{uid}/form", method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
public void postFormXml( @PathVariable( "uid" ) String uid, HttpServletRequest request, HttpServletResponse response )
{
}
/**
* select only the metadata required to describe form definitions
- *
- * @return the filtered options
+ *
+ * @return the filtered options
*/
private WebOptions filterMetadataOptions()
- {
- WebOptions options = new WebOptions(new HashMap<String,String>());
- options.setAssumeTrue( false);
+ {
+ WebOptions options = new WebOptions( new HashMap<String, String>() );
+ options.setAssumeTrue( false );
options.addOption( "categoryOptionCombos", "true" );
- options.addOption( "dataElements","true" );
- options.addOption( "dataSets", "true" );
+ options.addOption( "dataElements", "true" );
+ options.addOption( "dataSets", "true" );
return options;
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2012-12-11 10:20:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-02-03 09:53:30 +0000
@@ -40,14 +40,20 @@
import org.hisp.dhis.api.webdomain.user.UserAccount;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.i18n.I18nService;
import org.hisp.dhis.interpretation.Interpretation;
import org.hisp.dhis.interpretation.InterpretationService;
import org.hisp.dhis.message.MessageConversation;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.user.*;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
+import org.hisp.dhis.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -99,7 +105,10 @@
@Autowired
private ContextUtils contextUtils;
- @RequestMapping(produces = { "application/json", "text/*" })
+ @Autowired
+ private I18nService i18nService;
+
+ @RequestMapping( produces = { "application/json", "text/*" } )
public void getCurrentUser( HttpServletResponse response ) throws Exception
{
User currentUser = currentUserService.getCurrentUser();
@@ -247,7 +256,7 @@
JacksonUtils.toJson( response.getOutputStream(), recipients );
}
- @RequestMapping( value = "/assignedOrganisationUnits", produces = { "application/json", "text/*" } )
+ @RequestMapping(value = "/assignedOrganisationUnits", produces = { "application/json", "text/*" })
public void getAssignedOrganisationUnits( HttpServletResponse response ) throws IOException
{
User currentUser = currentUserService.getCurrentUser();
@@ -261,8 +270,8 @@
JacksonUtils.toJson( response.getOutputStream(), currentUser.getOrganisationUnits() );
}
- @SuppressWarnings( "unchecked" )
- @RequestMapping( value = "/forms", produces = { "application/json", "text/*" } )
+ @SuppressWarnings("unchecked")
+ @RequestMapping(value = "/forms", produces = { "application/json", "text/*" })
public void getForms( HttpServletResponse response ) throws IOException
{
User currentUser = currentUserService.getCurrentUser();
@@ -313,21 +322,27 @@
}
}
+ i18nService.internationalise( organisationUnits );
+
for ( OrganisationUnit organisationUnit : organisationUnits )
{
FormOrganisationUnit ou = new FormOrganisationUnit();
ou.setId( organisationUnit.getUid() );
- ou.setLabel( organisationUnit.getName() );
+ ou.setLabel( organisationUnit.getDisplayName() );
Set<DataSet> dataSets = new HashSet<DataSet>( CollectionUtils.intersection( organisationUnit.getDataSets(), userDataSets ) );
+ i18nService.internationalise( dataSets );
for ( DataSet dataSet : dataSets )
{
+ i18nService.internationalise( dataSet.getDataElements() );
+ i18nService.internationalise( dataSet.getSections() );
+
String uid = dataSet.getUid();
FormDataSet ds = new FormDataSet();
ds.setId( uid );
- ds.setLabel( dataSet.getName() );
+ ds.setLabel( dataSet.getDisplayName() );
forms.getForms().put( uid, FormUtils.fromDataSet( dataSet ) );
ou.getDataSets().add( ds );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java 2013-01-09 09:18:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/FormUtils.java 2013-02-03 09:53:30 +0000
@@ -54,7 +54,7 @@
public static Form fromDataSet( DataSet dataSet )
{
Form form = new Form();
- form.setLabel( dataSet.getName() );
+ form.setLabel( dataSet.getDisplayName() );
form.setPeriodType( dataSet.getPeriodType().getName() );
form.setAllowFuturePeriods( dataSet.isAllowFuturePeriods() );
@@ -63,7 +63,7 @@
for ( Section section : dataSet.getSections() )
{
Group s = new Group();
- s.setLabel( section.getName() );
+ s.setLabel( section.getDisplayName() );
s.setFields( inputsFromDataElements( section.getDataElements(), new ArrayList<DataElementOperand>( section.getGreyedFields() ) ) );
form.getGroups().add( s );
}
@@ -113,7 +113,7 @@
{
Field field = new Field();
- field.setLabel( dataElement.getName() );
+ field.setLabel( dataElement.getDisplayName() );
field.setDataElement( dataElement.getUid() );
field.setCategoryOptionCombo( dataElement.getCategoryCombo().getSortedOptionCombos().get( 0 ).getUid() );
field.setType( inputTypeFromDataElement( dataElement ) );
@@ -126,7 +126,7 @@
{
Field field = new Field();
- field.setLabel( dataElement.getName() + " " + categoryOptionCombo.getName() );
+ field.setLabel( dataElement.getDisplayName() + " " + categoryOptionCombo.getDisplayName() );
field.setDataElement( dataElement.getUid() );
field.setCategoryOptionCombo( categoryOptionCombo.getUid() );
field.setType( inputTypeFromDataElement( dataElement ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java 2012-10-21 22:00:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/form/Form.java 2013-02-03 09:53:30 +0000
@@ -29,12 +29,14 @@
import com.fasterxml.jackson.annotation.JsonProperty;
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
+@XmlRootElement( name = "form" )
public class Form
{
private String label;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm 2012-04-23 11:43:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionList.vm 2013-02-03 09:53:30 +0000
@@ -15,7 +15,7 @@
<select id="dataSetId" name="dataSetId" style="min-width:20em" onchange="javascript:getSectionByDataSet(this.options[this.selectedIndex].value)">
<option value="-1">[ $i18n.getString( "all" ) ]</option>
#foreach ( $dataset in $datasets )
- <option value="$dataset.id" #if($dataSetId==$dataset.id) selected="selected" #end>$dataset.name</option>
+ <option value="$dataset.id" #if($dataSetId==$dataset.id) selected="selected" #end>$dataset.displayName</option>
#end
</select>
</td>
@@ -24,7 +24,7 @@
<select id="categoryComboId" name="categoryComboId" style="min-width:20em">
<option value="-1">[ $i18n.getString( "all" ) ]</option>
#foreach ( $categoryCombo in $categoryCombos )
- <option value="$categoryCombo.id" #if($categoryComboId==$categoryCombo.id) selected="selected" #end>$categoryCombo.name</option>
+ <option value="$categoryCombo.id" #if($categoryComboId==$categoryCombo.id) selected="selected" #end>$categoryCombo.displayName</option>
#end
</select>
</td>
@@ -56,11 +56,11 @@
<tbody id="list">
#foreach( $section in $sections )
<tr id="tr${section.id}">
- <td onclick="showSectionDetails( $section.id )">$encoder.htmlEncode( $section.dataSet.name )</td>
- <td onclick="showSectionDetails( $section.id )">$encoder.htmlEncode( $section.name )</td>
+ <td onclick="showSectionDetails( $section.id )">$encoder.htmlEncode( $section.dataSet.displayName )</td>
+ <td onclick="showSectionDetails( $section.id )">$encoder.htmlEncode( $section.displayName )</td>
<td style="text-align:center"><a href="editSection.action?sectionId=$section.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a></td>
<td style="text-align:center"><a href="javascript:translate( '$section.getClass().getSimpleName()', '$section.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a></td>
- <td style="text-align:center"><a href="javascript:removeSection( '$section.id', '$encoder.jsEncode( $section.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a></td>
+ <td style="text-align:center"><a href="javascript:removeSection( '$section.id', '$encoder.jsEncode( $section.displayName )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a></td>
<td style="text-align:center"><a href="greySection.action?sectionId=$section.id" title="$i18n.getString( 'section_grey_field_managment' )"><img src="../images/edit_layout.png" alt="$i18n.getString( 'section_grey_field_managment' )"/></a></td>
<td style="text-align:center"><a href="javascript:showSectionDetails( $section.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionMultiDimensionalDataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionMultiDimensionalDataElement.vm 2010-10-29 15:38:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sectionMultiDimensionalDataElement.vm 2013-02-03 09:53:30 +0000
@@ -11,7 +11,7 @@
#set( $cols = $colRepeat.get( $category.id ) )
#foreach( $col in $cols )
#foreach( $categoryOption in $categoryOptions )
- <th colspan="$colCount"> <div align="center"> $categoryOption.name </div> </th>
+ <th colspan="$colCount"> <div align="center"> $categoryOption.displayName </div> </th>
#end
#end
</tr>
@@ -29,9 +29,9 @@
##data element name
<td>
#if( $useShortName )
- $encoder.htmlEncode( $dataElement.shortName )
+ $encoder.htmlEncode( $dataElement.displayShortName )
#else
- $encoder.htmlEncode( $dataElement.name )
+ $encoder.htmlEncode( $dataElement.displayName )
#end
</td>
#foreach( $optionCombo in $optionCombos )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm 2011-03-18 14:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm 2013-02-03 09:53:30 +0000
@@ -20,7 +20,7 @@
<p>
<select multiple id="dataSets" name="dataSets" size="25" style="width:680px">
#foreach ( $dataSet in $dataSets )
- <option value="$dataSet.id">$dataSet.name</option>
+ <option value="$dataSet.id">$dataSet.displayName</option>
#end
</select>
</p>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortSectionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortSectionForm.vm 2011-03-18 14:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortSectionForm.vm 2013-02-03 09:53:30 +0000
@@ -20,7 +20,7 @@
<p>
<select multiple id="sections" name="sections" size="25" style="width:680px">
#foreach ( $section in $sections )
- <option value="$section.id">$section.name</option>
+ <option value="$section.id">$section.displayName</option>
#end
</select>
</p>
=== modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache 2013-02-03 08:35:03 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/resources/dhis-mobile-manifest.appcache 2013-02-03 09:53:30 +0000
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# Version: 2.11-SNAPSHOT V10
+# Version: 2.11-SNAPSHOT V12
CACHE:
../mobile/index