dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37783
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19298: Translation of category options in data entry
------------------------------------------------------------
revno: 19298
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-06-06 13:44:58 +0200
message:
Translation of category options in data entry
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java
dhis-2/dhis-web/dhis-web-dataentry/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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2015-05-28 20:17:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2015-06-06 11:44:58 +0000
@@ -84,6 +84,15 @@
/**
* Returns a DataElementCategory.
*
+ * @param id the id of the DataElementCategory to return.
+ * @param i18nCategoryOptions whether to translate category options.
+ * @return the DataElementCategory with the given id, or null if no match.
+ */
+ DataElementCategory getDataElementCategory( int id, boolean i18nCategoryOptions );
+
+ /**
+ * Returns a DataElementCategory.
+ *
* @param uid the uid of the DataElementCategory to return.
* @return the DataElementCategory with the given uid, or null if no match.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2015-05-28 20:17:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2015-06-06 11:44:58 +0000
@@ -163,6 +163,22 @@
}
@Override
+ public DataElementCategory getDataElementCategory( int id, boolean i18nCategoryOptions )
+ {
+ DataElementCategory category = getDataElementCategory( id );
+
+ if ( category != null )
+ {
+ if ( i18nCategoryOptions )
+ {
+ i18n( i18nService, category.getCategoryOptions() );
+ }
+ }
+
+ return category;
+ }
+
+ @Override
public DataElementCategory getDataElementCategory( String uid )
{
return i18n( i18nService, categoryStore.getByUid( uid ) );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2015-05-17 15:31:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2015-06-06 11:44:58 +0000
@@ -29,6 +29,7 @@
*/
import com.opensymphony.xwork2.Action;
+
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
@@ -36,6 +37,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataentryform.DataEntryForm;
@@ -93,6 +95,13 @@
this.organisationUnitService = organisationUnitService;
}
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
private I18n i18n;
public void setI18n( I18n i18n )
@@ -286,7 +295,9 @@
for ( DataElementCategory dec : categoryCombo.getCategories() )
{
- optionsMap.put( dec.getId(), dec.getCategoryOptions() );
+ DataElementCategory category = categoryService.getDataElementCategory( dec.getId(), true );
+
+ optionsMap.put( category.getId(), category.getCategoryOptions() );
}
orderedOptionsMap.put( categoryCombo.getId(), optionsMap );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2015-02-09 17:46:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2015-06-06 11:44:58 +0000
@@ -30,6 +30,7 @@
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
<bean id="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" class="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" scope="prototype">