try{
InitialContext ic = CVUtility.getInitialContext();
IndividualLocalHome home = (IndividualLocalHome)ic.lookup("local/Individual");
IndividualLocal remote = home.findByPrimaryKey(new IndividualPK(individualId,this.dataSource));
IndividualVO indVO = remote.getIndividualVOWithBasicReferences();
HashMap hmDetails=new HashMap();
hmDetails.put("title",indVO.getFirstName() + " " + indVO.getLastName());
hmDetails.put("owner",new Integer(indVO.getOwner()));
hmDetails.put("module",new Integer(1));
hmDetails.put("recordtype",new Integer(2));
InitialContext ctxl=CVUtility.getInitialContext();
CvAtticLocalHome cahome=(CvAtticLocalHome)ctxl.lookup("local/CvAttic");
CvAtticLocal caremote =cahome.create();
caremote.setDataSource(this.dataSource);
int transactionID=caremote.getAtticTransactionID(indID,Constants.CV_GARBAGE,hmDetails);
HashMap hmind=new HashMap();
hmind.put("IndividualID",(new Integer(indVO.getContactID())).toString());
caremote.dumpData(indID,transactionID,"individual",hmind);
AddressVO adv = indVO.getPrimaryAddress();
if (adv != null)
{
HashMap hmaddr=new HashMap();
hmaddr.put("AddressID",(new Integer(adv.getAddressID())).toString());
caremote.dumpData(indID,transactionID,"address",hmaddr);
HashMap addressRelateHashMap = new HashMap();
addressRelateHashMap.put("Address",(new Integer(adv.getAddressID())).toString());
caremote.dumpData(indID,transactionID,"addressrelate", addressRelateHashMap);
}
Vector mocvec = indVO.getMOC();
if (mocvec != null)
{
Iterator it = mocvec.iterator();
while (it.hasNext())
{
MethodOfContactVO mocv = (MethodOfContactVO)it.next();
HashMap hmmocr=new HashMap();
hmmocr.put("MOCID",(new Integer(mocv.getMocID())).toString());
hmmocr.put("ContactType",(new Integer(2)).toString());
hmmocr.put("ContactID",(new Integer(individualId)).toString());
caremote.dumpData(indID, transactionID, "mocrelate", hmmocr);
HashMap hmmoc=new HashMap();
hmmoc.put("MOCID",(new Integer(mocv.getMocID())).toString());
hmmoc.put("MOCType", Integer.toString(mocv.getMocType()));
caremote.dumpData(indID, transactionID, "methodofcontact", hmmoc);
}
}
Vector vec = indVO.getCustomField();
if (vec != null)
{
Iterator it = vec.iterator();
while (it.hasNext())
{
CustomFieldVO cfv = (CustomFieldVO)it.next();
String cftablename = "customfieldscalar";
if (cfv.getFieldType() == CustomFieldVO.MULTIPLE)
{
cftablename = "customfieldmultiple";
}
HashMap hmcfv=new HashMap();
hmcfv.put("CustomFieldID",(new Integer(cfv.getFieldID())).toString());
caremote.dumpData(indID,transactionID,cftablename,hmcfv);
}
}
remote.setOperationIndividualId(individualId);
ctx.getUserTransaction().begin();
remote.remove();
ctx.getUserTransaction().commit();
HashMap historyInfo = new HashMap();
historyInfo.put("recordID",new Integer(individualId));
historyInfo.put("recordTypeID", new Integer(Constants.IndividualModuleID));
historyInfo.put("operation", new Integer(Constants.DELETED));
historyInfo.put("individualID", new Integer(indID));
historyInfo.put("referenceActivityID", new Integer(0));
historyInfo.put("recordName", indVO.getFirstName()+ " "+ indVO.getMiddleName()+ " " + indVO.getLastName());
CVUtility.addHistoryRecord(historyInfo , this.dataSource);
}catch(FinderException fe){
System.out.println("[Exception][ContactFacadeEJB.deleteIndividual] Exception Thrown: "+fe);
}catch(RemoveException fe){