コード例 #1
0
 /**
  * Lists the tasks for the specified ticket
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandList(ActionContext context) {
   if (!hasPermission(context, "tickets-tickets-tasks-view")) {
     return ("PermissionError");
   }
   // Parameters
   String ticketId = context.getRequest().getParameter("ticketId");
   Connection db = null;
   TaskList taskList = new TaskList();
   // Paged List
   PagedListInfo ticTaskListInfo = this.getPagedListInfo(context, "TicketTaskListInfo");
   ticTaskListInfo.setItemsPerPage(0);
   try {
     db = this.getConnection(context);
     // Load the task list
     taskList.setTicketId(Integer.parseInt(ticketId));
     taskList.setPagedListInfo(ticTaskListInfo);
     taskList.buildList(db);
     context.getRequest().setAttribute("TaskList", taskList);
     // Load the ticket
     Ticket thisTicket = new Ticket(db, Integer.parseInt(ticketId));
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     context.getRequest().setAttribute("TicketDetails", thisTicket);
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
   addModuleBean(context, "ViewTickets", "List Tasks");
   return getReturn(context, "ListTasks");
 }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandAdd(ActionContext context) {
   Exception errorMessage = null;
   // Load project
   Connection db = null;
   try {
     FileFolder thisFolder = (FileFolder) context.getFormBean();
     thisFolder.setParentId(context.getRequest().getParameter("parentId"));
     db = getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Build array of folder trails
     ProjectManagementFileFolders.buildHierarchy(db, context);
     context.getRequest().setAttribute("fileFolder", thisFolder);
   } catch (Exception e) {
     errorMessage = e;
   } finally {
     this.freeConnection(context, db);
   }
   if (errorMessage == null) {
     return ("AddOK");
   } else {
     context.getRequest().setAttribute("Error", errorMessage);
     return ("SystemError");
   }
 }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandMove(ActionContext context) {
   // Parameters
   String itemId = (String) context.getRequest().getParameter("id");
   Connection db = null;
   try {
     db = getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Load the folder
     FileFolder thisFolder = new FileFolder(db, Integer.parseInt(itemId));
     context.getRequest().setAttribute("FileFolder", thisFolder);
     // Load the current folders
     FileFolderHierarchy hierarchy = new FileFolderHierarchy();
     hierarchy.setLinkModuleId(Constants.DOCUMENTS_TICKETS);
     hierarchy.setLinkItemId(ticketId);
     hierarchy.build(db);
     context.getRequest().setAttribute("folderHierarchy", hierarchy);
     return "MoveOK";
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
 }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandModify(ActionContext context) {
   Exception errorMessage = null;
   boolean recordDeleted = false;
   // TODO: Add some permissions to get here!
   // Modify the itemId, and the folderId will be the location to return to
   String itemId = (String) context.getRequest().getParameter("id");
   String folderId = (String) context.getRequest().getParameter("folderId");
   Connection db = null;
   try {
     db = getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Load the file folder to be modified
     FileFolder thisFolder = (FileFolder) context.getFormBean();
     thisFolder.setId(Integer.parseInt(itemId));
     thisFolder.queryRecord(db, Integer.parseInt(itemId));
   } catch (Exception e) {
     errorMessage = e;
   } finally {
     this.freeConnection(context, db);
   }
   if (errorMessage == null) {
     return (executeCommandAdd(context));
   } else {
     context.getRequest().setAttribute("Error", errorMessage);
     return ("SystemError");
   }
 }
コード例 #5
0
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandModify(ActionContext context) {
   if (!(hasPermission(context, "tickets-tickets-tasks-edit"))) {
     return ("PermissionError");
   }
   Connection db = null;
   Task thisTask = null;
   String forward = context.getRequest().getParameter("forward");
   if (forward != null && !"".equals(forward.trim())) {
     context.getRequest().setAttribute("forward", forward);
   }
   String id = context.getRequest().getParameter("id");
   addModuleBean(context, "View Tickets", "Add Ticket");
   SystemStatus systemStatus = this.getSystemStatus(context);
   String ticketId = context.getRequest().getParameter("ticketId");
   Ticket thisTicket = null;
   try {
     db = this.getConnection(context);
     thisTask = (Task) context.getFormBean();
     if (thisTask.getId() == -1) {
       thisTask = new Task(db, Integer.parseInt(id));
     }
     // Load the ticket
     if (ticketId != null && !"".equals(ticketId)) {
       thisTicket = new Ticket(db, Integer.parseInt(ticketId));
     } else {
       thisTicket = new Ticket(db, thisTask.getTicketId());
     }
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     thisTask.checkEnabledOwnerAccount(db);
     if (thisTask.getContactId() > -1) {
       thisTask.checkEnabledLinkAccount(db);
       Contact contact = new Contact(db, thisTask.getContactId());
       thisTask.setContactName(contact.getNameFull());
     }
     LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
     list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
     context.getRequest().setAttribute("ticketTaskCategoryList", list);
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
   context.getRequest().setAttribute("Task", thisTask);
   if (!hasAuthority(context, thisTask.getOwner())
       || !(hasPermission(context, "tickets-tickets-tasks-edit"))) {
     if (hasPermission(context, "tickets-tickets-tasks-view")) {
       return "TaskDetailsOK";
     }
     return ("PermissionError");
   }
   return "AddTaskOK";
 }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandSave(ActionContext context) {
   Connection db = null;
   int resultCount = 0;
   boolean recordInserted = false;
   boolean isValid = false;
   try {
     db = this.getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Insert or update the folder
     FileFolder thisFolder = (FileFolder) context.getFormBean();
     boolean newFolder = (thisFolder.getId() == -1);
     if (newFolder) {
       thisFolder.setEnteredBy(getUserId(context));
     }
     thisFolder.setModifiedBy(getUserId(context));
     thisFolder.setLinkModuleId(Constants.DOCUMENTS_TICKETS);
     thisFolder.setLinkItemId(ticketId);
     if (newFolder) {
       isValid = this.validateObject(context, db, thisFolder);
       if (isValid) {
         recordInserted = thisFolder.insert(db);
       }
     } else {
       isValid = this.validateObject(context, db, thisFolder);
       if (isValid) {
         resultCount = thisFolder.update(db);
       }
     }
     // Build array of folder trails
     ProjectManagementFileFolders.buildHierarchy(db, context);
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
   if (recordInserted) {
     return ("InsertOK");
   } else if (resultCount == 1) {
     return ("UpdateOK");
   }
   return (executeCommandAdd(context));
 }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandSaveMove(ActionContext context) {
   // Parameters
   String newFolderId = (String) context.getRequest().getParameter("folderId");
   String itemId = (String) context.getRequest().getParameter("id");
   Connection db = null;
   try {
     db = getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Load the current folder
     FileFolder thisFolder = new FileFolder(db, Integer.parseInt(itemId));
     int folderId = Integer.parseInt(newFolderId);
     if (folderId != 0 && folderId != -1) {
       FileFolder newParent = new FileFolder(db, folderId);
       FileFolderHierarchy thisHierarchy = new FileFolderHierarchy();
       thisHierarchy.setLinkModuleId(Constants.DOCUMENTS_TICKETS);
       thisHierarchy.setLinkItemId(ticketId);
       thisHierarchy.build(db, thisFolder.getId());
       if (thisHierarchy.getHierarchy().hasFolder(Integer.parseInt(newFolderId))) {
         thisFolder.buildSubFolders(db);
         Iterator iterator = (Iterator) thisFolder.getSubFolders().iterator();
         while (iterator.hasNext()) {
           FileFolder childFolder = (FileFolder) iterator.next();
           childFolder.updateParentId(db, thisFolder.getParentId());
         }
       }
     }
     thisFolder.updateParentId(db, folderId);
     return "PopupCloseOK";
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
 }
コード例 #8
0
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandAdd(ActionContext context) {
    if (!hasPermission(context, "tickets-tickets-tasks-add")) {
      return ("PermissionError");
    }
    Connection db = null;

    try {
      db = this.getConnection(context);
      // Load the ticket
      Ticket thisTicket =
          new Ticket(db, Integer.parseInt(context.getRequest().getParameter("ticketId")));
      // Check access permission to organization record
      if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
        return ("PermissionError");
      }

      TicketTask thisTicketTask = (TicketTask) context.getFormBean();
      if (thisTicketTask.getEnteredBy() == -1) {
        thisTicketTask = new TicketTask();
        thisTicketTask.setTicketId(thisTicket.getId());
      }
      Task thisTask = thisTicketTask;
      context.getRequest().setAttribute("Task", thisTask);

      SystemStatus systemStatus = this.getSystemStatus(context);
      LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
      list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
      context.getRequest().setAttribute("ticketTaskCategoryList", list);
    } catch (Exception e) {
      context.getRequest().setAttribute("Error", e);
      return ("SystemError");
    } finally {
      this.freeConnection(context, db);
    }

    addModuleBean(context, "View Tickets", "Add Ticket");
    return ("AddTaskOK");
  }
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandDelete(ActionContext context) {
   Exception errorMessage = null;
   boolean recordDeleted = false;
   // Delete the itemId, and the folderId will be the location to return to
   String itemId = (String) context.getRequest().getParameter("id");
   String folderId = (String) context.getRequest().getParameter("folderId");
   Connection db = null;
   try {
     db = getConnection(context);
     // Load the ticket and the organization
     Ticket thisTicket = addTicket(context, db);
     int ticketId = thisTicket.getId();
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     // Load the file folder
     FileFolder thisFolder = new FileFolder(db, Integer.parseInt(itemId));
     recordDeleted = thisFolder.delete(db);
     // indexDeleteItem(context, thisFolder);
   } catch (Exception e) {
     errorMessage = e;
   } finally {
     this.freeConnection(context, db);
   }
   if (errorMessage == null) {
     if (recordDeleted) {
       return ("DeleteOK");
     } else {
       return ("DeleteERROR");
     }
   } else {
     context.getRequest().setAttribute("Error", errorMessage);
     return ("SystemError");
   }
 }
コード例 #10
0
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandSave(ActionContext context) {
    String permission = "tickets-tickets-tasks-edit";
    Connection db = null;
    int resultCount = -1;
    boolean recordInserted = false;
    boolean isValid = false;
    String addAnother = (String) context.getRequest().getParameter("addAnother");
    if (addAnother != null && !"".equals(addAnother.trim())) {
      context.getRequest().setAttribute("addAnother", addAnother);
    }
    String forward = context.getRequest().getParameter("forward");
    if (forward != null && !"".equals(forward.trim())) {
      context.getRequest().setAttribute("forward", forward);
    }
    String ticketId = context.getRequest().getParameter("ticketId");
    TicketTask thisTask = (TicketTask) context.getFormBean();
    SystemStatus systemStatus = this.getSystemStatus(context);
    String action = (thisTask.getId() > 0 ? "modify" : "insert");
    if ("insert".equals(action)) {
      permission = "tickets-tickets-tasks-add";
    }
    if (!hasPermission(context, permission)) {
      return ("PermissionError");
    }
    thisTask.setModifiedBy(getUserId(context));
    try {
      db = this.getConnection(context);
      if ("insert".equals(action)) {
        // Load the ticket
        Ticket thisTicket = new Ticket(db, Integer.parseInt(ticketId));
        // Check access permission to organization record
        if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
          return ("PermissionError");
        }
        if (forward != null || addAnother != null) {
          LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
          list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
          context.getRequest().setAttribute("ticketTaskCategoryList", list);
        }
        thisTask.setEnteredBy(getUserId(context));
        thisTask.setTicketId(Integer.parseInt(ticketId));
        isValid = this.validateObject(context, db, thisTask);
        if (isValid) {
          recordInserted = thisTask.insert(db);
        }
        if (recordInserted) {
          this.processInsertHook(context, thisTask);
        }
      } else {
        Task oldTask = new Task(db, thisTask.getId());
        if (!hasAuthority(context, oldTask.getOwner())) {
          return ("PermissionError");
        }
        isValid = this.validateObject(context, db, thisTask);
        if (isValid) {
          resultCount = thisTask.update(db);
        }
        if (resultCount == 1) {
          this.processUpdateHook(context, oldTask, thisTask);
        }
      }
      if (!isValid || !(recordInserted || resultCount == 1)) {
        if (thisTask.getContactId() > -1) {
          thisTask.checkEnabledLinkAccount(db);
          Contact contact = new Contact(db, thisTask.getContactId());
          thisTask.setContactName(contact.getNameFull());
          context.getRequest().setAttribute("Task", thisTask);
        }
      }
    } catch (Exception e) {
      context.getRequest().setAttribute("Error", e);
      return ("SystemError");
    } finally {
      this.freeConnection(context, db);
    }
    if (recordInserted || resultCount == 1) {
      if ((resultCount == 1 || recordInserted)
          && forward != null
          && "details".equals(forward.trim())) {
        context.getRequest().setAttribute("id", String.valueOf(thisTask.getId()));
        context.getRequest().setAttribute("forward", forward);
        return executeCommandDetails(context);
      }
      if (recordInserted && addAnother != null && "true".equals(addAnother.trim())) {
        Task task = new Task();
        task.setTicketId(ticketId);
        context.getRequest().setAttribute("Task", task);
        return "AddTaskOK";
      }

      addModuleBean(context, "View Tickets", "Ticket Save OK");
      return ("SaveOK");
    }
    if ("insert".equals(action)) {
      return executeCommandAdd(context);
    } else {
      return executeCommandModify(context);
    }
  }