dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20849
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9704: remove usage of getByName in DataElement*Service
------------------------------------------------------------
revno: 9704
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-02-04 11:14:07 +0700
message:
remove usage of getByName in DataElement*Service
modified:
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/DefaultDataElementService.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-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 2013-01-28 06:47:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-02-04 04:14:07 +0000
@@ -27,8 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
import org.apache.commons.collections.CollectionUtils;
import org.hisp.dhis.common.GenericDimensionalObjectStore;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
@@ -38,7 +36,15 @@
import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.transaction.annotation.Transactional;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
/**
* @author Abyot Asalefew
@@ -118,17 +124,17 @@
public Collection<DataElementCategory> getAllDataElementCategories()
{
- return i18n( i18nService, dataElementCategoryStore.getAll());
+ return i18n( i18nService, dataElementCategoryStore.getAll() );
}
public DataElementCategory getDataElementCategory( int id )
{
- return i18n( i18nService, dataElementCategoryStore.get( id ));
+ return i18n( i18nService, dataElementCategoryStore.get( id ) );
}
public DataElementCategory getDataElementCategory( String uid )
{
- return i18n( i18nService, dataElementCategoryStore.getByUid( uid ));
+ return i18n( i18nService, dataElementCategoryStore.getByUid( uid ) );
}
public Collection<DataElementCategory> getDataElementCategories( final Collection<Integer> identifiers )
@@ -146,7 +152,14 @@
public DataElementCategory getDataElementCategoryByName( String name )
{
- return i18n( i18nService, dataElementCategoryStore.getByName( name ));
+ List<DataElementCategory> dataElementCategories = new ArrayList<DataElementCategory>( dataElementCategoryStore.getAllEqName( name ) );
+
+ if ( dataElementCategories.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElementCategories.get( 0 ) );
}
// -------------------------------------------------------------------------
@@ -180,7 +193,14 @@
public DataElementCategoryOption getDataElementCategoryOptionByName( String name )
{
- return dataElementCategoryOptionStore.getByName( name );
+ List<DataElementCategoryOption> dataElementCategoryOptions = new ArrayList<DataElementCategoryOption>( dataElementCategoryOptionStore.getAllEqName( name ) );
+
+ if ( dataElementCategoryOptions.isEmpty() )
+ {
+ return null;
+ }
+
+ return dataElementCategoryOptions.get( 0 );
}
public Collection<DataElementCategoryOption> getDataElementCategoryOptions( final Collection<Integer> identifiers )
@@ -223,17 +243,17 @@
public Collection<DataElementCategoryCombo> getAllDataElementCategoryCombos()
{
- return i18n( i18nService, dataElementCategoryComboStore.getAll());
+ return i18n( i18nService, dataElementCategoryComboStore.getAll() );
}
public DataElementCategoryCombo getDataElementCategoryCombo( int id )
{
- return i18n( i18nService, dataElementCategoryComboStore.get( id ));
+ return i18n( i18nService, dataElementCategoryComboStore.get( id ) );
}
public DataElementCategoryCombo getDataElementCategoryCombo( String uid )
{
- return i18n( i18nService, dataElementCategoryComboStore.getByUid( uid ));
+ return i18n( i18nService, dataElementCategoryComboStore.getByUid( uid ) );
}
public Collection<DataElementCategoryCombo> getDataElementCategoryCombos( final Collection<Integer> identifiers )
@@ -252,7 +272,14 @@
public DataElementCategoryCombo getDataElementCategoryComboByName( String name )
{
- return i18n( i18nService, dataElementCategoryComboStore.getByName( name ));
+ List<DataElementCategoryCombo> dataElementCategoryCombos = new ArrayList<DataElementCategoryCombo>( dataElementCategoryComboStore.getAllEqName( name ) );
+
+ if ( dataElementCategoryCombos.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElementCategoryCombos.get( 0 ) );
}
// -------------------------------------------------------------------------
@@ -562,12 +589,12 @@
public Collection<DataElementCategory> getDataElementCategorysBetween( int first, int max )
{
- return i18n( i18nService, dataElementCategoryStore.getAllOrderedName( first, max ));
+ return i18n( i18nService, dataElementCategoryStore.getAllOrderedName( first, max ) );
}
public Collection<DataElementCategory> getDataElementCategorysBetweenByName( String name, int first, int max )
{
- return i18n( i18nService, dataElementCategoryStore.getAllLikeNameOrderedName( name, first, max ));
+ return i18n( i18nService, dataElementCategoryStore.getAllLikeNameOrderedName( name, first, max ) );
}
public int getDataElementCategoryComboCount()
@@ -582,7 +609,7 @@
public Collection<DataElementCategoryCombo> getDataElementCategoryCombosBetween( int first, int max )
{
- return i18n( i18nService, dataElementCategoryComboStore.getAllOrderedName( first, max ));
+ return i18n( i18nService, dataElementCategoryComboStore.getAllOrderedName( first, max ) );
}
public Collection<DataElementCategoryCombo> getDataElementCategoryCombosBetweenByName( String name, int first,
@@ -600,19 +627,19 @@
@Override
public Collection<DataElementCategory> getDataElementCategorysByConcept( Concept concept )
{
- return i18n( i18nService, dataElementCategoryStore.getByConcept( concept ));
+ return i18n( i18nService, dataElementCategoryStore.getByConcept( concept ) );
}
@Override
public Collection<DataElementCategory> getDataElementCategoryBetween( int first, int max )
{
- return i18n( i18nService, dataElementCategoryStore.getAllOrderedName( first, max ));
+ return i18n( i18nService, dataElementCategoryStore.getAllOrderedName( first, max ) );
}
@Override
public Collection<DataElementCategory> getDataElementCategoryBetweenByName( String name, int first, int max )
{
- return i18n( i18nService, dataElementCategoryStore.getAllLikeNameOrderedName( name, first, max ));
+ return i18n( i18nService, dataElementCategoryStore.getAllLikeNameOrderedName( name, first, max ) );
}
@Override
=== 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-02-03 10:44:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-02-04 04:14:07 +0000
@@ -27,11 +27,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.i18n.I18nUtils.getCountByName;
-import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetween;
-import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetweenByName;
-import static org.hisp.dhis.i18n.I18nUtils.getObjectsByName;
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.util.Filter;
+import org.hisp.dhis.system.util.FilterUtils;
+import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
@@ -43,14 +46,7 @@
import java.util.Map;
import java.util.Set;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.i18n.I18nService;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.system.util.Filter;
-import org.hisp.dhis.system.util.FilterUtils;
-import org.springframework.transaction.annotation.Transactional;
+import static org.hisp.dhis.i18n.I18nUtils.*;
/**
* @author Kristian Nordal
@@ -190,7 +186,14 @@
public DataElement getDataElementByName( String name )
{
- return i18n( i18nService, dataElementStore.getByName( name ) );
+ List<DataElement> dataElements = new ArrayList<DataElement>( dataElementStore.getAllEqName( name ) );
+
+ if ( dataElements.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElements.get( 0 ) );
}
public Collection<DataElement> searchDataElementsByName( String key )
@@ -200,7 +203,14 @@
public DataElement getDataElementByShortName( String shortName )
{
- return i18n( i18nService, dataElementStore.getByShortName( shortName ) );
+ List<DataElement> dataElements = new ArrayList<DataElement>( dataElementStore.getAllEqShortName( shortName ) );
+
+ if ( dataElements.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElements.get( 0 ) );
}
public Collection<DataElement> getDataElementsByAggregationOperator( String aggregationOperator )
@@ -420,7 +430,14 @@
public DataElementGroup getDataElementGroupByName( String name )
{
- return i18n( i18nService, dataElementGroupStore.getByName( name ) );
+ List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>( dataElementGroupStore.getAllEqName( name ) );
+
+ if ( dataElementGroups.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElementGroups.get( 0 ) );
}
public Collection<DataElementGroup> getGroupsContainingDataElement( DataElement dataElement )
@@ -508,7 +525,14 @@
public DataElementGroupSet getDataElementGroupSetByName( String name )
{
- return i18n( i18nService, dataElementGroupSetStore.getByName( name ) );
+ List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>( dataElementGroupSetStore.getAllEqName( name ) );
+
+ if ( dataElementGroupSets.isEmpty() )
+ {
+ return null;
+ }
+
+ return i18n( i18nService, dataElementGroupSets.get( 0 ) );
}
@Override