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

import gov.nih.nci.calab.dto.administration.ContainerBean;
import gov.nih.nci.calab.dto.administration.ContainerInfoBean;
import gov.nih.nci.calab.dto.administration.SampleBean;

import java.util.ArrayList;
import java.util.List;

/* CVS $Id: ManageSampleService.java,v 1.9 2006-04-04 15:32:54 pansu Exp $ */
public class ManageSampleService {
 
  public List<String> getAllSampleSOPs() {
	  List<String> sampleSOPs=new ArrayList();
	  sampleSOPs.add("Original");
	  sampleSOPs.add("Testing");
	  return sampleSOPs;
  }

  /**
   * 
   * @return auto-generated default value for sample ID prefix
   */
  public String getDefaultSampleIdPrefix() {
	  //tmp code to be replaced
	  String sampleIdPrefix="NCL-6";
	  return sampleIdPrefix;
  }
 
  /**
   * 
   * @param sampleIdPrefix
   * @param lotId
   * @return sampleId from sampleId prefix and lotId
   */
  public String getSampleId(String sampleIdPrefix, String lotId) {
	  return sampleIdPrefix+"-"+lotId;
  }
  
  /**
   * 
   * @return the default lot Id
   */
  public String getDefaultLotId() {
	  String lotId="N/A";
	  return lotId;
  }
  
  /**
   * Saves the sample into the database
   * @throws Exception
   */
  public void saveSample(SampleBean sample, ContainerBean[] containers, String comments) throws Exception{
	  //TODO fill in details to save the sample and associated containers.
  }
}

@@ -40,24 +40,151 @@
 istration;%0A%0A
+import gov.nih.nci.calab.db.DataAccessProxy;%0Aimport gov.nih.nci.calab.db.IDataAccess;%0Aimport gov.nih.nci.calab.domain.Aliquot;%0A
 import gov.n
@@ -378,16 +378,43 @@
 ayList;%0A
+import java.util.Iterator;%0A
 import j
@@ -474,9 +474,10 @@
 v 1.
-9
+10
  200
@@ -488,22 +488,23 @@
 -04 
-15:32:54 pansu
+20:02:49 zengje
  Exp
@@ -875,24 +875,26 @@
 replaced%0A%09  
+  
 String sampl
@@ -908,17 +908,613 @@
 ix=%22
-NCL-6%22;%0A%09
+hardcode-6%22;%0A%09%09try %7B%0A%09%09%09IDataAccess ida = (new DataAccessProxy()).getInstance(IDataAccess.TOOLKITAPI);%0A%09%09%09ida.open();%0A%09%09%09String hqlString = %22select max(sample.sampleSequenceId) from Sample sample%22;%0A%09%09%09List results = ida.query(hqlString, Aliquot.class.getName());%0A%09%09%09for (Iterator iter=results.iterator(); iter.hasNext();)%0A%09%09%09%7B%0A%09%09%09%09Object obj = iter.next();%0A%09%09%09%09System.out.println(%22ManageSampleService.getDefaultSampleIdPrefix(): return object type = %22%0A%09%09%09%09%09%09%09%09%09+ obj.getClass().getName());%0A%09%09%09%09sampleIdPrefix = %22NCL-%22 + obj;%0A%09%09%09%7D%0A%09%09%09ida.close();%09%09%09%0A%09%09%7Dcatch (Exception e)%7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09  
   re

Update getDefaultSampleIdPrefix()