Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see com.tsagate.foundation.processengine.ITask#executeTask(java.lang.Object)
   */
  public Object executeTask(Object object) throws Exception {
    Object ret = "";
    try {
      Map incomingRequest = (Map) object;

      String organizationId = (String) incomingRequest.get("organizationId");
      String path =
          DictionaryManager.getInstance("host", organizationId).getProperty("reportsPath", "");
      String reportName = (String) incomingRequest.get("reportName");

      Map parameters = new HashMap();
      parameters.put("reportTitle", "Requisition Line Report");
      String userId = (String) incomingRequest.get("userId");
      parameters.put("userId", userId);
      DBSession session = (DBSession) incomingRequest.get("dbsession");
      Connection con = session.getSqlConnection();

      String filePath = path + reportName + ".jasper";
      // JasperDesign jasperDesign = JasperManager.loadXmlDesign(filePath);
      // JasperReport jasperReport = JasperManager.compileReport(jasperDesign);
      JasperReport jasperReport = JasperManager.loadReport(filePath);
      JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, parameters, con);

      // JasperCompileManager.compileReportToFile(filePath);
      // filePath = path + "requisition-line.jasper";
      // JasperFillManager.fillReportToFile(filePath, parameters, con);

      // filePath = path + "requisitionLine.pdf";
      // JasperExportManager.exportReportToPdfFile(filePath);

      // You can use JasperPrint to create PDF
      UniqueKeyGenerator ukg = UniqueKeyGenerator.getInstance();
      String nameIt = ukg.getUniqueKey().toString();
      filePath =
          DictionaryManager.getInstance("host", organizationId).getProperty("reportsOut", "")
              + nameIt
              + ".pdf";
      JasperManager.printReportToPdfFile(jasperPrint, filePath);
      ret = nameIt + ".pdf";
      this.setStatus(Status.SUCCEEDED);
    } catch (Exception e) {
      this.setStatus(Status.FAILED);
      throw new TsaException(this.getName(), e);
    }
    return ret;
  }
Ejemplo n.º 2
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;
 }