dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32472
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16573: Refactored option store. The store that handled option sets was called option store.
------------------------------------------------------------
revno: 16573
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-08-29 15:03:34 +0200
message:
Refactored option store. The store that handled option sets was called option store.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java
dhis-2/dhis-services/dhis-service-core/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/option/OptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java 2014-08-29 12:48:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java 2014-08-29 13:03:34 +0000
@@ -38,7 +38,8 @@
*
* @version $OptionStore.java Jun 15, 2012 9:45:00 AM$
*/
-public interface OptionStore extends GenericIdentifiableObjectStore<OptionSet>
+public interface OptionStore
+ extends GenericIdentifiableObjectStore<Option>
{
List<Option> getOptions( int optionSetId, String key, Integer max );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2014-08-29 12:48:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2014-08-29 13:03:34 +0000
@@ -50,6 +50,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ private GenericIdentifiableObjectStore<OptionSet> optionSetStore;
+
+ public void setOptionSetStore( GenericIdentifiableObjectStore<OptionSet> optionSetStore )
+ {
+ this.optionSetStore = optionSetStore;
+ }
+
private OptionStore optionStore;
public void setOptionStore( OptionStore optionStore )
@@ -57,13 +64,6 @@
this.optionStore = optionStore;
}
- private GenericIdentifiableObjectStore<Option> optionValueStore;
-
- public void setOptionValueStore( GenericIdentifiableObjectStore<Option> optionValueStore )
- {
- this.optionValueStore = optionValueStore;
- }
-
private I18nService i18nService;
public void setI18nService( I18nService service )
@@ -72,43 +72,71 @@
}
// -------------------------------------------------------------------------
- // Implementation methods -
+ // OptionService implementation
+ // -------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
+ // Option Set
// -------------------------------------------------------------------------
public int saveOptionSet( OptionSet optionSet )
{
- return optionStore.save( optionSet );
+ return optionSetStore.save( optionSet );
}
public void updateOptionSet( OptionSet optionSet )
{
- optionStore.update( optionSet );
+ optionSetStore.update( optionSet );
}
public OptionSet getOptionSet( int id )
{
- return i18n( i18nService, optionStore.get( id ) );
+ return i18n( i18nService, optionSetStore.get( id ) );
}
public OptionSet getOptionSet( String uid )
{
- return i18n( i18nService, optionStore.getByUid( uid ) );
+ return i18n( i18nService, optionSetStore.getByUid( uid ) );
}
public OptionSet getOptionSetByName( String name )
{
- return i18n( i18nService, optionStore.getByName( name ) );
+ return i18n( i18nService, optionSetStore.getByName( name ) );
}
public void deleteOptionSet( OptionSet optionSet )
{
- optionStore.delete( optionSet );
+ optionSetStore.delete( optionSet );
}
public Collection<OptionSet> getAllOptionSets()
{
- return i18n( i18nService, optionStore.getAll() );
- }
+ return i18n( i18nService, optionSetStore.getAll() );
+ }
+
+ public Integer getOptionSetsCountByName( String name )
+ {
+ return optionStore.getCountLikeName( name );
+ }
+
+ public Collection<OptionSet> getOptionSetsBetweenByName( String name, int first, int max )
+ {
+ return new HashSet<>( i18n( i18nService, optionSetStore.getAllLikeNameOrderedName( name, first, max ) ) );
+ }
+
+ public Collection<OptionSet> getOptionSetsBetween( int first, int max )
+ {
+ return new HashSet<>( i18n( i18nService, optionSetStore.getAllOrderedName( first, max ) ) );
+ }
+
+ public Integer getOptionSetCount()
+ {
+ return optionSetStore.getCount();
+ }
+
+ // -------------------------------------------------------------------------
+ // Option
+ // -------------------------------------------------------------------------
public List<Option> getOptions( String optionSetUid, String key, Integer max )
{
@@ -139,43 +167,19 @@
return options;
}
- public Integer getOptionSetsCountByName( String name )
- {
- return optionStore.getCountLikeName( name );
- }
-
- public Collection<OptionSet> getOptionSetsBetweenByName( String name, int first, int max )
- {
- return new HashSet<>( i18n( i18nService, optionStore.getAllLikeNameOrderedName( name, first, max ) ) );
- }
-
- public Collection<OptionSet> getOptionSetsBetween( int first, int max )
- {
- return new HashSet<>( i18n( i18nService, optionStore.getAllOrderedName( first, max ) ) );
- }
-
- public Integer getOptionSetCount()
- {
- return optionStore.getCount();
- }
-
- // -------------------------------------------------------------------------
- // Option
- // -------------------------------------------------------------------------
-
public void updateOption( Option option )
{
- optionValueStore.update( option );
+ optionStore.update( option );
}
public Option getOption( int id )
{
- return i18n( i18nService, optionValueStore.get( id ) );
+ return i18n( i18nService, optionStore.get( id ) );
}
public Option getOptionByCode( String code )
{
- return i18n( i18nService, optionValueStore.getByCode( code ) );
+ return i18n( i18nService, optionStore.getByCode( code ) );
}
public Option getOptionByName( OptionSet optionSet, String name )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java 2014-08-29 12:48:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java 2014-08-29 13:03:34 +0000
@@ -41,7 +41,7 @@
* @author Chau Thu Tran
*/
public class HibernateOptionStore
- extends HibernateIdentifiableObjectStore<OptionSet>
+ extends HibernateIdentifiableObjectStore<Option>
implements OptionStore
{
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-08-25 19:32:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-08-29 13:03:34 +0000
@@ -351,16 +351,18 @@
<property name="cacheable" value="true" />
</bean>
+ <bean id="org.hisp.dhis.option.OptionSetStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
+ <property name="clazz" value="org.hisp.dhis.option.OptionSet" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="cacheable" value="true" />
+ </bean>
+
<bean id="org.hisp.dhis.option.OptionStore" class="org.hisp.dhis.option.hibernate.HibernateOptionStore">
- <property name="clazz" value="org.hisp.dhis.option.OptionSet" />
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
-
- <bean id="org.hisp.dhis.option.OptionValueStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
<property name="clazz" value="org.hisp.dhis.option.Option" />
<property name="sessionFactory" ref="sessionFactory" />
+ <property name="cacheable" value="true" />
</bean>
-
+
<bean id="org.hisp.dhis.mapping.MapStore" class="org.hisp.dhis.mapping.hibernate.HibernateMapStore">
<property name="clazz" value="org.hisp.dhis.mapping.Map" />
<property name="sessionFactory" ref="sessionFactory" />
@@ -681,8 +683,8 @@
</bean>
<bean id="org.hisp.dhis.option.OptionService" class="org.hisp.dhis.option.DefaultOptionService">
+ <property name="optionSetStore" ref="org.hisp.dhis.option.OptionSetStore" />
<property name="optionStore" ref="org.hisp.dhis.option.OptionStore" />
- <property name="optionValueStore" ref="org.hisp.dhis.option.OptionValueStore" />
<property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
</bean>