/**
  * 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");
   }
 }
 /**
  * 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);
   }
 }
  /**
   * 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");
   }
 }