dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15792
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5824: I18n db fix
------------------------------------------------------------
revno: 5824
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-01-30 11:28:30 +0100
message:
I18n db fix
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
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/i18n/I18nUtils.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java
--
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/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2012-01-30 09:49:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2012-01-30 10:28:30 +0000
@@ -234,7 +234,7 @@
if ( categoryOptionCombo == null ) // Total
{
- return dataElement.getName() + SPACE + NAME_TOTAL;
+ return dataElement.getDisplayName() + SPACE + NAME_TOTAL;
}
return categoryOptionCombo.isDefault() ? dataElement.getDisplayName() : dataElement.getDisplayName() + SPACE + categoryOptionCombo.getName();
@@ -287,7 +287,7 @@
{
this.dataElementId = dataElement.getId();
this.operandId = String.valueOf( dataElement.getId() );
- this.operandName = dataElement.getName() + SPACE + NAME_TOTAL;
+ this.operandName = dataElement.getDisplayName() + SPACE + NAME_TOTAL;
this.aggregationOperator = dataElement.getAggregationOperator();
this.frequencyOrder = dataElement.getFrequencyOrder();
this.aggregationLevels = new ArrayList<Integer>( dataElement.getAggregationLevels() );
=== 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 2012-01-28 16:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2012-01-30 10:28:30 +0000
@@ -300,9 +300,9 @@
return dataElementStore.dataElementCategoryOptionComboExists( id );
}
- public Collection<DataElement> getDataElementsLikeName( String name ) //TODO fix
+ public Collection<DataElement> getDataElementsLikeName( String name )
{
- return i18n( i18nService, dataElementStore.getLikeName( name ) );
+ return getObjectsByName( i18nService, dataElementStore, name );
}
public int getDataElementCount()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nUtils.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nUtils.java 2012-01-28 16:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nUtils.java 2012-01-30 10:28:30 +0000
@@ -87,4 +87,12 @@
i18n( i18nService, store.getBetweenByName( name, first, max ) ) :
Paging.getObjectsBetweenByName( i18n( i18nService, store.getAll() ), name, first, max );
}
+
+ public static <T extends IdentifiableObject> Collection<T> getObjectsByName(
+ I18nService i18nService, GenericIdentifiableObjectStore<T> store, String name )
+ {
+ return i18nService.currentLocaleIsBase() ?
+ i18n( i18nService, store.getLikeName( name ) ) :
+ Paging.getObjectsByName( i18n( i18nService, store.getAll() ), name );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2012-01-28 16:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2012-01-30 10:28:30 +0000
@@ -168,9 +168,9 @@
return i18n( i18nService, indicatorStore.getIndicatorsWithDataSets() );
}
- public Collection<Indicator> getIndicatorsLikeName( String name ) //TODO fix
+ public Collection<Indicator> getIndicatorsLikeName( String name )
{
- return i18n( i18nService, indicatorStore.getLikeName( name ) );
+ return getObjectsByName( i18nService, indicatorStore, name );
}
public int getIndicatorCount()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2012-01-28 16:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2012-01-30 10:28:30 +0000
@@ -434,7 +434,7 @@
public Collection<ValidationRule> getValidationRulesByName( String name )
{
- return i18n( i18nService, validationRuleStore.getLikeName( name ) );
+ return getObjectsByName( i18nService, validationRuleStore, name );
}
public Collection<ValidationRule> getValidationRulesByDataElements( Collection<DataElement> dataElements )
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java 2012-01-28 16:24:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java 2012-01-30 10:28:30 +0000
@@ -222,4 +222,22 @@
return list.subList( first, last );
}
+
+ public static <T extends IdentifiableObject> Collection<T> getObjectsByName( Collection<T> objects, String name )
+ {
+ final List<T> list = new ArrayList<T>();
+
+ if ( name != null )
+ {
+ for ( T object : objects )
+ {
+ if ( object != null && object.getDisplayName() != null && object.getDisplayName().toLowerCase().contains( name.toLowerCase() ) )
+ {
+ list.add( object );
+ }
+ }
+ }
+
+ return list;
+ }
}