← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13441: Aggregation services

 

------------------------------------------------------------
revno: 13441
committer: Samta Bajpayee<samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-27 12:30:44 +0000
message:
  Aggregation services
added:
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultAggregationService.java
modified:
  local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/DefaultModelAttributeValueService.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/hibernate/HibernateModelAttributeValueStore.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-coldchain/pom.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml	2013-10-18 05:57:53 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/pom.xml	2013-12-27 12:30:44 +0000
@@ -35,11 +35,11 @@
       <artifactId>dhis-in-service-configuration</artifactId>
       <version>${project.version}</version>
     </dependency>   
-	<dependency>
+	<!--<dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-aggregationengine-default</artifactId>
       <version>${project.version}</version>   
-    </dependency>	  
+    </dependency>-->	  
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-system</artifactId>

=== added directory 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation'
=== added file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultAggregationService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultAggregationService.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultAggregationService.java	2013-12-27 12:30:44 +0000
@@ -0,0 +1,39 @@
+package org.hisp.dhis.coldchain.aggregation;
+
+import java.util.Map;
+
+import org.hisp.dhis.lookup.Lookup;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class DefaultAggregationService implements AggregationService
+{
+	// -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+	
+	@Override
+	public String getQueryTemplate(String lookupName, Map<String,String> params) {
+		String tempQuery = null;
+		if(lookupName.equalsIgnoreCase(Lookup.WS_REF_TYPE))
+		{
+			String equipmenttypeid = params.get("equipmenttypeid");
+			String modelName = params.get("modelName");
+			String equipmentattributevalue = params.get("equipmentattributevalue");
+			tempQuery = "SELECT COUNT(*) FROM modelattributevalue "+
+						"INNER JOIN equipment ON modelattributevalue.modelid = equipment.modelid "+
+						"INNER JOIN equipmentattributevalue ON equipmentattributevalue.equipmentid = equipment.equipmentid"+
+						" WHERE " +
+                        " equipment.equipmenttypeid = "+equipmenttypeid+" AND " +
+                        " modelattributevalue.value = "+modelName+" AND " +
+                        " equipment.organisationunitid IN ( ? ) AND "+
+                        " equipmentattributevalue.value IN ( "+equipmentattributevalue+" )"+
+                        " GROUP BY modelattributevalue.value";					
+		}
+		return tempQuery;
+	}
+
+    
+
+  
+}

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/DefaultModelAttributeValueService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/DefaultModelAttributeValueService.java	2013-09-05 11:11:36 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/DefaultModelAttributeValueService.java	2013-12-27 12:30:44 +0000
@@ -76,5 +76,12 @@
     {
         return modelAttributeValueStore.modelAttributeValue( model, modelTypeAttribute, modelTypeAttributeOption );
     }
+
+	@Override
+	public Collection<ModelAttributeValue> getAllModelAttributeValuesByModelTypeAttribute(
+			ModelTypeAttribute modelTypeAttribute) {
+		
+		return modelAttributeValueStore.getAllModelAttributeValuesByModelTypeAttribute( modelTypeAttribute );
+	}
     
 }

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/hibernate/HibernateModelAttributeValueStore.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/hibernate/HibernateModelAttributeValueStore.java	2013-09-25 09:45:36 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/model/hibernate/HibernateModelAttributeValueStore.java	2013-12-27 12:30:44 +0000
@@ -98,4 +98,17 @@
 
         return (ModelAttributeValue) criteria.uniqueResult();
     }
+
+	@Override
+	public Collection<ModelAttributeValue> getAllModelAttributeValuesByModelTypeAttribute(
+			ModelTypeAttribute modelTypeAttribute) 
+	{
+		
+		Session session = sessionFactory.getCurrentSession();
+        
+        Criteria criteria = session.createCriteria( ModelAttributeValue.class );
+        
+        criteria.add( Restrictions.eq( "modelTypeAttribute", modelTypeAttribute ) );
+        return criteria.list();
+	}
 }