← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14038: Added TrackedEntityAttributeOptionStore

 

------------------------------------------------------------
revno: 14038
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-02-15 15:29:54 +0100
message:
  Added TrackedEntityAttributeOptionStore
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java
  dhis-2/dhis-services/dhis-service-tracker/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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java	2014-02-15 14:29:54 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, 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.Collection;
+
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+
+public interface TrackedEntityAttributeOptionStore
+    extends GenericIdentifiableObjectStore<TrackedEntityAttributeOption>
+{
+    /**
+     * Returns a {@link TrackedEntityAttributeOption} with a given name.
+     * 
+     * @param attribute {@link TrackedEntityAttribute}
+     * 
+     * @param name the name of the TrackedEntityAttributeOption to return.
+     * 
+     * @return the TrackedEntityAttributeOption with the given name, or null if
+     * no match.
+     */
+    TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name );
+
+    /**
+     * Get all {@link TrackedEntityAttributeOption} of a
+     * {@link TrackedEntityAttribute}
+     * 
+     * @param attribute {@link TrackedEntityAttribute}
+     * 
+     * @return {@link TrackedEntityAttributeOption}
+     */
+    Collection<TrackedEntityAttributeOption> get( TrackedEntityAttribute attribute );
+
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java	2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java	2014-02-15 14:29:54 +0000
@@ -97,29 +97,4 @@
      */
     Collection<TrackedEntityAttribute> getDisplayedInList( boolean displayInListNoProgram );
 
-    // -------------------------------------------------------------------------
-    // TrackedEntityAttributeOption
-    // -------------------------------------------------------------------------
-
-    /**
-     * Returns a {@link TrackedEntityAttributeOption} with a given name.
-     * 
-     * @param attribute {@link TrackedEntityAttribute}
-     * 
-     * @param name the name of the TrackedEntityAttributeOption to return.
-     * 
-     * @return the TrackedEntityAttributeOption with the given name, or null if
-     * no match.
-     */
-    TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name );
-
-    /**
-     * Get all {@link TrackedEntityAttributeOption} of a
-     * {@link TrackedEntityAttribute}
-     * 
-     * @param attribute {@link TrackedEntityAttribute}
-     * 
-     * @return {@link TrackedEntityAttributeOption}
-     */
-    Collection<TrackedEntityAttributeOption> get( TrackedEntityAttribute attribute );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2014-02-15 14:29:54 +0000
@@ -30,14 +30,12 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author Abyot Asalefew
- * @version $Id$
  */
 @Transactional
 public class DefaultTrackedEntityAttributeService
@@ -54,9 +52,9 @@
         this.attributeStore = attributeStore;
     }
 
-    private GenericNameableObjectStore<TrackedEntityAttributeOption> attributeOptionStore;
+    private TrackedEntityAttributeOptionStore attributeOptionStore;
 
-    public void setAttributeOptionStore( GenericNameableObjectStore<TrackedEntityAttributeOption> attributeOptionStore )
+    public void setAttributeOptionStore( TrackedEntityAttributeOptionStore attributeOptionStore )
     {
         this.attributeOptionStore = attributeOptionStore;
     }
@@ -197,7 +195,7 @@
 
     public TrackedEntityAttributeOption getTrackedEntityAttributeOption( TrackedEntityAttribute attribute, String name )
     {
-        return attributeStore.get( attribute, name );
+        return attributeOptionStore.get( attribute, name );
     }
 
     public TrackedEntityAttributeOption getTrackedEntityAttributeOption( int id )
@@ -207,6 +205,6 @@
 
     public Collection<TrackedEntityAttributeOption> getTrackedEntityAttributeOption( TrackedEntityAttribute attribute )
     {
-        return attributeStore.get( attribute );
+        return attributeOptionStore.get( attribute );
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java	2014-02-15 14:29:54 +0000
@@ -0,0 +1,54 @@
+package org.hisp.dhis.trackedentity.hibernate;
+
+/*
+ * Copyright (c) 2004-2013, 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.Collection;
+
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeOptionStore;
+
+public class HibernateTrackedEntityAttributeOptionStore
+    extends HibernateIdentifiableObjectStore<TrackedEntityAttributeOption>
+    implements TrackedEntityAttributeOptionStore
+{
+    public TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name )
+    {
+        return (TrackedEntityAttributeOption) getCriteria( Restrictions.eq( "name", name ),
+            Restrictions.eq( "attribute", attribute ) ).uniqueResult();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<TrackedEntityAttributeOption> get( TrackedEntityAttribute attribute )
+    {
+        return getCriteria( Restrictions.eq( "attribute", attribute ) ).list();
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java	2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java	2014-02-15 14:29:54 +0000
@@ -28,14 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeStore;
 
-import java.util.Collection;
-
 /**
  * @author Abyot Asalefew Gizaw
  */
@@ -95,21 +94,4 @@
     {
         return getCriteria( Restrictions.eq( "displayInListNoProgram", displayInListNoProgram ) ).list();
     }
-
-    // -------------------------------------------------------------------------
-    // TrackedEntityAttributeOption
-    // -------------------------------------------------------------------------
-
-    public TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name )
-    {
-        return (TrackedEntityAttributeOption) getCriteria( Restrictions.eq( "name", name ),
-            Restrictions.eq( "attribute", attribute ) ).uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<TrackedEntityAttributeOption> get( TrackedEntityAttribute attribute )
-    {
-        return getCriteria( Restrictions.eq( "attribute", attribute ) ).list();
-    }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-02-15 14:06:39 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-02-15 14:29:54 +0000
@@ -99,7 +99,7 @@
 	</bean>
 
 	<bean id="org.hisp.dhis.trackedentity.TrackedEntityAttributeOptionStore"
-		class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
+		class="org.hisp.dhis.trackedentity.hibernate.HibernateTrackedEntityAttributeOptionStore">
 		<property name="clazz"
 			value="org.hisp.dhis.trackedentity.TrackedEntityAttributeOption" />
 		<property name="sessionFactory" ref="sessionFactory" />