public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
   checkOpen();
   try {
     ((CallableStatement) _stmt).setCharacterStream(parameterName, reader);
   } catch (SQLException e) {
     handleException(e);
   }
 }
Пример #2
0
  @Override
  public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
    try {
      _cstmt.setCharacterStream(parameterName, reader);
    } catch (SQLException e) {
      onSqlException(e);

      throw e;
    } catch (RuntimeException e) {
      onRuntimeException(e);

      throw e;
    }
  }
 public void setCharacterStream(String parameterName, Reader reader, int length)
     throws SQLException {
   checkOpen();
   _stmt.setCharacterStream(parameterName, reader, length);
 }
Пример #4
0
  /** @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int) */
  public void setCharacterStream(int parameterIndex, Reader reader, int length)
      throws SQLException {

    original.setCharacterStream(parameterIndex, reader, length);
  }
Пример #5
0
  /** @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int) */
  public void setCharacterStream(String parameterName, Reader reader, int length)
      throws SQLException {

    original.setCharacterStream(parameterName, reader, length);
  }
  @Override
  public Object call() throws Exception {

    try {

      // Step 1

      /*
       * LOAD_AND_SPLIT(P_FILENAME IN CLOB, P_SPLIT varchar2 default 'Y',
       * P_FILE varchar2 default NULL, //new P_ERR_MSG OUT varchar2, P_MSG
       * OUT varchar2, P_TASK_ID_OUT OUT NUMBER, P_REF_E2B_MESSAGE_OUT OUT
       * VARCHAR2, P_USER_GROUP_OUT OUT VARCHAR2, //new P_USER_ID
       * varchar2, P_DISPLAY_OUTPUT VARCHAR2 DEFAULT 'N' ) return
       * varchar2;
       */

      String pRefE2bMsgOut = "";
      String errorMsgOut = "";
      String pTaskId = "";
      String pMsg = "";
      String userGroup = "";
      String userId = "primo";

      Connection con = null;
      con = ds.getConnection();
      log.info("Before auto commit: " + con.getAutoCommit());
      con.setAutoCommit(false);
      log.info("After auto commit: " + con.getAutoCommit());
      String sql = "{call ? := LAU_E2B_INBOUND.LOAD_AND_SPLIT(?,?,?,?,?,?,?,?,?,?)}"; // TOTAL
      // 11
      // parameters
      // including
      // the
      // return
      // value
      CallableStatement stmt = con.prepareCall(sql);
      stmt.registerOutParameter(1, OracleTypes.VARCHAR);
      log.info(
          "File Name: "
              + ReadConfig.getMessage().getString("folderWatchLocation")
              + "\\"
              + fileName);
      String fileContents =
          getFileContents(
              new File(ReadConfig.getMessage().getString("folderWatchLocation") + "\\" + fileName));
      stmt.setCharacterStream(
          2, new StringReader(fileContents), fileContents.length()); // P_FILENAME CLOB
      stmt.setString(3, "Y"); // P_SPLIT
      // stmt.setCharacterStream(4, new
      // StringReader(fileName),fileName.length());
      stmt.setString(4, fileName); // P_FILE FILE NAME
      stmt.registerOutParameter(5, OracleTypes.VARCHAR); // P_ERR_MSG
      stmt.registerOutParameter(6, OracleTypes.VARCHAR); // P_MSG
      stmt.registerOutParameter(7, OracleTypes.NUMBER); // P_TASK_ID_OUT
      stmt.registerOutParameter(8, OracleTypes.VARCHAR); // P_REF_E2B_MESSAGE_OUT
      stmt.registerOutParameter(9, OracleTypes.VARCHAR); // P_USER_GROUP_OUT
      stmt.setString(10, userId); // P_USER_ID
      stmt.setString(11, "N"); // P_DISPLAY_OUTPUT
      stmt.execute();

      // FUNCTION output
      int update = stmt.getInt(1);
      errorMsgOut = stmt.getString(5);
      pMsg = stmt.getString(6);
      pTaskId = stmt.getString(7);
      pRefE2bMsgOut = stmt.getString(8);
      userGroup = stmt.getString(9);

      log.info("Return UPDATE: " + update);
      log.info("Return P_MSG: " + pMsg);
      log.info("Return P_TASK_ID_OUT: " + pTaskId);
      log.info("Return P_REF_E2B_MESSAGE_OUT: " + pRefE2bMsgOut);
      log.info("Return P_USER_GROUP_OUT: " + userGroup);

      LauJobScheduler lauJobScheduler = new LauJobScheduler();
      lauJobScheduler.setTHREAD_ID(jobName);
      if (errorMsgOut != null) lauJobScheduler.setJOB_COMMENT(errorMsgOut);

      stmt.close();
      // update == 2 call import for each record
      // p-multi cases parameter must be
      // non sanofi - N
      if (update > 0) {
        // Update the Job Status to completed
        lauJobScheduler.setSTATUS("C");
        folderWatch.updateJobStatus(lauJobScheduler);

        // Step 2
        // if the FUNCTION returns success, get required details from
        // LAU_E2B_EXCHANGE_HISTORY
        sql =
            "SELECT E2B_EXCHANGE_ID,E2B_XML_FILE_NAME,E2B_MESSAGE_TYPE,XML_CONTENT_CLOB,E2B_PARTNER_ID,E2B_MESSAGENUMB "
                + "FROM LAU_E2B_EXCHANGE_HISTORY WHERE TASK_ID = "
                + pTaskId
                + " AND E2B_MESSAGE_TYPE != 'MULTI_CASES' AND REF_E2B_MESSAGENUMB = '"
                + pRefE2bMsgOut
                + "'";

        List<LauJobScheduler> results =
            getJdbcTemplate()
                .query(
                    sql,
                    new RowMapper<LauJobScheduler>() {
                      public LauJobScheduler mapRow(ResultSet rs, int i) throws SQLException {

                        LauJobScheduler jobScheduler = new LauJobScheduler();
                        jobScheduler.setE2B_EXCHANGE_ID(rs.getLong("E2B_EXCHANGE_ID"));
                        jobScheduler.setE2B_XML_FILE_NAME(rs.getString("E2B_XML_FILE_NAME"));
                        jobScheduler.setE2B_MESSAGE_TYPE(rs.getString("E2B_MESSAGE_TYPE"));
                        jobScheduler.setXML_CONTENT_CLOB(
                            clobToString(rs.getClob("XML_CONTENT_CLOB")));
                        jobScheduler.setE2B_PARTNER_ID(rs.getString("E2B_PARTNER_ID"));
                        jobScheduler.setE2B_MESSAGENUMB(rs.getString("E2B_MESSAGENUMB"));

                        return jobScheduler;
                      }
                    });

        // Iterate through results
        int cntrDoc = 1;
        for (LauJobScheduler jobScheduler : results) {

          log.info(jobScheduler.getE2B_EXCHANGE_ID() + " ---");
          log.info(jobScheduler.getE2B_XML_FILE_NAME() + " ---");
          log.info(jobScheduler.getE2B_MESSAGE_TYPE() + " ---");
          // log.info(jobScheduler.getXML_CONTENT_CLOB() + " ---");

          if (update == 1) { // 1 - Manual Import
            // Step 3
            // Create RTF from XML file contents
            InputStream is =
                new ByteArrayInputStream(jobScheduler.getXML_CONTENT_CLOB().getBytes());
            StreamSource source = new StreamSource(new InputStreamReader(is));
            StreamSource transformSource =
                new StreamSource(E2BFileOutput.class.getResourceAsStream("/E2Bstyle.xsl"));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Result result = new StreamResult(baos);

            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer(transformSource);
            transformer.transform(source, result);

            // Step 4
            // SharePoint file upload
            String sharePointTitle = "";
            if (jobScheduler.getE2B_MESSAGE_TYPE().equalsIgnoreCase("FRAGMENT")) {
              sharePointTitle =
                  jobScheduler
                          .getE2B_XML_FILE_NAME()
                          .substring(0, jobScheduler.getE2B_XML_FILE_NAME().lastIndexOf("."))
                      + "-"
                      + cntrDoc
                      + ".rtf";
            } else {
              sharePointTitle =
                  jobScheduler
                          .getE2B_XML_FILE_NAME()
                          .substring(0, jobScheduler.getE2B_XML_FILE_NAME().lastIndexOf("."))
                      + ".rtf";
            }

            SPResponse sPResponse =
                GroupInboxService.uploadToGroupInbox(userGroup, sharePointTitle, baos);
            cntrDoc++;
            // If true, file uploaded to SharePoint
            if (sPResponse.getSuccess().length() > 0) {
              if (Boolean.valueOf(sPResponse.getSuccess())) {

                log.info("Success " + Boolean.valueOf(sPResponse.getSuccess()));
                log.info("sPResponse.getFileId() -> " + sPResponse.getFileId());
                log.info("sPResponse.getMessage() -> " + sPResponse.getMessage());
                log.info("sPResponse.getFileName() -> " + sPResponse.getFileName());
                log.info("sPResponse.getFileUrl() -> " + sPResponse.getFileUrl());

                // Step 5
                // insert to LAU_EXTERNAL_DOCUMENTS
                ExternalDocuments externalDocs = new ExternalDocuments();
                externalDocs.setStatus("New");
                externalDocs.setUser(ReadConfig.getMessage().getString("systemUser"));
                externalDocs.setDstamp(CommonDAO.getTimestamp(getJdbcTemplate()));
                externalDocs.setDocumentName(sPResponse.getFileName());
                externalDocs.setDocumentTitle(sharePointTitle);
                externalDocs.setRejectReason("");
                externalDocs.setDocDescription(
                    "File Uploaded By " + ReadConfig.getMessage().getString("systemUser"));
                externalDocs.setObjectID(sPResponse.getFileId());
                externalDocs.setFileID(sPResponse.getFileId());
                externalDocs.setFileURL(sPResponse.getFileUrl());
                externalDocs.setGroupID(userGroup);
                externalDocs.setE2bExchangeId(jobScheduler.getE2B_EXCHANGE_ID());
                externalDocs.setE2B_PARTNER_ID(jobScheduler.getE2B_PARTNER_ID());
                externalDocs.setE2B_MESSAGENUMB(jobScheduler.getE2B_MESSAGENUMB());
                int rtn = insertDocumentStatus(externalDocs);
                log.info("Return from insertDocumentStatus(externalDocs) -> " + rtn);
              }
            }
          } else if (update == 2) // import each message
          {
            importE2bData(userId, Long.toString(jobScheduler.getE2B_EXCHANGE_ID()));
          }
        }

        boolean fileDeleteStatus =
            folderWatch.fileDelete(
                new File(
                    ReadConfig.getMessage().getString("folderWatchLocation") + "\\" + fileName));
        log.info("File delete status: " + fileDeleteStatus);

      } else {
        // Update the Job Status to error
        lauJobScheduler.setSTATUS("E");
        folderWatch.updateJobStatus(lauJobScheduler);
      }

    } catch (Exception e) {
      log.error(e);
      // Update the Job Status to error
      LauJobScheduler lauJobScheduler = new LauJobScheduler();
      lauJobScheduler.setSTATUS("E");
      lauJobScheduler.setJOB_COMMENT(e.toString());
      folderWatch.updateJobStatus(lauJobScheduler);
    }

    return null;
  }
 public void setCharacterStream(String parameterName, Reader reader, int length)
     throws SQLException {
   checkOpen();
   ((CallableStatement) _stmt).setCharacterStream(parameterName, reader, length);
 }
 public void setCharacterStream(String parameterName, Reader reader, long length)
     throws SQLException {
   passThru.setCharacterStream(parameterName, reader, length);
 }
Пример #9
0
 public void bind(VariableTable vt) throws java.sql.SQLException {
   int rows;
   Object val;
   try {
     stmt.clearParameters();
   } catch (java.sql.SQLException sqle) {
   }
   if (paramNames.length > 0) {
     for (rows = 0; rows < paramNames.length; rows++) {
       val = vt.getValue(paramNames[rows]);
       if (paramTypes[rows].equals("IN")) {
         if (val == null) stmt.setNull(rows + 1, 1);
         else {
           if (vt.getType(paramNames[rows]) != java.sql.Types.LONGVARCHAR
               && vt.getType(paramNames[rows]) != java.sql.Types.LONGVARBINARY)
             stmt.setObject(rows + 1, val);
           else if (vt.getType(paramNames[rows]) == java.sql.Types.LONGVARCHAR) {
             java.io.StringReader long_var = new java.io.StringReader(val.toString());
             stmt.setCharacterStream(rows + 1, long_var, 16384);
             // long_var.close();
           } else if (vt.getType(paramNames[rows]) == java.sql.Types.LONGVARBINARY) {
             java.io.File os_file = new java.io.File(val.toString());
             if (os_file.exists() && os_file.isFile() && os_file.canRead()) {
               try {
                 java.io.FileInputStream long_var = new java.io.FileInputStream(os_file);
                 stmt.setBinaryStream(rows + 1, long_var, 16384);
                 // long_var.close();
               } catch (java.io.IOException ioe) {
               }
             } else stmt.setNull(rows + 1, 1);
           }
         }
       } else if (paramTypes[rows].equals("OUT")) {
         stmt.registerOutParameter(rows + 1, vt.getType(paramNames[rows]));
       } else if (paramTypes[rows].equals("INOUT")) {
         if (val == null) stmt.setNull(rows + 1, 1);
         else {
           if (vt.getType(paramNames[rows]) != java.sql.Types.LONGVARCHAR
               && vt.getType(paramNames[rows]) != java.sql.Types.LONGVARBINARY)
             stmt.setObject(rows + 1, val);
           else if (vt.getType(paramNames[rows]) != java.sql.Types.LONGVARCHAR) {
             java.io.StringReader long_var = new java.io.StringReader(val.toString());
             stmt.setCharacterStream(rows + 1, long_var, 16384);
             // long_var.close();
           } else if (vt.getType(paramNames[rows]) != java.sql.Types.LONGVARBINARY) {
             java.io.File os_file = new java.io.File(val.toString());
             if (os_file.exists() && os_file.isFile() && os_file.canRead()) {
               try {
                 java.io.FileInputStream long_var = new java.io.FileInputStream(os_file);
                 stmt.setBinaryStream(rows + 1, long_var, 16384);
                 // long_var.close();
               } catch (java.io.IOException ioe) {
               }
             } else stmt.setNull(rows + 1, 1);
           }
         }
         stmt.registerOutParameter(rows + 1, vt.getType(paramNames[rows]));
       }
     }
   }
 }