← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2578: Bug fixes in DeTarget Service

 

------------------------------------------------------------
revno: 2578
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-01-15 15:02:11 +0530
message:
  Bug fixes in DeTarget Service
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


--
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-14 11:49:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/DefaultDeTargetService.java	2011-01-15 09:32:11 +0000
@@ -31,12 +31,14 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.source.Source;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author Mithilesh Kumar Thakur
  *
  * @version DefaultDeTargetService.java Jan 13, 2011 10:34:54 AM
  */
+@Transactional
 public class DefaultDeTargetService implements DeTargetService
 {
     // -------------------------------------------------------------------------

=== 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-14 11:49:59 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detarget/hibernate/HibernateDeTargetStore.java	2011-01-15 09:32:11 +0000
@@ -151,11 +151,13 @@
        Session session = sessionFactory.getCurrentSession();
 
        Criteria criteria = session.createCriteria( DeTargetMember.class );
-       criteria.createAlias( "dataelements", "i" );
-       criteria.createAlias( "decategoryOptionCombo", "j" );
-       criteria.add( Restrictions.eq( "i.id", dataelement.getId() ) );
-       criteria.add( Restrictions.eq( "j.id", deoptioncombo.getId() ) );
-
+       //criteria.createAlias( "dataelements", "i" );
+       //criteria.createAlias( "decategoryOptionCombo", "j" );
+       //criteria.add( Restrictions.eq( "i.id", dataelement.getId() ) );
+       //criteria.add( Restrictions.eq( "j.id", deoptioncombo.getId() ) );
+       criteria.add( Restrictions.eq( "dataelements", dataelement ) );
+       criteria.add( Restrictions.eq( "decategoryOptionCombo", deoptioncombo ) );
+       
        return criteria.list();
    }
    @SuppressWarnings( "unchecked" )

=== 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-14 08:56:27 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/DefaultDeTargetDataValueService.java	2011-01-15 09:32:11 +0000
@@ -37,12 +37,14 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.source.Source;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author Mithilesh Kumar Thakur
  *
  * @version DefaultDeTargetDataValueService.java Jan 13, 2011 10:36:40 AM
  */
+@Transactional
 public class DefaultDeTargetDataValueService implements DeTargetDataValueService
 {
     
@@ -151,9 +153,9 @@
        return deTargetDataValueStore.getDeTargetDataValues( deTarget );
    }
    
-   public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+   public Collection<DeTargetDataValue> getDeTargetDataValues( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
    {
-       return deTargetDataValueStore.getDeTargetDataValue( source, deTarget, dataelement, deoptioncombo );
+       return deTargetDataValueStore.getDeTargetDataValues( source, deTarget, dataelement, deoptioncombo );
    }
 
    public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget ,Period period, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
@@ -188,7 +190,7 @@
        
        for( OrganisationUnit orgChild : childOrgUnitList )
        {
-           DeTargetDataValue tempAggDataValue = getDeTargetDataValue(  orgChild,  deTarget,  dataelement , deoptioncombo );
+           DeTargetDataValue tempAggDataValue = getDeTargetDataValue(  orgChild,  deTarget,  period, dataelement , deoptioncombo );
            
            if( tempAggDataValue != null && tempAggDataValue.getValue() != null ) 
            {
@@ -204,8 +206,6 @@
                
        }
        
-       
        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-14 08:56:27 +0000
+++ local/in/dhis-in-services/dhis-in-service-survey/src/main/java/org/hisp/dhis/detargetdatavalue/hibernate/HibernateDeTargetDataValueStore.java	2011-01-15 09:32:11 +0000
@@ -278,7 +278,8 @@
         return criteria.list();
     }
    
-    public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
+    @SuppressWarnings( "unchecked" )
+    public Collection<DeTargetDataValue> getDeTargetDataValues( Source source, DeTarget deTarget, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
     {
         Session session = sessionFactory.getCurrentSession();
 
@@ -286,9 +287,9 @@
         criteria.add( Restrictions.eq( "source", source ) );
         criteria.add( Restrictions.eq( "deTarget", deTarget ) );
         criteria.add( Restrictions.eq( "dataelement", dataelement ) );
-        criteria.add( Restrictions.eq( "deoptioncombo", deoptioncombo ) );
+        criteria.add( Restrictions.eq( "decategoryOptionCombo", deoptioncombo ) );
 
-        return (DeTargetDataValue) criteria.uniqueResult();
+        return  criteria.list();
     }
     
     public DeTargetDataValue getDeTargetDataValue( Source source, DeTarget deTarget ,Period period, DataElement dataelement ,DataElementCategoryOptionCombo deoptioncombo )
@@ -300,7 +301,7 @@
         criteria.add( Restrictions.eq( "deTarget", deTarget ) );
         criteria.add( Restrictions.eq( "period", period ) );
         criteria.add( Restrictions.eq( "dataelement", dataelement ) );
-        criteria.add( Restrictions.eq( "deoptioncombo", deoptioncombo ) );
+        criteria.add( Restrictions.eq( "decategoryOptionCombo", deoptioncombo ) );
 
         return (DeTargetDataValue) criteria.uniqueResult();
     }