if (hm.get("RecordID") != null) {
linkId = ((Number)hm.get("RecordID")).intValue();
switch (recordType) {
case ActivityVO.ACTIVITY_LINK_ENTITY : // entity
try {
ContactHelperLocalHome home = (ContactHelperLocalHome)ic.lookup("local/ContactHelper");
ContactHelperLocal remote = home.create();
remote.setDataSource(this.dataSource);
String entityName = remote.getEntityName(linkId);
app.setEntityName(entityName);
app.setEntityID(linkId);
} catch (Exception e) {
logger.error("[Exception] ActivityHelperEJB.getActivityLink: ", e);
}
break;
case ActivityVO.ACTIVITY_LINK_INDIVIDUAL : // Individual
try {
ContactHelperLocalHome home = (ContactHelperLocalHome)ic.lookup("local/ContactHelper");
ContactHelperLocal remote = home.create();
remote.setDataSource(this.dataSource);
String individualName = remote.getIndividualName(linkId);
app.setIndividualName(individualName);
Collection contacts = remote.getPrimaryMOCForContact(0, linkId, 2);
app.setIndividualPrimaryContact("");
if(contacts.size() > 0){
MethodOfContactVO mc = (MethodOfContactVO) contacts.toArray()[0];
app.setIndividualPrimaryContact(mc.getContent());
}
app.setIndividualID(linkId);
} catch (Exception e) {
logger.error("[Exception] ActivityHelperEJB.getActivityLink: ", e);
}
break;
case ActivityVO.ACTIVITY_LINK_FILE : // File
try {
CvFileLocalHome fh = (CvFileLocalHome)ic.lookup("local/CvFile");
CvFileLocal fr = fh.create();
fr.setDataSource(this.dataSource);
CvFileVO flvo = fr.getFileBasic(gbUserId, linkId);
app.setAttachmentVec(flvo);
} catch (Exception e) {
logger.error("[Exception] ActivityHelperEJB.getActivityLink: ", e);
}
break;
case ActivityVO.ACTIVITY_LINK_OPPORTUNITY : // Opportunity - from module table
try {
OpportunityLocalHome home = (OpportunityLocalHome)ic.lookup("local/Opportunity");
OpportunityLocal local = home.create();
local.setDataSource(this.dataSource);
String opportunityName = local.getOpportunityName(linkId);
app.setRelatedFieldID(linkId);
app.setRelatedFieldValue(opportunityName);
app.setRelatedTypeID(ActivityVO.ACTIVITY_LINK_OPPORTUNITY);
app.setRelatedTypeValue("Opportunity");
} catch (Exception e) {
logger.error("[Exception] ActivityHelperEJB.getActivityLink: ", e);
}
break;
case ActivityVO.ACTIVITY_LINK_PROJECT : // Projects - from module table
try {
ProjectLocalHome home = (ProjectLocalHome)ic.lookup("local/Project");
ProjectLocal remote = (ProjectLocal)home.create();
remote.setDataSource(this.dataSource);
String projectTitle = remote.getProjectName(linkId);
app.setRelatedFieldID(linkId);
app.setRelatedFieldValue(projectTitle);
app.setRelatedTypeID(ActivityVO.ACTIVITY_LINK_PROJECT);