try{
InitialContext ic = CVUtility.getInitialContext();
EntityLocalHome home = (EntityLocalHome)ic.lookup("local/Entity");
EntityLocal remote = home.findByPrimaryKey(new EntityPK(entityId,this.dataSource));
EntityVO ev = remote.getEntityVOWithBasicReferences();
HashMap hmDetails=new HashMap();
hmDetails.put("title",ev.getName());
hmDetails.put("owner",new Integer(ev.getOwner()));
hmDetails.put("module",new Integer(1));
hmDetails.put("recordtype",new Integer(1));
InitialContext ctxl=CVUtility.getInitialContext();
CvAtticLocalHome cahome=(CvAtticLocalHome)ctxl.lookup("local/CvAttic");
CvAtticLocal caremote =cahome.create();
caremote.setDataSource(this.dataSource);
int transactionID=caremote.getAtticTransactionID(individualID,Constants.CV_GARBAGE,hmDetails);
HashMap hmentity=new HashMap();
hmentity.put("EntityID",(new Integer(ev.getContactID())).toString());
caremote.dumpData(individualID,transactionID,"entity",hmentity);
AddressVO adv = ev.getPrimaryAddress();
if (adv != null)
{
HashMap hmaddr=new HashMap();
hmaddr.put("AddressID",(new Integer(adv.getAddressID())).toString());
caremote.dumpData(individualID,transactionID,"address",hmaddr);
}
Vector vec = ev.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(individualID, transactionID, cftablename, hmcfv);
}
}
Vector mocvec = ev.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(1)).toString());
hmmocr.put("ContactID",(new Integer(entityId)).toString());
caremote.dumpData(individualID,transactionID,"mocrelate",hmmocr);
HashMap hmmoc=new HashMap();
hmmoc.put("methodofcontact",(new Integer(mocv.getMocID())).toString());
caremote.dumpData(individualID,transactionID,"methodofcontact",hmmoc);
}
}
ctx.getUserTransaction().begin();
remote.remove();
ctx.getUserTransaction().commit();
HashMap historyInfo = new HashMap();
historyInfo.put("recordID",new Integer(entityId));
historyInfo.put("recordTypeID", new Integer(Constants.EntityModuleID));
historyInfo.put("operation", new Integer(Constants.DELETED));
historyInfo.put("individualID", new Integer(individualID));
historyInfo.put("referenceActivityID", new Integer(0));
historyInfo.put("recordName", ev.getName());
CVUtility.addHistoryRecord(historyInfo , this.dataSource);
}catch(CreateException ce){
throw new EJBException(ce);
}catch(NamingException re){
throw new EJBException(re);