public Object executeTask(Object object) throws Exception {
    StringBuffer query = new StringBuffer();
    Object result = null;
    Map incomingRequest = (Map) object;
    try {

      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      BrowseObject b = (BrowseObject) incomingRequest.get("browseObject");
      String organizationId = (String) incomingRequest.get("organizationId");
      String userTimeZone = (String) incomingRequest.get("userTimeZone");
      String userDateFormat = (String) incomingRequest.get("userDateFormat");
      String sqlWhere = (String) incomingRequest.get("sqlWhere");
      List dateArguments = new ArrayList();

      if (Utility.isEmpty(userDateFormat)) {
        userDateFormat =
            PropertiesManager.getInstance(organizationId)
                .getProperty("MISC", "DATEFORMAT", "MM-dd-yyyy");
      }

      sqlWhere =
          ReportDates.dateWhereClauseDecoder(
              sqlWhere, dateArguments, organizationId, userTimeZone, userDateFormat);

      if (Utility.isEmpty(sqlWhere)) {
        sqlWhere = "";
      }
      String sqlSelect = b.getSqlSelect();

      query.append(sqlSelect);
      query.append(" from " + b.getSqlFrom());
      query.append(" " + sqlWhere);
      Log.debug(this, incomingRequest.get("userId") + " - query: " + query.toString());

      long start = System.currentTimeMillis();
      System.out.println("Report Query: " + query.toString());
      List list = dbs.query(query.toString(), dateArguments.toArray(), b.getMaxRows());
      long end = System.currentTimeMillis();
      Log.error(
          this,
          "It took "
              + ((end - start) / 1000)
              + " seconds to execute the query: "
              + query.toString());
      Log.debug(this, incomingRequest.get("userId") + " - dbs.query COMPLETE.");

      result = list;

      this.setStatus(dbs.getStatus());
    } catch (Exception e) {
      incomingRequest.put("failed", Boolean.TRUE);
      Log.error(
          this,
          "Error executing Report Query: " + query.toString() + " -Exception: " + e.getMessage());
      e.printStackTrace();

      this.setStatus(Status.FAILED);
    }
    return result;
  }
  /* (non-Javadoc)
   * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object)
   */
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;

    try {
      String oid = (String) incomingRequest.get("organizationId");
      String icIvcHeaderString = (String) incomingRequest.get("InvoiceHeader_icIvcHeader");
      String fiscalYear = (String) incomingRequest.get("InvoiceHeader_fiscalYear");
      //			String	poType = (String) incomingRequest.get("InvoiceHeader_poType");

      if (Utility.isEmpty(fiscalYear)) {
        fiscalYear = "1994";
      }

      String temp = AutoGenType.toString("INV", oid);
      if (Utility.isEmpty(temp) || temp.equals("INV")) {
        temp = "INV";
      }

      incomingRequest.put("AutoGen_documentType", temp);
      incomingRequest.put("AutoGen_genYear", fiscalYear);
      incomingRequest.put("InvoiceLine_icIvcHeader", icIvcHeaderString);

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      Log.error(this, e.toString());
    }
    return null;
  }
  public Object executeTask(Object object) throws Exception {
    Object ret = null;
    Map incomingRequest = (Map) object;
    try {
      SendQueue sendQueue = (SendQueue) incomingRequest.get("alertSendQueue");

      sendQueue.setStatus("10");
      sendQueue.setErrorText("Alert sucessfully sent");
      sendQueue.setAttempts(sendQueue.getAttempts().add(new BigDecimal(1)));
      sendQueue.setDatesent(Dates.today("yyyy/MM/dd", ""));
      sendQueue.setTimesent(Dates.getNow(null, ""));

      if (incomingRequest.containsKey("report")
          && !Utility.isEmpty((String) incomingRequest.get("report"))) {
        // sendQueue.setAttachment((String) incomingRequest.get("report"));
        incomingRequest.put("SendQueue_attachment", incomingRequest.get("report"));
      }

      ret = sendQueue;
      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException("AlertGetProcessFromType failed!" + e.getMessage(), e);
    }
    return ret;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    List result = null;

    try {
      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      String itemNumber = (String) incomingRequest.get("InvFormProduct_itemNumber");
      if (Utility.isEmpty(itemNumber)) {
        throw new Exception(
            "InvFormProduct_itemNumber cannot be empty.  InvFormProduct could not be retrieved.");
      }

      String queryString =
          "from InvFormProduct as InvFormProduct where InvFormProduct.id.itemNumber = ? ";
      result =
          dbs.query(
              queryString,
              new Object[] {
                itemNumber,
              },
              new Type[] {Hibernate.STRING});

      this.setStatus(dbs.getStatus());
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw e;
    }
    return result;
  }
Exemple #5
0
 public void setInputValue(Map keyMap, String value) {
   if (Utility.isEmpty(value)) {
     this.inputValues.remove(keyMap);
   } else {
     this.inputValues.put(keyMap, value);
   }
 }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      // Always use host database configuration for this table
      DBSession dbs = new DBSession("host");
      String mailId = (String) incomingRequest.get("HostUser_mailId");

      mailId = Utility.ckNull(mailId).toLowerCase();

      String queryString = "from HostUser as HostUser where HostUser.mailId = ? ";
      List resultList =
          dbs.query(
              queryString,
              new Object[] {
                mailId,
              },
              new Type[] {Hibernate.STRING});

      if (resultList != null && resultList.size() > 0) {
        result = resultList.get(0);
      }
      this.setStatus(dbs.getStatus());

      dbs.close();
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw e;
    }
    return result;
  }
 public UpdateLastRunAlert(String _organizationId) {
   String _fileName =
       DictionaryManager.getInstance("host", organizationId).getProperty("alerts-path");
   this.fileName = _fileName;
   this.organizationId = _organizationId;
   this.xmlDocument = Utility.loadXml(this.fileName, this.organizationId);
 }
  public Object executeTask(Object object) throws Exception {
    Object ret = null;
    Map incomingRequest = (Map) object;
    String organizationId = (String) incomingRequest.get("organizationId");

    try {
      String alertName = (String) incomingRequest.get("alertname");
      Alert alert = AlertManager.getInstance().getAlert(organizationId, alertName);

      String action = alert.getProcess();
      if (!Utility.isEmpty(action)) {
        PuridiomProcessLoader processLoader = new PuridiomProcessLoader(organizationId);
        PuridiomProcess process = processLoader.loadProcess(action);
        Map newIncomingRequest = new HashMap();
        newIncomingRequest.put("organizationId", organizationId);
        try {
          process.executeProcess(newIncomingRequest);
        } catch (Exception e) {
          // TODO: handle exception if process to be executed from alert fails.
        }
      }

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException("AlertGetProcessFromType failed!" + e.getMessage(), e);
    }
    return ret;
  }
  /* (non-Javadoc)
   * @see com.tsagate.puridiom.process.ITask#executeTask(java.lang.Object)
   */
  public Object executeTask(Object object) throws Exception {

    Map incomingRequest = (Map) object;

    String icRfqHeader = (String) incomingRequest.get("RfqVendor_icRfqHeader");
    String vendorId = (String) incomingRequest.get("RfqVendor_vendorId");

    if (Utility.isEmpty(icRfqHeader) || Utility.isEmpty(vendorId)) {
      this.setStatus(Status.FAILED);
    } else {
      incomingRequest.put("RfqBid_icRfqHeader", icRfqHeader);
      incomingRequest.put("RfqBid_vendorId", vendorId);
    }

    return null;
  }
  /**
   * Method executeTask.
   *
   * @param object
   *     <p>incomingRequest
   */
  public Object executeTask(Object object) throws Exception {
    Object ret = null;
    try {
      Map incomingRequest = (Map) object;
      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      String AssetCost_tagNumber = (String) incomingRequest.get("AssetCost_tagNumber");

      if (Utility.isEmpty(AssetCost_tagNumber)) {
        AssetCost_tagNumber = (String) incomingRequest.get("Asset_tagNumber");
      }

      String sql =
          "Select MAX(AssetCost.id.sequenceNo) from AssetCost AssetCost Where AssetCost.id.tagNumber = ?";
      List resultList =
          dbs.query(sql, new Object[] {AssetCost_tagNumber}, new Type[] {Hibernate.STRING});

      if (resultList != null && resultList.size() > 0) {
        ret = resultList.get(0);
        if (ret == null) {
          ret = new BigDecimal(0);
        }
      } else {
        ret = new BigDecimal(0);
      }
      this.setStatus(Status.SUCCEEDED);

    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException(this.getName(), e);
    }
    return ret;
  }
Exemple #11
0
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    try {
      String newStatus = (String) incomingRequest.get("newStatus");
      if (Utility.isEmpty(newStatus)) {
        newStatus = DocumentStatus.PO_AWARDED;
      }

      PoHeader poHeader = (PoHeader) incomingRequest.get("poHeader");
      List poLineList = (List) incomingRequest.get("poLineList");

      poHeader.setStatus(newStatus);
      Log.debug(this, poHeader.getDisplayPoNumber().toString() + " newStatus is: " + newStatus);

      for (int i = 0; i < poLineList.size(); i++) {
        PoLine poLine = (PoLine) poLineList.get(i);
        if (!poLine.getStatus().equals(DocumentStatus.CLOSED)
            || !poLine.getStatus().equals(DocumentStatus.CANCELLED)) {
          poLine.setStatus(newStatus);
        }
      }

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException("An Error ocurred closing order ", e);
    }
    return null;
  }
  private Contact getVendorContact(String vendorId, String contactCode, String organizationId)
      throws Exception {
    if (Utility.isEmpty(vendorId)) {
      return null;
    }
    if (Utility.isEmpty(contactCode)) {
      contactCode = "001";
    }

    Map incomingRequest = new HashMap();
    PuridiomProcessLoader processLoader = new PuridiomProcessLoader(organizationId);
    PuridiomProcess process = processLoader.loadProcess("contact-retrieve-by-code.xml");
    incomingRequest.put("organizationId", organizationId);
    incomingRequest.put("Contact_contactCode", contactCode);
    incomingRequest.put("Contact_vendorId", vendorId);
    process.executeProcess(incomingRequest);

    return (Contact) incomingRequest.get("contact");
  }
 private void output() {
   try {
     File f = Utility.getOidFile(this.fileName, this.organizationId);
     if (f.isFile()) {
       FileOutputStream fos = new FileOutputStream(f);
       this.output(fos);
     }
   } catch (IOException ie) {
     Log.error(this, ie.toString());
   }
 }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      String organizationId = (String) incomingRequest.get("organizationId");
      String userId = (String) incomingRequest.get("userId");
      String securityAnswer = (String) incomingRequest.get("securityAnswer");
      String newSecurityQuestion = (String) incomingRequest.get("newSecurityQuestion");
      String newSecurityAnswer = (String) incomingRequest.get("newSecurityAnswer");

      if (incomingRequest.containsKey("securityAnswer") && Utility.isEmpty(securityAnswer)) {
        throw new PasswordSecurityException("You must answer your current security question!");
      }
      if (Utility.isEmpty(newSecurityQuestion)) {
        throw new PasswordSecurityException("You must select a new security question!");
      }
      if (Utility.isEmpty(newSecurityAnswer)) {
        throw new PasswordSecurityException("You must answer your new security question!");
      }

      if (Utility.isEmpty(securityAnswer)) {
        securityAnswer = "";
      } else {
        securityAnswer = securityAnswer.trim();
      }
      newSecurityAnswer = newSecurityAnswer.trim();

      incomingRequest.put("UserProfile_organizationId", organizationId);
      incomingRequest.put("UserProfile_userId", userId);
      incomingRequest.put("UserProfile_securityQuestion", newSecurityQuestion);
      incomingRequest.put("UserProfile_securityAnswer", newSecurityAnswer);
      incomingRequest.put("securityAnswer", securityAnswer);

      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
Exemple #15
0
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    BigDecimal icNews = new BigDecimal(incomingRequest.get("ic_news").toString());

    if (Utility.isObjectEmpty(icNews)) {
      this.setStatus(Status.FAILED);
      throw new TsaException("News id is necessary to retrieve a News");
    } else {
      this.setStatus(Status.SUCCEEDED);
    }

    return null;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      PoHeader poHeader = (PoHeader) incomingRequest.get("poHeader");
      PoLine poLine = (PoLine) incomingRequest.get("poLine");

      if (poHeader == null) {
        throw new Exception("Recent Order Item cannot be setup.  PoHeader was not found.");
      }
      if (poLine == null) {
        throw new Exception("Recent Order Item cannot be setup.  PoLine was not found.");
      }

      String source = poLine.getItemSource();
      String location = poLine.getItemLocation();
      String buyer = poHeader.getBuyerCode();
      if (source.equals("CAT") || source.equals("XML")) {
        location = poLine.getCatalogId();
      }
      if (Utility.isEmpty(buyer)) {
        buyer = poHeader.getOwner();
      }

      incomingRequest.put("RecentOrderItem_buyerCode", buyer);
      incomingRequest.put("RecentOrderItem_itemNumber", poLine.getItemNumber());
      incomingRequest.put("RecentOrderItem_itemSource", source);
      incomingRequest.put("RecentOrderItem_itemLocation", location);
      incomingRequest.put("RecentOrderItem_description", poLine.getDescription());
      incomingRequest.put("RecentOrderItem_dateEntered", Dates.today("", ""));

      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      String organizationId = (String) incomingRequest.get("organizationId");
      String userTimeZone = (String) incomingRequest.get("userTimeZone");
      String userDateFormat = (String) incomingRequest.get("userDateFormat");

      PropertiesManager propertiesManager = PropertiesManager.getInstance(organizationId);

      if (Utility.isEmpty(userDateFormat)) {
        userDateFormat = propertiesManager.getProperty("MISC", "DateFormat", "");
      }

      String today = Dates.today(userDateFormat, userTimeZone);

      incomingRequest.put("AssetService_tagNumber", "");
      incomingRequest.put("AssetService_sequenceNo", "0");
      incomingRequest.put("AssetService_serviceCallDate", today);
      incomingRequest.put("AssetService_callInitiatedBy", "");
      incomingRequest.put("AssetService_dateInitiated", today);
      incomingRequest.put("AssetService_responseDate", today);
      incomingRequest.put("AssetService_completionDate", today);
      incomingRequest.put("AssetService_serviceAction", "");
      incomingRequest.put("AssetService_serviceCost", "0");
      incomingRequest.put("AssetService_lastChgBy", "");
      incomingRequest.put("AssetService_dateChanged", today);

      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      String organizationId = (String) incomingRequest.get("organizationId");
      String backupApproverAction = (String) incomingRequest.get("backupApproverAction");
      RequisitionHeader rqh = (RequisitionHeader) incomingRequest.get("requisitionHeader");
      if (rqh == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException(this.getName() + " RequisitionHeader was not found!");
      }
      String requisitionNumber = rqh.getRequisitionNumber();
      if (requisitionNumber == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException(this.getName() + " RequisitionNumber was not found!");
      }

      ApprovalLog approvalLog = (ApprovalLog) incomingRequest.get("approver");
      if (approvalLog == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException(
            this.getName()
                + " ApprovalLog record was not found.  Email record cannot be written to notify the initial approver that the requisition has been approved by the backup approver!");
      }

      String backupApprover = approvalLog.getBackupApprover();
      String currentApprover = approvalLog.getCallForward();

      if (Utility.isEmpty(backupApprover)) {
        // this.setStatus(Status.FAILED);
        // throw new TsaException(this.getName() + " BackupApprover was not found.  Email record
        // cannot be written to notify the requisitioner that the requisition has been approved by
        // the backup approver!");
      }
      if (Utility.isEmpty(currentApprover)) {
        this.setStatus(Status.FAILED);
        throw new TsaException(
            this.getName()
                + " CurrentApprover was not found.  Email record cannot be written to notify the requisitioner that the requisition has been approved by the backup approver!");
      }

      incomingRequest.put("SendQueue_doctype", "REQ");
      incomingRequest.put(
          "SendQueue_docic", (String) incomingRequest.get("RequisitionHeader_icReqHeader"));

      if (!Utility.isEmpty(requisitionNumber)) {
        String owner = (String) incomingRequest.get("userId");

        StringBuffer subject = new StringBuffer("");
        subject.append(
            UserManager.getInstance().getUser(organizationId, backupApprover).getDisplayName());
        subject.append(" has " + backupApproverAction + " Requisition ");
        subject.append(requisitionNumber);
        subject.append(" on your behalf.  No action is required from you at this time.");

        incomingRequest.put("SendQueue_subject", subject.toString());
        incomingRequest.put("SendQueue_sendfromtype", "E");
        incomingRequest.put(
            "SendQueue_sendfrom",
            UserManager.getInstance().getUser(organizationId, owner).getMailId());
        incomingRequest.put("SendQueue_sendtotype", "E");
        incomingRequest.put(
            "SendQueue_sendto",
            UserManager.getInstance().getUser(organizationId, currentApprover).getMailId());
        incomingRequest.put("SendQueue_action", EmailActionCodes.EMAIL);
        incomingRequest.put("SendQueue_messagetext", subject.toString());
        incomingRequest.put("isRequisitionForwardApprovalProcess", "Y");

        PuridiomProcessLoader processLoader = new PuridiomProcessLoader();
        PuridiomProcess process = processLoader.loadProcess("sendqueue-add.xml");
        process.executeProcess(incomingRequest);
        this.status = process.getStatus();
      } else {
        this.setStatus(Status.SUCCEEDED);
        Log.debug(this, "No record will be written for this Req: " + requisitionNumber);
      }
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      BomMethod bomMethod = (BomMethod) incomingRequest.get("bomMethod");
      if (bomMethod == null) {
        bomMethod = new BomMethod();
      }

      if (incomingRequest.containsKey("BomMethod_icMethod")) {
        String icMethodString = (String) incomingRequest.get("BomMethod_icMethod");
        if (Utility.isEmpty(icMethodString)) {
          icMethodString = "0";
        }
        BigDecimal icMethod = new BigDecimal(icMethodString);
        bomMethod.setIcMethod(icMethod);
      }
      if (incomingRequest.containsKey("BomMethod_parentItem")) {
        String parentItem = (String) incomingRequest.get("BomMethod_parentItem");
        bomMethod.setParentItem(parentItem);
      }
      if (incomingRequest.containsKey("BomMethod_componentItem")) {
        String componentItem = (String) incomingRequest.get("BomMethod_componentItem");
        bomMethod.setComponentItem(componentItem);
      }
      if (incomingRequest.containsKey("BomMethod_methodId")) {
        String methodId = (String) incomingRequest.get("BomMethod_methodId");
        bomMethod.setMethodId(methodId);
      }
      if (incomingRequest.containsKey("BomMethod_batchSize")) {
        String batchSizeString = (String) incomingRequest.get("BomMethod_batchSize");
        if (Utility.isEmpty(batchSizeString)) {
          batchSizeString = "0";
        }
        BigDecimal batchSize = new BigDecimal(batchSizeString);
        bomMethod.setBatchSize(batchSize);
      }
      if (incomingRequest.containsKey("BomMethod_unitOfMeasure")) {
        String unitOfMeasure = (String) incomingRequest.get("BomMethod_unitOfMeasure");
        bomMethod.setUnitOfMeasure(unitOfMeasure);
      }
      if (incomingRequest.containsKey("BomMethod_description")) {
        String description = (String) incomingRequest.get("BomMethod_description");
        bomMethod.setDescription(description);
      }
      if (incomingRequest.containsKey("BomMethod_notes")) {
        String notes = (String) incomingRequest.get("BomMethod_notes");
        bomMethod.setNotes(notes);
      }
      if (incomingRequest.containsKey("BomMethod_dateEntered")) {
        String dateEnteredString = (String) incomingRequest.get("BomMethod_dateEntered");
        Date dateEntered = Dates.getDate(dateEnteredString);
        bomMethod.setDateEntered(dateEntered);
      }
      if (incomingRequest.containsKey("BomMethod_owner")) {
        String owner = (String) incomingRequest.get("BomMethod_owner");
        bomMethod.setOwner(owner);
      }

      result = bomMethod;
      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
Exemple #20
0
 public String getInputValue(Map keyMap) {
   String value = (String) this.inputValues.get(keyMap);
   return Utility.ckNull(value);
 }
  public Object executeTask(Object object) throws Exception {
    try {

      Map incomingRequest = (Map) object;
      String assignTo = (String) incomingRequest.get("assignTo");

      if (Utility.isEmpty(assignTo)) {
        // Notification cannot be sent
        throw new Exception(
            "The notification cannot be sent because the assigned buyer user id was not specified (assignTo).");
      }

      if (assignTo.equalsIgnoreCase("AUTORELEASE")) {
        // Notification should not be sent
        this.setStatus(Status.SUCCEEDED);
        return null;
      }

      if (assignTo.equalsIgnoreCase("UNASSIGNED")) {
        assignTo = "PURCHASING";
      }

      String userId = (String) incomingRequest.get("userId");
      String organizationId = (String) incomingRequest.get("organizationId");
      RequisitionHeader requisitionHeader =
          (RequisitionHeader) incomingRequest.get("requisitionHeader");
      List requisitionLineList = (List) incomingRequest.get("requisitionLineList");
      String assignType = (String) incomingRequest.get("assignType");
      if (assignType == null) {
        assignType = "MANUAL";
      }
      UserProfile assignedBuyer = UserManager.getInstance().getUser(organizationId, assignTo);
      UserProfile requisitioner =
          UserManager.getInstance()
              .getUser(organizationId, requisitionHeader.getRequisitionerCode());
      UserProfile owner =
          UserManager.getInstance().getUser(organizationId, requisitionHeader.getOwner());
      StringBuffer message = new StringBuffer();
      StringBuffer sendTo = new StringBuffer();
      String sendFrom = UserManager.getInstance().getUser(organizationId, userId).getMailId();

      if (Utility.isEmpty(sendFrom)) {
        sendFrom =
            PropertiesManager.getInstance(organizationId)
                .getProperty("MAILEVENTS", "AdminEmailAddr", "");
      }
      if (!Utility.isEmpty(assignedBuyer.getMailId())) {
        sendTo.append(assignedBuyer.getMailId());
      }
      if (!Utility.isEmpty(requisitioner.getMailId()) && assignType.equals("MANUAL")) {
        if (sendTo.length() > 0) {
          sendTo.append(";" + requisitioner.getMailId());
        } else {
          sendTo.append(requisitioner.getMailId());
        }
      }
      if (!Utility.isEmpty(owner.getMailId())) {
        if (sendTo.length() > 0) {
          sendTo.append(";" + owner.getMailId());
        } else {
          sendTo.append(owner.getMailId());
        }
      }

      if (!Utility.isEmpty(assignedBuyer.getMailId())) {
        message.append(
            "Request "
                + requisitionHeader.getRequisitionNumber()
                + " was assigned to "
                + assignedBuyer.getDisplayName()
                + " on "
                + HiltonUtility.getFormattedDate(
                    requisitionHeader.getAssignedDate(), organizationId)
                + ".");
        message.append("\r");
        message.append("\r");
        message.append("This request contains the following items:");
        message.append("\r");

        for (int il = 0; il < requisitionLineList.size(); il++) {
          RequisitionLine requisitionLine = (RequisitionLine) requisitionLineList.get(il);
          message.append(requisitionLine.getLineNumber() + "." + "  ");
          if (!Utility.isEmpty(requisitionLine.getItemNumber())) {
            message.append(requisitionLine.getItemNumber() + " - ");
          }
          message.append(requisitionLine.getDescription());
          message.append("\r");
        }

        incomingRequest.put(
            "SendQueue_subject",
            "Assignment Notification: Requisition " + requisitionHeader.getRequisitionNumber());
        incomingRequest.put("SendQueue_sendfromtype", "E");
        incomingRequest.put("SendQueue_sendfrom", sendFrom);
        incomingRequest.put("SendQueue_sendtotype", "E");
        incomingRequest.put("SendQueue_action", "EN");
        incomingRequest.put("SendQueue_messagetext", message.toString());
        incomingRequest.put("SendQueue_owner", userId);
        incomingRequest.put("SendQueue_doctype", "REQ");
        incomingRequest.put("SendQueue_docic", String.valueOf(requisitionHeader.getIcReqHeader()));
        incomingRequest.put("SendQueue_sendto", sendTo.toString());

        PuridiomProcessLoader processLoader = new PuridiomProcessLoader();
        PuridiomProcess process = processLoader.loadProcess("sendqueue-add.xml");
        process.executeProcess(incomingRequest);
        this.status = process.getStatus();

        if (this.getStatus() != Status.SUCCEEDED) {
          throw new Exception("The email record could not be written to the queue.");
        }
      }

      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }

    return null;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      InvStage invStage = (InvStage) incomingRequest.get("invStage");
      if (invStage == null) {
        invStage = new InvStage();
      }

      if (incomingRequest.containsKey("InvStage_stageId")) {
        String stageId = (String) incomingRequest.get("InvStage_stageId");
        invStage.setStageId(stageId);
      }
      if (incomingRequest.containsKey("InvStage_description")) {
        String description = (String) incomingRequest.get("InvStage_description");
        invStage.setDescription(description);
      }
      if (incomingRequest.containsKey("InvStage_respons")) {
        String respons = (String) incomingRequest.get("InvStage_respons");
        invStage.setRespons(respons);
      }
      if (incomingRequest.containsKey("InvStage_notes")) {
        String notes = (String) incomingRequest.get("InvStage_notes");
        invStage.setNotes(notes);
      }
      if (incomingRequest.containsKey("InvStage_workCenterId")) {
        String workCenterId = (String) incomingRequest.get("InvStage_workCenterId");
        invStage.setWorkCenterId(workCenterId);
      }
      if (incomingRequest.containsKey("InvStage_utilization")) {
        String utilizationString = (String) incomingRequest.get("InvStage_utilization");
        if (Utility.isEmpty(utilizationString)) {
          utilizationString = "0";
        }
        BigDecimal utilization = new BigDecimal(utilizationString);
        invStage.setUtilization(utilization);
      }
      if (incomingRequest.containsKey("InvStage_qtyDays")) {
        String qtyDaysString = (String) incomingRequest.get("InvStage_qtyDays");
        if (Utility.isEmpty(qtyDaysString)) {
          qtyDaysString = "0";
        }
        BigDecimal qtyDays = new BigDecimal(qtyDaysString);
        invStage.setQtyDays(qtyDays);
      }
      if (incomingRequest.containsKey("InvStage_setupHours")) {
        String setupHoursString = (String) incomingRequest.get("InvStage_setupHours");
        if (Utility.isEmpty(setupHoursString)) {
          setupHoursString = "0";
        }
        BigDecimal setupHours = new BigDecimal(setupHoursString);
        invStage.setSetupHours(setupHours);
      }
      if (incomingRequest.containsKey("InvStage_partsHour")) {
        String partsHourString = (String) incomingRequest.get("InvStage_partsHour");
        if (Utility.isEmpty(partsHourString)) {
          partsHourString = "0";
        }
        BigDecimal partsHour = new BigDecimal(partsHourString);
        invStage.setPartsHour(partsHour);
      }
      if (incomingRequest.containsKey("InvStage_timePart")) {
        String timePartString = (String) incomingRequest.get("InvStage_timePart");
        if (Utility.isEmpty(timePartString)) {
          timePartString = "0";
        }
        BigDecimal timePart = new BigDecimal(timePartString);
        invStage.setTimePart(timePart);
      }
      if (incomingRequest.containsKey("InvStage_vendorName")) {
        String vendorName = (String) incomingRequest.get("InvStage_vendorName");
        invStage.setVendorName(vendorName);
      }
      if (incomingRequest.containsKey("InvStage_leadTime")) {
        String leadTimeString = (String) incomingRequest.get("InvStage_leadTime");
        if (Utility.isEmpty(leadTimeString)) {
          leadTimeString = "0";
        }
        BigDecimal leadTime = new BigDecimal(leadTimeString);
        invStage.setLeadTime(leadTime);
      }
      if (incomingRequest.containsKey("InvStage_outside")) {
        String outside = (String) incomingRequest.get("InvStage_outside");
        invStage.setOutside(outside);
      }
      if (incomingRequest.containsKey("InvStage_descriptor")) {
        String descriptor = (String) incomingRequest.get("InvStage_descriptor");
        invStage.setDescriptor(descriptor);
      }
      if (incomingRequest.containsKey("InvStage_machineId")) {
        String machineId = (String) incomingRequest.get("InvStage_machineId");
        invStage.setMachineId(machineId);
      }
      if (incomingRequest.containsKey("InvStage_backflush")) {
        String backflush = (String) incomingRequest.get("InvStage_backflush");
        invStage.setBackflush(backflush);
      }

      if (incomingRequest.containsKey("InvStage_persons")) {
        String personsString = (String) incomingRequest.get("InvStage_persons");
        if (Utility.isEmpty(personsString)) {
          personsString = "0";
        }
        BigDecimal persons = new BigDecimal(personsString);
        invStage.setPersons(persons);
      }
      if (incomingRequest.containsKey("InvStage_ccost")) {
        String ccostString = (String) incomingRequest.get("InvStage_ccost");
        if (Utility.isEmpty(ccostString)) {
          ccostString = "0";
        }
        BigDecimal ccost = new BigDecimal(ccostString);
        invStage.setCcost(ccost);
      }
      if (incomingRequest.containsKey("InvStage_unitOfMeasure")) {
        String unitOfMeasure = (String) incomingRequest.get("InvStage_unitOfMeasure");
        invStage.setUnitOfMeasure(unitOfMeasure);
      }

      if (incomingRequest.containsKey("InvStage_dateEntered")) {
        String dateEnteredString = (String) incomingRequest.get("InvStage_dateEntered");
        Date dateEntered = Dates.getDate(dateEnteredString);
        invStage.setDateEntered(dateEntered);
      }
      if (incomingRequest.containsKey("InvStage_dateExpires")) {
        String dateExpiresString = (String) incomingRequest.get("InvStage_dateExpires");
        Date dateExpires = Dates.getDate(dateExpiresString);
        invStage.setDateExpires(dateExpires);
      }
      if (incomingRequest.containsKey("InvStage_owner")) {
        String owner = (String) incomingRequest.get("InvStage_owner");
        invStage.setOwner(owner);
      }
      if (incomingRequest.containsKey("InvStage_status")) {
        String status = (String) incomingRequest.get("InvStage_status");
        invStage.setStatus(status);
      }

      result = invStage;
      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      SendQueue sendQueue = (SendQueue) incomingRequest.get("sendQueue");
      if (sendQueue == null) {
        sendQueue = new SendQueue();
      }

      if (incomingRequest.containsKey("SendQueue_queueid")) {
        String queueidString = (String) incomingRequest.get("SendQueue_queueid");
        if (Utility.isEmpty(queueidString)) {
          queueidString = "0";
        }
        BigDecimal queueid = new BigDecimal(queueidString);
        sendQueue.setQueueid(queueid);
      }
      if (incomingRequest.containsKey("SendQueue_doctype")) {
        String doctype = (String) incomingRequest.get("SendQueue_doctype");
        sendQueue.setDoctype(doctype);
      }
      if (incomingRequest.containsKey("SendQueue_docic")) {
        String docicString = (String) incomingRequest.get("SendQueue_docic");
        if (Utility.isEmpty(docicString)) {
          docicString = "0";
        }
        BigDecimal docic = new BigDecimal(docicString);
        sendQueue.setDocic(docic);
      }
      if (incomingRequest.containsKey("SendQueue_subject")) {
        String subject = (String) incomingRequest.get("SendQueue_subject");
        sendQueue.setSubject(subject);
      }
      if (incomingRequest.containsKey("SendQueue_messagetext")) {
        String messagetext = (String) incomingRequest.get("SendQueue_messagetext");
        sendQueue.setMessage(messagetext);
      }
      if (incomingRequest.containsKey("SendQueue_messagetext2")) {
        String messagetext2 = (String) incomingRequest.get("SendQueue_messagetext2");
        sendQueue.setMessagetext2(messagetext2);
      }
      if (incomingRequest.containsKey("SendQueue_owner")) {
        String owner = (String) incomingRequest.get("SendQueue_owner");
        sendQueue.setOwner(owner);
      }
      if (incomingRequest.containsKey("SendQueue_sendfromtype")) {
        String sendfromtype = (String) incomingRequest.get("SendQueue_sendfromtype");
        sendQueue.setSendfromtype(sendfromtype);
      }
      if (incomingRequest.containsKey("SendQueue_sendfrom")) {
        String sendfrom = (String) incomingRequest.get("SendQueue_sendfrom");
        sendQueue.setSendfrom(sendfrom);
      }
      if (incomingRequest.containsKey("SendQueue_sendtotype")) {
        String sendtotype = (String) incomingRequest.get("SendQueue_sendtotype");
        sendQueue.setSendtotype(sendtotype);
      }
      if (incomingRequest.containsKey("SendQueue_sendto")) {
        String sendto = (String) incomingRequest.get("SendQueue_sendto");
        sendQueue.setSendto(sendto);
      }
      if (incomingRequest.containsKey("SendQueue_status")) {
        String status = (String) incomingRequest.get("SendQueue_status");
        sendQueue.setStatus(status);
      }
      if (incomingRequest.containsKey("SendQueue_dateadded")) {
        String dateadded = (String) incomingRequest.get("SendQueue_dateadded");
        sendQueue.setDateadded(dateadded);
      }
      if (incomingRequest.containsKey("SendQueue_timeadded")) {
        String timeadded = (String) incomingRequest.get("SendQueue_timeadded");
        sendQueue.setTimeadded(timeadded);
      }
      if (incomingRequest.containsKey("SendQueue_action")) {
        String action = (String) incomingRequest.get("SendQueue_action");
        sendQueue.setAction(action);
      }
      if (incomingRequest.containsKey("SendQueue_datesent")) {
        String datesent = (String) incomingRequest.get("SendQueue_datesent");
        sendQueue.setDatesent(datesent);
      }
      if (incomingRequest.containsKey("SendQueue_timesent")) {
        String timesent = (String) incomingRequest.get("SendQueue_timesent");
        sendQueue.setTimesent(timesent);
      }
      if (incomingRequest.containsKey("SendQueue_attachment")) {
        String attachment = (String) incomingRequest.get("SendQueue_attachment");
        sendQueue.setAttachment(attachment);
      }
      if (incomingRequest.containsKey("SendQueue_vendorId")) {
        String vendorId = (String) incomingRequest.get("SendQueue_vendorId");
        sendQueue.setVendorId(vendorId);
      }
      if (incomingRequest.containsKey("SendQueue_attempts")) {
        String attempts = (String) incomingRequest.get("SendQueue_attempts");
        if (Utility.isEmpty(attempts)) {
          attempts = "0";
        }
        sendQueue.setAttempts(new BigDecimal(attempts));
      }
      if (incomingRequest.containsKey("SendQueue_errorText")) {
        String errorText = (String) incomingRequest.get("SendQueue_errorText");
        sendQueue.setErrorText(errorText);
      }
      if (incomingRequest.containsKey("SendQueue_args")) {
        String args = (String) incomingRequest.get("SendQueue_args");
        sendQueue.setArgs(args);
      }

      result = sendQueue;
      this.status = Status.SUCCEEDED;
    } catch (Exception e) {
      this.status = Status.FAILED;

      e.printStackTrace();
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    List result;
    try {
      Map incomingRequest = (Map) object;
      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      String o = (String) incomingRequest.get("organizationId");
      String userId = (String) incomingRequest.get("userId");
      String userDateFormat = (String) incomingRequest.get("userDateFormat");
      BrowseObject b = (BrowseObject) incomingRequest.get("browseObject");
      List groupFilters = b.getGroupFilters();
      List groupFilterOptions = new ArrayList();
      List commodities = new ArrayList();
      // boolean unspscCommodities = PropertiesManager.getInstance(o).getProperty("MISC",
      // "CommodityType", "").equalsIgnoreCase("UNSPSC");
      boolean unspscCommodities = false;
      boolean commoditySet = false;

      PropertiesManager propertiesManager = PropertiesManager.getInstance(o);

      if (Utility.isEmpty(userDateFormat)) {
        userDateFormat = propertiesManager.getProperty("MISC", "DateFormat", "MM-dd-yyyy");
      }

      for (int ix = 0; ix < groupFilters.size(); ix++) {
        BrowseGroupFilter gf = (BrowseGroupFilter) groupFilters.get(ix);
        StringBuffer query = new StringBuffer();
        StringBuffer queryFilter = new StringBuffer();

        if (!Utility.isEmpty(gf.getType()) && gf.getType().equals("CostRange")) {
          incomingRequest.put("CostRange_itemType", incomingRequest.get("as_item_type"));
        }

        List dateArguments = new ArrayList();

        if (Utility.isEmpty(gf.getType()) || !gf.getType().equals("Keywords")) {
          query.append(gf.getSqlSelect() + " from " + gf.getSqlFrom() + " where 1 = 1");

          if (Utility.ckNull(gf.getSqlWhere()).length() > 0) {
            query.append(" and ( " + gf.getSqlWhere() + ")");
          }
          if (Utility.ckNull(b.getSqlWhere()).length() > 0) {
            String sqlWhere = b.getSqlWhere();
            sqlWhere = sqlWhere.replaceAll(":as_userid", "'" + userId + "'");
            if (sqlWhere.indexOf(":as_today") > 0) {
              dateArguments.add(
                  Dates.getDate(
                      Dates.today(userDateFormat, (String) incomingRequest.get("userTimeZone"))));
            }
            sqlWhere = sqlWhere.replaceAll(":as_today", "?");

            query.append(" and ( " + sqlWhere + ")");
          }

          List filters = b.getBrowseFilters();
          if (filters != null) {
            for (int i = 0; i < filters.size(); i++) {
              BrowseFilter filter = (BrowseFilter) filters.get(i);
              String key = filter.getColumnName();

              if (!b.validateColumn(key)) {
                // skip this filter
                continue;
              }

              String value = encoder.encodeForSQL(new OracleCodec(), filter.getValue());

              String operator = filter.getOperator();
              String logicalOperator = filter.getLogicalOperator();

              if (!BrowseValidationUtility.permissibleOperators.contains(operator)) {
                operator = "=";
              }

              if (!BrowseValidationUtility.permissibleLogicalOperators.contains(logicalOperator)) {
                logicalOperator = "AND";
              }

              String type = filter.getType();

              if (!Utility.isEmpty(value)) {
                if (Utility.isEmpty(operator)) {
                  operator = "=";
                }
                if (Utility.isEmpty(logicalOperator)) {
                  logicalOperator = "AND";
                }
                if (Utility.isEmpty(type)) {
                  type = "STRING";
                }

                if (queryFilter.length() > 0) {
                  queryFilter.append(" " + logicalOperator + " ");
                }

                if (type.equalsIgnoreCase("DATE")) {
                  dateArguments.add(Dates.getDate(userDateFormat, value));
                  queryFilter.append(" " + key + " " + operator + " ?");
                } else if (operator.equalsIgnoreCase("LIKE")) {
                  queryFilter.append(" UPPER(" + key + ") " + operator + " '" + value + "'");
                } else {
                  queryFilter.append(" " + key + " " + operator + " '" + value + "'");
                }

                if (key.indexOf(".commodity") > 0) {
                  if (!Utility.isEmpty(value)) {
                    commoditySet = true;
                    if (value.indexOf("%") > 0) {
                      String commodity = "00000000";
                      for (int iv = 0; iv < value.length(); iv++) {
                        char temp = value.charAt(iv);
                        if (temp != '%') {
                          if (iv == 0) {
                            commodity = temp + commodity.substring(iv + 1);
                          } else if (commodity.length() >= (iv + 1)) {
                            commodity =
                                commodity.substring(0, iv) + temp + commodity.substring(iv + 1);
                          } else {
                            commodity = commodity.substring(0, iv) + temp;
                          }
                        }
                      }
                      if (!commodities.contains(commodity)) {
                        commodities.add(commodity);
                      }
                    }
                  }
                }
              }
            }
          }

          if (queryFilter.length() > 0) {
            query.append("AND (" + queryFilter + " )");
          }

          if (gf.getType().equalsIgnoreCase("Commodity") && unspscCommodities) {
            String originalQueryString = query.toString();
            List commodityList = null;
            CommodityGetUNSPSCWhereClause commodityWhere = new CommodityGetUNSPSCWhereClause();

            int attempts = 0;
            while ((commodityList == null || commodityList.size() == 0) && attempts <= 3) {
              query = new StringBuffer(originalQueryString);

              String commodityArray[] = new String[commodities.size()];
              commodities.toArray(commodityArray);
              incomingRequest.put("Commodity_commodity", commodityArray);
              incomingRequest.put("retrieveAllCodes", "N");

              if (attempts > 0) {
                incomingRequest.put("retrieveAllFamilies", "Y");
                if (attempts > 1) {
                  incomingRequest.put("retrieveAllGroups", "Y");
                  if (attempts > 2) {
                    incomingRequest.put("retrieveAllCommodities", "Y");
                  }
                }
              }

              String unspscWhere = (String) commodityWhere.executeTask(incomingRequest);
              if (!Utility.isEmpty(unspscWhere)) {
                query.append(" AND (" + unspscWhere + ")");
              }

              if (!Utility.isEmpty(gf.getSqlGroupBy())) {
                query.append(" group by " + gf.getSqlGroupBy());
              }
              if (!Utility.isEmpty(gf.getSqlOrderBy())) {
                query.append(" order by " + gf.getSqlOrderBy());
              }

              Log.debug(this, "group filter query: " + query.toString());

              Object arguments[] = new Object[dateArguments.size()];
              for (int i = 0; i < dateArguments.size(); i++) {
                arguments[i] = dateArguments.get(i);
              }
              commodityList = dbs.query(query.toString(), arguments);

              attempts++;
            }

            gf.setSelectionValues(commodityList);
          } else {
            if (!Utility.isEmpty(gf.getSqlGroupBy())) {
              query.append(" group by " + gf.getSqlGroupBy());
            }
            if (!Utility.isEmpty(gf.getSqlOrderBy())) {
              query.append(" order by " + gf.getSqlOrderBy());
            }

            Log.debug(this, "group filter query: " + query.toString());

            Object arguments[] = new Object[dateArguments.size()];
            for (int i = 0; i < dateArguments.size(); i++) {
              arguments[i] = dateArguments.get(i);
            }
            List list = dbs.query(query.toString(), arguments);

            gf.setSelectionValues(list);
          }
        }
      }

      result = groupFilters;

      this.setStatus(dbs.getStatus());
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      InvoiceHeader invoiceHeader = (InvoiceHeader) incomingRequest.get("invoiceHeader");
      BigDecimal icIvcHeader = invoiceHeader.getIcIvcHeader();
      String newStatus = invoiceHeader.getStatus();
      String invoiceUser = invoiceHeader.getEnteredBy();
      // String buyerUser = invoiceHeader.getAssignedBuyer() ;
      /*String reqTotal = "$" + requisitionHeader.getTotal().toString() ;*/
      String invoiceTotal =
          HiltonUtility.getCurrency(
              invoiceHeader.getInvoiceTotal(),
              invoiceHeader.getCurrencyCode(),
              (String) incomingRequest.get("organizationId"),
              true);
      if (invoiceTotal.indexOf("yen") > 0) {
        invoiceTotal = invoiceTotal.replaceAll(";", "");
        invoiceTotal = invoiceTotal.replaceAll("&yen", "¥");
      }
      String purpose = invoiceHeader.getInvoiceDesc();
      String nextUser = "";
      String queryString =
          "select UserProfile.mailId from ApprovalLog as ApprovalLog, UserProfile as UserProfile where ApprovalLog.id.userId = UserProfile.userId and ApprovalLog.id.icHeader = ? and ApprovalLog.id.userId <> ? ";
      List resultList =
          dbs.query(
              queryString,
              new Object[] {icIvcHeader, invoiceUser},
              new Type[] {Hibernate.BIG_DECIMAL, Hibernate.STRING});

      if (resultList != null && resultList.size() > 0) {
        for (int x = 0; x < resultList.size(); x++) {
          nextUser += (String) resultList.get(x) + "; ";
        }
      }
      this.setStatus(dbs.getStatus());

      nextUser +=
          UserManager.getInstance()
              .getUser((String) incomingRequest.get("organizationId"), invoiceUser)
              .getMailId();

      if (invoiceHeader == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException(this.getName() + " Invoice could not be recalled!");
      }

      Log.debug(
          this,
          "Writting send_queue record for invoice: "
              + invoiceHeader.getInvoiceNumber()
              + ", status "
              + newStatus);

      if (newStatus.equals(DocumentStatus.IVC_RECALLED) && !Utility.isEmpty(nextUser)) {
        String owner = (String) incomingRequest.get("userId");
        StringBuffer subject = new StringBuffer("Invoice ");
        subject.append(invoiceHeader.getInvoiceNumber());
        subject.append(" recalled");
        StringBuffer message = new StringBuffer("Invoice ");
        message.append(invoiceHeader.getInvoiceNumber());
        message.append(
            " was recalled by "
                + UserManager.getInstance()
                    .getUser((String) incomingRequest.get("organizationId"), owner)
                    .getDisplayName());
        message.append(" on " + Dates.today("") + "\n\n");
        message.append(
            "Invoice Creator: "
                + UserManager.getInstance()
                    .getUser((String) incomingRequest.get("organizationId"), invoiceUser)
                    .getDisplayName()
                + "\n");
        message.append("Invoice Total: " + invoiceTotal + "\n");
        message.append("Description: " + purpose);

        incomingRequest.put("SendQueue_doctype", "IVC");
        incomingRequest.put(
            "SendQueue_docic", (String) incomingRequest.get("InvoiceHeader_icIvcHeader"));
        incomingRequest.put("SendQueue_subject", subject.toString());
        incomingRequest.put("SendQueue_messagetext", message.toString());
        incomingRequest.put("SendQueue_owner", owner);
        incomingRequest.put("SendQueue_sendfromtype", "E");
        incomingRequest.put(
            "SendQueue_sendfrom",
            UserManager.getInstance()
                .getUser((String) incomingRequest.get("organizationId"), owner)
                .getMailId());
        incomingRequest.put("SendQueue_sendtotype", "E");
        incomingRequest.put("SendQueue_sendto", nextUser);
        incomingRequest.put("SendQueue_action", EmailActionCodes.EMAIL);

        PuridiomProcessLoader processLoader = new PuridiomProcessLoader();
        PuridiomProcess process = processLoader.loadProcess("sendqueue-add.xml");
        process.executeProcess(incomingRequest);
        this.status = process.getStatus();
      } else {
        this.setStatus(Status.SUCCEEDED);
        Log.debug(
            this,
            "No record will be written for this Invoice: " + invoiceHeader.getInvoiceNumber());
      }
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException("Invoice Approval Email couldn't be processed.", e);
    }
    return result;
  }