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;
  }
Beispiel #2
0
 public int checkAuthority(Object budgetKey, String authority) {
   Log.info(this, this.getKeyAsString() + " Checking with: " + authority);
   for (int i = 0; i < this.budgetDrawerList.size(); i++) {
     BudgetDrawer drawer = (BudgetDrawer) this.budgetDrawerList.get(i);
     Log.info(
         this, this.getKeyAsString() + " Authority found: " + drawer.getComp_id().getAuthority());
     if (drawer.getComp_id().getAuthority().trim().equalsIgnoreCase(authority)) {
       if (drawer.getStatus().equalsIgnoreCase("03")) {
         i = this.budgetDrawerList.size();
         Log.info(
             this,
             this.getKeyAsString()
                 + "Authority: "
                 + drawer.getComp_id().getAuthority()
                 + " is inactive");
         return BudgetReturn.AUTHORITYNOTACTIVE;
       } else {
         i = this.budgetDrawerList.size();
         return BudgetReturn.NOEXCEPTION;
       }
     }
   }
   Log.info(this, this.getKeyAsString() + "No matching authority found.");
   return BudgetReturn.NOAUTHORITY;
 }
 /**
  * @param content
  * @param from
  * @param subject
  * @param organizationId
  */
 private void handleStringContent(String content) {
   Log.debug(this, "handleStringContent");
   try {
     this.bodytext.append(content);
     Log.debug(this, content);
   } catch (Exception e) {
     // TODO: handle exception
   }
 }
 public void handleMessage(Message message, String contentType)
     throws IOException, MessagingException {
   Log.debug(this, "handleMessage");
   Object objContent = message.getContent();
   if (objContent instanceof Multipart) {
     Log.debug(this, "handleMessage-multipart");
     Multipart multipart = (Multipart) message.getContent();
     this.handleContent(multipart, contentType);
   } else {
     Log.debug(this, "handleMessage-string");
     this.handleStringContent((String) objContent);
   }
 }
  /**
   * Method executeTask.
   *
   * @param object
   *     <p>incomingRequest
   */
  public Object executeTask(Object object) throws Exception {
    Object ret = null;
    try {
      Map incomingRequest = (Map) object;
      Contact contact = (Contact) incomingRequest.get("contact");
      String vendorId = "";

      if (contact != null) {
        vendorId = contact.getComp_id().getVendorId();
      }

      incomingRequest.put("Vendor_vendorId", vendorId);
      incomingRequest.put("Address_addressType", vendorId);
      incomingRequest.put("VendorCommRel_vendorId", vendorId);
      // for alternate contacts
      incomingRequest.put("Contact_vendorId", vendorId);
      incomingRequest.put("Contact_contactType", "ALTERNATE");
      // incomingRequest.put("Contact_contactCode", "002");

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      Log.error(this, e.toString());
      this.setStatus(Status.FAILED);
    }
    return ret;
  }
Beispiel #6
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;
  }
  public void getReqLinesToExecute() {
    Log.debug(this, "Retrieve list of POs with status Order Pending from Change Request.");
    try {
      PuridiomProcessLoader processLoader = new PuridiomProcessLoader(this.getOrganizationId());
      PuridiomProcess process =
          processLoader.loadProcess("poheader-retrieve-for-autoaward-revision.xml");
      Map incomingRequest = new HashMap();
      incomingRequest.put("organizationId", this.getOrganizationId());
      incomingRequest.put("autoAwardRevision", "true");

      process.executeProcess(incomingRequest);
    } catch (Exception e) {
      Log.error(this, "getPosToExecute failed: " + e.getMessage());
      // TODO NOTIFY SOMEBODY
    }
  }
  public Object executeTask(Object object) throws Exception {
    Map incomingRequest = (Map) object;
    Object result = null;

    try {
      DBSession dbs = (DBSession) incomingRequest.get("dbsession");
      PoHeader poHeader = (PoHeader) incomingRequest.get("poHeader");
      if (poHeader != null) {

        String queryString =
            "from InvoiceHeader as InvoiceHeader where InvoiceHeader.icPoHeader = ? and InvoiceHeader.invoiceNumber<>'N/A' order by InvoiceHeader.invoiceDate";
        List resultList =
            dbs.query(
                queryString,
                new Object[] {poHeader.getIcPoHeader()},
                new Type[] {Hibernate.BIG_DECIMAL});
        result = resultList;
      } else {
        Log.error(
            this, "IcPoHeader was empty.  InvoiceHeaderRetrieveByOrder could not be executed.");
      }

      this.setStatus(dbs.getStatus());
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw e;
    }
    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;
  }
  /** @param multipart */
  private void handleContent(Multipart multipart, String contentType) {
    Log.debug(this, "handleContent");

    try {
      // String contentType=multipart.getContentType();
      for (int j = 0; j < multipart.getCount(); j++) {
        Part part = multipart.getBodyPart(j);
        Log.debug(this, String.valueOf(part.getLineCount()));
        Log.debug(this, String.valueOf(part.getContent()));
        Log.debug(this, String.valueOf(part.getContentType()));

        if (HiltonUtility.isEmpty(contentType) || part.getContentType().indexOf(contentType) >= 0) {
          String disposition = part.getDisposition();
          Log.debug(this, "handleContent-disposition: " + disposition);
          // if (disposition != null)
          // {
          InputStream inputStream = part.getInputStream();
          byte[] buffer = new byte[inputStream.available()];
          int bytesRead;
          while ((bytesRead = inputStream.read(buffer)) > -1) // Read
          // bytes
          // until
          // EOF
          {
            Log.debug(this, "reading contents");
          }

          String tmp = new String(buffer);
          this.bodytext.append(tmp);
          this.bodytext.append("\r\n");
          Log.debug(this, "handleContent: " + tmp);

          if (inputStream != null) {
            try {
              inputStream.close();
            } catch (IOException io) {
              Log.error(this, " error Closing InputStream" + io.getMessage());
              io.printStackTrace();
            }
          }
        }
      }
      // }
    } catch (Exception e) {
      Log.error(this, e.getMessage());
      e.printStackTrace();
    }
  }
 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());
   }
 }
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    String requestURI = request.getRequestURI();
    ApprovalLink approvalLink = new ApprovalLink();
    String approvalLinkURL =
        requestURI.substring(requestURI.lastIndexOf("/") + 1, requestURI.length());
    String[] approvalLinkData = this.getIcApprovalLink(approvalLinkURL);
    String message = "";
    response.setContentType("text/plain");

    try {
      approvalLink = this.retrieveApprovalLink(approvalLinkData[0], approvalLinkData[1]);

      message = this.acknowledgedReceipt(approvalLink, approvalLinkData[1]);

      message += "Thank you";

      out.println(message);

      Log.debug(
          this,
          "Receipt Acknowledgement (ApprovalLink = "
              + approvalLink.getIcApprovalLink()
              + ") was processing successfully");

    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();

      Log.error(
          this,
          "Error processing Receipt Acknowledgement (ApprovalLink = "
              + approvalLink.getIcApprovalLink()
              + ") : "
              + e.getMessage());
    }
    out.close();
  }
Beispiel #13
0
  public boolean isMaxLockExpired() {
    String sTimeOutPeriod =
        PropertiesManager.getInstance(this.getOrganizationId())
            .getProperty("budgetservice", "lockingPeriod", "30");
    long timeOut = 2000L * (Long.parseLong(sTimeOutPeriod));
    Calendar now = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    long diff = now.getTimeInMillis() - this.getLockingStart().getTimeInMillis();

    if (diff > timeOut) {
      Log.info(this, "Lock Max Expired. Will be Timed out. ");
      return true;
    }
    return false;
  }
 /**
  * Method executeTask.
  *
  * @param object
  *     <p>incomingRequest
  */
 public Object executeTask(Object object) throws Exception {
   Object ret = null;
   try {
     Map incomingRequest = (Map) object;
     RequisitionLine reqLine = (RequisitionLine) incomingRequest.get("requisitionLine");
     reqLine.setBackordered(new BigDecimal(0));
     reqLine.setStatus(DocumentStatus.CANCELLED);
     ret = reqLine;
     this.setStatus(Status.SUCCEEDED);
   } catch (Exception e) {
     Log.error(this, e.toString());
     this.setStatus(Status.FAILED);
   } finally {
     return ret;
   }
 }
  private Object getBuyerData(String organizationId, String userId) {
    Object ret = null;
    try {
      PuridiomProcessLoader processLoader = new PuridiomProcessLoader();
      PuridiomProcess process = processLoader.loadProcess("buyer-graph-data.xml");
      Map incomingRequest = new HashMap();
      incomingRequest.put("organizationId", organizationId);
      incomingRequest.put("userId", userId);

      process.executeProcess(incomingRequest);

      this.setData(incomingRequest);
    } catch (Exception e) {
      Log.error(this, e.toString());
    }

    return ret;
  }
Beispiel #16
0
  public BigDecimal setLocked(boolean _locked, String userId, BigDecimal token) {
    if (_locked) {
      this.locked = _locked;
      this.lockingToken = token;
      this.setLockingId(userId);
      this.setLockingStart(Calendar.getInstance(TimeZone.getTimeZone("GMT")));
      return this.lockingToken;
    } else {
      Calendar now = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
      long diff = now.getTimeInMillis() - this.getLockingStart().getTimeInMillis();
      Log.info(this, "TransactionTotal Time: " + diff);
      this.locked = _locked;
      this.lockingToken = new BigDecimal(0);
      this.setLockingId("");
      this.setLockingStart(now);

      return this.lockingToken;
    }
  }
  /**
   * Method executeTask.
   *
   * @author EDSAC inserts values generated only by the system
   * @param object
   *     <p>incomingRequest
   */
  public Object executeTask(Object object) throws Exception {
    Object ret = null;
    try {
      Map incomingRequest = (Map) object;

      ReceiptLine recLine = (ReceiptLine) incomingRequest.get("receiptLine");

      incomingRequest.put("InspectionHeader_icRecLine", recLine.getIcRecLine().toString());
      incomingRequest.put("InspectionHeader_location", recLine.getInspLocation());
      incomingRequest.put("InspectionHeader_area", recLine.getInspArea());
      incomingRequest.put("InspectionHeader_storage", recLine.getInspStorage());

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      Log.error(this, e.toString());
      this.setStatus(Status.FAILED);
    }
    return ret;
  }
Beispiel #18
0
  public List today() {
    List list = new ArrayList();
    try {
      PuridiomProcessLoader processLoader = new PuridiomProcessLoader(this.getOrganizationId());
      PuridiomProcess process = processLoader.loadProcess("sendqueue-retrieve-by-action-date.xml");
      Map incomingRequest = new HashMap();
      incomingRequest.put("organizationId", this.getOrganizationId());
      incomingRequest.put("SendQueue_dateadded", Dates.today("yyyy/MM/dd", ""));
      this.setAction(incomingRequest);

      process.executeProcess(incomingRequest);
      if (process.getStatus() == Status.SUCCEEDED) {
        list = (List) incomingRequest.get("daysList");
      }
    } catch (Exception e) {
      Log.error(this, e.getMessage() + " -getting today's list");
    }

    return list;
  }
  /**
   * 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 vendorId = (String) incomingRequest.get("Contact_vendorId");

      String queryString =
          "from Contact as Contact where Contact.id.vendorId = ? order by Contact.id.contactType DESC, Contact.id.contactCode ASC";
      List resultList =
          dbs.query(queryString, new Object[] {vendorId}, new Type[] {Hibernate.STRING});

      ret = resultList;
      this.setStatus(dbs.getStatus());
    } catch (Exception e) {
      Log.error(this, e.toString());
      this.setStatus(Status.FAILED);
    }
    return ret;
  }
  public Object executeTask(Object object) throws Exception {
    Object result = null;

    try {
      PuridiomProcessLoader processLoader = new PuridiomProcessLoader();
      PuridiomProcess process = null;
      Map incomingRequest = (Map) object;

      String organizationId = (String) incomingRequest.get("organizationId");
      List poHeaderList = (List) incomingRequest.get("poHeaderList");

      if (poHeaderList != null && poHeaderList.size() > 0) {
        for (Iterator iterator = poHeaderList.iterator(); iterator.hasNext(); ) {
          PoHeader poHeader = (PoHeader) iterator.next();

          incomingRequest.put("userId", incomingRequest.get("userId"));
          incomingRequest.put("organizationId", organizationId);
          incomingRequest.put("dbsession", incomingRequest.get("dbsession"));

          incomingRequest.put("PoHeader_icPoHeader", poHeader.getIcPoHeader().toString());
          incomingRequest.put("PoLine_icPoHeader", poHeader.getIcPoHeader().toString());
          incomingRequest.put("ApprovalLog_icHeader", poHeader.getIcPoHeader().toString());
          incomingRequest.put("PoHeader_status", poHeader.getStatus());
          incomingRequest.put("PoHeader_poType", poHeader.getPoType());
          incomingRequest.put("poaction", "FORWARD");
          incomingRequest.put("formtype", "PO");
          incomingRequest.put("newStatus", DocumentStatus.PO_AWARDED);

          process = processLoader.loadProcess("po-autoaward-revision.xml");
          process.executeProcess(incomingRequest);
        }
      }
      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      Log.error(this, "PoHeaderAutoAwardRevision failed: " + e.getMessage());
      this.setStatus(Status.FAILED);
      throw new TsaException(
          "PoHeaderAutoAwardRevision failed to retrieve POs: " + e.getMessage(), e);
    }
    return result;
  }
  public Object executeTask(Object object) throws Exception {
    Log.debug(this, "execute Task");
    Object ret = null;
    try {
      Map incomingRequest = (Map) object;

      PoHeader blanket = (PoHeader) incomingRequest.get("blanket");
      if (blanket == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException("Blanket Order was not Found.");
      }

      PoHeader newPoHeader = (PoHeader) incomingRequest.get("poHeader");
      if (newPoHeader == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException("Release Order was not Found.");
      }

      RequisitionHeader requisitionHeader =
          (RequisitionHeader) incomingRequest.get("requisitionHeader");
      if (requisitionHeader == null) {
        this.setStatus(Status.FAILED);
        throw new TsaException("Requisition was not Found!.");
      }

      if (blanket.getTaxCode().equals("SHIPTO")) {
        newPoHeader.setTaxCode(requisitionHeader.getShipToAddress().getAddrFld10());
      }

      incomingRequest.put("poHeader", newPoHeader);

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException("No currency Code found!");
    }

    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;
    Object result = null;

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

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

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

      if (incomingRequest.containsKey("PoLine_catalogId")
          && incomingRequest.containsKey("PoLine_itemNumber")) {
        String catalogId = (String) incomingRequest.get("PoLine_catalogId");
        String itemNumber = (String) incomingRequest.get("PoLine_itemNumber");
        if (!HiltonUtility.isEmpty(catalogId) && !HiltonUtility.isEmpty(itemNumber)) {
          BigDecimal leadDays =
              CatalogItemManager.getInstance().getLeadDays(organizationId, catalogId, itemNumber);
          incomingRequest.put("PoLine_poPromised", Dates.add(today, leadDays.intValue()));
        }
      }

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      Log.debug(this, e.getMessage());
      e.printStackTrace();
      throw e;
    }

    return result;
  }
Beispiel #23
0
  /* (non-Javadoc)
   * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
   */
  public int compare(Object objectOne, Object objectTwo) {
    String stringOne = (String) objectOne;
    String stringTwo = (String) objectTwo;
    if (stringOne == null && stringTwo == null) {
      return 0;
    } else if (stringOne == null || objectTwo == null) {
      return -1;
    } else {
      try {
        byte asciiBytes1[] = stringOne.getBytes("ASCII");
        byte asciiBytes2[] = stringTwo.getBytes("ASCII");

        int len1 = asciiBytes1.length;
        int len2 = asciiBytes2.length;

        if (len1 == len2) {
          int k = 0;

          while (k < len1) {
            byte b1 = asciiBytes1[k];
            byte b2 = asciiBytes2[k];

            if (b1 != b2) {
              return b1 - b2;
            }
            k++;
          }
          return 0;
        } else {
          return len1 - len2;
        }
      } catch (UnsupportedEncodingException e) {
        Log.error(this, e.getMessage());
      }

      return stringOne.compareTo(stringTwo);
    }
  }
Beispiel #24
0
 public Comparator getComparator(Object object) {
   Comparator compareTool = null;
   try {
     if (object instanceof Double) {
       compareTool = new DoubleComparator();
     }
     if (object instanceof Integer) {
       compareTool = new IntegerComparator();
     } else if (object instanceof String) {
       compareTool = new StringComparator();
     } else if (object instanceof Date) {
       compareTool = new DateComparator();
     } else if (object instanceof Boolean) {
       compareTool = new BooleanComparator();
     } else if (object instanceof BigDecimal) {
       compareTool = new BigDecimalComparator();
     } else {
       compareTool = new ObjectComparator();
     }
   } catch (Exception exception) {
     Log.error(this, exception.toString());
   }
   return compareTool;
 }
  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;
  }
Beispiel #26
0
 /**
  * Method executeTask.
  *
  * @param object
  *     <p>incomingRequest
  * @author EDSAC returns a copy of asset with tagNumber changed, trackingNumber "N/A" and status
  *     Pending in a list
  */
 public Object executeTask(Object object) throws Exception {
   Map incomingRequest = (Map) object;
   List assetList = new ArrayList();
   try {
     Asset asset = (Asset) incomingRequest.get("asset");
     Asset assetClon =
         new Asset(
             asset.getAssetClass(),
             asset.getSecurityCode(),
             asset.getCommodity(),
             asset.getManufacturer(),
             asset.getModel(),
             asset.getSerialNumber(),
             asset.getAssetCost(),
             asset.getDateInService(),
             asset.getDeprecMethod(),
             asset.getWarrantyStart(),
             asset.getWarrantyEnd(),
             asset.getUpgradeReqs(),
             asset.getContractService(),
             asset.getPurchaseOrder(),
             asset.getDateEntered(),
             asset.getAssetStatus(),
             asset.getAssetUdf1(),
             asset.getAssetUdf2(),
             asset.getAssetUdf3(),
             asset.getAssetUdf4(),
             asset.getAssetUdf5(),
             asset.getTotalCost(),
             asset.getIcText(),
             asset.getImageFile(),
             asset.getPoVendor(),
             asset.getContractorName(),
             asset.getOwner(),
             asset.getDeprecTerm(),
             asset.getDateReceived(),
             asset.getIcReceipt(),
             asset.getAssetUdf6(),
             asset.getAssetUdf7(),
             asset.getAssetUdf8(),
             asset.getAssetUdf9(),
             asset.getAssetUdf10(),
             asset.getIcLineKey(),
             asset.getItemNumber(),
             asset.getItemLocation(),
             asset.getIcAccount(),
             asset.getIcDsbHeader(),
             asset.getIcDsbLine(),
             asset.getLocalCurrencyPrice(),
             asset.getOriginalCost(),
             asset.getExitValue(),
             asset.getDateInactive(),
             asset.getLastChgBy(),
             asset.getDateChanged(),
             asset.getDescription(),
             asset.getLease(),
             asset.getLeaseType(),
             asset.getLeaseTerm(),
             asset.getMonthlyPayment(),
             asset.getLeasingCompany(),
             asset.getRenewalDate(),
             asset.getFinancing(),
             asset.getPrinted(),
             asset.getTrackingNumber(),
             asset.getFiscalYear());
     assetClon.setTagNumber(UniqueKeyGenerator.getInstance().getUniqueKey().toString());
     assetClon.setAssetStatus("Pending");
     assetClon.setTrackingNumber("N/A");
     assetList.add(assetClon);
   } catch (Exception e) {
     Log.error(this, e.toString());
     this.setStatus(Status.FAILED);
   }
   return assetList;
 }
  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;
  }
Beispiel #28
0
 public BuyerGraphData() {
   Log.debug(this, "started");
 }
  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 {
    Object ret = null;
    try {
      Map incomingRequest = (Map) object;
      boolean createReleaseFromReq =
          ((String) incomingRequest.get("createReleaseFromReq")).equals(String.valueOf(true));

      List requisitionLineList = (List) incomingRequest.get("requisitionLineList");
      List msgList = new ArrayList();

      if (requisitionLineList.size() > 0) { // items to create release for
        String recalculate = (String) incomingRequest.get("recalculate");
        if (recalculate == null) {
          recalculate = "N";
        }
        List newReleases = new ArrayList();
        RequisitionHeader rqh = (RequisitionHeader) incomingRequest.get("requisitionHeader");
        PoHeader blanket = (PoHeader) incomingRequest.get("blanket");
        Log.debug(this, "Release Request AutoRelease for req: " + rqh.getRequisitionNumber());
        Log.debug(this, "Release Request AutoRelease for blanket: " + blanket.getPoNumber());
        Log.debug(this, "AutoRelease recalculate: " + recalculate);

        Map newIncomingRequest = new HashMap();
        newIncomingRequest.put("blanket", blanket);
        newIncomingRequest.put("requisitionHeader", rqh);
        newIncomingRequest.put("RequisitionHeader_icReqHeader", rqh.getIcReqHeader().toString());

        newIncomingRequest.put("PoHeader_icPoHeader", blanket.getIcPoHeader().toString());

        newIncomingRequest.put("requisitionLineList", requisitionLineList);
        newIncomingRequest.put("createReleaseFromReq", "true");
        newIncomingRequest.put("Vendor_vendorId", blanket.getVendorId());
        newIncomingRequest.put("recalculate", recalculate);
        newIncomingRequest.put("createdfrom", this.createdFrom());

        newIncomingRequest.put("organizationId", incomingRequest.get("organizationId"));
        newIncomingRequest.put("userId", incomingRequest.get("userId"));
        newIncomingRequest.put("userTimeZone", incomingRequest.get("userTimeZone"));
        newIncomingRequest.put("dbsession", incomingRequest.get("dbsession"));
        newIncomingRequest.put("createReleaseFromReq", new Boolean(createReleaseFromReq));
        newIncomingRequest.put("forwardallowed", new Boolean(createReleaseFromReq));

        PuridiomProcessLoader processLoader = new PuridiomProcessLoader();

        PuridiomProcess process = processLoader.loadProcess("po-create-release-partial.xml");
        process.executeProcess(newIncomingRequest);
        if (process.getStatus() != Status.SUCCEEDED) {
          msgList.add("Items " + requisitionLineList + " could not be placed on Order! ");
        } else {
          PoHeader poHeader = (PoHeader) newIncomingRequest.get("poHeader");
          // msgList.add("Items " + requisitionLineList + " where Released on " +
          // OrderType.RELEASE_ORDER +
          //                 "# " + poHeader.getPoNumber() + "-" +
          // poHeader.getReleaseNumber().toString());
          newReleases.add(poHeader);
          AutoReleasedItemsSummary autoReleasedItems =
              new AutoReleasedItemsSummary(rqh, requisitionLineList, poHeader);
          autoReleasedItems.setPoNumber(poHeader.getPoNumber());
          autoReleasedItems.setReleaseNumber(poHeader.getReleaseNumber());
          // autoReleasedItems.setRqSubType(rqh.getRqSubType());
          autoReleasedItems.setRequisitionNumber(rqh.getRequisitionNumber());
          autoReleasedItems.setReleaseOrder(poHeader);
          msgList.add(autoReleasedItems);
          incomingRequest.put("PoHeader_icPoHeader", poHeader.getIcPoHeader().toString());
        }

        incomingRequest.put("releaseMessages", msgList);
        incomingRequest.put("poFromRelease", "Y");
        incomingRequest.put("releases", newReleases);

      } else {
        // rest of items should go through normal process.?????????
      }
      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
    }
    return super.executeTask(object);
  }