← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21084: Impl ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute

 

------------------------------------------------------------
revno: 21084
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 11:47:21 +0100
message:
  Impl  ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.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/trackedentity/TrackedEntityAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java	2015-10-02 09:07:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java	2015-11-17 10:47:21 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
 
 import java.util.List;
 
@@ -207,4 +208,13 @@
      * @return null if valid, a message if not
      */
     String validateValueType( TrackedEntityAttribute trackedEntityAttribute, String value );
+    
+    /**
+     * Returns a tracked entity attribute.
+     * 
+     * @param programUid the program identifier.
+     * @param attributeUid the tracked entity attribute identifier.
+     * @return a tracked entity attribute.
+     */
+    ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute( String programUid, String attributeUid );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2015-10-22 02:38:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2015-11-17 10:47:21 +0000
@@ -36,6 +36,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
+import org.hisp.dhis.program.ProgramTrackedEntityAttributeStore;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.user.UserService;
@@ -71,6 +73,13 @@
         this.programService = programService;
     }
 
+    private ProgramTrackedEntityAttributeStore programAttributeStore;
+
+    public void setProgramAttributeStore( ProgramTrackedEntityAttributeStore programAttributeStore )
+    {
+        this.programAttributeStore = programAttributeStore;
+    }
+
     @Autowired
     private TrackedEntityInstanceService trackedEntityInstanceService;
 
@@ -299,4 +308,22 @@
 
         return null;
     }
+
+    // -------------------------------------------------------------------------
+    // ProgramTrackedEntityAttribute
+    // -------------------------------------------------------------------------
+
+    public ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute( String programUid, String attributeUid )
+    {
+        Program program = programService.getProgram( programUid );
+        
+        TrackedEntityAttribute attribute = getTrackedEntityAttribute( attributeUid );
+        
+        if ( program == null || attribute == null )
+        {
+            return null;
+        }
+        
+        return programAttributeStore.get( program, attribute );
+    }
 }

=== 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	2015-11-17 09:50:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2015-11-17 10:47:21 +0000
@@ -1199,6 +1199,7 @@
     class="org.hisp.dhis.trackedentity.DefaultTrackedEntityAttributeService">
     <property name="attributeStore" ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeStore" />
     <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+    <property name="programAttributeStore" ref="org.hisp.dhis.program.ProgramTrackedEntityAttributeStore" />
   </bean>
 
   <bean id="org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService"