Package org.xmlBlaster.contrib.dbwriter.info

Examples of org.xmlBlaster.contrib.dbwriter.info.SqlInfo


   /**
    * @see org.xmlBlaster.contrib.replication.I_DbSpecific#getContentFromGuid(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    */
   public String getContentFromGuid(String guid, String catalog, String schema, String table, I_AttributeTransformer transformer) throws Exception {
      // throw new Exception("SpecificOracle.getContentFromGuid is not implemented yet for table='" + table + "' and guid='" + guid + "'");
      SqlInfo obj = new SqlInfo(this.info);
      Connection conn = null;
      Statement st = null;
      String completeTable = schema;
      if (completeTable != null)
         completeTable += "." + table;
      else
         completeTable = table;
      try {
         conn = this.dbPool.reserve();
         st = conn.createStatement();
         String sql = "select * from " + completeTable + " WHERE rowid=CHARTOROWID('" + guid + "')";
         ResultSet rs = st.executeQuery(sql);
         if (rs.next()) {
            obj.fillOneRowWithObjects(rs, transformer);
            SqlRow row = (SqlRow)obj.getRows().get(0);
            rs.close();
            return row.toXml("", false);
         }
         else {
            log.severe("The entry guid='" + guid + "' for table '" + completeTable + "' was not found (anymore)");
View Full Code Here


         }
         else if (endOfTransition != null) { // initial dum, binary, ready to import from file system (last file part arrived)
            this.writer.update(topic, is, attrMap);
         }
         else { // replication xml, build an SqlInfo from XML
            SqlInfo updateInfo = this.parser.parse(is, this.charSet);
            if (updateInfo == null) {
               log.warning("The entry was not for us");
               return;
            }
            ClientProperty keepTransactionOpenProp = (ClientProperty)attrMap.get(ReplicationConstants.KEEP_TRANSACTION_OPEN);
            if (keepTransactionOpenProp != null && keepTransactionOpenProp.getBooleanValue()) {
               // is the property already set ? No, then pass it to the info object
               if (updateInfo.getDescription().getAttribute(ReplicationConstants.KEEP_TRANSACTION_OPEN) == null) {
                  log.fine("Setting the property '" + ReplicationConstants.KEEP_TRANSACTION_OPEN + "' to true");
                  updateInfo.getDescription().setAttribute(keepTransactionOpenProp);
               }
               else
                  log.warning("The property '" + ReplicationConstants.KEEP_TRANSACTION_OPEN + "' was already set as a description attribute (will not overwrite it)");
            }
            this.writer.store(updateInfo);
View Full Code Here

    *
    */
   public byte[] replace(byte[] oldContent, Map clientProperties) {
      if (!this.initialDumpAsXml)
      return oldContent;
      SqlInfo sqlInfo = new SqlInfo(this.info);
      SqlDescription description = new SqlDescription(this.info);
      description.setCommand(INITIAL_XML_CMD);
      ClientProperty prop = (ClientProperty)clientProperties.get(FILENAME_ATTR);
     
      if (prop != null)
         description.setAttribute(prop);
      prop = (ClientProperty)clientProperties.get(TIMESTAMP_ATTR);
     
      if (prop != null)
         description.setAttribute(prop);

      prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_SEQ, clientProperties);
      if (prop != null) {
         prop = new ClientProperty(XBConnectionMetaData.JMSX_GROUP_SEQ, null, null, prop.getStringValue());
         description.setAttribute(prop);
      }
     
      prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_EOF, clientProperties);
      if (prop != null) {
         prop = new ClientProperty(XBConnectionMetaData.JMSX_GROUP_EOF, null, null, prop.getStringValue());
         description.setAttribute(prop);
      }
     
      prop = XBMessage.get(XBConnectionMetaData.JMSX_GROUP_EX, clientProperties);
      if (prop != null) {
         prop = new ClientProperty(XBConnectionMetaData.JMSX_GROUP_EX, null, null, prop.getStringValue());
         description.setAttribute(prop);
      }
     
      prop = new ClientProperty(DUMP_CONTENT_ATTR, oldContent);
      description.setAttribute(prop);
      sqlInfo.setDescription(description);
      String ret = sqlInfo.toXml("");
      if (log.isLoggable(Level.FINEST))
         log.finest(ret);
      return ret.getBytes();
   }
View Full Code Here

    * @param conn
    * @return
    * @throws Exception
    */
   private synchronized SqlDescription getTableDescription(String catalog, String schema, String tableName, Connection conn) throws Exception {
      SqlInfo sqlInfo = getTableDescriptionFromCache(catalog, schema, tableName);
      if (sqlInfo == null) {
         sqlInfo = new SqlInfo(this.info);
         if (sqlInfo.fillMetadata(conn, catalog, schema, tableName, null, null))
            addToSqlInfoCache(sqlInfo);
      }
      return sqlInfo.getDescription();
   }
View Full Code Here

      sendEndOfTransitionMessage(info, session, null, null, dumpId, producer);
   }
  
   public void sendEndOfTransitionMessage(I_Info info, XBSession session, String initialFilesLocation, String shortFilename, String dumpId, XBMessageProducer producer) throws JMSException {
      TextMessage  endMsg = session.createTextMessage();
      SqlInfo sqlInfo = new SqlInfo(info);
      SqlDescription description = new SqlDescription(info);

      description.setAttribute(END_OF_TRANSITION , "" + true);
      endMsg.setBooleanProperty(END_OF_TRANSITION , true);
      description.setAttribute(FILENAME_ATTR, shortFilename);
      endMsg.setStringProperty(FILENAME_ATTR, shortFilename);
      if (initialFilesLocation != null) {
         description.setAttribute(INITIAL_FILES_LOCATION, initialFilesLocation);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         description.setAttribute(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
      }
      sqlInfo.setDescription(description);
      endMsg.setText(sqlInfo.toXml(""));
      producer.send(endMsg);
   }
View Full Code Here

   public void setOutputStream(OutputStream out, String command, String ident, ChangeEvent event) throws Exception {
      this.out = out;
      size = 0;
      this.transactionId = null;
      this.allTransactions.clear();
      this.sqlInfo = new SqlInfo(this.info);
      SqlDescription description = new SqlDescription(this.info);
      description.setCommand(REPLICATION_CMD);
      if (ident != null)
         description.setIdentity(ident);
      this.sqlInfo.setDescription(description);
View Full Code Here

      "</sql>\n";

     
      SqlInfoParser parser = new SqlInfoParser();
      parser.init(this.info);
      SqlInfo record = parser.parse(xml);

      SqlDescription description = record.getDescription();
      assertNotNull("the description shall not be null", description);
      assertNotNull("the identity shall not be null", description.getIdentity());
      assertNotNull("the command shall not be null", description.getCommand());

      assertEquals("the identity content is wrong", "EDDI", description.getIdentity());
      assertEquals("the command content is wrong", "INSERT", description.getCommand());

      // test the column descriptions
      SqlColumn[] colDescriptions = description.getColumns();
      assertEquals("the number of column descriptions is wrong", 4, colDescriptions.length);
      String[] names = new String[] { "DATUM", "CPU", "COL1", "ICAO_ID"};
      for (int i=0; i < colDescriptions.length; i++) {
         log.info("test column description #" + i + " names: '" + names[i] + "' and '" + colDescriptions[i].getColName() + "'");
         assertEquals("the name of the column description #" + i + " is wrong", names[i], colDescriptions[i].getColName());
      }
     
      List rows = record.getRows();
      assertEquals("the number of rows is wrong", 3, rows.size());
      int[] attr = new int[] { 2, 0, 1 };
      for (int i=0; i < 3; i++) {
         SqlRow row = (SqlRow)rows.get(i);
         assertEquals("wrong number of columns for row '" + i+ "'", 4, row.getColumnNames().length);
         assertEquals("wrong number of attributes for row '" + i+ "'", attr[i], row.getAttributeNames().length);
      }
     
      System.out.println("\n\nshould be:\n" + xml);
      System.out.println("\nis:\n" + record.toXml(""));
      assertXMLEqual("output xml is not the same as input xml", xml, record.toXml(""));
      //assertXpathNotExists("/myRootTag/row[@num='0']", xml);
      //assertXpathEvaluatesTo("CREATE", "/myRootTag/desc/command/text()", xml);
      log.info("SUCCESS");
   }
View Full Code Here

         // is = new InputSource(new FileInputStream(xmlFileName));
         is = new FileInputStream(xmlFileName);
        
      }
      String charSet = System.getProperty("charSet", null);
      SqlInfo record = parser.parse(is, charSet);
      SqlDescription description = record.getDescription();
      assertNotNull("the description shall not be null", description);
      assertNotNull("the identity shall not be null", description.getIdentity());
      assertNotNull("the command shall not be null", description.getCommand());

      assertEquals("the identity content is wrong", "EDDI", description.getIdentity());
      assertEquals("the command content is wrong", "INSERT", description.getCommand());

      // test the column descriptions
      SqlColumn[] colDescriptions = description.getColumns();
      assertEquals("the number of column descriptions is wrong", 4, colDescriptions.length);
      String[] names = new String[] { "DATUM", "CPU", "COL1", "ICAO_ID"};
      for (int i=0; i < colDescriptions.length; i++) {
         log.info("test column description #" + i + " names: '" + names[i] + "' and '" + colDescriptions[i].getColName() + "'");
         assertEquals("the name of the column description #" + i + " is wrong", names[i], colDescriptions[i].getColName());
      }
     
      List rows = record.getRows();
      assertEquals("the number of rows is wrong", 3, rows.size());
      int[] attr = new int[] { 2, 0, 1 };
      for (int i=0; i < 3; i++) {
         SqlRow row = (SqlRow)rows.get(i);
         assertEquals("wrong number of columns for row '" + i+ "'", 4, row.getColumnNames().length);
         assertEquals("wrong number of attributes for row '" + i+ "'", attr[i], row.getAttributeNames().length);
      }
     
      System.out.println("\n\nshould be:\n" + xml);
      System.out.println("\nis:\n" + record.toXml(""));
      assertXMLEqual("output xml is not the same as input xml", xml, record.toXml(""));
      //assertXpathNotExists("/myRootTag/row[@num='0']", xml);
      //assertXpathEvaluatesTo("CREATE", "/myRootTag/desc/command/text()", xml);
      log.info("SUCCESS");
   }
View Full Code Here

                   "  </row>\n" +
               "</sql>\n";
     
      SqlInfoParser parser = new SqlInfoParser();
      parser.init(this.info);
      SqlInfo record = parser.parse(xml);
      log.info(record.toXml(""));
     
      xml = "" +
      "<?xml version='1.0' encoding='UTF-8' ?>\n" +
      "<sql>\n" +
      "  <row num='0'>\n" +
      "    <col name='TEST'>100</col>\n" +
      "    <attr name='oldContent' encoding='forcePlain'><col name='TEST' encoding='base64'>Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj5MVEQgICBSQUZJUzw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8</col></attr>" +
      "    <attr name='test1' encoding='forcePlain'><col name='test2'><![CDATA[>>>>>>>>>>>>>>>>>>>>>>>>>>LTD RAFIS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]]></col></attr>" +
      "  </row>\n" +
      "</sql>\n";

      record = parser.parse(xml);
      log.info(record.toXml(""));
     
     
      log.info("SUCCESS");
   }
View Full Code Here

         try {
            String oldName = "COM_RECORDID";
            String newName = "COM_MESSAGEID";
            SqlInfoParser  parser = new SqlInfoParser();
            parser.init(info);
            SqlInfo sqlInfo = parser.parse(xmlTxt);
            List rows = sqlInfo.getRows();
            assertEquals("The number of rows is wrong", 1, rows.size());
            SqlRow row = (SqlRow)rows.get(0);
            log.info(row.toXml(""));
            row.renameColumn(oldName, newName);
            log.info(row.toXml(""));
View Full Code Here

TOP

Related Classes of org.xmlBlaster.contrib.dbwriter.info.SqlInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.