Пример #1
0
 /**
  * Selects the entities
  *
  * @return the SUCCESS result
  */
 public String load() throws ServiceException {
   ActionContext context = ActionContext.getContext();
   Map<String, Object> session = context.getSession();
   User loginUser = (User) session.get(AuthenticationSuccessListener.LOGIN_USER);
   this.userID = loginUser.getId();
   return SUCCESS;
 }
Пример #2
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;
 }
Пример #3
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;
  }
Пример #4
0
 /**
  * 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;
 }
Пример #5
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;
  }
Пример #6
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;
 }
Пример #7
0
 /** 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;
 }