← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2564: Added methods declaration in dhis-in-services

 

------------------------------------------------------------
revno: 2564
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-01-14 14:26:27 +0530
message:
  Added methods declaration in dhis-in-services
modified:
  local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java
  local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java
  local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java
  local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java
  local/in/dhis-in-services/dhis-in-service-survey/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 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java	2011-01-13 07:06:44 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java	2011-01-14 08:56:27 +0000
@@ -120,9 +120,9 @@
         deTargetStore.updateDeTargetMember( deTargetMember );
     }
    
-    public int deleteDeTargetMember( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+    public int deleteDeTargetMember( DeTarget deTarget ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
      {
-         return deTargetStore.deleteDeTargetMember( deTargetMember , dataelement, deoptioncombo );
+         return deTargetStore.deleteDeTargetMember( deTarget , dataelement, deoptioncombo );
      }
 }
 

=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java	2011-01-13 07:06:44 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java	2011-01-14 08:56:27 +0000
@@ -152,7 +152,7 @@
 
        Criteria criteria = session.createCriteria( DeTarget.class );
        criteria.createAlias( "dataelements", "i" );
-       criteria.createAlias( "deoptioncombos", "j" );
+       criteria.createAlias( "decategoryOptionCombo", "j" );
        criteria.add( Restrictions.eq( "i.id", dataelement.getId() ) );
        criteria.add( Restrictions.eq( "j.id", deoptioncombo.getId() ) );
 
@@ -185,15 +185,15 @@
        session.update( deTargetMember );
    }
 
-   public int deleteDeTargetMember( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+   public int deleteDeTargetMember( DeTarget deTarget ,DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
    {
        Session session = sessionFactory.getCurrentSession();
 
-       List<DeTargetDataValue> deTargetDataValueList = new ArrayList<DeTargetDataValue>( deTargetDataValueService.getDeTargetMemberDataValues( deTargetMember, dataelement, deoptioncombo ) );
+       List<DeTargetDataValue> deTargetDataValueList = new ArrayList<DeTargetDataValue>( deTargetDataValueService.getDeTargetDataValues(  deTarget , dataelement , deoptioncombo  ) );
        
        if( deTargetDataValueList == null || deTargetDataValueList.isEmpty() )        
        {
-           session.delete( deTargetMember );
+           session.delete( deTarget );
        }
        else
        {            
@@ -207,10 +207,11 @@
    {
        Session session = sessionFactory.getCurrentSession();
 
-       Criteria criteria = session.createCriteria( DeTarget.class );
-       criteria.createAlias( "detargets", "d" );
-       criteria.add( Restrictions.eq( "d.id", deTarget.getId() ) );
-
+       Criteria criteria = session.createCriteria( DeTargetMember.class );
+       //criteria.createAlias( "detarget", "d" );
+       //criteria.add( Restrictions.eq( "d.id", deTarget.getId() ) );
+       criteria.add( Restrictions.eq( "detarget", deTarget ) );
+       
        return criteria.list();
    }
 

=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java	2011-01-13 09:02:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java	2011-01-14 08:56:27 +0000
@@ -26,12 +26,16 @@
  */
 package org.hisp.dhis.detargetdatavalue;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.detarget.DeTarget;
-import org.hisp.dhis.detarget.DeTargetMember;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.source.Source;
 
 /**
@@ -52,7 +56,14 @@
     {
         this.deTargetDataValueStore = deTargetDataValueStore;
     }
+    
+    private OrganisationUnitService organisationUnitService;
 
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+    
     // -------------------------------------------------------------------------
     // Basic DeTargetDataValue
     // -------------------------------------------------------------------------
@@ -94,12 +105,12 @@
     {
         return deTargetDataValueStore.deleteDeTargetDataValuesByDeTargetDataElementCategoryOptionComboAndSource( deTarget, dataelement, deoptioncombo, source );
     }
-    
+ /*   
     public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget )
     {
         return deTargetDataValueStore.getDeTargetDataValue( source, deTarget );
     }
-    
+ */   
     public Collection<DeTargetDataValue> getAllDeTargetDataValues()
     {
         return deTargetDataValueStore.getAllDeTargetDataValues();
@@ -144,11 +155,57 @@
    {
        return deTargetDataValueStore.getDeTargetDataValue( source, deTarget, dataelement, deoptioncombo );
    }
-   
+
+   public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget ,Period period, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+   {
+       return deTargetDataValueStore.getDeTargetDataValue( source, deTarget, period, dataelement, deoptioncombo );
+   }
+   
+   
+   /*   
    public Collection<DeTargetDataValue> getDeTargetMemberDataValues( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo decategoryOptionCombo )
    {
        return deTargetDataValueStore.getDeTargetMemberDataValues( deTargetMember ,dataelement ,decategoryOptionCombo );
    }
+*/
+   public Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget ,DataElement dataelement ,DataElementCategoryOptionCombo decategoryOptionCombo )
+   {
+       return deTargetDataValueStore.getDeTargetDataValues( deTarget ,dataelement ,decategoryOptionCombo );
+   }
+   
 
+   public Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget , Source source, Period period)
+   {
+        return deTargetDataValueStore.getDeTargetDataValues( deTarget ,source , period );
+   }
+   
+   public Double getAggregatedDeTargetDataValue( Source source, DeTarget deTarget,Period period, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+   {
+       List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
+       childOrgUnitList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( source.getId() ) );
+       
+       Double aggDataValue = 0.0;
+       
+       for( OrganisationUnit orgChild : childOrgUnitList )
+       {
+           DeTargetDataValue tempAggDataValue = getDeTargetDataValue(  orgChild,  deTarget,  dataelement , deoptioncombo );
+           
+           if( tempAggDataValue != null && tempAggDataValue.getValue() != null ) 
+           {
+               try
+               {
+                   aggDataValue += Double.parseDouble( tempAggDataValue.getValue() );
+               }
+               catch( Exception e )
+               {
+                   
+               }
+           }
+               
+       }
+       
+       
+       return aggDataValue;
+       
+   }
 }
-

=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java	2011-01-13 09:02:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java	2011-01-14 08:56:27 +0000
@@ -38,10 +38,9 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.detarget.DeTarget;
-import org.hisp.dhis.detarget.DeTargetMember;
 import org.hisp.dhis.detargetdatavalue.DeTargetDataValue;
 import org.hisp.dhis.detargetdatavalue.DeTargetDataValueStore;
-
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.source.Source;
 
 
@@ -102,7 +101,7 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
-        Query query = session.createQuery( "delete SurveyDataValue where survey = :survey" );
+        Query query = session.createQuery( "delete DeTargetDataValue where deTarget = :deTarget" );
         query.setEntity( "survey", deTarget );
 
         return query.executeUpdate();
@@ -112,7 +111,7 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
-        Query query = session.createQuery( "delete SurveyDataValue where dataelement = :dataelement ,deoptioncombo =:deoptioncombo" );
+        Query query = session.createQuery( "delete DeTargetDataValue where dataelement = :dataelement ,deoptioncombo =:deoptioncombo" );
         query.setEntity( "dataelement", dataelement );
         query.setEntity( "dataelement", dataelement );
 
@@ -123,7 +122,7 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
-        Query query = session.createQuery( "delete SurveyDataValue where survey = :survey,dataelement = :dataelement, deoptioncombo = :deoptioncombo ,source = :source" );
+        Query query = session.createQuery( "delete DeTargetDataValue where deTarget = :deTarget,dataelement = :dataelement, deoptioncombo = :deoptioncombo ,source = :source" );
         query.setEntity( "deTarget", deTarget );
         query.setEntity( "dataelement", dataelement );
         query.setEntity( "deoptioncombo", deoptioncombo );
@@ -131,7 +130,7 @@
 
         return query.executeUpdate();
     }
-   
+    /*  
     public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget )
     {
         Session session = sessionFactory.getCurrentSession();
@@ -142,6 +141,7 @@
 
         return (DeTargetDataValue) criteria.uniqueResult();
     }
+    */
     @SuppressWarnings( "unchecked" )
     public Collection<DeTargetDataValue> getAllDeTargetDataValues()
     {
@@ -225,6 +225,7 @@
 
         return criteria.list();
     }
+    /*
     @SuppressWarnings( "unchecked" )
     public Collection<DeTargetDataValue> getDeTargetMemberDataValues( DeTargetMember deTargetMember ,DataElement dataelement ,DataElementCategoryOptionCombo decategoryOptionCombo )
     {
@@ -237,6 +238,33 @@
 
         return criteria.list();
     }
+*/    
+    @SuppressWarnings( "unchecked" )
+     public Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget , Source source, Period period )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( DeTargetDataValue.class );
+        criteria.add( Restrictions.eq( "deTarget", deTarget ) );
+        criteria.add( Restrictions.eq( "source", source ) );
+        criteria.add( Restrictions.eq( "period", period ) );
+
+        return criteria.list();
+    }
+    
+    @SuppressWarnings( "unchecked" )
+    public Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget ,DataElement dataelement ,DataElementCategoryOptionCombo decategoryOptionCombo )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( DeTargetDataValue.class );
+        criteria.add( Restrictions.eq( "deTarget", deTarget ) );
+        criteria.add( Restrictions.eq( "dataelement", dataelement ) );
+        criteria.add( Restrictions.eq( "decategoryOptionCombo", decategoryOptionCombo ) );
+
+        return criteria.list();
+    }
+    
     
     @SuppressWarnings( "unchecked" )
     public Collection<DeTargetDataValue> getDeTargetDataValues( DeTarget deTarget )
@@ -263,6 +291,22 @@
         return (DeTargetDataValue) criteria.uniqueResult();
     }
     
+    public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget ,Period period, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( DeTargetDataValue.class );
+        criteria.add( Restrictions.eq( "source", source ) );
+        criteria.add( Restrictions.eq( "deTarget", deTarget ) );
+        criteria.add( Restrictions.eq( "period", period ) );
+        criteria.add( Restrictions.eq( "dataelement", dataelement ) );
+        criteria.add( Restrictions.eq( "deoptioncombo", deoptioncombo ) );
+
+        return (DeTargetDataValue) criteria.uniqueResult();
+    }
+    
+    
+    
 }
 
     

=== modified file 'local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml	2011-01-13 09:02:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/resources/META-INF/dhis/beans.xml	2011-01-14 08:56:27 +0000
@@ -57,6 +57,8 @@
     class="org.hisp.dhis.detargetdatavalue.DefaultDeTargetDataValueService">
     <property name="deTargetDataValueStore"
       ref="org.hisp.dhis.detargetdatavalue.DeTargetDataValueStore"/>
+	  <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService">
+	  </property>
   </bean>   
 
 <!-- DeTarget Store definitions -->