/**
   * Unselects the entities
   *
   * @return the SUCCESS result
   */
  public String unselect() throws ServiceException {
    Campaign campaign = null;
    Set<TargetList> targetLists = null;

    if ("Campaign".equals(this.getRelationKey())) {
      campaign =
          campaignService.getEntityById(Campaign.class, Integer.valueOf(this.getRelationValue()));
      targetLists = campaign.getTargetLists();
    }

    if (this.getSeleteIDs() != null) {
      String[] ids = seleteIDs.split(",");
      Collection<TargetList> selectedTargetLists = new ArrayList<TargetList>();
      for (int i = 0; i < ids.length; i++) {
        Integer selectId = Integer.valueOf(ids[i]);
        A:
        for (TargetList targetList : targetLists) {
          if (targetList.getId().intValue() == selectId.intValue()) {
            selectedTargetLists.add(targetList);
            break A;
          }
        }
      }
      targetLists.removeAll(selectedTargetLists);
    }

    if ("Campaign".equals(this.getRelationKey())) {
      campaignService.makePersistent(campaign);
    }
    return SUCCESS;
  }
  /**
   * Saves entity field
   *
   * @return original TargetList record
   * @throws Exception
   */
  private TargetList saveEntity() throws Exception {
    TargetList originalTargetList = null;
    if (targetList.getId() == null) {
      UserUtil.permissionCheck("create_targetList");
    } else {
      UserUtil.permissionCheck("update_targetList");
      originalTargetList = baseService.getEntityById(TargetList.class, targetList.getId());
      targetList.setTargets(originalTargetList.getTargets());
      targetList.setContacts(originalTargetList.getContacts());
      targetList.setLeads(originalTargetList.getLeads());
      targetList.setUsers(originalTargetList.getUsers());
      targetList.setAccounts(originalTargetList.getAccounts());
    }

    User assignedTo = null;
    if (this.getAssignedToID() != null) {
      assignedTo = userService.getEntityById(User.class, this.getAssignedToID());
    }
    targetList.setAssigned_to(assignedTo);

    User owner = null;
    if (this.getOwnerID() != null) {
      owner = userService.getEntityById(User.class, this.getOwnerID());
    }
    targetList.setOwner(owner);

    super.updateBaseInfo(targetList);
    return originalTargetList;
  }
Example #3
0
  /**
   * Saves the entity.
   *
   * @return the SUCCESS result
   */
  public String save() throws Exception {
    CallDirection direction = null;
    if (directionID != null) {
      direction = callDirectionService.getEntityById(CallDirection.class, directionID);
    }
    call.setDirection(direction);
    CallStatus status = null;
    if (statusID != null) {
      status = callStatusService.getEntityById(CallStatus.class, statusID);
    }
    call.setStatus(status);
    ReminderOption reminderOptionPop = null;
    if (reminderOptionPopID != null) {
      reminderOptionPop =
          reminderOptionService.getEntityById(ReminderOption.class, reminderOptionPopID);
    }
    call.setReminder_option_pop(reminderOptionPop);
    ReminderOption reminderOptionEmail = null;
    if (reminderOptionEmailID != null) {
      reminderOptionEmail =
          reminderOptionService.getEntityById(ReminderOption.class, reminderOptionEmailID);
    }
    call.setReminder_option_email(reminderOptionEmail);
    User user = null;
    if (assignedToID != null) {
      user = userService.getEntityById(User.class, assignedToID);
    }
    call.setAssigned_to(user);
    SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy HH:mm:ss");
    Date start_date = null;
    if (startDate != null) {
      start_date = dateFormat.parse(startDate);
    }
    call.setStart_date(start_date);

    String relatedObject = call.getRelated_object();
    if ("Account".equals(relatedObject)) {
      call.setRelated_record(relatedAccountID);
    } else if ("Case".equals(relatedObject)) {
      call.setRelated_record(relatedCaseID);
    } else if ("Contact".equals(relatedObject)) {
      call.setRelated_record(relatedContactID);
    } else if ("Lead".equals(relatedObject)) {
      call.setRelated_record(relatedLeadID);
    } else if ("Opportunity".equals(relatedObject)) {
      call.setRelated_record(relatedOpportunityID);
    } else if ("Target".equals(relatedObject)) {
      call.setRelated_record(relatedTargetID);
    } else if ("Task".equals(relatedObject)) {
      call.setRelated_record(relatedTaskID);
    }

    super.updateBaseInfo(call);

    getbaseService().makePersistent(call);
    return SUCCESS;
  }
  /**
   * Imports the entities
   *
   * @return the SUCCESS result
   */
  public String importCSV() throws Exception {
    File file = this.getUpload();
    CsvListReader reader = new CsvListReader(new FileReader(file), CsvPreference.EXCEL_PREFERENCE);
    int failedNum = 0;
    int successfulNum = 0;
    try {
      final String[] header = reader.getCSVHeader(true);

      List<String> line = new ArrayList<String>();
      Map<String, String> failedMsg = new HashMap<String, String>();
      while ((line = reader.read()) != null) {

        Map<String, String> row = new HashMap<String, String>();
        for (int i = 0; i < line.size(); i++) {
          row.put(header[i], line.get(i));
        }

        TargetList targetList = new TargetList();
        try {
          String id = row.get(getText("entity.id.label"));
          if (!CommonUtil.isNullOrEmpty(id)) {
            targetList.setId(Integer.parseInt(id));
          }
          targetList.setName(CommonUtil.fromNullToEmpty(row.get(getText("entity.name.label"))));
          targetList.setDescription(
              CommonUtil.fromNullToEmpty(row.get(getText("entity.description.label"))));
          targetList.setNotes(CommonUtil.fromNullToEmpty(row.get(getText("entity.notes.label"))));
          String assignedToID = row.get(getText("entity.assigned_to_id.label"));
          if (CommonUtil.isNullOrEmpty(assignedToID)) {
            targetList.setAssigned_to(null);
          } else {
            User assignedTo = userService.getEntityById(User.class, Integer.parseInt(assignedToID));
            targetList.setAssigned_to(assignedTo);
          }
          baseService.makePersistent(targetList);
          successfulNum++;
        } catch (Exception e) {
          failedNum++;
          String Name = CommonUtil.fromNullToEmpty(targetList.getName());
          failedMsg.put(Name, e.getMessage());
        }
      }

      this.setFailedMsg(failedMsg);
      this.setFailedNum(failedNum);
      this.setSuccessfulNum(successfulNum);
      this.setTotalNum(successfulNum + failedNum);
    } finally {
      reader.close();
    }
    return SUCCESS;
  }
 /**
  * Saves the entity.
  *
  * @return the SUCCESS result
  */
 public String save() throws Exception {
   TargetList originalTargetList = saveEntity();
   final Collection<ChangeLog> changeLogs = changeLog(originalTargetList, targetList);
   if ("Campaign".equals(this.getRelationKey())) {
     Campaign campaign =
         campaignService.getEntityById(Campaign.class, Integer.valueOf(this.getRelationValue()));
     Set<Campaign> campaigns = targetList.getCampaigns();
     if (campaigns == null) {
       campaigns = new HashSet<Campaign>();
     }
     campaigns.add(campaign);
   }
   targetList = getBaseService().makePersistent(targetList);
   this.setId(targetList.getId());
   this.setSaveFlag("true");
   if (changeLogs != null) {
     taskExecutor.execute(
         new Runnable() {
           public void run() {
             batchInserChangeLogs(changeLogs);
           }
         });
   }
   return SUCCESS;
 }
 public String relateTargetListUser() throws Exception {
   targetList = baseService.getEntityById(TargetList.class, id);
   Set<User> users = targetList.getUsers();
   Iterator<User> userIterator = users.iterator();
   int totalRecords = users.size();
   ListUserAction.getListJson(userIterator, totalRecords, null, false);
   return null;
 }
 public String relateTargetListTarget() throws Exception {
   targetList = baseService.getEntityById(TargetList.class, id);
   Set<Target> targets = targetList.getTargets();
   Iterator<Target> targetIterator = targets.iterator();
   long totalRecords = targets.size();
   ListTargetAction.getListJson(targetIterator, totalRecords, null, false);
   return null;
 }
 /**
  * Gets the related leads.
  *
  * @return null
  */
 public String relateTargetListLead() throws Exception {
   targetList = baseService.getEntityById(TargetList.class, id);
   Set<Lead> leads = targetList.getLeads();
   Iterator<Lead> leadIterator = leads.iterator();
   long totalRecords = leads.size();
   ListLeadAction.getListJson(leadIterator, totalRecords, null, false);
   return null;
 }
 /**
  * Gets the list data.
  *
  * @return null
  */
 @Override
 public String list() throws Exception {
   SearchCondition searchCondition = getSearchCondition();
   SearchResult<TargetList> result = baseService.getPaginationObjects(CLAZZ, searchCondition);
   Iterator<TargetList> targetLists = result.getResult().iterator();
   long totalRecords = result.getTotalRecords();
   getListJson(targetLists, totalRecords, null, false);
   return null;
 }
Example #10
0
 /**
  * Gets the list data.
  *
  * @return null
  */
 public String listFew() throws Exception {
   UserUtil.permissionCheck("view_document");
   User loginUser = UserUtil.getLoginUser();
   SearchCondition searchCondition = getFewSearchCondition(loginUser.getScope_task(), loginUser);
   String hql = "select new Document(id,name) from Document";
   SearchResult<Document> result =
       baseService.getPaginationObjectsWithHql(CLAZZ, hql, searchCondition);
   Iterator<Document> tasks = result.getResult().iterator();
   getJson(tasks);
   return null;
 }
Example #11
0
 /** Prepares the list */
 public void prepare() throws Exception {
   ActionContext context = ActionContext.getContext();
   Map<String, Object> session = context.getSession();
   String local = (String) session.get("locale");
   this.statuses = callStatusService.getOptions(CallStatus.class.getSimpleName(), local);
   this.directions = callDirectionService.getOptions(CallDirection.class.getSimpleName(), local);
   this.reminderOptions =
       reminderOptionService.getOptions(ReminderOption.class.getSimpleName(), local);
   // Gets reminder email template list
   String hql =
       "select new EmailTemplate(id,name) from EmailTemplate where type = 'callRemind' order by created_on";
   reminderTemplates = emailTemplateService.findByHQL(hql);
 }
 /**
  * Copies the selected entities
  *
  * @return the SUCCESS result
  */
 public String copy() throws Exception {
   UserUtil.permissionCheck("create_targetList");
   if (this.getSeleteIDs() != null) {
     String[] ids = seleteIDs.split(",");
     for (int i = 0; i < ids.length; i++) {
       String copyid = ids[i];
       TargetList oriRecord = baseService.getEntityById(TargetList.class, Integer.valueOf(copyid));
       TargetList targetListRecord = oriRecord.clone();
       targetListRecord.setId(null);
       this.getbaseService().makePersistent(targetListRecord);
     }
   }
   return SUCCESS;
 }
Example #13
0
  /**
   * Gets the list data.
   *
   * @return null
   */
  public String listFull() throws Exception {
    UserUtil.permissionCheck("view_document");
    User loginUser = UserUtil.getLoginUser();
    int scope = loginUser.getScope_document();
    StringBuilder hqlBuilder = new StringBuilder("select new Document(id,name) from Document");

    if (scope == Role.OWNER_OR_DISABLED) {
      hqlBuilder.append(" where owner = ").append(loginUser.getId());
    }
    hqlBuilder.append(" order by created_on desc");
    List<Document> result = baseService.findByHQL(hqlBuilder.toString());
    documents = result.iterator();
    return SUCCESS;
  }
 /**
  * Gets the entity.
  *
  * @return the SUCCESS result
  */
 public String get() throws Exception {
   if (this.getId() != null) {
     targetList = baseService.getEntityById(TargetList.class, this.getId());
     User assignedTo = targetList.getAssigned_to();
     if (assignedTo != null) {
       this.setAssignedToID(assignedTo.getId());
       this.setAssignedToText(assignedTo.getName());
     }
     this.getBaseInfo(targetList, TargetList.class.getSimpleName(), Constant.CRM_NAMESPACE);
   } else {
     this.initBaseInfo();
   }
   return SUCCESS;
 }
Example #15
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;
  }
  /**
   * Selects the entities
   *
   * @return the SUCCESS result
   */
  public String select() throws ServiceException {
    Campaign campaign = null;
    Set<TargetList> targetLists = null;

    if ("Campaign".equals(this.getRelationKey())) {
      campaign =
          campaignService.getEntityById(Campaign.class, Integer.valueOf(this.getRelationValue()));
      targetLists = campaign.getTargetLists();
    }

    if (this.getSeleteIDs() != null) {
      String[] ids = seleteIDs.split(",");
      for (int i = 0; i < ids.length; i++) {
        String selectId = ids[i];
        targetList = baseService.getEntityById(TargetList.class, Integer.valueOf(selectId));
        targetLists.add(targetList);
      }
    }

    if ("Campaign".equals(this.getRelationKey())) {
      campaignService.makePersistent(campaign);
    }
    return SUCCESS;
  }
  /**
   * Gets the list data.
   *
   * @return null
   */
  public String listFull() throws Exception {
    UserUtil.permissionCheck("view_targetList");

    Map<String, String> fieldTypeMap = new HashMap<String, String>();
    fieldTypeMap.put("created_on", Constant.DATA_TYPE_DATETIME);
    fieldTypeMap.put("updated_on", Constant.DATA_TYPE_DATETIME);

    User loginUser = UserUtil.getLoginUser();
    SearchCondition searchCondition =
        getSearchCondition(fieldTypeMap, loginUser.getScope_targetList(), loginUser);
    SearchResult<TargetList> result = baseService.getPaginationObjects(CLAZZ, searchCondition);
    Iterator<TargetList> targetLists = result.getResult().iterator();
    long totalRecords = result.getTotalRecords();
    getListJson(targetLists, totalRecords, searchCondition, true);
    return null;
  }
  private InputStream getDownloadContent(boolean isTemplate) throws Exception {
    UserUtil.permissionCheck("view_targetList");
    String fileName = getText("entity.targetList.label") + ".csv";
    fileName = new String(fileName.getBytes(), "ISO8859-1");
    File file = new File(fileName);
    ICsvMapWriter writer = new CsvMapWriter(new FileWriter(file), CsvPreference.EXCEL_PREFERENCE);
    try {
      final String[] header =
          new String[] {
            getText("entity.id.label"),
            getText("entity.name.label"),
            getText("entity.description.label"),
            getText("entity.notes.label"),
            getText("entity.assigned_to_id.label"),
            getText("entity.assigned_to_name.label")
          };
      writer.writeHeader(header);
      if (!isTemplate) {
        String[] ids = seleteIDs.split(",");
        for (int i = 0; i < ids.length; i++) {
          String id = ids[i];
          TargetList targetList = baseService.getEntityById(TargetList.class, Integer.parseInt(id));
          final HashMap<String, ? super Object> data1 = new HashMap<String, Object>();
          data1.put(header[0], targetList.getId());
          data1.put(header[1], CommonUtil.fromNullToEmpty(targetList.getName()));
          data1.put(header[2], CommonUtil.fromNullToEmpty(targetList.getDescription()));
          data1.put(header[3], CommonUtil.fromNullToEmpty(targetList.getNotes()));
          if (targetList.getAssigned_to() != null) {
            data1.put(header[4], targetList.getAssigned_to().getId());
            data1.put(header[5], targetList.getAssigned_to().getName());
          } else {
            data1.put(header[4], "");
            data1.put(header[5], "");
          }
          writer.write(data1, header);
        }
      }
    } catch (Exception e) {
      throw e;
    } finally {
      writer.close();
    }

    InputStream in = new FileInputStream(file);
    this.setFileName(fileName);
    return in;
  }
Example #19
0
  /** Mass update entity record information */
  public String massUpdate() throws Exception {
    saveEntity();
    String[] fieldNames = this.massUpdate;
    if (fieldNames != null) {
      Collection<String> feildNameCollection = new ArrayList<String>();
      for (int i = 0; i < fieldNames.length; i++) {
        feildNameCollection.add(fieldNames[i]);
        if ("reminder_pop".equals(fieldNames[i])) {
          feildNameCollection.add("reminder_email");
          feildNameCollection.add("reminder_option_pop");
          feildNameCollection.add("reminder_option_email");
        }
      }

      String[] selectIDArray = this.seleteIDs.split(",");
      Collection<Call> calls = new ArrayList<Call>();
      User loginUser = this.getLoginUser();
      User user = userService.getEntityById(User.class, loginUser.getId());
      Collection<ChangeLog> allChangeLogs = new ArrayList<ChangeLog>();
      for (String IDString : selectIDArray) {
        int id = Integer.parseInt(IDString);
        Call callInstance = this.baseService.getEntityById(Call.class, id);
        Call originalCall = callInstance.clone();
        for (String fieldName : feildNameCollection) {
          Object value = BeanUtil.getFieldValue(call, fieldName);
          BeanUtil.setFieldValue(callInstance, fieldName, value);
        }
        callInstance.setUpdated_by(user);
        callInstance.setUpdated_on(new Date());
        Collection<ChangeLog> changeLogs = changeLog(originalCall, callInstance);
        allChangeLogs.addAll(changeLogs);
        calls.add(callInstance);
      }
      final Collection<ChangeLog> changeLogsForSave = allChangeLogs;
      if (calls.size() > 0) {
        this.baseService.batchUpdate(calls);
        taskExecutor.execute(
            new Runnable() {
              public void run() {
                batchInserChangeLogs(changeLogsForSave);
              }
            });
      }
    }
    return SUCCESS;
  }
Example #20
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;
 }
Example #21
0
 /**
  * Gets the entity.
  *
  * @return the SUCCESS result
  */
 public String get() throws Exception {
   if (this.getId() != null) {
     call = baseService.getEntityById(Call.class, this.getId());
     CallStatus status = call.getStatus();
     if (status != null) {
       statusID = status.getId();
     }
     CallDirection direction = call.getDirection();
     if (direction != null) {
       directionID = direction.getId();
     }
     ReminderOption reminderOptionPop = call.getReminder_option_pop();
     if (reminderOptionPop != null) {
       reminderOptionPopID = reminderOptionPop.getId();
     }
     ReminderOption reminderOptionEmail = call.getReminder_option_email();
     if (reminderOptionEmail != null) {
       reminderOptionEmailID = reminderOptionEmail.getId();
     }
     User user = call.getAssigned_to();
     if (user != null) {
       assignedToID = user.getId();
     }
     Date start_date = call.getStart_date();
     SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy HH:mm:ss");
     if (start_date != null) {
       startDate = dateFormat.format(start_date);
     }
     String relatedObject = call.getRelated_object();
     Integer relatedRecord = call.getRelated_record();
     setRelatedRecord(relatedObject, relatedRecord);
   } else {
     ActionContext context = ActionContext.getContext();
     Map<String, Object> session = context.getSession();
     User loginUser = (User) session.get(AuthenticationSuccessListener.LOGIN_USER);
     this.assignedToID = loginUser.getId();
     if (!CommonUtil.isNullOrEmpty(this.getRelationKey())) {
       call.setRelated_object(this.getRelationKey());
       setRelatedRecord(this.getRelationKey(), Integer.parseInt(this.getRelationValue()));
     }
   }
   return SUCCESS;
 }
Example #22
0
  /**
   * Gets the list JSON data.
   *
   * @return list JSON data
   */
  public String list() throws Exception {

    SearchCondition searchCondition = getSearchCondition();
    SearchResult<SalesStage> result = baseService.getPaginationObjects(CLAZZ, searchCondition);
    List<SalesStage> salesStages = result.getResult();

    long totalRecords = result.getTotalRecords();

    // Constructs the JSON data
    String json = "{\"total\": " + totalRecords + ",\"rows\": [";
    int size = salesStages.size();
    for (int i = 0; i < size; i++) {
      SalesStage instance = (SalesStage) salesStages.get(i);
      Integer id = instance.getId();
      String name = instance.getName();
      int sequence = instance.getSequence();

      json +=
          "{\"id\":\""
              + id
              + "\",\"salesStage.id\":\""
              + id
              + "\",\"salesStage.name\":\""
              + name
              + "\",\"salesStage.sequence\":\""
              + sequence
              + "\"}";
      if (i < size - 1) {
        json += ",";
      }
    }
    json += "]}";

    // Returns JSON data back to page
    HttpServletResponse response = ServletActionContext.getResponse();
    response.getWriter().write(json);
    return null;
  }
 /** Mass update entity record information */
 public String massUpdate() throws Exception {
   saveEntity();
   String[] fieldNames = this.massUpdate;
   if (fieldNames != null) {
     String[] selectIDArray = this.seleteIDs.split(",");
     Collection<TargetList> targetLists = new ArrayList<TargetList>();
     User loginUser = this.getLoginUser();
     User user = userService.getEntityById(User.class, loginUser.getId());
     Collection<ChangeLog> allChangeLogs = new ArrayList<ChangeLog>();
     for (String IDString : selectIDArray) {
       int id = Integer.parseInt(IDString);
       TargetList targetListInstance = this.baseService.getEntityById(TargetList.class, id);
       TargetList originalTargetList = targetListInstance.clone();
       for (String fieldName : fieldNames) {
         Object value = BeanUtil.getFieldValue(targetList, fieldName);
         BeanUtil.setFieldValue(targetListInstance, fieldName, value);
       }
       targetListInstance.setUpdated_by(user);
       targetListInstance.setUpdated_on(new Date());
       Collection<ChangeLog> changeLogs = changeLog(originalTargetList, targetListInstance);
       allChangeLogs.addAll(changeLogs);
       targetLists.add(targetListInstance);
     }
     final Collection<ChangeLog> changeLogsForSave = allChangeLogs;
     if (targetLists.size() > 0) {
       this.baseService.batchUpdate(targetLists);
       taskExecutor.execute(
           new Runnable() {
             public void run() {
               batchInserChangeLogs(changeLogsForSave);
             }
           });
     }
   }
   return SUCCESS;
 }
Example #24
0
  /**
   * Sends invitation mail to all participants.
   *
   * @return the SUCCESS result
   */
  public String sendInvites() throws Exception {

    UserUtil.permissionCheck("update_call");
    call = baseService.getEntityById(Call.class, call.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);
    }
    this.setId(call.getId());
    ActionContext context = ActionContext.getContext();
    Map<String, Object> session = context.getSession();
    User loginUser = (User) session.get(AuthenticationSuccessListener.LOGIN_USER);

    StringBuilder targetEmails = new StringBuilder("");
    Set<Contact> contacts = call.getContacts();
    if (contacts != null) {
      for (Contact contact : contacts) {
        String email = contact.getEmail();
        if (CommonUtil.isNullOrEmpty(email)) {
          continue;
        }
        if (targetEmails.length() > 0) {
          targetEmails.append(",");
        }
        targetEmails.append(email);
      }
    }
    Set<Lead> leads = call.getLeads();
    if (leads != null) {
      for (Lead lead : leads) {
        String email = lead.getEmail();
        if (CommonUtil.isNullOrEmpty(email)) {
          continue;
        }
        if (targetEmails.length() > 0) {
          targetEmails.append(",");
        }
        targetEmails.append(email);
      }
    }
    from = loginUser.getEmail();
    if (from == null) {
      from = "";
    }
    Set<User> users = call.getUsers();
    if (users != null) {
      for (User user : users) {
        String email = user.getEmail();
        if (CommonUtil.isNullOrEmpty(email) || (from != null && email.endsWith(from))) {
          continue;
        }
        if (targetEmails.length() > 0) {
          targetEmails.append(",");
        }
        targetEmails.append(email);
      }
    }
    if (targetEmails.length() > 0) {
      to = targetEmails.toString();
    }

    // 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;
  }
Example #25
0
 /**
  * Deletes the selected entity.
  *
  * @return the SUCCESS result
  */
 public String delete() throws ServiceException {
   baseService.batchDeleteEntity(SalesStage.class, this.getSeleteIDs());
   return SUCCESS;
 }
Example #26
0
  /**
   * Saves entity field
   *
   * @return original call record
   * @throws ParseException
   */
  private Call saveEntity() throws Exception {
    Call originalCall = null;
    if (call.getId() == null) {
      UserUtil.permissionCheck("create_call");
    } else {
      UserUtil.permissionCheck("update_call");
      originalCall = baseService.getEntityById(Call.class, call.getId());
      call.setContacts(originalCall.getContacts());
      call.setLeads(originalCall.getLeads());
      call.setUsers(originalCall.getUsers());
    }

    CallDirection direction = null;
    if (directionID != null) {
      direction = callDirectionService.getEntityById(CallDirection.class, directionID);
    }
    call.setDirection(direction);
    CallStatus status = null;
    if (statusID != null) {
      status = callStatusService.getEntityById(CallStatus.class, statusID);
    }
    call.setStatus(status);
    ReminderOption reminderOptionEmail = null;
    if (reminderOptionEmailID != null) {
      reminderOptionEmail =
          reminderOptionService.getEntityById(ReminderOption.class, reminderOptionEmailID);
    }
    call.setReminder_option_email(reminderOptionEmail);
    EmailTemplate reminderTemplate = null;
    if (reminderTemplateID != null) {
      reminderTemplate =
          emailTemplateService.getEntityById(EmailTemplate.class, reminderTemplateID);
    }
    call.setReminder_template(reminderTemplate);
    User user = null;
    if (this.getAssignedToID() != null) {
      user = userService.getEntityById(User.class, this.getAssignedToID());
    }
    call.setAssigned_to(user);
    User owner = null;
    if (this.getOwnerID() != null) {
      owner = userService.getEntityById(User.class, this.getOwnerID());
    }
    call.setOwner(owner);
    SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT);
    Date start_date = null;
    if (!CommonUtil.isNullOrEmpty(startDate)) {
      start_date = dateFormat.parse(startDate);
    }
    call.setStart_date(start_date);

    String relatedObject = call.getRelated_object();
    if ("Account".equals(relatedObject)) {
      call.setRelated_record(relatedAccountID);
    } else if ("CaseInstance".equals(relatedObject)) {
      call.setRelated_record(relatedCaseID);
    } else if ("Contact".equals(relatedObject)) {
      call.setRelated_record(relatedContactID);
    } else if ("Lead".equals(relatedObject)) {
      call.setRelated_record(relatedLeadID);
    } else if ("Opportunity".equals(relatedObject)) {
      call.setRelated_record(relatedOpportunityID);
    } else if ("Target".equals(relatedObject)) {
      call.setRelated_record(relatedTargetID);
    } else if ("Task".equals(relatedObject)) {
      call.setRelated_record(relatedTaskID);
    }
    super.updateBaseInfo(call);
    return originalCall;
  }
Example #27
0
 /** Prepares the list */
 public void prepare() throws Exception {
   this.statuses = callStatusService.getAllObjects(CallStatus.class.getSimpleName());
   this.directions = callDirectionService.getAllObjects(CallDirection.class.getSimpleName());
   this.reminderOptions =
       reminderOptionService.getAllObjects(ReminderOption.class.getSimpleName());
 }
 /**
  * Deletes the selected entities.
  *
  * @return the SUCCESS result
  */
 public String delete() throws Exception {
   UserUtil.permissionCheck("delete_targetList");
   baseService.batchDeleteEntity(TargetList.class, this.getSeleteIDs());
   return SUCCESS;
 }