← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13362: PBF: Added LookupTable; Saving TariffData in correspondence to Dataset instead orgunitgroup

 

------------------------------------------------------------
revno: 13362
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-12-21 05:25:33 +0000
message:
  PBF: Added LookupTable; Saving TariffData in correspondence to Dataset instead orgunitgroup
added:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/Lookup.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupService.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupStore.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultLookupService.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateLookupStore.java
  local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/Lookup.hbm.xml
modified:
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValue.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueService.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueStore.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultTariffDataValueService.java
  local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateTariffDataValueStore.java
  local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/TariffDataValue.hbm.xml
  local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.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-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/AddTariffDataAction.java	2013-12-21 05:25:33 +0000
@@ -1,17 +1,13 @@
 package org.hisp.dhis.pbf.action;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueService;
@@ -19,139 +15,137 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class AddTariffDataAction implements Action {
-	// -------------------------------------------------------------------------
-	// Dependencies
-	// -------------------------------------------------------------------------
-
-	private TariffDataValueService tariffDataValueService;
-
-	public void setTariffDataValueService(TariffDataValueService tariffDataValueService) 
-	{
-		this.tariffDataValueService = tariffDataValueService;
-	}
-	
-	private DataElementService dataElementService;
-	
-	public void setDataElementService(DataElementService dataElementService) {
-		this.dataElementService = dataElementService;
-	}
-
-	private OrganisationUnitService organisationUnitService;
-	
-	public void setOrganisationUnitService(
-			OrganisationUnitService organisationUnitService) {
-		this.organisationUnitService = organisationUnitService;
-	}
-	
-	private OrganisationUnitGroupService organisationUnitGroupService;
-	
-	public void setOrganisationUnitGroupService(
-			OrganisationUnitGroupService organisationUnitGroupService) {
-		this.organisationUnitGroupService = organisationUnitGroupService;
-	}
-	
-	private DataElementCategoryService categoryService;
-	
-	public void setCategoryService(DataElementCategoryService categoryService) {
-		this.categoryService = categoryService;
-	}
-	
-	private CurrentUserService currentUserService;
-	
-	public void setCurrentUserService(CurrentUserService currentUserService) {
-		this.currentUserService = currentUserService;
-	}
-
-	// -------------------------------------------------------------------------
+public class AddTariffDataAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private TariffDataValueService tariffDataValueService;
+
+    public void setTariffDataValueService( TariffDataValueService tariffDataValueService )
+    {
+        this.tariffDataValueService = tariffDataValueService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+    
+    // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
-	
-	
-	private String pbfType;
-	private String tariff;
-	private String startDate;
-	private String endDate;
-	
-	private String dataElementId;
-	private String orgUnitUid;
-	
-	public void setDataElementId(String dataElementId) {
-		this.dataElementId = dataElementId;
-	}
-
-	public void setOrgUnitUid(String orgUnitUid) {
-		this.orgUnitUid = orgUnitUid;
-	}
-
-	public void setPbfType(String pbfType) {
-		this.pbfType = pbfType;
-	}
-
-	public void setTariff(String tariff) {
-		this.tariff = tariff;
-	}
-
-	public void setStartDate(String startDate) {
-		this.startDate = startDate;
-	}
-
-	public void setEndDate(String endDate) {
-		this.endDate = endDate;
-	}
-
-	// -------------------------------------------------------------------------
+
+    private String pbfType;
+
+    private String tariff;
+
+    private String startDate;
+
+    private String endDate;
+
+    private String dataElementId;
+
+    private String orgUnitUid;
+
+    public void setDataElementId( String dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    public void setOrgUnitUid( String orgUnitUid )
+    {
+        this.orgUnitUid = orgUnitUid;
+    }
+
+    public void setPbfType( String pbfType )
+    {
+        this.pbfType = pbfType;
+    }
+
+    public void setTariff( String tariff )
+    {
+        this.tariff = tariff;
+    }
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-	public String execute() throws Exception {
-		
-		Date sDate;
-		Date eDate;
-		SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
-		sDate = dateFormat.parse(startDate);
-		eDate = dateFormat.parse(endDate);
-		
-		DataElement dataElement = dataElementService.getDataElement(Integer.parseInt(dataElementId));
-		
-		List<String> orgUids = new ArrayList<String>();
-		orgUids.add(orgUnitUid);
-		List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitsByUid(orgUids);
-		
-		OrganisationUnitGroup orgUnitGrp = organisationUnitGroupService.getOrganisationUnitGroup(Integer.parseInt(pbfType));
-		DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-		
-		TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue(organisationUnits.get(0), dataElement, optionCombo, orgUnitGrp, sDate, eDate);
-		
-		TariffDataValue tariffDataValue1;
-		
-		if(tariffDataValue == null)
-		{
-			tariffDataValue1 = new TariffDataValue();
-		}
-		else
-		{
-			tariffDataValue1 = tariffDataValueService.getTariffDataValue(organisationUnits.get(0), dataElement, optionCombo, orgUnitGrp, sDate, eDate);
-		}
-		
-		tariffDataValue1.setValue(Double.parseDouble(tariff));
-		tariffDataValue1.setStartDate(sDate);
-		tariffDataValue1.setEndDate(eDate);
-		tariffDataValue1.setTimestamp(new Date());
-		tariffDataValue1.setStoredBy(currentUserService.getCurrentUsername());
-		tariffDataValue1.setDataElement(dataElement);
-		tariffDataValue1.setOptionCombo(optionCombo);
-		tariffDataValue1.setOrganisationUnitGroup(orgUnitGrp);
-		tariffDataValue1.setOrganisationUnit(organisationUnits.get(0));
-		
-		if(tariffDataValue == null)
-		{
-			tariffDataValueService.addTariffDataValue(tariffDataValue1);
-		}
-		else
-		{
-			tariffDataValueService.updateTariffDataValue(tariffDataValue1);
-		}		
-		return SUCCESS;
-	}
+    public String execute()
+        throws Exception
+    {
+        SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        Date sDate = dateFormat.parse( startDate );
+        Date eDate = dateFormat.parse( endDate );
+
+        DataElement dataElement = dataElementService.getDataElement( Integer.parseInt( dataElementId ) );
+
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
+
+        DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( pbfType ) );
+        
+        TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( organisationUnit, dataElement, dataSet, sDate, eDate );
+
+        if ( tariffDataValue == null )
+        {
+            tariffDataValue = new TariffDataValue();
+            
+            tariffDataValue.setValue( Double.parseDouble( tariff ) );
+            tariffDataValue.setStartDate( sDate );
+            tariffDataValue.setEndDate( eDate );
+            tariffDataValue.setTimestamp( new Date() );
+            tariffDataValue.setStoredBy( currentUserService.getCurrentUsername() );
+            tariffDataValue.setDataElement( dataElement );
+            tariffDataValue.setDataSet( dataSet );
+            tariffDataValue.setOrganisationUnit( organisationUnit );
+            
+            tariffDataValueService.addTariffDataValue( tariffDataValue );
+        }
+        else
+        {
+            tariffDataValue.setValue( Double.parseDouble( tariff ) );
+            tariffDataValue.setTimestamp( new Date() );
+            tariffDataValue.setStoredBy( currentUserService.getCurrentUsername() );
+            
+            tariffDataValueService.updateTariffDataValue( tariffDataValue );
+        }
+
+        return SUCCESS;
+    }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/DeleteTariffDataAction.java	2013-12-21 05:25:33 +0000
@@ -4,128 +4,110 @@
 import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueService;
 
 import com.opensymphony.xwork2.Action;
 
-public class DeleteTariffDataAction implements Action {
-	// -------------------------------------------------------------------------
-	// Dependencies
-	// -------------------------------------------------------------------------
-
-	private TariffDataValueService tariffDataValueService;
-
-	public void setTariffDataValueService(TariffDataValueService tariffDataValueService) 
-	{
-		this.tariffDataValueService = tariffDataValueService;
-	}
-	private DataElementService dataElementService;
-	
-	public void setDataElementService(DataElementService dataElementService) {
-		this.dataElementService = dataElementService;
-	}
-
-	private OrganisationUnitService organisationUnitService;
-	
-	public void setOrganisationUnitService(
-			OrganisationUnitService organisationUnitService) {
-		this.organisationUnitService = organisationUnitService;
-	}
-	
-	private OrganisationUnitGroupService organisationUnitGroupService;
-	
-	public void setOrganisationUnitGroupService(
-			OrganisationUnitGroupService organisationUnitGroupService) {
-		this.organisationUnitGroupService = organisationUnitGroupService;
-	}
-	
-	private DataElementCategoryService categoryService;
-	
-	public void setCategoryService(DataElementCategoryService categoryService) {
-		this.categoryService = categoryService;
-	}
-	// -------------------------------------------------------------------------
+public class DeleteTariffDataAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private TariffDataValueService tariffDataValueService;
+
+    public void setTariffDataValueService( TariffDataValueService tariffDataValueService )
+    {
+        this.tariffDataValueService = tariffDataValueService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
-	
-	private String organisationUnitId;
-	
-	private String dataElementId;
-	
-	private String categoryOptionComboId;
-	
-	private String organisationUnitGroupId;
-	
-	private String startDate;
-	
-	private String endDate;
-	
-	public void setOrganisationUnitId(String organisationUnitId) {
-		this.organisationUnitId = organisationUnitId;
-	}
-
-
-	public void setDataElementId(String dataElementId) {
-		this.dataElementId = dataElementId;
-	}
-
-
-	public void setCategoryOptionComboId(String categoryOptionComboId) {
-		this.categoryOptionComboId = categoryOptionComboId;
-	}
-
-
-	public void setOrganisationUnitGroupId(String organisationUnitGroupId) {
-		this.organisationUnitGroupId = organisationUnitGroupId;
-	}
-
-
-	public void setStartDate(String startDate) {
-		this.startDate = startDate;
-	}
-
-
-	public void setEndDate(String endDate) {
-		this.endDate = endDate;
-	}
-
-
-	// -------------------------------------------------------------------------
+
+    private Integer organisationUnitId;
+
+    private Integer dataElementId;
+
+    private Integer dataSetId;
+
+    private String startDate;
+
+    private String endDate;
+
+    public void setOrganisationUnitId( Integer organisationUnitId )
+    {
+        this.organisationUnitId = organisationUnitId;
+    }
+
+    public void setDataElementId( Integer dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    public void setDataSetId( Integer dataSetId )
+    {
+        this.dataSetId = dataSetId;
+    }
+
+    public void setStartDate( String startDate )
+    {
+        this.startDate = startDate;
+    }
+
+    public void setEndDate( String endDate )
+    {
+        this.endDate = endDate;
+    }
+
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-	public String execute() throws Exception {
-		
-		Date sDate;
-		Date eDate;
-		int orgUnitId = Integer.parseInt(organisationUnitId);
-		
-		int deId = Integer.parseInt(dataElementId);
-		
-		int categoryId = Integer.parseInt(categoryOptionComboId);
-		int orgUnitGrpId = Integer.parseInt(organisationUnitGroupId);
-		SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
-		sDate = dateFormat.parse(startDate);
-		eDate = dateFormat.parse(endDate);
-		DataElement dataElement = dataElementService.getDataElement(deId);
-		OrganisationUnitGroup orgUnitGrp = organisationUnitGroupService.getOrganisationUnitGroup(orgUnitGrpId);
-		DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo(categoryId);
-		OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(orgUnitId);
-		
-		TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue
-						(organisationUnit, dataElement, optionCombo, orgUnitGrp, sDate, eDate);
-				
-				
-		tariffDataValueService.deleteTariffDataValue(tariffDataValue);
-		
-		return SUCCESS;
-	}
+    public String execute()
+        throws Exception
+    {
+        SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+        
+        Date sDate = dateFormat.parse( startDate );
+        Date eDate = dateFormat.parse( endDate );
+        
+        DataElement dataElement = dataElementService.getDataElement( dataElementId );
+        DataSet dataSet = dataSetService.getDataSet( dataSetId );
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+        TariffDataValue tariffDataValue = tariffDataValueService.getTariffDataValue( organisationUnit, dataElement, dataSet, sDate, eDate );
+
+        tariffDataValueService.deleteTariffDataValue( tariffDataValue );
+
+        return SUCCESS;
+    }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/GetDataElementforTariffAction.java	2013-12-21 05:25:33 +0000
@@ -15,103 +15,111 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class GetDataElementforTariffAction implements Action
+public class GetDataElementforTariffAction
+    implements Action
 {
-	private final static String TARIFF_SETTING_AUTHORITY = "TARIFF_SETTING_AUTHORITY";
-	
-	private final static String TARIFF_DATAELEMENT = "TARIFF_DATAELEMENT";
-	
-	// -------------------------------------------------------------------------
+    private final static String TARIFF_SETTING_AUTHORITY = "TARIFF_SETTING_AUTHORITY";
+
+    private final static String TARIFF_DATAELEMENT = "TARIFF_DATAELEMENT";
+
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	
-	private DataElementService dataElementService;
-	
-	public void setDataElementService(DataElementService dataElementService) {
-		this.dataElementService = dataElementService;
-	}
-	
-	private ConstantService constantService;
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private ConstantService constantService;
 
     public void setConstantService( ConstantService constantService )
     {
         this.constantService = constantService;
     }
-    
+
     private OrganisationUnitService organisationUnitService;
-    
-    public void setOrganisationUnitService(
-			OrganisationUnitService organisationUnitService) {
-		this.organisationUnitService = organisationUnitService;
-	}
-
-	// -------------------------------------------------------------------------
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
-	
-	private List<String> dataElementList = new ArrayList<String>();
-	
-    public List<String> getDataElementList() {
-		return dataElementList;
-	}
-
-	public void setDataElementList(List<String> dataElementList) {
-		this.dataElementList = dataElementList;
-	}
-
-	private String tariff_setting_authority;
-	
-	public String getTariff_setting_authority() {
-		return tariff_setting_authority;
-	}
-	
-	private List<String> levelOrgUnitIds = new ArrayList<String>();
-	
-	public List<String> getLevelOrgUnitIds() {
-		return levelOrgUnitIds;
-	}
-	
-	// -------------------------------------------------------------------------
+
+    private List<String> dataElementList = new ArrayList<String>();
+
+    public List<String> getDataElementList()
+    {
+        return dataElementList;
+    }
+
+    public void setDataElementList( List<String> dataElementList )
+    {
+        this.dataElementList = dataElementList;
+    }
+
+    private String tariff_setting_authority;
+
+    public String getTariff_setting_authority()
+    {
+        return tariff_setting_authority;
+    }
+
+    private List<String> levelOrgUnitIds = new ArrayList<String>();
+
+    public List<String> getLevelOrgUnitIds()
+    {
+        return levelOrgUnitIds;
+    }
+
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
-	public String execute()
+    public String execute()
     {
-		Constant tariff_authority = constantService.getConstantByName( TARIFF_SETTING_AUTHORITY );
-		Constant tariffDataElement = constantService.getConstantByName( TARIFF_DATAELEMENT );
-		if(tariff_authority == null)
-		{
-			tariff_setting_authority = "Level 3";
-			List<OrganisationUnit> allLevelOrg =new ArrayList<OrganisationUnit>(organisationUnitService.getOrganisationUnitsAtLevel(3)) ;
-			for(OrganisationUnit org : allLevelOrg)
-			{
-				levelOrgUnitIds.add("\""+org.getUid()+"\"");
-			}
-		}
-		else
-		{
-			
-			tariff_setting_authority = "Level "+(int)tariff_authority.getValue();
-			List<OrganisationUnit> allLevelOrg =new ArrayList<OrganisationUnit>(organisationUnitService.getOrganisationUnitsAtLevel((int)tariff_authority.getValue())) ;
-			for(OrganisationUnit org : allLevelOrg)
-			{
-				levelOrgUnitIds.add("\""+org.getUid()+"\"");
-			}
-		}
-    	List<DataElement> dataElements = new ArrayList<DataElement>(dataElementService.getAllDataElements());
-    	
-    	for(DataElement de : dataElements)
-    	{
-    		Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
-    		for ( AttributeValue attValue : attrValueSet )
-            {
-                if (!(dataElementList.contains("\""+de.getName()+"\"")) && attValue.getAttribute().getId() == tariffDataElement.getValue() )
+        Constant tariff_authority = constantService.getConstantByName( TARIFF_SETTING_AUTHORITY );
+        
+        Constant tariffDataElement = constantService.getConstantByName( TARIFF_DATAELEMENT );
+        if ( tariff_authority == null )
+        {
+            tariff_setting_authority = "Level 3";
+            List<OrganisationUnit> allLevelOrg = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 3 ) );
+            for ( OrganisationUnit org : allLevelOrg )
+            {
+                levelOrgUnitIds.add( "\"" + org.getUid() + "\"" );
+            }
+        }
+        else
+        {
+            tariff_setting_authority = "Level " + (int) tariff_authority.getValue();
+            List<OrganisationUnit> allLevelOrg = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( (int) tariff_authority.getValue() ) );
+            for ( OrganisationUnit org : allLevelOrg )
+            {
+                levelOrgUnitIds.add( "\"" + org.getUid() + "\"" );
+            }
+        }
+        
+        List<DataElement> dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
+
+        for ( DataElement de : dataElements )
+        {
+            Set<AttributeValue> attrValueSet = new HashSet<AttributeValue>( de.getAttributeValues() );
+            for ( AttributeValue attValue : attrValueSet )
+            {
+                if ( dataElementList != null && !( dataElementList.contains( "\"" + de.getName() + "\"" ) )
+                    && attValue.getAttribute().getId() == tariffDataElement.getValue() )
                 {
-                	dataElementList.add("\""+de.getName()+"\"");
+                    dataElementList.add( "\"" + de.getName() + "\"" );
                 }
-            }    		
-    	}
-    	
+            }
+        }
+
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/action/LoadTariffDetailsAction.java	2013-12-21 05:25:33 +0000
@@ -3,15 +3,14 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hisp.dhis.constant.Constant;
-import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.pbf.api.Lookup;
+import org.hisp.dhis.pbf.api.LookupService;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueService;
 import org.hisp.dhis.user.CurrentUserService;
@@ -20,124 +19,141 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class LoadTariffDetailsAction implements Action
+public class LoadTariffDetailsAction
+    implements Action
 {
-	private final static String PBF_ORGUNIT_GROUP_SET = "PBF_ORGUNIT_GROUP_SET";
-	
-	// -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	
-	private TariffDataValueService tariffDataValueService;
-
-	public void setTariffDataValueService(TariffDataValueService tariffDataValueService) 
-	{
-		this.tariffDataValueService = tariffDataValueService;
-	}
-	
-	private DataElementService dataElementService;
-	
-	public void setDataElementService(DataElementService dataElementService) {
-		this.dataElementService = dataElementService;
-	}
-
-	private OrganisationUnitService organisationUnitService;
-	
-	public void setOrganisationUnitService(
-			OrganisationUnitService organisationUnitService) {
-		this.organisationUnitService = organisationUnitService;
-	}
-	
-	private OrganisationUnitGroupService organisationUnitGroupService;
-	
-	public void setOrganisationUnitGroupService(
-			OrganisationUnitGroupService organisationUnitGroupService) {
-		this.organisationUnitGroupService = organisationUnitGroupService;
-	}
-	
-	private CurrentUserService currentUserService;
-	
-	public void setCurrentUserService(CurrentUserService currentUserService) {
-		this.currentUserService = currentUserService;
-	}
-
-	private ConstantService constantService;
-
-    public void setConstantService( ConstantService constantService )
-    {
-        this.constantService = constantService;
-    }
-    
-	// -------------------------------------------------------------------------
+
+    private TariffDataValueService tariffDataValueService;
+
+    public void setTariffDataValueService( TariffDataValueService tariffDataValueService )
+    {
+        this.tariffDataValueService = tariffDataValueService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private LookupService lookupService;
+    
+    public void setLookupService( LookupService lookupService )
+    {
+        this.lookupService = lookupService;
+    }
+
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    // -------------------------------------------------------------------------
     // Input / Output
     // -------------------------------------------------------------------------
-	private String dataElementName;
-	
-	 public void setDataElementName(String dataElementName) {
-			this.dataElementName = dataElementName;
-		}
-	private String orgUnitUid;
-	
-	public void setOrgUnitUid(String orgUnitUid) {
-		this.orgUnitUid = orgUnitUid;
-	}
-
-	private List<TariffDataValue> tariffList = new ArrayList<TariffDataValue>();
-	
-	public List<TariffDataValue> getTariffList() {
-		return tariffList;
-	}
-	
-	private String updateAuthority;
-	
-	public String getUpdateAuthority() {
-		return updateAuthority;
-	}
-
-	private DataElement selecteddataElement;
-	
-	public DataElement getSelecteddataElement() {
-		return selecteddataElement;
-	}
-
-	private List<OrganisationUnitGroup> orGroupList = new ArrayList<OrganisationUnitGroup>();
-	
-	public List<OrganisationUnitGroup> getOrGroupList() {
-		return orGroupList;
-	}
-	
-	// -------------------------------------------------------------------------
+    private String dataElementName;
+
+    public void setDataElementName( String dataElementName )
+    {
+        this.dataElementName = dataElementName;
+    }
+
+    private String orgUnitUid;
+
+    public void setOrgUnitUid( String orgUnitUid )
+    {
+        this.orgUnitUid = orgUnitUid;
+    }
+
+    private List<TariffDataValue> tariffList = new ArrayList<TariffDataValue>();
+
+    public List<TariffDataValue> getTariffList()
+    {
+        return tariffList;
+    }
+
+    private String updateAuthority;
+
+    public String getUpdateAuthority()
+    {
+        return updateAuthority;
+    }
+
+    private DataElement selecteddataElement;
+
+    public DataElement getSelecteddataElement()
+    {
+        return selecteddataElement;
+    }
+
+    private List<DataSet> dataSets = new ArrayList<DataSet>();
+    
+    public List<DataSet> getDataSets()
+    {
+        return dataSets;
+    }
+    
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-	
-	public String execute()
+
+    public String execute()
     {
-		Constant pbf_orgunitGrpSet = constantService.getConstantByName( PBF_ORGUNIT_GROUP_SET );
-		User curUser = currentUserService.getCurrentUser();
-		List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>( curUser.getUserCredentials()
-	            .getUserAuthorityGroups() );
-		for ( UserAuthorityGroup userAuthorityGroup : userAuthorityGroups )
+        User curUser = currentUserService.getCurrentUser();
+        
+        List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>( curUser.getUserCredentials().getUserAuthorityGroups() );
+        
+        for ( UserAuthorityGroup userAuthorityGroup : userAuthorityGroups )
         {
             userAuthorityGroup.getUserGroupAccesses();
             if ( userAuthorityGroup.getAuthorities().contains( "F_TARIFFDATAVALUE_UPDATE" ) )
-            {               
-            	updateAuthority = "Yes";
+            {
+                updateAuthority = "Yes";
             }
             else
-            {                
-            	updateAuthority = "No";
+            {
+                updateAuthority = "No";
             }
         }
-		
-		OrganisationUnitGroupSet organisationUnitGroupSet =  organisationUnitGroupService.getOrganisationUnitGroupSet((int)pbf_orgunitGrpSet.getValue());
-		orGroupList = new ArrayList<OrganisationUnitGroup>(organisationUnitGroupSet.getOrganisationUnitGroups()) ;
-		selecteddataElement = dataElementService.getDataElementByName(dataElementName);
-		List<String> orgUids = new ArrayList<String>();
-		orgUids.add(orgUnitUid);
-		List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitsByUid(orgUids);
-		
-		tariffList = new ArrayList<TariffDataValue>(tariffDataValueService.getTariffDataValues(organisationUnits.get(0), selecteddataElement)) ;
-		
+
+        selecteddataElement = dataElementService.getDataElementByName( dataElementName );
+
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitUid );
+
+        tariffList = new ArrayList<TariffDataValue>( tariffDataValueService.getTariffDataValues( organisationUnit, selecteddataElement ) );
+
+        List<Lookup> lookups = new ArrayList<Lookup>( lookupService.getAllLookupsByType( Lookup.DS_PBF_TYPE ) );
+        
+        for( Lookup lookup : lookups )
+        {
+            Integer dataSetId = Integer.parseInt( lookup.getValue() );
+            
+            DataSet dataSet = dataSetService.getDataSet( dataSetId );
+            
+            dataSets.add( dataSet );
+        }
+        
         return SUCCESS;
     }
 }
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/Lookup.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/Lookup.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/Lookup.java	2013-12-21 05:25:33 +0000
@@ -0,0 +1,81 @@
+package org.hisp.dhis.pbf.api;
+
+import org.hisp.dhis.common.BaseNameableObject;
+
+public class Lookup extends BaseNameableObject
+{
+    public static final String DS_PBF_TYPE = "DS_PBF_TYPE";
+    
+    private String type;
+    
+    private String value;
+    
+    // -------------------------------------------------------------------------
+    // Contructors
+    // -------------------------------------------------------------------------
+
+    public Lookup()
+    {
+        
+    }
+    
+    // -------------------------------------------------------------------------
+    // hashCode, equals
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int hashCode()
+    {
+        return name.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o == null )
+        {
+            return false;
+        }
+
+        if ( !(o instanceof Lookup) )
+        {
+            return false;
+        }
+
+        final Lookup other = (Lookup) o;
+
+        return name.equals( other.getName() );
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+
+    
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupService.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupService.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupService.java	2013-12-21 05:25:33 +0000
@@ -0,0 +1,27 @@
+package org.hisp.dhis.pbf.api;
+
+import java.util.Collection;
+
+public interface LookupService
+{
+    String ID = LookupService.class.getName();
+
+    // -------------------------------------------------------------------------
+    // Lookup
+    // -------------------------------------------------------------------------
+
+    int addLookup( Lookup lookup );
+
+    void updateLookup( Lookup lookup );
+
+    void deleteLookup( Lookup lookup );
+
+    Lookup getLookup( int id );
+
+    Lookup getLookupByName( String name );
+    
+    Collection<Lookup> getAllLookupsByType( String type );
+    
+    Collection<Lookup> getAllLookups();
+
+}

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupStore.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupStore.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/LookupStore.java	2013-12-21 05:25:33 +0000
@@ -0,0 +1,16 @@
+package org.hisp.dhis.pbf.api;
+
+import java.util.Collection;
+
+import org.hisp.dhis.common.GenericNameableObjectStore;
+
+public interface LookupStore extends GenericNameableObjectStore<Lookup>
+{
+    String ID = LookupStore.class.getName();
+    
+    // -------------------------------------------------------------------------
+    // Lookup
+    // -------------------------------------------------------------------------
+
+    Collection<Lookup> getAllLookupsByType( String type );
+}

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValue.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValue.java	2013-12-07 09:10:04 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValue.java	2013-12-21 05:25:33 +0000
@@ -4,9 +4,8 @@
 import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 
 public class TariffDataValue implements Serializable
 {
@@ -15,9 +14,7 @@
     
     private DataElement dataElement;
     
-    private DataElementCategoryOptionCombo optionCombo;
-    
-    private OrganisationUnitGroup organisationUnitGroup;
+    private DataSet dataSet;
     
     private Date startDate;
     
@@ -39,11 +36,11 @@
         
     }
     
-    public TariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataElementCategoryOptionCombo optionCombo, OrganisationUnitGroup organisationUnitGroup, Date startDate, Date endDate, Double value )
+    public TariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate, Double value )
     {
         this.organisationUnit = organisationUnit;
         this.dataElement = dataElement;
-        this.organisationUnitGroup = organisationUnitGroup;
+        this.dataSet = dataSet;
         this.startDate = startDate;
         this.endDate = endDate;
         this.value = value;
@@ -73,8 +70,7 @@
 
         final TariffDataValue other = (TariffDataValue) o;
 
-        return dataElement.equals( other.getDataElement() ) && optionCombo.equals( other.getOptionCombo() )
-            && organisationUnitGroup.equals( other.getOrganisationUnitGroup() ) && organisationUnit.equals( other.getOrganisationUnit() );
+        return dataElement.equals( other.getDataElement() ) && dataSet.equals( other.getDataSet() ) && organisationUnit.equals( other.getOrganisationUnit() );
     }
 
     @Override
@@ -83,8 +79,7 @@
         final int prime = 31;
         int result = 1;
 
-        result = result * prime + optionCombo.hashCode();
-        result = result * prime + organisationUnitGroup.hashCode();
+        result = result * prime + dataSet.hashCode();
         result = result * prime + dataElement.hashCode();
         result = result * prime + organisationUnit.hashCode();
 
@@ -115,26 +110,6 @@
         this.dataElement = dataElement;
     }
 
-    public DataElementCategoryOptionCombo getOptionCombo()
-    {
-        return optionCombo;
-    }
-
-    public void setOptionCombo( DataElementCategoryOptionCombo optionCombo )
-    {
-        this.optionCombo = optionCombo;
-    }
-
-    public OrganisationUnitGroup getOrganisationUnitGroup()
-    {
-        return organisationUnitGroup;
-    }
-
-    public void setOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
-    {
-        this.organisationUnitGroup = organisationUnitGroup;
-    }
-
     public Date getStartDate()
     {
         return startDate;
@@ -195,4 +170,14 @@
         this.comment = comment;
     }
 
+    public DataSet getDataSet()
+    {
+        return dataSet;
+    }
+
+    public void setDataSet( DataSet dataSet )
+    {
+        this.dataSet = dataSet;
+    }
+
 }

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueService.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueService.java	2013-12-07 09:10:04 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueService.java	2013-12-21 05:25:33 +0000
@@ -4,9 +4,8 @@
 import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 
 public interface TariffDataValueService
 {
@@ -18,13 +17,11 @@
     
     void deleteTariffDataValue( TariffDataValue tariffDataValue );
         
-    TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataElementCategoryOptionCombo optionCombo, OrganisationUnitGroup organisationUnitGroup, Date startDate, Date endDate );
-    
-    TariffDataValue getTariffDataValue( int organisationUnitId, int dataElementId, int categoryOptionComboId, int organisationUnitGroupId, Date startDate, Date endDate );
+    TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate );
     
     Collection<TariffDataValue> getAllTariffDataValues();
     
-    Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, OrganisationUnitGroup organisationUnitGroup );
+    Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataSet dataSet );
     
     Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataElement dataElement );
 }

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueStore.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueStore.java	2013-12-07 09:10:04 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/api/TariffDataValueStore.java	2013-12-21 05:25:33 +0000
@@ -4,9 +4,8 @@
 import java.util.Date;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 
 public interface TariffDataValueStore
 {
@@ -18,13 +17,11 @@
     
     void deleteTariffDataValue( TariffDataValue tariffDataValue );
         
-    TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataElementCategoryOptionCombo optionCombo, OrganisationUnitGroup organisationUnitGroup, Date startDate, Date endDate );
-    
-    TariffDataValue getTariffDataValue( int organisationUnitId, int dataElementId, int categoryOptionComboId, int organisationUnitGroupId, Date startDate, Date endDate );
+    TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate );
     
     Collection<TariffDataValue> getAllTariffDataValues();
     
-    Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, OrganisationUnitGroup organisationUnitGroup );
+    Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataSet dataSet );
     
     Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataElement dataElement );
 }

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultLookupService.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultLookupService.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultLookupService.java	2013-12-21 05:25:33 +0000
@@ -0,0 +1,68 @@
+package org.hisp.dhis.pbf.impl;
+
+import java.util.Collection;
+
+import org.hisp.dhis.pbf.api.Lookup;
+import org.hisp.dhis.pbf.api.LookupService;
+import org.hisp.dhis.pbf.api.LookupStore;
+
+public class DefaultLookupService implements LookupService
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private LookupStore lookupStore;
+
+    public void setLookupStore( LookupStore lookupStore )
+    {
+        this.lookupStore = lookupStore;
+    }
+
+    // -------------------------------------------------------------------------
+    // Lookup
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int addLookup( Lookup lookup )
+    {
+        return lookupStore.save( lookup );
+    }
+
+    @Override
+    public void updateLookup( Lookup lookup )
+    {
+        lookupStore.update( lookup );
+    }
+
+    @Override
+    public void deleteLookup( Lookup lookup )
+    {
+        lookupStore.delete( lookup );
+    }
+
+    @Override
+    public Lookup getLookup( int id )
+    {
+        return lookupStore.get( id );
+    }
+
+    @Override
+    public Lookup getLookupByName( String name )
+    {
+        return lookupStore.getByName( name );
+    }
+
+    @Override
+    public Collection<Lookup> getAllLookupsByType( String type )
+    {
+        return lookupStore.getAllLookupsByType( type );
+    }
+
+    @Override
+    public Collection<Lookup> getAllLookups()
+    {
+        return lookupStore.getAll( );
+    }
+    
+}

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultTariffDataValueService.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultTariffDataValueService.java	2013-12-10 12:41:41 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/DefaultTariffDataValueService.java	2013-12-21 05:25:33 +0000
@@ -3,11 +3,9 @@
 import java.util.Collection;
 import java.util.Date;
 
-import org.hibernate.Session;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueService;
 import org.hisp.dhis.pbf.api.TariffDataValueStore;
@@ -50,18 +48,9 @@
     }
 
     @Override
-    public TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement,
-        DataElementCategoryOptionCombo optionCombo, OrganisationUnitGroup organisationUnitGroup, Date startDate,
-        Date endDate )
-    {
-        return tariffDataValueStore.getTariffDataValue( organisationUnit, dataElement, optionCombo, organisationUnitGroup, startDate, endDate );
-    }
-
-    @Override
-    public TariffDataValue getTariffDataValue( int organisationUnitId, int dataElementId, int categoryOptionComboId,
-        int organisationUnitGroupId, Date startDate, Date endDate )
-    {
-        return tariffDataValueStore.getTariffDataValue( organisationUnitId, dataElementId, categoryOptionComboId, organisationUnitGroupId, startDate, endDate );
+    public TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate )
+    {
+        return tariffDataValueStore.getTariffDataValue( organisationUnit, dataElement, dataSet, startDate, endDate );
     }
 
     @Override
@@ -71,9 +60,9 @@
     }
 
     @Override
-    public Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, OrganisationUnitGroup organisationUnitGroup )
+    public Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataSet dataSet )
     {
-        return tariffDataValueStore.getTariffDataValues( organisationUnit, organisationUnitGroup );
+        return tariffDataValueStore.getTariffDataValues( organisationUnit, dataSet );
     }
 
     @Override

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateLookupStore.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateLookupStore.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateLookupStore.java	2013-12-21 05:25:33 +0000
@@ -0,0 +1,24 @@
+package org.hisp.dhis.pbf.impl;
+
+import java.util.Collection;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.pbf.api.Lookup;
+import org.hisp.dhis.pbf.api.LookupStore;
+
+public class HibernateLookupStore extends HibernateIdentifiableObjectStore<Lookup> implements LookupStore
+{
+
+    public Collection<Lookup> getAllLookupsByType( String type )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( Lookup.class );
+        criteria.add( Restrictions.eq( "type", type ) );
+
+        return criteria.list();
+    }
+}

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateTariffDataValueStore.java'
--- local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateTariffDataValueStore.java	2013-12-10 12:41:41 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/java/org/hisp/dhis/pbf/impl/HibernateTariffDataValueStore.java	2013-12-21 05:25:33 +0000
@@ -8,16 +8,10 @@
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.pbf.api.TariffDataValue;
 import org.hisp.dhis.pbf.api.TariffDataValueStore;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.system.objectmapper.DataValueRowMapper;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
 
 public class HibernateTariffDataValueStore implements TariffDataValueStore
 {
@@ -36,7 +30,6 @@
     // TariffDataValue
     // -------------------------------------------------------------------------
     
-    
     @Override
     public void addTariffDataValue( TariffDataValue tariffDataValue )
     {
@@ -62,17 +55,14 @@
     }
 
     @Override
-    public TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement,
-        DataElementCategoryOptionCombo optionCombo, OrganisationUnitGroup organisationUnitGroup, Date startDate,
-        Date endDate )
+    public TariffDataValue getTariffDataValue( OrganisationUnit organisationUnit, DataElement dataElement, DataSet dataSet, Date startDate, Date endDate )
     {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( TariffDataValue.class );
         criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
         criteria.add( Restrictions.eq( "dataElement", dataElement ) );        
-        criteria.add( Restrictions.eq( "optionCombo", optionCombo ) );
-        criteria.add( Restrictions.eq( "organisationUnitGroup", organisationUnitGroup ) );
+        criteria.add( Restrictions.eq( "dataSet", dataSet ) );
         criteria.add( Restrictions.eq( "startDate", startDate ) );
         criteria.add( Restrictions.eq( "endDate", endDate ) );
 
@@ -80,16 +70,6 @@
     }
 
     @Override
-    public TariffDataValue getTariffDataValue( int organisationUnitId, int dataElementId, int categoryOptionComboId,
-        int organisationUnitGroupId, Date startDate, Date endDate )
-    {
-        /**
-         * TODO
-         */
-       return null;
-    }
-
-    @Override
     public Collection<TariffDataValue> getAllTariffDataValues()
     {
         Session session = sessionFactory.getCurrentSession();
@@ -100,14 +80,13 @@
     }
 
     @Override
-    public Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit,
-        OrganisationUnitGroup organisationUnitGroup )
+    public Collection<TariffDataValue> getTariffDataValues( OrganisationUnit organisationUnit, DataSet dataSet )
     {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( TariffDataValue.class );
         criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
-        criteria.add( Restrictions.eq( "organisationUnitGroup", organisationUnitGroup ) );
+        criteria.add( Restrictions.eq( "organisationUnitGroup", dataSet ) );
 
         return criteria.list();
     }

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/META-INF/dhis/beans.xml	2013-12-21 05:25:33 +0000
@@ -13,7 +13,15 @@
     <bean id="org.hisp.dhis.pbf.api.TariffDataValueService" class="org.hisp.dhis.pbf.impl.DefaultTariffDataValueService">
         <property name="tariffDataValueStore" ref="org.hisp.dhis.pbf.api.TariffDataValueStore" />
     </bean>
+
+    <bean id="org.hisp.dhis.pbf.api.LookupStore" class="org.hisp.dhis.pbf.impl.HibernateLookupStore">
+        <property name="clazz" value="org.hisp.dhis.pbf.api.Lookup"/>
+        <property name="sessionFactory" ref="sessionFactory" />
+    </bean>
     
+    <bean id="org.hisp.dhis.pbf.api.LookupService" class="org.hisp.dhis.pbf.impl.DefaultLookupService">
+        <property name="lookupStore" ref="org.hisp.dhis.pbf.api.LookupStore" />
+    </bean>
     
 	<!-- Home page -->
 	<bean id="org.hisp.dhis.pbf.action.NoAction" class="org.hisp.dhis.pbf.action.NoAction" scope="prototype">
@@ -31,9 +39,9 @@
 		<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />	
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-		<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />	
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+		<property name="lookupService" ref="org.hisp.dhis.pbf.api.LookupService" />
     </bean>
     
     <!-- Add Tariff -->
@@ -41,17 +49,16 @@
 		<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     </bean>
+    
     <!-- Delete Tariff -->
     <bean id="org.hisp.dhis.pbf.action.DeleteTariffDataAction" class="org.hisp.dhis.pbf.action.DeleteTariffDataAction" scope="prototype">
 		<property name="tariffDataValueService" ref="org.hisp.dhis.pbf.api.TariffDataValueService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     </bean>
     
 </beans>
\ No newline at end of file

=== added file 'local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/Lookup.hbm.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/Lookup.hbm.xml	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/Lookup.hbm.xml	2013-12-21 05:25:33 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+  >
+
+<hibernate-mapping>
+
+    <class name="org.hisp.dhis.pbf.api.Lookup" table="lookup">
+
+	   <id name="id" column="lookupid">
+	      <generator class="native" />
+	    </id>
+	    
+	    &identifiableProperties;
+	
+	    <property name="name" column="name" not-null="true" unique="true" length="230" />
+	
+	    <property name="description" type="text" />
+	     
+	    <property name="type" column="type" length="230" />   
+	         
+	    <property name="value" column="value" type="text" />
+
+    </class>
+    
+</hibernate-mapping>

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/TariffDataValue.hbm.xml'
--- local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/TariffDataValue.hbm.xml	2013-12-07 09:10:04 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/resources/org/hisp/dhis/pbf/hibernate/TariffDataValue.hbm.xml	2013-12-21 05:25:33 +0000
@@ -8,9 +8,8 @@
 
     <composite-id>
       <key-many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid" foreign-key="fk_tariffdatavalue_organisationunitid" />      
-      <key-many-to-one name="organisationUnitGroup" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" column="orgunitgroupid" foreign-key="fk_datavalue_organisationunitgroupid" />
+      <key-many-to-one name="dataSet" class="org.hisp.dhis.dataset.DataSet" column="datasetid" foreign-key="fk_tariffdatavalue_datasetid" />
       <key-many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid" foreign-key="fk_tariffdatavalue_dataelementid" />
-      <key-many-to-one name="optionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="categoryoptioncomboid" foreign-key="fk_tariffdatavalue_categoryoptioncomboid" />
       <key-property name="startDate" column="startdate" />
       <key-property name="endDate" column="enddate" />
     </composite-id>

=== modified file 'local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm'
--- local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm	2013-12-11 12:08:01 +0000
+++ local/in/dhis-web-maintenance-pbf/src/main/webapp/dhis-web-maintenance-pbf/loadTariffData.vm	2013-12-21 05:25:33 +0000
@@ -79,25 +79,25 @@
 			$( "#addTariff" ).dialog( "close" );
 	    }
 });
-function deleteTariffDataValue(organisationUnitId,dataElementId,optionComboId,organisationUnitGroupId,startDate,endDate)
-{
-				var dataValue = {
-        		        		'organisationUnitId' : organisationUnitId ,
-								'dataElementId' : dataElementId,
-								'categoryOptionComboId' : optionComboId,
-								'organisationUnitGroupId' : organisationUnitGroupId,
-								'startDate' : startDate,
-								'endDate' : endDate
-        		    			};
-								
-								jQuery.ajax( {
-                                url: 'deleteTariffData.action', 
-								data: dataValue,
-                                dataType: 'json',
-								success: handleSuccess,
-                                error: handleError
-                              } );
-		function handleSuccess( json )
+
+	function deleteTariffDataValue( organisationUnitId, dataElementId, dataSetId, startDate, endDate)
+	{
+		var dataValue = {
+		        		'organisationUnitId' : organisationUnitId ,
+						'dataElementId' : dataElementId,								
+						'dataSetId' : dataSetId,
+						'startDate' : startDate,
+						'endDate' : endDate
+		    			};
+									
+		jQuery.ajax( {
+	                url: 'deleteTariffData.action', 
+					data: dataValue,
+	                dataType: 'json',
+					success: handleSuccess,
+	                error: handleError
+	              } );
+	    function handleSuccess( json )
 	    {
 			getTariffData();			
 	    }
@@ -105,26 +105,29 @@
 	    {
 			getTariffData();			
 	    }
-}
-function editTariffDataValue ( organisationUnitId,dataElementId,optionComboId,organisationUnitGroupId,startDate,endDate,value )
-{
-	$( "#addTariff" ).attr('selected','Edit Tariff')
-	$('#pbfType option[value='+organisationUnitGroupId+']').attr('selected','selected');
-	$('#pbfType').attr('disabled','disabled');
-	$('#tariff').val(value);
-	$('#startDate').val(startDate);
-	$('#startDate').attr('disabled','disabled');
-	$('#endDate').val(endDate);
-	$('#endDate').attr('disabled','disabled');
-	
-	$( "#addTariff" ).dialog( "open" );
-}
+	}
+
+	function editTariffDataValue( organisationUnitId, dataElementId, dataSetId, startDate, endDate, value )
+	{
+		$( "#addTariff" ).attr('selected','Edit Tariff')
+		$('#pbfType option[value='+organisationUnitGroupId+']').attr('selected','selected');
+		$('#pbfType').attr('disabled','disabled');
+		$('#tariff').val(value);
+		$('#startDate').val(startDate);
+		$('#startDate').attr('disabled','disabled');
+		$('#endDate').val(endDate);
+		$('#endDate').attr('disabled','disabled');
+		
+		$( "#addTariff" ).dialog( "open" );
+	}
 </script>
+
 <div style="width:100%">
 	<input type="button" value="Add New Tariff" style="float:right;" id="openAddTariff"/>
 </div>
 <br/><br/>
 <input type="hidden" id="dataElementId" name="dataElementId" value="$!selecteddataElement.id"/>
+
 <table style="width:100%" class="mainPageTable">
 	<thead >
 		<tr >
@@ -132,39 +135,39 @@
 			<th >Tariff</th>
 			<th >Start Date</th>
 			<th >End Date</th>
-			#if($updateAuthority == 'Yes')
+			#if( $updateAuthority == 'Yes' )
 				<th >Operations</th>
 			#end
         </tr>
 	</thead>
 	<tbody id="list">
 		#set( $mark = false )
-		#foreach($tariff in $tariffList )
+		#foreach( $tariff in $tariffList )
 			#if( $mark )
-    						#set( $mark = false )
-    					#else
-    						#set( $mark = true )
-    					#end
-		<tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8"  #end>
-			<td >$!tariff.organisationUnitGroup.name</td>
-			<td >$!tariff.value</td>
-			<td >$!tariff.startDate</td>
-			<td >$!tariff.endDate</td>
+                #set( $mark = false )
+			#else
+				#set( $mark = true )
+			#end
+            <tr #if( $mark ) bgcolor = "#FFFFFF" #else bgcolor="#E0ECF8"  #end>
+				<td >$!tariff.dataSet.name</td>
+				<td >$!tariff.value</td>
+				<td >$!tariff.startDate</td>
+				<td >$!tariff.endDate</td>
 			#if($updateAuthority == 'Yes')
-            <td>
-				<a href="javascript:deleteTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate')">
-					<img src="images/delete.png" width="17px"/>
-				</a>
-				<a href="javascript:editTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.optionCombo.id','$tariff.organisationUnitGroup.id','$tariff.startDate','$tariff.endDate','$tariff.value')">
-					<img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/>
-				</a>
-				
-			</td>
+	            <td>
+					<a href="javascript:deleteTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.dataSet.id','$tariff.startDate','$tariff.endDate')">
+						<img src="images/delete.png" width="17px"/>
+					</a>
+					<a href="javascript:editTariffDataValue('$tariff.organisationUnit.id','$tariff.dataElement.id','$tariff.dataSet.id','$tariff.startDate','$tariff.endDate','$tariff.value')">
+						<img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/>
+					</a>				
+				</td>
 			#end
         </tr>
 		#end
     </tbody>
-</table>
+</table>
+
 <div id="addTariff" title="Add New Tariff">
 	<table style="width:100%;table-layout:fixed;">
 		<tr >
@@ -172,8 +175,8 @@
 			<td style="width:60%;">
 				<select id="pbfType" style="width:100%;">
 					<option value="-1">Select PBF Type</option>
-					#foreach($orGrp in $orGroupList)
-						<option value="$orGrp.id">$orGrp.name</option>
+					#foreach( $dataSet in $dataSets )
+						<option value="$dataSet.id">$dataSet.name</option>
 					#end
                 </select>
 			</td>