=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2013-01-27 20:34:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2013-01-28 08:50:29 +0000 @@ -73,6 +73,8 @@ public class DataElement extends BaseNameableObject { + public static final String[] I18N_PROPERTIES = { "name", "shortName", "description", "formName" }; + /** * Determines if a de-serialized file is compatible with this class. */ @@ -114,7 +116,12 @@ * The name to appear in forms. */ private String formName; - + + /** + * The i18n variant of the display name. Should not be persisted. + */ + protected transient String displayFormName; + /** * If this DataElement is active or not (enabled or disabled). */ @@ -413,7 +420,17 @@ */ public String getFormNameFallback() { - return formName != null && !formName.isEmpty() ? formName : getDisplayName(); + return formName != null && !formName.isEmpty() ? getDisplayFormName() : getDisplayName(); + } + + public String getDisplayFormName() + { + return ( displayFormName != null && !displayFormName.trim().isEmpty() ) ? displayFormName : formName; + } + + public void setDisplayFormName( String displayFormName ) + { + this.displayFormName = displayFormName; } /** === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-01-11 13:12:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-01-28 08:50:29 +0000 @@ -79,7 +79,8 @@ private GenericIdentifiableObjectStore dataElementGroupSetStore; - public void setDataElementGroupSetStore( GenericIdentifiableObjectStore dataElementGroupSetStore ) + public void setDataElementGroupSetStore( + GenericIdentifiableObjectStore dataElementGroupSetStore ) { this.dataElementGroupSetStore = dataElementGroupSetStore; } @@ -142,7 +143,7 @@ } } ); } - + public List getDataElementsByUid( Collection uids ) { return dataElementStore.getByUid( uids ); @@ -328,29 +329,29 @@ { return i18n( i18nService, dataElementStore.getDataElementsByAggregationLevel( aggregationLevel ) ); } - + public Map> getDataElementCategoryOptionCombos() { return dataElementStore.getDataElementCategoryOptionCombos(); } - + public Map getDataElementUidIdMap() { Map map = new HashMap(); - + for ( DataElement dataElement : getAllDataElements() ) { map.put( dataElement.getUid(), dataElement.getId() ); } - + return map; } - + public Collection getDataElements( DataSet dataSet, String key, Integer max ) { - return dataElementStore.get( dataSet, key, max ); + return i18n( i18nService, dataElementStore.get( dataSet, key, max ) ); } - + // ------------------------------------------------------------------------- // DataElementGroup // ------------------------------------------------------------------------- @@ -376,19 +377,19 @@ { return i18n( i18nService, dataElementGroupStore.get( id ) ); } - + public DataElementGroup getDataElementGroup( int id, boolean i18nDataElements ) { DataElementGroup group = getDataElementGroup( id ); - + if ( i18nDataElements ) { i18n( i18nService, group.getMembers() ); } - + return group; } - + public Collection getDataElementGroups( final Collection identifiers ) { Collection groups = getAllDataElementGroups(); @@ -401,7 +402,7 @@ } } ); } - + public Collection getDataElementGroupsByUid( Collection uids ) { return dataElementGroupStore.getByUid( uids ); @@ -487,16 +488,16 @@ { return i18n( i18nService, dataElementGroupSetStore.get( id ) ); } - + public DataElementGroupSet getDataElementGroupSet( int id, boolean i18nGroups ) { DataElementGroupSet groupSet = getDataElementGroupSet( id ); - + if ( i18nGroups ) { i18n( i18nService, groupSet.getDataElements() ); } - + return groupSet; } @@ -571,7 +572,7 @@ } } ); } - + public List getDataElementGroupSetsByUid( Collection uids ) { return dataElementGroupSetStore.getByUid( uids ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-01-05 15:22:55 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-01-28 08:50:29 +0000 @@ -212,28 +212,26 @@ { String hql = "select distinct de from DataElement de join de.dataSets ds where ds.id in (:ids)"; - return sessionFactory.getCurrentSession().createQuery( hql ).setParameterList( "ids", - ConversionUtils.getIdentifiers( DataSet.class, dataSets ) ).list(); + return sessionFactory.getCurrentSession().createQuery( hql ) + .setParameterList( "ids", ConversionUtils.getIdentifiers( DataSet.class, dataSets ) ).list(); } @SuppressWarnings( "unchecked" ) public Collection getDataElementsByAggregationLevel( int aggregationLevel ) { String hql = "from DataElement de join de.aggregationLevels al where al = :aggregationLevel"; - + return getQuery( hql ).setInteger( "aggregationLevel", aggregationLevel ).list(); } public Map> getDataElementCategoryOptionCombos() { - final String sql = - "select de.uid, coc.uid " + - "from dataelement de " + - "join categorycombos_optioncombos cc on de.categorycomboid = cc.categorycomboid " + - "join categoryoptioncombo coc on cc.categoryoptioncomboid = coc.categoryoptioncomboid"; - + final String sql = "select de.uid, coc.uid " + "from dataelement de " + + "join categorycombos_optioncombos cc on de.categorycomboid = cc.categorycomboid " + + "join categoryoptioncombo coc on cc.categoryoptioncomboid = coc.categoryoptioncomboid"; + final Map> sets = new HashMap>(); - + jdbcTemplate.query( sql, new RowCallbackHandler() { @Override @@ -242,30 +240,33 @@ { String dataElement = rs.getString( 1 ); String categoryOptionCombo = rs.getString( 2 ); - + Set set = sets.get( dataElement ) != null ? sets.get( dataElement ) : new HashSet(); - - set.add( categoryOptionCombo ); + + set.add( categoryOptionCombo ); sets.put( dataElement, set ); } } ); - + return sets; } - + @SuppressWarnings( "unchecked" ) public Collection get( DataSet dataSet, String key, Integer max ) { String hql = "select dataElement from DataSet dataSet inner join dataSet.dataElements as dataElement where dataSet.id = :dataSetId "; - - if( key != null ) + + if ( key != null ) { hql += " and lower(dataElement.name) like lower('%" + key + "%') "; } - + Query query = getQuery( hql ); query.setInteger( "dataSetId", dataSet.getId() ); - query.setMaxResults( max ); + if ( max != null ) + { + query.setMaxResults( max ); + } return query.list(); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2012-01-26 11:40:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2013-01-28 08:50:29 +0000 @@ -46,6 +46,7 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.NameableObject; +import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.system.util.LocaleUtils; import org.hisp.dhis.translation.Translation; import org.hisp.dhis.translation.TranslationService; @@ -86,20 +87,20 @@ for ( String string : localeStrings ) { Locale locale = LocaleUtils.getLocale( string ); - + if ( locale != null ) { locales.add( locale ); } } - + Collections.sort( locales, new Comparator() + { + public int compare( Locale l1, Locale l2 ) { - public int compare( Locale l1, Locale l2 ) - { - return l1.getDisplayName().compareTo( l2.getDisplayName() ); - } - } ); + return l1.getDisplayName().compareTo( l2.getDisplayName() ); + } + } ); } // ------------------------------------------------------------------------- @@ -136,18 +137,18 @@ { return; } - + List properties = getObjectPropertyNames( object ); - + Collection translations = translationService.getTranslations( getClassName( object ), getId( object ), locale ); - + Map translationMap = convertTranslations( translations ); - + for ( String property : properties ) { String value = translationMap.get( property ); - + if ( value != null && !value.isEmpty() ) { setProperty( object, "display", property, value ); @@ -161,21 +162,21 @@ { return; } - + Object peek = objects.iterator().next(); List properties = getObjectPropertyNames( peek ); - + Collection translations = translationService.getTranslations( getClassName( peek ), locale ); for ( Object object : objects ) { Map translationMap = getTranslationsForObject( translations, getId( object ) ); - + for ( String property : properties ) { String value = translationMap.get( property ); - + if ( value != null && !value.isEmpty() ) { setProperty( object, "display", property, value ); @@ -183,31 +184,37 @@ } } } - + public Map getObjectPropertyValues( Object object ) { List properties = getObjectPropertyNames( object ); - + Map translations = new HashMap(); - + for ( String property : properties ) { translations.put( property, getProperty( object, property ) ); } - + return translations; } public List getObjectPropertyNames( Object object ) { - if ( !( object instanceof IdentifiableObject ) ) + if ( !(object instanceof IdentifiableObject) ) { throw new IllegalArgumentException( "I18n object must be identifiable: " + object ); } - return ( object instanceof NameableObject ) ? Arrays.asList( NameableObject.I18N_PROPERTIES ) : Arrays.asList( IdentifiableObject.I18N_PROPERTIES ); + if ( object instanceof DataElement ) + { + return Arrays.asList( DataElement.I18N_PROPERTIES ); + } + + return (object instanceof NameableObject) ? Arrays.asList( NameableObject.I18N_PROPERTIES ) : Arrays + .asList( IdentifiableObject.I18N_PROPERTIES ); } - + // ------------------------------------------------------------------------- // Object // ------------------------------------------------------------------------- @@ -232,9 +239,9 @@ { String key = translationEntry.getKey(); String value = translationEntry.getValue(); - + Translation translation = translationService.getTranslation( className, id, locale, key ); - + if ( value != null && !value.trim().isEmpty() ) { if ( translation != null ) @@ -260,33 +267,33 @@ { return getTranslations( className, id, getCurrentLocale() ); } - + public Map getTranslations( String className, int id, Locale locale ) { if ( locale != null && className != null ) { return convertTranslations( translationService.getTranslations( className, id, locale ) ); } - + return new HashMap(); } // ------------------------------------------------------------------------- // Locale // ------------------------------------------------------------------------- - + public Locale getCurrentLocale() { return (Locale) userSettingService.getUserSetting( UserSettingService.KEY_DB_LOCALE ); } - + public boolean currentLocaleIsBase() { return getCurrentLocale() == null; } - + public List getAvailableLocales() - { + { return locales; } === 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 2013-01-04 18:10:25 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2013-01-28 08:50:29 +0000 @@ -227,7 +227,8 @@ { DataSet dataSet = dataSetService.getDataSet( dataSetId, true, false, false ); - List dataElements = new ArrayList( dataSet.getDataElements() ); + List dataElements = new ArrayList( dataElementService.getDataElements( dataSet, null, + null ) ); if ( dataElements.isEmpty() ) { @@ -306,7 +307,13 @@ String displayMode = dataSet.getDataSetType(); - if ( multiOrganisationUnit != null && multiOrganisationUnit != 0 ) // for multiOrg, we only support section forms + if ( multiOrganisationUnit != null && multiOrganisationUnit != 0 ) // for + // multiOrg, + // we + // only + // support + // section + // forms { OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( multiOrganisationUnit ); List organisationUnitChildren = new ArrayList(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2012-11-07 14:39:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2013-01-28 08:50:29 +0000 @@ -196,4 +196,5 @@ long_text = Long text text_type = Text type legend_set=Legend set -skip_total_in_reports=Skip category total in reports \ No newline at end of file +skip_total_in_reports=Skip category total in reports +translation_label_formName = Form name \ No newline at end of file