package gov.nih.nci.calab.service.workflow;

import gov.nih.nci.calab.db.DataAccessProxy;
import gov.nih.nci.calab.db.IDataAccess;
import gov.nih.nci.calab.domain.Aliquot;
import gov.nih.nci.calab.domain.DataStatus;
import gov.nih.nci.calab.domain.LabFile;
import gov.nih.nci.calab.service.util.CalabConstants;
import gov.nih.nci.calab.service.util.StringUtils;

/**
 * Generalizes Mask functionality for masking Aliquot, File, etc.  
 * @author doswellj
 * @param strType Type of Mask (e.g., aliquot, file, run, etc.)
 * @param strId	  The id associated to the type
 * @param strDescription The mask description associated to the mask type and Id. 
 *
 */
public class MaskService 
{
    
	//This functionality is pending the completed Object Model
	public void setMask(String strType, String strId, String strDescription) throws Exception
    {
        IDataAccess ida = (new DataAccessProxy()).getInstance(IDataAccess.HIBERNATE);

		try {
	        ida.open();
	        
	        if (strType.equals("aliquot"))
	        {
	            //TODO Find Aliquot record based on the strID
//				List aliquots = ida.search("from Aliquot aliquot where aliquot.name='" + strId + "'");
				Aliquot aliquot = (Aliquot)ida.load(Aliquot.class, StringUtils.convertToLong(strId));
				DataStatus maskStatus = new DataStatus();
				maskStatus.setReason(strDescription);
				maskStatus.setStatus(CalabConstants.MASK_STATUS);
				ida.createObject(maskStatus);
				
				aliquot.setDataStatus(maskStatus);
				ida.store(aliquot); 	        	
	        }
	        if (strType.equals("file"))
	        {
				LabFile file = (LabFile)ida.load(LabFile.class, StringUtils.convertToLong(strId));
				DataStatus maskStatus = new DataStatus();
				maskStatus.setReason(strDescription);
				maskStatus.setStatus(CalabConstants.MASK_STATUS);
				ida.createObject(maskStatus);
				
				file.setDataStatus(maskStatus);
				ida.store(file); 	        	
	        }
			ida.close();
		}catch (Exception e) {
			
			ida.rollback();
			ida.close();
			
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
        	
        	 
    }
    
}

@@ -1920,32 +1920,16 @@
       %7D%0A
-%09%09%09ida.close();%0A
 %09%09%7Dcatch
@@ -1944,17 +1944,16 @@
 ion e) %7B
-%0A
 %09%09%09%0A%09%09%09i
@@ -1971,28 +1971,8 @@
 ();%0A
-%09%09%09ida.close();%0A%09%09%09%0A
 %09%09%09e
@@ -2041,16 +2041,49 @@
 ());%0A%09%09%7D
+ finally %7B%0A%09%09%09ida.close();%0A%09%09%7D%0A%09%09
 %0A       

Add finally{}