← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1392: Added method getAllOperands to DataElementService. Added property conceptName to Category.

 

------------------------------------------------------------
revno: 1392
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-02-04 10:59:45 +0100
message:
  Added method getAllOperands to DataElementService. Added property conceptName to Category.
added:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/OperandMapper.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
  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/hibernate/HibernateDataElementStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.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/DataElementCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java	2009-12-18 08:47:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java	2010-02-04 09:59:45 +0000
@@ -47,6 +47,8 @@
 {
     public static final String DEFAULT_NAME = "default";
         
+    private String conceptName;
+    
     private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
 
     // -------------------------------------------------------------------------
@@ -119,7 +121,17 @@
     // ------------------------------------------------------------------------
     // Getters and setters
     // ------------------------------------------------------------------------
-    
+
+    public String getConceptName()
+    {
+        return conceptName;
+    }
+
+    public void setConceptName( String conceptName )
+    {
+        this.conceptName = conceptName;
+    }
+
     public List<DataElementCategoryOption> getCategoryOptions()
     {
         return categoryOptions;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-01-27 11:51:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-02-04 09:59:45 +0000
@@ -487,4 +487,15 @@
 
     Collection<DataElementGroupSet> getDataElementGroupSets( Collection<Integer> identifiers );
 
+    // -------------------------------------------------------------------------
+    // Operand
+    // -------------------------------------------------------------------------
+
+    /**
+     * Returns all Operands. Requires the categoryoptioncomboname resource table
+     * to be populated.
+     * 
+     * @return a collection of all Operands.
+     */
+    Collection<Operand> getAllOperands();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2010-01-27 11:51:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2010-02-04 09:59:45 +0000
@@ -268,4 +268,16 @@
      *         collection if there are no CalculcatedDataELements
      */
     Collection<CalculatedDataElement> getAllCalculatedDataElements();
+
+    // -------------------------------------------------------------------------
+    // Operand
+    // -------------------------------------------------------------------------
+
+    /**
+     * Returns all Operands. Requires the categoryoptioncomboname resource table
+     * to be populated.
+     * 
+     * @return a collection of all Operands.
+     */
+    Collection<Operand> getAllOperands();
 }

=== 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	2010-01-27 11:51:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2010-02-04 09:59:45 +0000
@@ -614,4 +614,12 @@
         } );
     }
 
+    // -------------------------------------------------------------------------
+    // Operand
+    // -------------------------------------------------------------------------
+    
+    public Collection<Operand> getAllOperands()
+    {
+        return dataElementStore.getAllOperands();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2010-01-27 11:51:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2010-02-04 09:59:45 +0000
@@ -27,11 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
 import org.amplecode.quick.StatementManager;
+import org.amplecode.quick.mapper.ObjectMapper;
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
@@ -42,7 +45,9 @@
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementStore;
+import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.hierarchy.HierarchyViolationException;
+import org.hisp.dhis.system.objectmapper.OperandMapper;
 
 /**
  * @author Torgeir Lorange Ostby
@@ -409,4 +414,31 @@
         return criteria.list();
     }
 
+    // -------------------------------------------------------------------------
+    // Operand
+    // -------------------------------------------------------------------------
+    
+    public Collection<Operand> getAllOperands()
+    {
+        final ObjectMapper<Operand> mapper = new ObjectMapper<Operand>();
+        
+        final String sql =
+            "SELECT de.dataelementid, cocn.categoryoptioncomboid, cocn.categoryoptioncomboname " +
+            "FROM dataelement as de " +
+            "JOIN categorycombo as cc on de.categorycomboid=cc.categorycomboid " +
+            "JOIN categorycombos_optioncombos as ccoc on cc.categorycomboid=ccoc.categorycomboid " +
+            "JOIN categoryoptioncomboname as cocn on ccoc.categoryoptioncomboid=cocn.categoryoptioncomboid " +
+            "ORDER BY de.name;";
+        
+        try
+        {
+            ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
+            
+            return mapper.getCollection( resultSet, new OperandMapper() );
+        }
+        catch ( SQLException ex )
+        {
+            throw new RuntimeException( "Failed to get all operands", ex );
+        }   
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2009-10-19 17:10:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2010-02-04 09:59:45 +0000
@@ -17,6 +17,8 @@
     <property name="name">
       <column name="name" not-null="true" unique="true" length="160"/>
     </property>
+	
+	<property name="conceptName"/>
     
     <list name="categoryOptions" table="categories_categoryoptions">
       <key column="categoryid"/>

=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/OperandMapper.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/OperandMapper.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/OperandMapper.java	2010-02-04 09:59:45 +0000
@@ -0,0 +1,23 @@
+package org.hisp.dhis.system.objectmapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.amplecode.quick.mapper.RowMapper;
+import org.hisp.dhis.dataelement.Operand;
+
+public class OperandMapper
+    implements RowMapper<Operand>
+{
+    @Override
+    public Operand mapRow( ResultSet resultSet )
+        throws SQLException
+    {
+        Operand operand = new Operand(
+            resultSet.getInt( 1 ),
+            resultSet.getInt( 2 ),
+            resultSet.getString( 3 ) );
+        
+        return operand;
+    }
+}