← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13576: CCEI: AggregationEngine workin progress

 

------------------------------------------------------------
revno: 13576
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-06 06:13:15 +0000
message:
  CCEI: AggregationEngine workin progress
added:
  local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryResult.vm
modified:
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/equipment/Equipment.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/Equipment.hbm.xml
  local/in/dhis-in-services/dhis-in-service-lookup/src/main/java/org/hisp/dhis/lookup/hibernate/HibernateLookupStore.java
  local/in/dhis-in-services/dhis-in-service-lookup/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/SaveEquipmentDataValueAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/manager/action/SaveFacilityDataValueAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java
  local/in/dhis-web-dataentry-ccem/src/main/java/org/hisp/dhis/dataentry/action/SaveEquipmentDataValueAction.java
  local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryAction.java
  local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java
  local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java
  local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/equipment/action/SaveEquipmentDataValueAction.java
  local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm
  local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm
  local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryForm.vm


--
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-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java	2013-12-30 04:45:24 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/aggregation/CCEIAggregationService.java	2014-01-06 06:13:15 +0000
@@ -10,12 +10,19 @@
 
 public interface CCEIAggregationService
 {
-    String ID = CCEIAggregationService.class.getName();  
-    
+    String ID = CCEIAggregationService.class.getName();
+
     String getQueryTemplate( String lookupName, Map<String,String> params );
-    
-    Map<String, Integer> calculateStorageCapacityData( DataElement dataElement, Set<OrganisationUnit> orgUnits, Set<OrganisationUnitGroup> orgUnitGroups );
+
+    String getQueryForRefrigeratorWorkingStatus( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String workingStatus );
+    
+    String getQueryForRefrigeratorUtilization( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String utilization );
+
+    Map<String, Integer> calculateStorageCapacityData( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, Set<OrganisationUnitGroup> orgUnitGroups );
+    
+    Map<String, Integer> calculateRefrigeratorWorkingStatus( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, String query );
+
+    Map<String, Integer> calculateRefrigeratorUtilization( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, String query );
     
     String importData( Map<String, Integer> aggregationResultMap, Period period );
-    
 }

=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/equipment/Equipment.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/equipment/Equipment.java	2013-09-25 09:45:36 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/equipment/Equipment.java	2014-01-06 06:13:15 +0000
@@ -1,6 +1,7 @@
 package org.hisp.dhis.coldchain.equipment;
 
 import java.io.Serializable;
+import java.util.Date;
 import java.util.Set;
 
 import org.hisp.dhis.coldchain.model.Model;
@@ -23,6 +24,8 @@
     
     private boolean working = false;
     
+    private Date registrationDate;
+    
     private Set<EquipmentStatus> equipmentStatusUpdates;
     
     // -------------------------------------------------------------------------
@@ -143,5 +146,15 @@
     {
         this.model = model;
     }
+
+    public Date getRegistrationDate()
+    {
+        return registrationDate;
+    }
+
+    public void setRegistrationDate( Date registrationDate )
+    {
+        this.registrationDate = registrationDate;
+    }
     
 }

=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java	2013-12-30 04:45:24 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/lookup/Lookup.java	2014-01-06 06:13:15 +0000
@@ -13,6 +13,21 @@
     public static final String WS_REF_TYPE = "WS_REF_TYPE";
     
     public static final String CCEI_AGG_TYPE_STORAGE_CAPACITY = "STORAGE CAPACITY";
+    public static final String CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL = "REF WORKING STATUS BY MODEL";
+    public static final String CCEI_AGG_TYPE_REF_UTILIZATION = "REF UTILIZATION";
+    public static final String CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE = "REF WORKING STATUS BY TYPE";
+    
+    public static final String CCEI_WORKING_STATUS_OPTIONSET = "WORKING_STATUS_OPTIONSET";
+    
+    public static final String CCEI_EQUIPMENTTYPE_MODELTYPEATTRIBUTE = "EQUIPMENTTYPE_MODELTYPEATTRIBUTE";    
+    public static final String CCEI_MODEL_MODELTYPEATTRIBUTE = "MODEL_MODELTYPEATTRIBUTE";
+    
+    public static final String CCEI_UTILIZATION_OPTIONSET = "UTILIZATION_OPTIONSET";
+    
+    public static final String CCEI_REF_EQUIPMENTTYPE_ID = "REF_EQUIPMENTTYPE_ID";
+    
+    public static final String ORGUNITID_BY_COMMA = "ORGUNITID_BY_COMMA";
+    public static final String CURRENT_PERIOD_ENDDATE = "CURRENT_PERIOD_ENDDATE";
     
     private String type;
     

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java	2013-12-30 04:45:24 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/aggregation/DefaultCCEIAggregationService.java	2014-01-06 06:13:15 +0000
@@ -3,6 +3,7 @@
 import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
 import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -18,19 +19,23 @@
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.lookup.Lookup;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
 import org.springframework.transaction.annotation.Transactional;
 
 @Transactional
-public class DefaultCCEIAggregationService implements CCEIAggregationService
+public class DefaultCCEIAggregationService
+    implements CCEIAggregationService
 {
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
     private CCEMReportManager ccemReportManager;
@@ -54,6 +59,20 @@
         this.currentUserService = currentUserService;
     }
 
+    private PeriodService periodService;
+    
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    private DataElementCategoryService dataElementCategoryService;
+    
+    public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
+    {
+        this.dataElementCategoryService = dataElementCategoryService;
+    }
+
     private JdbcTemplate jdbcTemplate;
 
     public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
@@ -61,65 +80,165 @@
         this.jdbcTemplate = jdbcTemplate;
     }
 
-	// -------------------------------------------------------------------------
-    // 
-    // -------------------------------------------------------------------------    
-	@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;
-	}
-
+    // -------------------------------------------------------------------------
+    //
+    // -------------------------------------------------------------------------
     
-	public Map<String, Integer> calculateStorageCapacityData( DataElement dataElement, Set<OrganisationUnit> orgUnits, Set<OrganisationUnitGroup> orgUnitGroups )
-	{
-		Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
-
-		/**
-		 * TODO need to get all parameters from lookup
-		 */
-		CCEMReport ccemReport = ccemReportManager.getCCEMReportByReportId( "22" );
-		Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
+    public String getQueryForRefrigeratorWorkingStatus( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String workingStatus )
+    {
+        String query = "SELECT equipment.organisationunitid,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 " + 
+                                " modelattributevalue.modeltypeattributeid = " + modelTypeAttributeId +" AND " +
+                                " equipment.organisationunitid IN ( " + Lookup.ORGUNITID_BY_COMMA + " ) AND " +
+                                " equipmentattributevalue.value IN ( " + workingStatus + " ) AND " +
+                                " equipment.registrationdate <= '" + Lookup.CURRENT_PERIOD_ENDDATE +"'" +
+                            " GROUP BY equipment.organisationunitid";
+        return query;
+    }
+
+    public String getQueryForRefrigeratorUtilization( Integer equipmentTypeId, Integer modelTypeAttributeId, String modelName, String utilization )
+    {
+        String query = "SELECT equipment.organisationunitid,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 " + 
+                                " modelattributevalue.modeltypeattributeid = " + modelTypeAttributeId +" AND " +
+                                " equipment.organisationunitid IN ( " + Lookup.ORGUNITID_BY_COMMA + " ) AND " +
+                                " equipmentattributevalue.value IN ( " + utilization + " )" +
+                            " GROUP BY equipment.organisationunitid";
+        return query;
+    }
+
+    @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;
+    }
+
+    public Map<String, Integer> calculateRefrigeratorWorkingStatus( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, String query )
+    {
+        Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
+        
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        
+        try
+        {
+            Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnits ) );
+            String orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
+
+            query = query.replace( Lookup.ORGUNITID_BY_COMMA, orgUnitIdsByComma );
+            
+            query = query.replace( Lookup.CURRENT_PERIOD_ENDDATE, simpleDateFormat.format( period.getEndDate() ) );
+            
+            System.out.println( query );
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer orgUnitId = rs.getInt( 1 );
+                Integer countValue = rs.getInt( 2 );
+                aggregationResultMap.put( orgUnitId+":"+dataElement.getId(), countValue );
+            }
+        }
+        catch( Exception e )
+        {
+            System.out.println("Exception :"+ e.getMessage() );
+        }
+        
+        return aggregationResultMap;
+    }
+
+    public Map<String, Integer> calculateRefrigeratorUtilization( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, String query )
+    {
+        Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
+        
+        try
+        {
+            Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnits ) );
+            String orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
+
+            query = query.replace( "ORGUNITID_BY_COMMA", orgUnitIdsByComma );
+            
+            SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+            while ( rs.next() )
+            {
+                Integer orgUnitId = rs.getInt( 1 );
+                Integer countValue = rs.getInt( 2 );
+                aggregationResultMap.put( orgUnitId+":"+dataElement.getId(), countValue );
+            }
+        }
+        catch( Exception e )
+        {
+            System.out.println("Exception :"+ e.getMessage() );
+        }
+        
+        return aggregationResultMap;
+    }
+
+    public Map<String, Integer> calculateStorageCapacityData( Period period, DataElement dataElement, Set<OrganisationUnit> orgUnits, Set<OrganisationUnitGroup> orgUnitGroups )
+    {
+        Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
+
+        /**
+         * TODO need to get all parameters from lookup
+         */
+        CCEMReport ccemReport = ccemReportManager.getCCEMReportByReportId( "22" );
+        Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
         List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager.getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
 
         Calendar calendar = Calendar.getInstance();
         calendar.setTime( new Date() );
-        String periodStartDate = "";
+        String periodStartDate = period.getStartDateString();
+
         String periodEndDate = "";
-        Integer periodId = ccemReportManager.getPeriodId( periodStartDate, "Yearly" );
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy" );
+        Period period1 = PeriodType.getPeriodFromIsoString( simpleDateFormat.format( period.getStartDate() ) );
+        period1 = periodService.reloadPeriod( period1 );
+        Integer periodId = period1.getId();
+        // Integer periodId = ccemReportManager.getPeriodId( periodStartDate,
+        // "Yearly" );
 
         CCEMReportDesign ccemReportDesign1 = reportDesignList.get( 0 );
         String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
+
+        ccemReportDesign1 = reportDesignList.get( 1 );
+        ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
         String[] partsOfCellContent = ccemCellContent1.split( "-" );
         Integer vscrActualInventoryTypeId = Integer.parseInt( partsOfCellContent[0].split( ":" )[0] );
         Integer vscrActualInventoryTypeAttributeId = Integer.parseInt( partsOfCellContent[0].split( ":" )[1] );
         Double factor = Double.parseDouble( partsOfCellContent[0].split( ":" )[2] );
-        
+
         Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnits ) );
         String orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
 
         Collection<Integer> orgUnitGroupIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnitGroup.class, orgUnitGroups ) );
         String orgUnitGroupIdsByComma = getCommaDelimitedString( orgUnitGroupIds );
 
-        Map<Integer, Double> equipmentSumByInventoryTypeMap = new HashMap<Integer, Double>( ccemReportManager.getSumOfEquipmentDatabyInventoryType( orgUnitIdsByComma, vscrActualInventoryTypeId, vscrActualInventoryTypeAttributeId, factor ) );
+        Map<Integer, Double> equipmentSumByInventoryTypeMap = new HashMap<Integer, Double>(
+            ccemReportManager.getSumOfEquipmentDatabyInventoryType( orgUnitIdsByComma, vscrActualInventoryTypeId, vscrActualInventoryTypeAttributeId, factor ) );
 
         String[] partsOfVSRActualCellContent = partsOfCellContent[1].split( ":" );
         Integer vsrActualInventoryTypeId = Integer.parseInt( partsOfVSRActualCellContent[0] );
@@ -189,6 +308,14 @@
                 try
                 {
                     vsReqLiveBirthData = Double.parseDouble( tempStr );
+                    constant = constantService.getConstantByName( "LiveBirthsPerThousand" );                    
+                    Double liveBirthPerThousand = 39.98;
+                    if( constant != null )
+                    {
+                        liveBirthPerThousand = constant.getValue();
+                    }
+                    vsReqLiveBirthData = ( vsReqLiveBirthData * liveBirthPerThousand ) / 1000;
+                    
                 }
                 catch ( Exception e )
                 {
@@ -224,11 +351,13 @@
                 }
             }
 
-            System.out.println( vsReqLiveBirthData + " : " + vsReqVaccineVolumePerChildData + " : " + vsReqSupplyIntervalData + " : " + vsReqReserveStockData );
-            // Formula for calculating Requirement 
+            System.out.println( vsReqLiveBirthData + " : " + vsReqVaccineVolumePerChildData + " : "
+                + vsReqSupplyIntervalData + " : " + vsReqReserveStockData );
+            // Formula for calculating Requirement
             try
             {
-            	vaccineRequirement = vsReqLiveBirthData * vsReqVaccineVolumePerChildData * ( (vsReqSupplyIntervalData + vsReqReserveStockData) / 52);
+                vaccineRequirement = vsReqLiveBirthData * vsReqVaccineVolumePerChildData
+                    * ((vsReqSupplyIntervalData + vsReqReserveStockData) / 52);
             }
             catch ( Exception e )
             {
@@ -244,42 +373,44 @@
             numberOfData.put( "Difference", "" + diffVaccineReq );
 
             Double diffPercentage = 0.0;
-            if( vaccineActualValue == 0 && diffVaccineReq == 0 )
+            if ( vaccineActualValue == 0 && diffVaccineReq == 0 )
             {
-            	diffPercentage = 0.0;
+                diffPercentage = 0.0;
             }
             else
             {
-            	diffPercentage = (diffVaccineReq / vaccineActualValue) * 100;
+                diffPercentage = (diffVaccineReq / vaccineActualValue) * 100;
             }
-            
+
             if ( diffPercentage < -30.0 )
             {
-            	aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 1 );
+                aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 1 );
             }
             else if ( diffPercentage >= -30.0 && diffPercentage < -10.0 )
             {
-            	aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 1 );
+                aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 1 );
             }
             else if ( diffPercentage >= -10.0 && diffPercentage < 10.0 )
             {
+                //aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 0 );
             }
             else if ( diffPercentage >= 10.0 && diffPercentage < 30.0 )
             {
+                //aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 0 );
             }
             else
             {
+                //aggregationResultMap.put( orgUnit.getId() + ":" + dataElement.getId(), 0 );
             }
         }
 
-		return aggregationResultMap;
-	}
- 
-	
+        return aggregationResultMap;
+    }
+
     public String importData( Map<String, Integer> aggregationResultMap, Period period )
     {
-    	String importStatus = "";
-    			
+        String importStatus = "";
+
         Integer updateCount = 0;
         Integer insertCount = 0;
 
@@ -296,78 +427,75 @@
 
         String query = "";
         int insertFlag = 1;
-        String insertQuery = "INSERT IGNORE INTO datavalue ( dataelementid, periodid, sourceid, categoryoptioncomboid, value, storedby, lastupdated ) VALUES ";
-        
+        String insertQuery = "INSERT INTO datavalue ( dataelementid, periodid, sourceid, categoryoptioncomboid, value, storedby, lastupdated, attributeoptioncomboid ) VALUES ";
+
         try
         {
-	        int count = 1;
-	        for ( String cellKey : aggregationResultMap.keySet() )
-	        {
-	            // Orgunit
-	            String[] oneRow = cellKey.split( ":" );
-	            Integer orgUnitId = Integer.parseInt( oneRow[0] );
-	            Integer deId = Integer.parseInt( oneRow[1] );
-	            Integer deCOCId = 1;
-	            Integer periodId = period.getId();
-	            String value = aggregationResultMap.get( cellKey )+"";
-	        
-	            query = "SELECT value FROM datavalue WHERE dataelementid = " + deId + " AND categoryoptioncomboid = " + deCOCId + " AND periodid = " + periodId + " AND sourceid = " + orgUnitId;
-	    		SqlRowSet sqlResultSet1 = jdbcTemplate.queryForRowSet( query );
-	    		if ( sqlResultSet1 != null && sqlResultSet1.next() )
-	    		{
-	    		    String updateQuery = "UPDATE datavalue SET value = '" + value + "', storedby = '" + storedBy
-	    						+ "',lastupdated='" + lastUpdatedDate + "' WHERE dataelementid = " + deId
-	    						+ " AND periodid = " + periodId + " AND sourceid = " + orgUnitId
-	    						+ " AND categoryoptioncomboid = " + deCOCId;		    
-	    		  
-	    		    jdbcTemplate.update( updateQuery );
-	    		    updateCount++;
-	    		}
-	    		else
-	    		{
-	                if( value != null && !value.trim().equals( "" ) ) 
-	                {
-	        			insertQuery += "( " + deId + ", " + periodId + ", " + orgUnitId + ", " + deCOCId + ", '" + value + "', '" + storedBy + "', '" + lastUpdatedDate + "'), ";
-	        		    insertFlag = 2;
-	        		    insertCount++;
-	                }
-	    		}
-	            
-	            if ( count == 1000 )
-	            {
-	                count = 1;
-	
-	                if ( insertFlag != 1 )
-	                {
-	                    insertQuery = insertQuery.substring( 0, insertQuery.length() - 2 );
-	                    jdbcTemplate.update( insertQuery );
-	                }
-	
-	                insertFlag = 1;
-	
-	                insertQuery = "INSERT IGNORE INTO datavalue ( dataelementid, periodid, sourceid, categoryoptioncomboid, value, storedby, lastupdated ) VALUES ";
-	            }
-	
-	            count++;
-	        }
-	
-	        if ( insertFlag != 1 )
-	        {
-	            insertQuery = insertQuery.substring( 0, insertQuery.length() - 2 );
-	            jdbcTemplate.update( insertQuery );
-	        }
-
-	        importStatus = "Successfully populated aggregated data for the period : " + period.getStartDateString();
-	        importStatus = "<br/> Total new records : "+ insertCount;
-	        importStatus = "<br/> Total updated records : "+ updateCount;
+            int count = 1;
+            for ( String cellKey : aggregationResultMap.keySet() )
+            {
+                // Orgunit
+                String[] oneRow = cellKey.split( ":" );
+                Integer orgUnitId = Integer.parseInt( oneRow[0] );
+                Integer deId = Integer.parseInt( oneRow[1] );
+                Integer deCOCId = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId();
+                Integer periodId = period.getId();
+                String value = aggregationResultMap.get( cellKey ) + "";
+
+                query = "SELECT value FROM datavalue WHERE dataelementid = " + deId + " AND categoryoptioncomboid = " + deCOCId + " AND periodid = " + periodId + " AND sourceid = " + orgUnitId;
+                SqlRowSet sqlResultSet1 = jdbcTemplate.queryForRowSet( query );
+                if ( sqlResultSet1 != null && sqlResultSet1.next() )
+                {
+                    String updateQuery = "UPDATE datavalue SET value = '" + value + "', storedby = '" + storedBy + "',lastupdated='" + lastUpdatedDate + "' WHERE dataelementid = " + deId + " AND periodid = "
+                        + periodId + " AND sourceid = " + orgUnitId + " AND categoryoptioncomboid = " + deCOCId;
+
+                    jdbcTemplate.update( updateQuery );
+                    updateCount++;
+                }
+                else
+                {
+                    if ( value != null && !value.trim().equals( "" ) )
+                    {
+                        insertQuery += "( " + deId + ", " + periodId + ", " + orgUnitId + ", " + deCOCId + ", '" + value + "', '" + storedBy + "', '" + lastUpdatedDate + "'," + deCOCId + "), ";
+                        insertFlag = 2;
+                        insertCount++;
+                    }
+                }
+
+                if ( count == 1000 )
+                {
+                    count = 1;
+
+                    if ( insertFlag != 1 )
+                    {
+                        insertQuery = insertQuery.substring( 0, insertQuery.length() - 2 );
+                        jdbcTemplate.update( insertQuery );
+                    }
+
+                    insertFlag = 1;
+
+                    insertQuery = "INSERT INTO datavalue ( dataelementid, periodid, sourceid, categoryoptioncomboid, value, storedby, lastupdated, attributeoptioncomboid ) VALUES ";
+                }
+
+                count++;
+            }
+
+            if ( insertFlag != 1 )
+            {
+                insertQuery = insertQuery.substring( 0, insertQuery.length() - 2 );
+                jdbcTemplate.update( insertQuery );
+            }
+
+            importStatus = "Successfully populated aggregated data for the period : " + period.getStartDateString();
+            importStatus += "<br/> Total new records : " + insertCount;
+            importStatus += "<br/> Total updated records : " + updateCount;
 
         }
-        catch( Exception e )
+        catch ( Exception e )
         {
-        	importStatus = "Exception occured while import, please check log for more details" + e.getMessage();
+            importStatus = "Exception occured while import, please check log for more details" + e.getMessage();
         }
-        
-        
+
         return importStatus;
     }
 

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java	2013-12-30 09:54:47 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/DefaultCCEMReportManager.java	2014-01-06 06:13:15 +0000
@@ -148,7 +148,7 @@
                 Integer sourceId = rs.getInt( 3 );
                 String value = rs.getString( 4 );
 
-                System.out.println("********DE : " + deId + ":" + pId + ":" + sourceId + " : " + value );
+                //System.out.println("********DE : " + deId + ":" + pId + ":" + sourceId + " : " + value );
                 dataElementDataForRequirement.put( deId + ":" + pId + ":" + sourceId, value );
             }
         }

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml	2013-12-30 04:45:24 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/META-INF/dhis/beans.xml	2014-01-06 06:13:15 +0000
@@ -102,6 +102,8 @@
 		<property name="ccemReportManager" ref="org.hisp.dhis.coldchain.reports.CCEMReportManager" />
 		<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService"/>
+		<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 		<property name="jdbcTemplate" ref="jdbcTemplate"/>
     </bean>
 	

=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/Equipment.hbm.xml'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/Equipment.hbm.xml	2013-09-05 11:11:36 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/resources/org/hisp/dhis/coldchain/hibernate/Equipment.hbm.xml	2014-01-06 06:13:15 +0000
@@ -21,6 +21,8 @@
 
     <property name="working" not-null="true" />
     
+    <property name="registrationDate" column="registrationdate" />
+    
 	<set name="equipmentStatusUpdates" cascade="all-delete-orphan" inverse="true" >
       <key column="equipmentid" />
 	  <one-to-many class="org.hisp.dhis.coldchain.equipment.EquipmentStatus" />

=== modified file 'local/in/dhis-in-services/dhis-in-service-lookup/src/main/java/org/hisp/dhis/lookup/hibernate/HibernateLookupStore.java'
--- local/in/dhis-in-services/dhis-in-service-lookup/src/main/java/org/hisp/dhis/lookup/hibernate/HibernateLookupStore.java	2013-12-24 12:32:37 +0000
+++ local/in/dhis-in-services/dhis-in-service-lookup/src/main/java/org/hisp/dhis/lookup/hibernate/HibernateLookupStore.java	2014-01-06 06:13:15 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.lookup;
+package org.hisp.dhis.lookup.hibernate;
 
 import java.util.Collection;
 
@@ -17,6 +17,7 @@
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( Lookup.class );
+        
         criteria.add( Restrictions.eq( "type", type ) );
 
         return criteria.list();

=== modified file 'local/in/dhis-in-services/dhis-in-service-lookup/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-in-services/dhis-in-service-lookup/src/main/resources/META-INF/dhis/beans.xml	2013-12-24 12:32:37 +0000
+++ local/in/dhis-in-services/dhis-in-service-lookup/src/main/resources/META-INF/dhis/beans.xml	2014-01-06 06:13:15 +0000
@@ -5,7 +5,7 @@
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd";>
 
 	<!-- Store definitions -->	
-    <bean id="org.hisp.dhis.lookup.LookupStore" class="org.hisp.dhis.lookup.HibernateLookupStore">
+    <bean id="org.hisp.dhis.lookup.LookupStore" class="org.hisp.dhis.lookup.hibernate.HibernateLookupStore">
         <property name="clazz" value="org.hisp.dhis.lookup.Lookup"/>
         <property name="sessionFactory" ref="sessionFactory" />
     </bean>

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/SaveEquipmentDataValueAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/SaveEquipmentDataValueAction.java	2013-10-18 05:57:53 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/SaveEquipmentDataValueAction.java	2014-01-06 06:13:15 +0000
@@ -118,12 +118,12 @@
         
         DataSet dataSet = dataSetService.getDataSet( selectedDataSetId );
         
-       
+       /*
         if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
         {
             return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
         }
-
+*/
         
         
         List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/manager/action/SaveFacilityDataValueAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/manager/action/SaveFacilityDataValueAction.java	2013-12-23 12:24:45 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/manager/action/SaveFacilityDataValueAction.java	2014-01-06 06:13:15 +0000
@@ -9,7 +9,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.coldchain.equipment.action.SaveEquipmentDataValueAction;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -33,7 +32,7 @@
 
 public class SaveFacilityDataValueAction implements Action
 {
-    private static final Log log = LogFactory.getLog( SaveEquipmentDataValueAction.class );
+    private static final Log log = LogFactory.getLog( SaveFacilityDataValueAction.class );
     
     public static final String PREFIX_DATAELEMENT = "dataelement";
     // -------------------------------------------------------------------------
@@ -142,12 +141,12 @@
         
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
         
-       
+/*       
         if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
         {
             return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
         }
-
+*/
         List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
         
         String storedBy = currentUserService.getCurrentUsername();

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java	2013-12-30 09:54:47 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEIReportAction.java	2014-01-06 06:13:15 +0000
@@ -4319,8 +4319,7 @@
 
             for ( Integer orgUnitId : selOrgUnitList )
             {
-                List<OrganisationUnit> orgUnitChildren = new ArrayList<OrganisationUnit>( organisationUnitService
-                    .getOrganisationUnitWithChildren( orgUnitId ) );
+                List<OrganisationUnit> orgUnitChildren = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
                 OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
 
                 for ( Integer orgUnitGroupId : orgunitGroupList )
@@ -4338,14 +4337,11 @@
                     // ccemReportManager.getOrgunitIdsByComma( orgUnitId,
                     // orgUnitGrpId );
 
-                    OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService
-                        .getOrganisationUnitGroup( orgUnitGroupId );
+                    OrganisationUnitGroup orgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroupId );
 
-                    List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>( orgUnitGroup
-                        .getMembers() );
+                    List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
                     orgUnitGroupMembers.retainAll( orgUnitChildren );
-                    Collection<Integer> orgUnitGroupMemberIds = new ArrayList<Integer>( getIdentifiers(
-                        OrganisationUnit.class, orgUnitGroupMembers ) );
+                    Collection<Integer> orgUnitGroupMemberIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnitGroupMembers ) );
                     String orgUnitidsByComma = getCommaDelimitedString( orgUnitGroupMemberIds );
                     Integer totalFacilities = orgUnitGroupMembers.size();
 
@@ -4475,8 +4471,7 @@
                          * 10, 2 );
                          */
 
-                        Map<String, Integer> dataValueCountMap = new HashMap<String, Integer>( ccemReportManager
-                            .getDataValueAndCount( dataelementId1 + "", orgUnitidsByComma, periodIdsByComma ) );
+                        Map<String, Integer> dataValueCountMap = new HashMap<String, Integer>( ccemReportManager.getDataValueAndCount( dataelementId1 + "", orgUnitidsByComma, periodIdsByComma ) );
 
                         if ( dataElement1.getOptionSet() != null )
                         {
@@ -4493,11 +4488,8 @@
                                 double percentageOfOptionValueCount = 0.0;
                                 try
                                 {
-                                    percentageOfOptionValueCount = (double) optionValueCount / (double) totalFacilities
-                                        * 100.0;
-                                    percentageOfOptionValueCount = Math.round( percentageOfOptionValueCount
-                                        * Math.pow( 10, 2 ) )
-                                        / Math.pow( 10, 2 );
+                                    percentageOfOptionValueCount = (double) optionValueCount / (double) totalFacilities * 100.0;
+                                    percentageOfOptionValueCount = Math.round( percentageOfOptionValueCount * Math.pow( 10, 2 ) ) / Math.pow( 10, 2 );
                                 }
                                 catch ( Exception e )
                                 {

=== modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java	2013-12-23 12:24:45 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateCCEMReportAction.java	2014-01-06 06:13:15 +0000
@@ -725,8 +725,7 @@
             }
 
             orgUnitList.retainAll( orgUnitGroupMembers );
-            Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class,
-                orgUnitList ) );
+            Collection<Integer> orgUnitIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnitList ) );
             orgUnitIdsByComma = getCommaDelimitedString( orgUnitIds );
 
             // Calculations for Actual Column

=== modified file 'local/in/dhis-web-dataentry-ccem/src/main/java/org/hisp/dhis/dataentry/action/SaveEquipmentDataValueAction.java'
--- local/in/dhis-web-dataentry-ccem/src/main/java/org/hisp/dhis/dataentry/action/SaveEquipmentDataValueAction.java	2013-10-18 05:57:53 +0000
+++ local/in/dhis-web-dataentry-ccem/src/main/java/org/hisp/dhis/dataentry/action/SaveEquipmentDataValueAction.java	2014-01-06 06:13:15 +0000
@@ -125,12 +125,12 @@
         
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
         
-       
+       /*
         if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
         {
             return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
         }
-
+*/
         List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
         
         String storedBy = currentUserService.getCurrentUsername();

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryAction.java	2013-12-30 04:45:24 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/AddAggregationQueryAction.java	2014-01-06 06:13:15 +0000
@@ -1,5 +1,8 @@
 package org.hisp.dhis.ccem.aggregation.action;
 
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
 import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
 import org.hisp.dhis.coldchain.aggregation.CCEIAggregationService;
@@ -11,89 +14,175 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class AddAggregationQueryAction implements Action
+public class AddAggregationQueryAction
+    implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private CaseAggregationConditionService aggregationConditionService;
 
     public void setAggregationConditionService( CaseAggregationConditionService aggregationConditionService )
     {
         this.aggregationConditionService = aggregationConditionService;
     }
-    
+
     private DataElementService dataElementService;
-    
-    public void setDataElementService(DataElementService dataElementService) 
+
+    public void setDataElementService( DataElementService dataElementService )
     {
-		this.dataElementService = dataElementService;
-	}
-    
+        this.dataElementService = dataElementService;
+    }
+
     private LookupService lookupService;
-    
-    public void setLookupService(LookupService lookupService) 
+
+    public void setLookupService( LookupService lookupService )
     {
-		this.lookupService = lookupService;
-	}
-    
+        this.lookupService = lookupService;
+    }
+
     private CCEIAggregationService cceiAggregationService;
-    
-	public void setCceiAggregationService( CCEIAggregationService cceiAggregationService) 
-	{
-		this.cceiAggregationService = cceiAggregationService;
-	}
-    
-	private DataElementCategoryService dataElementCategoryService;
-	
-	public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService) 
-	{
-		this.dataElementCategoryService = dataElementCategoryService;
-	}
-	
+
+    public void setCceiAggregationService( CCEIAggregationService cceiAggregationService )
+    {
+        this.cceiAggregationService = cceiAggregationService;
+    }
+
+    private DataElementCategoryService dataElementCategoryService;
+
+    public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
+    {
+        this.dataElementCategoryService = dataElementCategoryService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/ Output
     // -------------------------------------------------------------------------
 
-	private String name;
-    
+    private String name;
+
     private String aggType;
-    
+
     private Integer dataElementId;
-    
-    public void setName(String name) 
-    {
-		this.name = name;
-	}
-
-	public void setAggType(String aggType) 
-	{
-		this.aggType = aggType;
-	}
-
-	public void setDataElementId(Integer dataElementId) 
-	{
-		this.dataElementId = dataElementId;
-	}
-
-	// -------------------------------------------------------------------------
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public void setAggType( String aggType )
+    {
+        this.aggType = aggType;
+    }
+
+    public void setDataElementId( Integer dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-	public String execute()
+    public String execute()
         throws Exception
     {
-		DataElement dataElement = dataElementService.getDataElement( dataElementId );
-		
-		/**
-		 * TODO support for category option combo
-		 */
-		if( aggType.equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY ) )
-		{
-			CaseAggregationCondition condition = new CaseAggregationCondition( name, aggType, "NONE", dataElement, dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
-			
-			aggregationConditionService.addCaseAggregationCondition( condition );
-		}
+        DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+        /**
+         * TODO support for category option combo
+         */
+        if ( aggType.equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY ) )
+        {
+            CaseAggregationCondition condition = new CaseAggregationCondition( name, aggType, "NONE", dataElement, dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
+
+            aggregationConditionService.addCaseAggregationCondition( condition );    
+        }
+        else if ( aggType.equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL ) )
+        {
+            HttpServletRequest request = ServletActionContext.getRequest();
+            
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_WORKING_STATUS_OPTIONSET );
+            
+            String[] workingStatusValues = request.getParameterValues( lookup.getName() );
+            String workingStatus = "";
+            for( String workingStatusValue : workingStatusValues )
+            {
+                workingStatus += "'" + workingStatusValue + "',";
+            }
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_MODEL_MODELTYPEATTRIBUTE );
+            
+            String modelName = request.getParameter( lookup.getName() );
+            modelName = "'" + modelName + "'";
+            Integer modelTypeAttributeId = Integer.parseInt( lookup.getValue() );
+            
+            workingStatus = workingStatus.substring( 0, workingStatus.length()-1 );
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_REF_EQUIPMENTTYPE_ID );
+            
+            Integer equipmentTypeId = Integer.parseInt( lookup.getValue() );
+            
+            String query = cceiAggregationService.getQueryForRefrigeratorWorkingStatus( equipmentTypeId, modelTypeAttributeId, modelName, workingStatus );
+            
+            CaseAggregationCondition condition = new CaseAggregationCondition( name, aggType, query, dataElement, dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
+            
+            aggregationConditionService.addCaseAggregationCondition( condition );
+        }
+        else if ( aggType.equals( Lookup.CCEI_AGG_TYPE_REF_UTILIZATION ) )
+        {
+            HttpServletRequest request = ServletActionContext.getRequest();
+            
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_UTILIZATION_OPTIONSET );
+            String utilization = request.getParameter( lookup.getName() );
+            utilization = "'" + utilization  + "'";
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_MODEL_MODELTYPEATTRIBUTE );
+            String modelName = request.getParameter( lookup.getName() );
+            modelName = "'" + modelName + "'";
+            Integer modelTypeAttributeId = Integer.parseInt( lookup.getValue() );
+
+            lookup = lookupService.getLookupByName( Lookup.CCEI_REF_EQUIPMENTTYPE_ID );            
+            Integer equipmentTypeId = Integer.parseInt( lookup.getValue() );
+
+            String query = cceiAggregationService.getQueryForRefrigeratorUtilization( equipmentTypeId, modelTypeAttributeId, modelName,  utilization );
+            
+            CaseAggregationCondition condition = new CaseAggregationCondition( name, aggType, query, dataElement, dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
+            
+            aggregationConditionService.addCaseAggregationCondition( condition );
+        }
+        else if ( aggType.equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE ) )
+        {
+            HttpServletRequest request = ServletActionContext.getRequest();
+            
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_WORKING_STATUS_OPTIONSET );
+            
+            String[] workingStatusValues = request.getParameterValues( lookup.getName() );
+            String workingStatus = "";
+            for( String workingStatusValue : workingStatusValues )
+            {
+                workingStatus += "'" + workingStatusValue + "',";
+            }
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_EQUIPMENTTYPE_MODELTYPEATTRIBUTE );
+            
+            String modelName = request.getParameter( lookup.getName() );
+            modelName = "'" + modelName + "'";
+            Integer modelTypeAttributeId = Integer.parseInt( lookup.getValue() );
+            
+            workingStatus = workingStatus.substring( 0, workingStatus.length()-1 );
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_REF_EQUIPMENTTYPE_ID );
+            
+            Integer equipmentTypeId = Integer.parseInt( lookup.getValue() );
+            
+            String query = cceiAggregationService.getQueryForRefrigeratorWorkingStatus( equipmentTypeId, modelTypeAttributeId, modelName, workingStatus );
+            
+            CaseAggregationCondition condition = new CaseAggregationCondition( name, aggType, query, dataElement, dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() );
+            
+            aggregationConditionService.addCaseAggregationCondition( condition );
+        }
+
 
         return SUCCESS;
     }

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java	2013-12-27 12:32:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/GetAggregationParameterAction.java	2014-01-06 06:13:15 +0000
@@ -1,18 +1,16 @@
 package org.hisp.dhis.ccem.aggregation.action;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.hisp.dhis.coldchain.equipment.EquipmentTypeAttribute;
+import org.hisp.dhis.coldchain.equipment.EquipmentTypeAttributeService;
 import org.hisp.dhis.coldchain.model.ModelAttributeValue;
 import org.hisp.dhis.coldchain.model.ModelAttributeValueService;
 import org.hisp.dhis.coldchain.model.ModelTypeAttribute;
-import org.hisp.dhis.coldchain.model.ModelTypeAttributeOption;
 import org.hisp.dhis.coldchain.model.ModelTypeAttributeService;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.lookup.Lookup;
 import org.hisp.dhis.lookup.LookupService;
 import org.hisp.dhis.option.OptionService;
@@ -20,95 +18,156 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class GetAggregationParameterAction implements Action 
+public class GetAggregationParameterAction
+    implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	private LookupService lookupService;
-
-	public void setLookupService(LookupService lookupService) 
-	{
-		this.lookupService = lookupService;
-	}
-	
-    private OptionService optionService; 
-    
-    public void setOptionService(OptionService optionService) {
-		this.optionService = optionService;
-	}
+    private LookupService lookupService;
+
+    public void setLookupService( LookupService lookupService )
+    {
+        this.lookupService = lookupService;
+    }
+
+    private OptionService optionService;
+
+    public void setOptionService( OptionService optionService )
+    {
+        this.optionService = optionService;
+    }
+
     private ModelAttributeValueService modelAttributeValueService;
-    
-	public void setModelAttributeValueService(
-			ModelAttributeValueService modelAttributeValueService) {
-		this.modelAttributeValueService = modelAttributeValueService;
-	}
-
-	private ModelTypeAttributeService modelTypeAttributeService;
-	
-    public void setModelTypeAttributeService(
-			ModelTypeAttributeService modelTypeAttributeService) {
-		this.modelTypeAttributeService = modelTypeAttributeService;
-	}    
-    
-	// -------------------------------------------------------------------------
+
+    public void setModelAttributeValueService( ModelAttributeValueService modelAttributeValueService )
+    {
+        this.modelAttributeValueService = modelAttributeValueService;
+    }
+
+    private ModelTypeAttributeService modelTypeAttributeService;
+
+    public void setModelTypeAttributeService( ModelTypeAttributeService modelTypeAttributeService )
+    {
+        this.modelTypeAttributeService = modelTypeAttributeService;
+    }
+
+    private EquipmentTypeAttributeService equipmentTypeAttributeService;
+    
+    public void setEquipmentTypeAttributeService( EquipmentTypeAttributeService equipmentTypeAttributeService )
+    {
+        this.equipmentTypeAttributeService = equipmentTypeAttributeService;
+    }
+
+    // -------------------------------------------------------------------------
     // Input/ Output
     // -------------------------------------------------------------------------
-	private String aggTypeId;
-	
-    public void setAggTypeId(String aggTypeId) {
-		this.aggTypeId = aggTypeId;
-	}
-    
-    private Map<String,List<String>> lookUpParamMap;
-    
-    public Map<String, List<String>> getLookUpParamMap() {
-		return lookUpParamMap;
-	}
+    private String aggTypeId;
+
+    public void setAggTypeId( String aggTypeId )
+    {
+        this.aggTypeId = aggTypeId;
+    }
+
+    private Map<String, List<String>> lookUpParamMap;
+
+    public Map<String, List<String>> getLookUpParamMap()
+    {
+        return lookUpParamMap;
+    }
+
     List<Lookup> lookups;
-	
-    public List<Lookup> getLookups() 
+
+    public List<Lookup> getLookups()
     {
-		return lookups;
-	}
+        return lookups;
+    }
 
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-	public String execute()
+    public String execute()
         throws Exception
     {
-		Lookup lookup = lookupService.getLookup(Integer.parseInt(aggTypeId));
-		String lookupType = lookup.getName();
-		
-		lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( lookupType ) );
-		
-		lookUpParamMap = new HashMap<String,List<String>>();
-		for(Lookup lp : lookups)
-		{
-			if(lp.getName().equalsIgnoreCase("optionset"))
-			{
-				OptionSet os = optionService.getOptionSet(Integer.parseInt(lp.getValue()));
-				
-				lookUpParamMap.put(lp.getName(), os.getOptions());
-			}
-			if(lp.getName().equalsIgnoreCase("modeltypeattribute"))
-			{
-			   ModelTypeAttribute mtAttribute =	modelTypeAttributeService.getModelTypeAttribute(Integer.parseInt(lp.getValue()));
-			   
-			   List<ModelAttributeValue> modelAttValueList = new ArrayList<ModelAttributeValue>( modelAttributeValueService.getAllModelAttributeValuesByModelTypeAttribute(mtAttribute) );
-			   
-			   List<String> modelNameList = new ArrayList<String>();
-			   
-			   for(ModelAttributeValue maValue : modelAttValueList)
-			   {
-				   modelNameList.add(maValue.getValue());
-			   }
-			   
-			   lookUpParamMap.put(lp.getName(), modelNameList);  
-			}
-		}
-		
-    	return SUCCESS;
+        lookUpParamMap = new HashMap<String, List<String>>();
+        
+        if( aggTypeId.equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY ) )
+        {
+
+        }
+        else if( aggTypeId.equals( Lookup.CCEI_AGG_TYPE_REF_UTILIZATION ) )
+        {
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_MODEL_MODELTYPEATTRIBUTE );
+            
+            ModelTypeAttribute mtAttribute = modelTypeAttributeService.getModelTypeAttribute( Integer.parseInt( lookup.getValue() ) );
+
+            List<ModelAttributeValue> modelAttValueList = new ArrayList<ModelAttributeValue>( modelAttributeValueService.getAllModelAttributeValuesByModelTypeAttribute( mtAttribute ) );
+
+            List<String> modelNameList = new ArrayList<String>();
+
+            for ( ModelAttributeValue maValue : modelAttValueList )
+            {
+                modelNameList.add( maValue.getValue() );
+            }
+
+            lookUpParamMap.put( lookup.getName(), modelNameList );
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_UTILIZATION_OPTIONSET );
+            
+            OptionSet os = optionService.getOptionSet( Integer.parseInt( lookup.getValue() ) );
+            
+            lookUpParamMap.put( lookup.getName(), os.getOptions() );
+        }
+        else if( aggTypeId.equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL ) )
+        {
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_WORKING_STATUS_OPTIONSET );
+            
+            OptionSet os = optionService.getOptionSet( Integer.parseInt( lookup.getValue() ) );
+            
+            lookUpParamMap.put( lookup.getName(), os.getOptions() );
+            
+            lookup = lookupService.getLookupByName( Lookup.CCEI_MODEL_MODELTYPEATTRIBUTE );
+            
+            ModelTypeAttribute mtAttribute = modelTypeAttributeService.getModelTypeAttribute( Integer.parseInt( lookup.getValue() ) );
+
+            List<ModelAttributeValue> modelAttValueList = new ArrayList<ModelAttributeValue>( modelAttributeValueService.getAllModelAttributeValuesByModelTypeAttribute( mtAttribute ) );
+
+            List<String> modelNameList = new ArrayList<String>();
+
+            for ( ModelAttributeValue maValue : modelAttValueList )
+            {
+                modelNameList.add( maValue.getValue() );
+            }
+
+            lookUpParamMap.put( lookup.getName(), modelNameList );
+        }
+        else if( aggTypeId.equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE ) )
+        {
+            Lookup lookup = lookupService.getLookupByName( Lookup.CCEI_WORKING_STATUS_OPTIONSET );
+            
+            OptionSet os = optionService.getOptionSet( Integer.parseInt( lookup.getValue() ) );
+            
+            lookUpParamMap.put( lookup.getName(), os.getOptions() );
+
+            lookup = lookupService.getLookupByName( Lookup.CCEI_EQUIPMENTTYPE_MODELTYPEATTRIBUTE );
+            
+            ModelTypeAttribute mtAttribute = modelTypeAttributeService.getModelTypeAttribute( Integer.parseInt( lookup.getValue() ) );
+
+            lookUpParamMap.put( lookup.getName(), mtAttribute.getOptionSet().getOptions() );
+            
+            /*
+            List<ModelAttributeValue> modelAttValueList = new ArrayList<ModelAttributeValue>( modelAttributeValueService.getAllModelAttributeValuesByModelTypeAttribute( mtAttribute ) );
+
+            List<String> modelNameList = new ArrayList<String>();
+
+            for ( ModelAttributeValue maValue : modelAttValueList )
+            {
+                modelNameList.add( maValue.getValue() );
+            }
+            */
+        }
+
+        
+        return SUCCESS;
     }
 }

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java	2013-12-30 04:45:24 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/aggregation/action/RunAggregationQueryAction.java	2014-01-06 06:13:15 +0000
@@ -26,7 +26,8 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class RunAggregationQueryAction implements Action 
+public class RunAggregationQueryAction
+    implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -40,7 +41,7 @@
     }
 
     private OrganisationUnitService organisationUnitService;
-    
+
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
     {
         this.organisationUnitService = organisationUnitService;
@@ -61,77 +62,98 @@
     }
 
     private CCEIAggregationService cceiAggregationService;
-    
-    public void setCceiAggregationService( CCEIAggregationService cceiAggregationService) 
+
+    public void setCceiAggregationService( CCEIAggregationService cceiAggregationService )
     {
-		this.cceiAggregationService = cceiAggregationService;
-	}
-    
+        this.cceiAggregationService = cceiAggregationService;
+    }
+
     private PeriodService periodService;
-    
-    public void setPeriodService(PeriodService periodService) 
+
+    public void setPeriodService( PeriodService periodService )
     {
-		this.periodService = periodService;
-	}
+        this.periodService = periodService;
+    }
 
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
-	private List<DataElement> dataElements = new ArrayList<DataElement>();
-    
-    public List<DataElement> getDataElements() 
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
+
+    public List<DataElement> getDataElements()
     {
-		return dataElements;
-	}
+        return dataElements;
+    }
 
     private String importStatus = "";
-    
-	public String getImportStatus() 
-	{
-		return importStatus;
-	}
-    
+
+    public String getImportStatus()
+    {
+        return importStatus;
+    }
+
     // -------------------------------------------------------------------------
     // Action
     // -------------------------------------------------------------------------
 
-	public String execute()
+    public String execute()
         throws Exception
     {
-		Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
-		
-		Set<OrganisationUnit> orgUnitList = new HashSet<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
-
-    	Set<OrganisationUnitGroup> orgUnitGroups = new HashSet<OrganisationUnitGroup>( organisationUnitGroupService.getAllOrganisationUnitGroups() );
-    	
-    	List<OrganisationUnitGroup> ouGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getOrganisationUnitGroupByName( EquipmentAttributeValue.HEALTHFACILITY ) ); 
-        
-    	OrganisationUnitGroup ouGroup = ouGroups.get( 0 );				
-       
+        Map<String, Integer> aggregationResultMap = new HashMap<String, Integer>();
+
+        Set<OrganisationUnit> orgUnitList = new HashSet<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
+
+        Set<OrganisationUnitGroup> orgUnitGroups = new HashSet<OrganisationUnitGroup>( organisationUnitGroupService.getAllOrganisationUnitGroups() );
+
+        List<OrganisationUnitGroup> ouGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getOrganisationUnitGroupByName( EquipmentAttributeValue.HEALTHFACILITY ) );
+
+        OrganisationUnitGroup ouGroup = ouGroups.get( 0 );
+
         if ( ouGroup != null )
         {
             orgUnitList.retainAll( ouGroup.getMembers() );
         }
-        
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyyMM");
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyyMM" );
         String curMonth = simpleDateFormat.format( new Date() );
         Period period = PeriodType.getPeriodFromIsoString( curMonth );
         period = periodService.reloadPeriod( period );
-        
+
         Set<CaseAggregationCondition> conditions = new HashSet<CaseAggregationCondition>( aggregationConditionService.getAllCaseAggregationCondition() );
-        for( CaseAggregationCondition condition : conditions )
-        {
-        	DataElement dataElement = condition.getAggregationDataElement();
-        	if( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY) )
-        	{
-        		aggregationResultMap.putAll( cceiAggregationService.calculateStorageCapacityData( dataElement, orgUnitList, orgUnitGroups ) );
-        	}
-        	
-        	dataElements.add( dataElement );
-        }
-        
-        importStatus = cceiAggregationService.importData(aggregationResultMap, period);
-        
+        for ( CaseAggregationCondition condition : conditions )
+        {
+            DataElement dataElement = condition.getAggregationDataElement();
+            
+            if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL ) || condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE ) )
+            {
+                aggregationResultMap.putAll( cceiAggregationService.calculateRefrigeratorWorkingStatus( period, dataElement, orgUnitList, condition.getAggregationExpression() ) );
+            }
+
+            /*
+            if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_STORAGE_CAPACITY ) )
+            {
+                aggregationResultMap.putAll( cceiAggregationService.calculateStorageCapacityData( period, dataElement, orgUnitList, orgUnitGroups ) );
+            }
+            else if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_MODEL ) || condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_WORKING_STATUS_BY_TYPE ) )
+            {
+                aggregationResultMap.putAll( cceiAggregationService.calculateRefrigeratorWorkingStatus( period, dataElement, orgUnitList, condition.getAggregationExpression() ) );
+            }
+            else if ( condition.getOperator().equals( Lookup.CCEI_AGG_TYPE_REF_UTILIZATION ) )
+            {
+                aggregationResultMap.putAll( cceiAggregationService.calculateRefrigeratorUtilization( period, dataElement, orgUnitList, condition.getAggregationExpression() ) );
+            }
+            */
+
+            dataElements.add( dataElement );
+        }
+
+        for( String key : aggregationResultMap.keySet() )
+        {
+            System.out.println( key + " -- " + aggregationResultMap.get(  key ) );
+        }
+        
+        //importStatus = cceiAggregationService.importData( aggregationResultMap, period );
+
         return SUCCESS;
     }
 

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/equipment/action/SaveEquipmentDataValueAction.java'
--- local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/equipment/action/SaveEquipmentDataValueAction.java	2013-10-18 05:57:53 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/java/org/hisp/dhis/ccem/equipment/action/SaveEquipmentDataValueAction.java	2014-01-06 06:13:15 +0000
@@ -118,14 +118,6 @@
         
         DataSet dataSet = dataSetService.getDataSet( selectedDataSetId );
         
-       
-        if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
-        {
-            return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
-        }
-
-        
-        
         List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
         
         String storedBy = currentUserService.getCurrentUsername();

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm	2013-12-27 12:32:48 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationParam.vm	2014-01-06 06:13:15 +0000
@@ -1,15 +1,16 @@
+
 <table style="width:100%" cellpadding="5" cellspacing="5">	
-#foreach($lookup in $lookups)
-	<tr >
-	#set($parameterList = $lookUpParamMap.get($lookup.name))
-	<td style="width:40%">$lookup.name </td>
-	<td style="width:60%">
-		<select id="$lookup.name" style="width:100%" multiple>
-			#foreach($param in $parameterList)
-				<option value="$param">$param</option>
-			#end
-		</select>
-	</td>
-	</tr>
-#end
+    #foreach($lookupParamKey in $lookUpParamMap.keySet() )
+        <tr>
+            #set( $parameterList = $lookUpParamMap.get($lookupParamKey) )
+            <td style="width:40%">$lookupParamKey</td>
+            <td style="width:60%">
+                <select id="$lookupParamKey" name="$lookupParamKey" style="width:100%" multiple>
+                #foreach($param in $parameterList)
+				    <option value="$param">$param</option>
+                #end
+                </select>
+            </td>
+        </tr>
+    #end
 </table>
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm	2013-12-30 04:45:24 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/addAggregationQuery.vm	2014-01-06 06:13:15 +0000
@@ -42,7 +42,7 @@
 				<select style='width:100%; margin-bottom:-5px;' id="aggType" name="aggType" onchange="getParameters()">
                     <option value="-1" >Please Select</option>
 					#foreach( $lookup in $lookups )
-						<option value="$lookup.value">$lookup.value</option>
+						<option value="$lookup.name">$lookup.value</option>
 					#end
 				</select>
 			</td>
@@ -56,10 +56,8 @@
     </tbody>
 </table>
 
-
 <p>	
-	<input type="submit" value="$i18n.getString( 'add' )" />
-	<input type="button" value="$i18n.getString( 'test_condition' )" onclick='testCaseAggregationCondition();'/>
+	<input type="submit" value="$i18n.getString( 'add' )" />	
 	<input type="button" value="$i18n.getString( 'cancel' )" onClick="cancelOnClick();" />
 </p>
 

=== modified file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryForm.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryForm.vm	2013-12-30 04:45:24 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryForm.vm	2014-01-06 06:13:15 +0000
@@ -1,7 +1,5 @@
 <h3>$i18n.getString( "manual_aggregation" )</h3>
 
-<h4>$encoder.htmlEncode( $dataSet.displayName )</h4>
-
 <form id="runAggregationQueryForm" action="runAggregationQuery.action" method="post">
   
   <table id="selectionTable">

=== added file 'local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryResult.vm'
--- local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryResult.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-ccem/src/main/webapp/dhis-web-maintenance-ccem/runAggregationQueryResult.vm	2014-01-06 06:13:15 +0000
@@ -0,0 +1,2 @@
+
+$importStatus
\ No newline at end of file