예제 #1
0
  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;
  }
예제 #2
0
  /** @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();
    }
  }
  /**
   * 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;
  }
  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;
  }
예제 #5
0
  /* (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;
  }
예제 #6
0
 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());
   }
 }
 /**
  * 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;
   }
 }
예제 #8
0
  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
    }
  }
예제 #9
0
  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;
  }
  /**
   * 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;
  }
예제 #11
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;
  }
예제 #14
0
  /**
   * 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();
  }
예제 #15
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);
    }
  }
예제 #16
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;
 }
  /* (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 userDateFormat = (String) incomingRequest.get("userDateFormat");
      PropertiesManager propertiesManager = PropertiesManager.getInstance(organizationId);
      CatalogSecurity catalogSecurity = (CatalogSecurity) incomingRequest.get("catalogSecurity");
      String isCatalog = HiltonUtility.ckNull((String) incomingRequest.get("isCatalog"));
      String catalogId = (String) catalogSecurity.getCatalogId();
      String accesType = (String) catalogSecurity.getAccessType();
      String accessId = (String) catalogSecurity.getAccessId();

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

      String today = Dates.today(userDateFormat, (String) incomingRequest.get("userTimeZone"));

      if (isCatalog.equalsIgnoreCase("V")) {
        DBSession dbs = (DBSession) incomingRequest.get("dbsession");

        String queryString =
            "from CatalogSecurity as cs "
                + "where cs.catalogId = ? and cs.itemNumber != '0' "
                + "and cs.accessType = ? ";

        List resultList =
            dbs.query(
                queryString,
                new Object[] {catalogId, accesType},
                new Type[] {Hibernate.STRING, Hibernate.STRING});

        if (resultList != null && resultList.size() > 0) {
          for (int i = 0; i < resultList.size(); i++) {
            CatalogSecurity catalogItemSecurity = (CatalogSecurity) resultList.get(i);

            if (!accessId.equalsIgnoreCase(catalogItemSecurity.getAccessId())) {
              PuridiomProcessLoader processLoader =
                  new PuridiomProcessLoader((String) incomingRequest.get("organizationId"));
              PuridiomProcess process = processLoader.loadProcess("catalogsecurity-add.xml");

              Map updateParameters = new HashMap();

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

              updateParameters.put(
                  "CatalogSecurity_catalogId", (String) catalogSecurity.getCatalogId());
              updateParameters.put(
                  "CatalogSecurity_itemNumber", (String) catalogItemSecurity.getItemNumber());
              updateParameters.put(
                  "CatalogSecurity_accessType", (String) catalogSecurity.getAccessType());
              updateParameters.put(
                  "CatalogSecurity_accessId", (String) catalogSecurity.getAccessId());
              updateParameters.put("CatalogSecurity_owner", (String) catalogSecurity.getOwner());
              updateParameters.put("CatalogSecurity_dateEntered", today);
              updateParameters.put("CatalogSecurity_dateChanged", today);
              updateParameters.put(
                  "CatalogSecurity_lastChangedBy", (String) catalogSecurity.getCatalogId());

              process.executeProcess(updateParameters);

              catalogSecurity.setAccessId(accessId);

              dbs.add(catalogSecurity);
              if (dbs.getStatus() != Status.SUCCEEDED) {
                throw new TsaException(
                    "error ocurred at update catalog security from  for "
                        + catalogSecurity.getItemNumber());
              }
            }
          }
        }
      }

      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      Log.error(this, "An Error occurred at CatalogItemSecurityAddFromCatalog" + e);
      e.printStackTrace();
      throw e;
    }
    return result;
  }
예제 #18
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;
 }