------------------------------------------------------------ revno: 18525 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Sun 2015-03-08 11:49:07 +0100 message: Introduced interface GenericDimensionalObjectStore added: dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericDimensionalObjectStore.java modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.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/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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericDimensionalObjectStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericDimensionalObjectStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericDimensionalObjectStore.java 2015-03-08 10:49:07 +0000 @@ -0,0 +1,54 @@ +package org.hisp.dhis.common; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.List; + +/** + * @author Lars Helge Overland + */ +public interface GenericDimensionalObjectStore<T> + extends GenericNameableObjectStore<T> +{ + /** + * Retrieves a List of dimensional objects. + * + * @param dataDimension indicates whether to fetch objects defined as dimensional. + * @return a List of objects. + */ + List<T> getByDataDimension( boolean dataDimension ); + + /** + * Retrieves a List of dimensional objects. Ignore ACL / sharing. + * + * @param dataDimension indicates whether to fetch objects defined as dimensional. + * @return a List of objects. + */ + List<T> getByDataDimensionNoAcl( boolean dataDimension ); +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java 2015-03-08 10:49:07 +0000 @@ -46,9 +46,6 @@ /** * Return the number of objects where the name is equal the given name. - * <p/> - * This count is _unfiltered_ (no ACL!), so this is not the same as - * getAllEqShortName().size(). * * @param shortName the name. * @return Count of objects. @@ -70,13 +67,4 @@ * @return a List of objects. */ List<T> getAllEqShortNameIgnoreCase( String shortName ); - - /** - * Retrieves a List of dimensional objects. TODO move to new - * GenericDimensionObjectStore. - * - * @param dataDimension indicates whether to fetch objects defined as dimensional. - * @return a List of objects. - */ - List<T> getByDataDimension( boolean dataDimension ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryStore.java 2015-03-08 10:49:07 +0000 @@ -30,13 +30,13 @@ import java.util.Collection; -import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.GenericDimensionalObjectStore; /** * @author Lars Helge Overland */ public interface CategoryStore - extends GenericNameableObjectStore<DataElementCategory> + extends GenericDimensionalObjectStore<DataElementCategory> { Collection<DataElementCategory> getCategoriesByDimensionType( String dimensionType ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java 2015-03-08 10:49:07 +0000 @@ -28,12 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.GenericDimensionalObjectStore; /** * @author Morten Olav Hansen <morte...@gmail.com> */ public interface OrganisationUnitGroupSetStore - extends GenericNameableObjectStore<OrganisationUnitGroupSet> + extends GenericDimensionalObjectStore<OrganisationUnitGroupSet> { } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-02-25 08:32:15 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-03-08 10:49:07 +0000 @@ -28,6 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Query; @@ -37,22 +43,16 @@ import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.AuditLogUtil; import org.hisp.dhis.common.BaseIdentifiableObject; -import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.GenericDimensionalObjectStore; import org.hisp.dhis.common.NameableObject; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; - /** * @author bobj */ public class HibernateIdentifiableObjectStore<T extends BaseIdentifiableObject> - extends HibernateGenericStore<T> implements GenericNameableObjectStore<T> + extends HibernateGenericStore<T> implements GenericDimensionalObjectStore<T> { private static final Log log = LogFactory.getLog( HibernateIdentifiableObjectStore.class ); @@ -433,6 +433,14 @@ @Override @SuppressWarnings( "unchecked" ) + public List<T> getByDataDimensionNoAcl( boolean dataDimension ) + { + return getCriteria() + .add( Restrictions.eq( "dataDimension", dataDimension ) ).list(); + } + + @Override + @SuppressWarnings( "unchecked" ) public List<T> getByUid( Collection<String> uids ) { if ( uids == null || uids.isEmpty() ) === 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 2015-02-19 18:22:57 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2015-03-08 10:49:07 +0000 @@ -41,7 +41,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.GenericDimensionalObjectStore; import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; @@ -97,10 +97,9 @@ this.categoryOptionGroupStore = categoryOptionGroupStore; } - private GenericNameableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore; + private GenericDimensionalObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore; - public void setCategoryOptionGroupSetStore( - GenericNameableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore ) + public void setCategoryOptionGroupSetStore( GenericDimensionalObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore ) { this.categoryOptionGroupSetStore = categoryOptionGroupSetStore; } === 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2015-03-08 10:49:07 +0000 @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.GenericDimensionalObjectStore; import org.hisp.dhis.common.GenericNameableObjectStore; import org.hisp.dhis.common.ListMap; import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator; @@ -75,9 +76,9 @@ this.dataElementGroupStore = dataElementGroupStore; } - private GenericNameableObjectStore<DataElementGroupSet> dataElementGroupSetStore; + private GenericDimensionalObjectStore<DataElementGroupSet> dataElementGroupSetStore; - public void setDataElementGroupSetStore( GenericNameableObjectStore<DataElementGroupSet> dataElementGroupSetStore ) + public void setDataElementGroupSetStore( GenericDimensionalObjectStore<DataElementGroupSet> dataElementGroupSetStore ) { this.dataElementGroupSetStore = dataElementGroupSetStore; }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp