← Back to team overview

dhis2-devs team mailing list archive

Re: [Branch ~dhis2-devs-core/dhis2/trunk] Rev 938: Made the uniqueness constraint on CategoryOption back in. Will maintain it in a transition period.

 

Could some one remind me once again what the point of having a
category option in two separate categories is? is there a use case
here? It does not seem totally obvious, but maybe I am missing
something.

Regards,
jason


On Fri, Oct 30, 2009 at 3:24 PM,  <noreply@xxxxxxxxxxxxx> wrote:
> ------------------------------------------------------------
> revno: 938
> committer: Lars Helge Oeverland larshelge@xxxxxxxxx
> branch nick: trunk
> timestamp: Fri 2009-10-30 14:22:00 +0100
> message:
>  Made the uniqueness constraint on CategoryOption back in. Will maintain it in a transition period.
> 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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java
>  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.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     2009-10-29 11:27:49 +0000
> +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java     2009-10-30 13:22:00 +0000
> @@ -141,11 +141,11 @@
>     Collection<DataElementCategoryOption> getDataElementCategoryOptions( Collection<Integer> identifiers );
>
>     /**
> -     * Retrieves the DataElementCategoryOptions with the given name.
> +     * Retrieves the DataElementCategoryOption with the given name.
>      * @param name the name.
> -     * @return the DataElementCategoryOptions with the given name.
> +     * @return the DataElementCategoryOption with the given name.
>      */
> -    Collection<DataElementCategoryOption> getDataElementCategoryOptionsByName( String name );
> +    DataElementCategoryOption getDataElementCategoryOptionByName( String name );
>
>     /**
>      * Returns all DataElementCategoryOptions.
>
> === 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       2009-10-29 11:27:49 +0000
> +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java       2009-10-30 13:22:00 +0000
> @@ -62,9 +62,9 @@
>         this.dataElementCategoryStore = dataElementCategoryStore;
>     }
>
> -    private GenericStore<DataElementCategoryOption> dataElementCategoryOptionStore;
> +    private GenericIdentifiableObjectStore<DataElementCategoryOption> dataElementCategoryOptionStore;
>
> -    public void setDataElementCategoryOptionStore( GenericStore<DataElementCategoryOption> dataElementCategoryOptionStore )
> +    public void setDataElementCategoryOptionStore( GenericIdentifiableObjectStore<DataElementCategoryOption> dataElementCategoryOptionStore )
>     {
>         this.dataElementCategoryOptionStore = dataElementCategoryOptionStore;
>     }
> @@ -194,19 +194,9 @@
>         return dataElementCategoryOptionStore.get( id );
>     }
>
> -    public Collection<DataElementCategoryOption> getDataElementCategoryOptionsByName( String name )
> +    public DataElementCategoryOption getDataElementCategoryOptionByName( String name )
>     {
> -        Collection<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
> -
> -        for ( DataElementCategoryOption categoryOption : getAllDataElementCategoryOptions() )
> -        {
> -            if ( categoryOption.getName().equals( name ) )
> -            {
> -                categoryOptions.add( categoryOption );
> -            }
> -        }
> -
> -        return categoryOptions;
> +        return dataElementCategoryOptionStore.getByName( name );
>     }
>
>     public Collection<DataElementCategoryOption> getDataElementCategoryOptions( Collection<Integer> identifiers )
>
> === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java'
> --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java      2009-10-20 10:51:16 +0000
> +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java      2009-10-30 13:22:00 +0000
> @@ -106,7 +106,7 @@
>         //dataelementcategoryoption
>         executeSql( "ALTER TABLE dataelementcategoryoption DROP COLUMN shortname" );
>         executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT fk_dataelement_categoryid" );
> -        executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT dataelementcategoryoption_name_key" );
> +        //executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT dataelementcategoryoption_name_key" ); will be maintained in transition period
>         executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT dataelementcategoryoption_shortname_key" );
>
>         log.info( "Updated Category sort order and primary keys" );
>
> === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml'
> --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml     2009-10-21 18:41:33 +0000
> +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml     2009-10-30 13:22:00 +0000
> @@ -13,7 +13,7 @@
>     <property name="uuid" length="40"/>
>
>     <property name="name">
> -      <column name="name" not-null="true" length="160"/>
> +      <column name="name" not-null="true" unique="true" length="160"/>
>     </property>
>
>     <list name="categoryOptionCombos" table="categoryoptioncombos_categoryoptions" inverse="true">
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>



Follow ups

References