/**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandView(ActionContext context) {
    if (!(hasPermission(context, "sales-leads-action-plans-view"))) {
      return ("PermissionError");
    }
    Exception errorMessage = null;
    Connection db = null;
    try {
      db = this.getConnection(context);
      User user = this.getUser(context, this.getUserId(context));
      String contactId = context.getRequest().getParameter("contactId");
      if (contactId == null) {
        contactId = context.getRequest().getParameter("contactId");
      }
      boolean popup =
          (context.getRequest().getParameter("popup") != null
              && "true".equals(context.getRequest().getParameter("popup")));
      Contact ContactDetails = new Contact(db, Integer.parseInt(contactId));
      if (!isRecordAccessPermitted(context, ContactDetails)) {
        return ("PermissionError");
      }
      context.getRequest().setAttribute("ContactDetails", ContactDetails);

      PagedListInfo planWorkListInfo =
          this.getPagedListInfo(context, "accountActionPlanWorkListInfo");
      planWorkListInfo.setLink(
          "SalesActionPlans.do?command=View&contactId=" + contactId + (popup ? "&popup=true" : ""));
      if (!planWorkListInfo.hasListFilters()) {
        planWorkListInfo.addFilter(1, "myhierarchy");
        planWorkListInfo.addFilter(2, "true");
      }

      ActionPlanWorkList planWorkList = new ActionPlanWorkList();
      planWorkList.setPagedListInfo(planWorkListInfo);
      planWorkList.setSiteId(ContactDetails.getSiteId());
      if (user.getSiteId() == -1) {
        planWorkList.setIncludeAllSites(true);
      }

      planWorkList.setLinkModuleId(ActionPlan.getMapIdGivenConstantId(db, ActionPlan.LEADS));
      planWorkList.setLinkItemId(contactId);

      if ("my".equals(planWorkListInfo.getFilterValue("listFilter1"))) {
        planWorkList.setOwner(this.getUserId(context));
      } else if ("mymanaged".equals(planWorkListInfo.getFilterValue("listFilter1"))) {
        planWorkList.setManager(this.getUserId(context));
      } else if ("mywaiting".equals(planWorkListInfo.getFilterValue("listFilter1"))) {
        planWorkList.setOwner(this.getUserId(context));
        planWorkList.setManager(this.getUserId(context));
        planWorkList.setCurrentStepOwner(this.getUserId(context));
        planWorkList.setAllMyPlans(true);
      } else if ("myhierarchy".equals(planWorkListInfo.getFilterValue("listFilter1"))) {
        planWorkList.setOwnerRange(this.getUserRange(context));
      }

      if ("all".equals(planWorkListInfo.getFilterValue("listFilter2"))) {
        planWorkList.setEnabled(Constants.UNDEFINED);
      } else if ("true".equals(planWorkListInfo.getFilterValue("listFilter2"))) {
        planWorkList.setEnabled(Constants.TRUE);
      } else if ("false".equals(planWorkListInfo.getFilterValue("listFilter2"))) {
        planWorkList.setEnabled(Constants.FALSE);
      }

      planWorkList.setBuildPhaseWork(true);
      planWorkList.setBuildStepWork(true);
      planWorkList.setBuildLinkedObject(true);
      planWorkList.buildList(db);
      context.getRequest().setAttribute("actionPlanWorkList", planWorkList);
    } catch (Exception e) {
      errorMessage = e;
    } finally {
      this.freeConnection(context, db);
    }
    if (errorMessage == null) {
      return getReturn(context, "View");
    } else {
      context.getRequest().setAttribute("Error", errorMessage);
      return ("SystemError");
    }
  }