Exemplo n.º 1
0
 /**
  * Gets the entity.
  *
  * @return the SUCCESS result
  */
 public String get() throws Exception {
   if (this.getId() != null) {
     UserUtil.permissionCheck("view_call");
     call = baseService.getEntityById(Call.class, this.getId());
     UserUtil.scopeCheck(call, "scope_call");
     CallStatus status = call.getStatus();
     if (status != null) {
       statusID = status.getId();
     }
     CallDirection direction = call.getDirection();
     if (direction != null) {
       directionID = direction.getId();
     }
     ReminderOption reminderOptionEmail = call.getReminder_option_email();
     if (reminderOptionEmail != null) {
       reminderOptionEmailID = reminderOptionEmail.getId();
     }
     EmailTemplate reminderTemplate = call.getReminder_template();
     if (reminderTemplate != null) {
       reminderTemplateID = reminderTemplate.getId();
     }
     User assignedTo = call.getAssigned_to();
     if (assignedTo != null) {
       this.setAssignedToID(assignedTo.getId());
       this.setAssignedToText(assignedTo.getName());
     }
     Date start_date = call.getStart_date();
     SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT);
     if (start_date != null) {
       startDate = dateFormat.format(start_date);
     }
     String relatedObject = call.getRelated_object();
     Integer relatedRecord = call.getRelated_record();
     if (relatedRecord != null) {
       setRelatedRecord(relatedObject, relatedRecord);
     }
     this.getBaseInfo(call, Call.class.getSimpleName(), Constant.CRM_NAMESPACE);
   } else {
     this.initBaseInfo();
     if (!CommonUtil.isNullOrEmpty(this.getRelationKey())) {
       call.setRelated_object(this.getRelationKey());
       setRelatedRecord(this.getRelationKey(), Integer.parseInt(this.getRelationValue()));
     }
   }
   return SUCCESS;
 }
Exemplo n.º 2
0
  public String selectTemplate() throws Exception {
    UserUtil.permissionCheck("update_call");
    call = baseService.getEntityById(Call.class, this.getId());
    Date start_date = call.getStart_date();
    SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT);
    startDate = "";
    if (start_date != null) {
      startDate = dateFormat.format(start_date);
    }

    EmailTemplate emailTemplte =
        emailTemplateService.getEntityById(EmailTemplate.class, emailTemplateID);
    this.setText_only(emailTemplte.isText_only());
    this.setSubject(CommonUtil.fromNullToEmpty(emailTemplte.getSubject()));
    String content = "";
    if (this.isText_only()) {
      content = emailTemplte.getText_body();
    } else {
      content = emailTemplte.getHtml_body();
    }
    // Replaces the variable in the body
    if (content != null) {
      content =
          content.replaceAll("\\$call.subject", CommonUtil.fromNullToEmpty(call.getSubject()));
      content = content.replaceAll("\\$call.start_date", startDate);
    }
    if (this.isText_only()) {
      this.setText_body(content);
    } else {
      this.setHtml_body(content);
    }
    // Gets email template list
    String hql =
        "select new EmailTemplate(id,name) from EmailTemplate where type = 'callInvite' order by created_on";
    emailTemplates = emailTemplateService.findByHQL(hql);
    return SUCCESS;
  }
Exemplo n.º 3
0
  private Collection<ChangeLog> changeLog(Call originalCall, Call call) {
    Collection<ChangeLog> changeLogs = null;
    if (originalCall != null) {
      ActionContext context = ActionContext.getContext();
      Map<String, Object> session = context.getSession();
      String entityName = Call.class.getSimpleName();
      Integer recordID = call.getId();
      User loginUser = (User) session.get(AuthenticationSuccessListener.LOGIN_USER);
      changeLogs = new ArrayList<ChangeLog>();

      String oldSubject = CommonUtil.fromNullToEmpty(originalCall.getSubject());
      String newSubject = CommonUtil.fromNullToEmpty(call.getSubject());
      if (!oldSubject.equals(newSubject)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName, recordID, "entity.subject.label", oldSubject, newSubject, loginUser);
        changeLogs.add(changeLog);
      }

      String oldStatus = getOptionValue(originalCall.getStatus());
      String newStatus = getOptionValue(call.getStatus());
      if (!oldStatus.equals(newStatus)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName, recordID, "entity.status.label", oldStatus, newStatus, loginUser);
        changeLogs.add(changeLog);
      }

      SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_EDIT_FORMAT);
      String oldStartDateValue = "";
      Date oldStartDate = originalCall.getStart_date();
      if (oldStartDate != null) {
        oldStartDateValue = dateFormat.format(oldStartDate);
      }
      String newStartDateValue = "";
      Date newStartDate = call.getStart_date();
      if (newStartDate != null) {
        newStartDateValue = dateFormat.format(newStartDate);
      }
      if (!oldStartDateValue.equals(newStartDateValue)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.start_date.label",
                oldStartDateValue,
                newStartDateValue,
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldRelatedObject = CommonUtil.fromNullToEmpty(originalCall.getRelated_object());
      String newRelatedObject = CommonUtil.fromNullToEmpty(call.getRelated_object());
      if (!oldRelatedObject.equals(newRelatedObject)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.related_object.label",
                oldRelatedObject,
                newRelatedObject,
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldRelatedRecord = String.valueOf(originalCall.getRelated_record());
      String newRelatedRecord = String.valueOf(call.getRelated_record());
      if (!oldRelatedRecord.equals(newRelatedRecord)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.related_record.label",
                oldRelatedRecord,
                newRelatedRecord,
                loginUser);
        changeLogs.add(changeLog);
      }

      boolean oldReminderEmail = originalCall.isReminder_email();
      boolean newReminderEmail = call.isReminder_email();
      if (oldReminderEmail != newReminderEmail) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.reminder.label",
                String.valueOf(oldReminderEmail),
                String.valueOf(newReminderEmail),
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldReminderOption = getOptionValue(originalCall.getReminder_option_email());
      String newReminderOption = getOptionValue(call.getReminder_option_email());
      if (!oldReminderOption.equals(newReminderOption)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.reminder_option_email_name.label",
                oldReminderOption,
                newReminderOption,
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldReminderTemplateName = "";
      EmailTemplate oldReminderTemplate = originalCall.getReminder_template();
      if (oldReminderTemplate != null) {
        oldReminderTemplateName = CommonUtil.fromNullToEmpty(oldReminderTemplate.getName());
      }
      String newReminderTemplateName = "";
      EmailTemplate newReminderTemplate = call.getReminder_template();
      if (newReminderTemplate != null) {
        newReminderTemplateName = CommonUtil.fromNullToEmpty(newReminderTemplate.getName());
      }
      if (oldReminderTemplateName != newReminderTemplateName) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.reminder_template.label",
                oldReminderTemplateName,
                newReminderTemplateName,
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldDescription = CommonUtil.fromNullToEmpty(originalCall.getDescription());
      String newDescription = CommonUtil.fromNullToEmpty(call.getDescription());
      if (!oldDescription.equals(newDescription)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.description.label",
                oldDescription,
                newDescription,
                loginUser);
        changeLogs.add(changeLog);
      }

      String oldNotes = CommonUtil.fromNullToEmpty(originalCall.getNotes());
      String newNotes = CommonUtil.fromNullToEmpty(call.getNotes());
      if (!oldNotes.equals(newNotes)) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName, recordID, "entity.notes.label", oldNotes, newNotes, loginUser);
        changeLogs.add(changeLog);
      }

      String oldAssignedToName = "";
      User oldAssignedTo = originalCall.getAssigned_to();
      if (oldAssignedTo != null) {
        oldAssignedToName = oldAssignedTo.getName();
      }
      String newAssignedToName = "";
      User newAssignedTo = call.getAssigned_to();
      if (newAssignedTo != null) {
        newAssignedToName = newAssignedTo.getName();
      }
      if (oldAssignedToName != newAssignedToName) {
        ChangeLog changeLog =
            saveChangeLog(
                entityName,
                recordID,
                "entity.assigned_to.label",
                CommonUtil.fromNullToEmpty(oldAssignedToName),
                CommonUtil.fromNullToEmpty(newAssignedToName),
                loginUser);
        changeLogs.add(changeLog);
      }
    }
    return changeLogs;
  }