Package org.xmlBlaster.util.qos

Examples of org.xmlBlaster.util.qos.ClientProperty


      String[] colNames = row.getColumnNames();
      StringBuffer buf = new StringBuffer(256);
      buf.append(" SET ");
      boolean firstHit = true;
      for (int i=0; i < colNames.length; i++) {
         ClientProperty colContent = row.getColumn(colNames[i]);
         if (true) { // we need all entries
            searchEntries.add(colContent);
            if (firstHit)
               firstHit = false;
            else
View Full Code Here


            type == Types.STRUCT ||
            type == Types.VARBINARY);
   }

   private static String getVal(SqlDescription description, String key) {
      ClientProperty prop = description.getAttribute(key);
      if (prop == null)
         return null;
      return prop.getStringValue();
   }
View Full Code Here

         return null;
      return prop.getStringValue();
   }
  
   private static void setVal(SqlDescription description, String key, String val) {
      ClientProperty prop = description.getAttribute(key);
      if (prop == null)
         return;
      prop.setValue(val);
   }
View Full Code Here

         if (setSize < 1)
            throw new Exception("SqlDescription.update: could not update since the row did generate an empty set of columns to update. Row: " + newRow.toXml("") + " cols: " + toXml(""));
         if (parserForOld == null)
            throw new Exception("SqlDescription.update: the parser is null. It is needed to parse the old value");
        
         ClientProperty prop = newRow.getAttribute(ReplicationConstants.OLD_CONTENT_ATTR);
         if (prop == null || prop.getValueRaw() == null)
            throw new Exception("The attribute '" + ReplicationConstants.OLD_CONTENT_ATTR + "' was not defined for '" + newRow.toXml("") + "'");

         String xmlLiteral = OLD_PREFIX + prop.getStringValue() + OLD_POSTFIX;
         ByteArrayInputStream bais = new ByteArrayInputStream(xmlLiteral.getBytes());
         SqlInfo sqlInfo = parserForOld.parse(bais, this.charSet);
        
         // CONVERT
        
View Full Code Here

      }
     
      Iterator iter = this.attributeKeys.iterator();
      while (iter.hasNext()) {
         Object key = iter.next();
         ClientProperty prop = (ClientProperty)this.attributes.get(key);
         sb.append(prop.toXml(extraOffset + "  ", SqlInfoParser.ATTR_TAG));
         if (doTruncate && sb.length() > SqlInfo.MAX_BUF_SIZE) {
            sb.append(" ...");
            return sb.toString();
         }
      }
View Full Code Here

   public synchronized void update(String topic, InputStream is, Map attrMap) throws Exception {
      if (!this.isAlive) {
         throw new Exception("update topic='" + topic + "' happens when we not alive: \n");
      }
      try {
         ClientProperty dumpProp = (ClientProperty)attrMap.get(ReplicationConstants.DUMP_ACTION);
         ClientProperty endToRemoteProp = (ClientProperty)attrMap.get(ReplicationConstants.INITIAL_DATA_END_TO_REMOTE);
         ClientProperty initialDumpAsXml = (ClientProperty)attrMap.get(ReplicationConstants.INITIAL_DUMP_AS_XML);
         ClientProperty endOfTransition = (ClientProperty)attrMap.get(ReplicationConstants.END_OF_TRANSITION);
        
         if (dumpProp != null && initialDumpAsXml == null) { // initial dump (xml)
            this.writer.update(topic, is, attrMap);
         }
         else if (endToRemoteProp != null) { // initial dump, binary
            this.writer.update(topic, is, attrMap);
         }
         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);
               }
View Full Code Here

            Map attr = transformer.transform(queryRs, -1);
            if (attr != null) {
               Iterator iter = attr.entrySet().iterator();
               while (iter.hasNext()) {
                  Map.Entry entry = (Map.Entry)iter.next();
                  ClientProperty prop = new ClientProperty((String)entry.getKey(), null, null, entry.getValue().toString());
                  description.setAttribute(prop);
               }
            }
         }
         return true;
View Full Code Here

         Map attr = transformer.transform(rs, -1);
         if (attr != null) {
            Iterator iter = attr.entrySet().iterator();
            while (iter.hasNext()) {
               Map.Entry entry = (Map.Entry)iter.next();
               ClientProperty prop = new ClientProperty((String)entry.getKey(), null, null, entry.getValue().toString());
               description.setAttribute(prop);
            }
         }
      }
     
      if (fillData) {
         int count = 0;
         while (rs.next()) {
            SqlRow row = new SqlRow(this.info, count);
            count++;
            getRows().add(row);
            for (int i=1; i<=numberOfColumns; i++) {
               String value = rs.getString(i);
               ClientProperty prop = new ClientProperty(meta.getColumnName(i), null, null, value);
               row.setColumn(prop);
            }
            if (transformer != null) {
               Map attr = transformer.transform(rs, count);
               if (attr != null) {
                  Iterator iter = attr.entrySet().iterator();
                  while (iter.hasNext()) {
                     Map.Entry entry = (Map.Entry)iter.next();
                     ClientProperty prop = new ClientProperty((String)entry.getKey(), null, null, entry.getValue().toString());
                     row.setAttribute(prop);
                  }
               }
            }
         }
View Full Code Here

      int count = getRowCount();
      SqlRow row = new SqlRow(this.info, count);
      getRows().add(row);
      for (int i=1; i<=numberOfColumns; i++) {
         String value = rs.getString(i);
         ClientProperty prop = new ClientProperty(meta.getColumnName(i), null, null, value);
         row.setColumn(prop);
      }
      if (transformer != null) {
         Map attr = transformer.transform(rs, count);
         if (attr != null)
View Full Code Here

   public static ClientProperty buildClientProperty(ResultSetMetaData meta, ResultSet rs, int pos) throws Exception {
      String name = meta.getColumnName(pos);
      Object val = rs.getObject(pos);

      if (val == null)
         return new ClientProperty(name, null, null, (String)null);
      if (val instanceof String) // TODO FIX THIS DIRTY HACK
         return new ClientProperty(name, null, Constants.ENCODING_BASE64, (String)val);
     
      if (val instanceof Boolean)
         return new ClientProperty(name, null, null, "" + ((Boolean)val).booleanValue());

      if (val instanceof Short)
         return new ClientProperty(name, null, null, "" + ((Short)val).shortValue());

      if (val instanceof Integer)
         return new ClientProperty(name, null, null, "" + ((Integer)val).intValue());

      if (val instanceof Long)
         return new ClientProperty(name, null, null, "" + ((Long)val).longValue());

      if (val instanceof Float)
         return new ClientProperty(name, null, null, "" + ((Float)val).floatValue());
        
      if (val instanceof Double)
         return new ClientProperty(name, null, null, "" + ((Double)val).doubleValue());

      if (val instanceof byte[]) {
         ClientProperty prop = new ClientProperty(name, null, null);
         prop.setValue((byte[])val);
      }
      if (val instanceof Clob) { // only for relatively small clobs (< 10MB)
         try {
            Clob clob = (Clob)val;
            InputStream in = clob.getAsciiStream();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            // StringBuffer strBuf = new StringBuffer();
            byte[] buf = new byte[100000];
            int read = 0;
            int count=0;
            while (  (read=in.read(buf)) != -1) {
               baos.write(buf, 0, read);
               count++;
               if (count > 100)
                  throw new IllegalArgumentException("The clob '" + name + "' is too big, already exceeding 10 MB. Will stop processing it");
            }
            in.close();
            ClientProperty prop  = new ClientProperty(name, null, null);
            prop.setValue(new String(baos.toByteArray()));
            return prop;
         }
         catch (Exception ex) {
            throw new Exception("An exception occured when processing '" + name + "'", ex);
         }
      }
      if (val instanceof Blob) { // only for relatively small clobs (< 10MB)
         try {
            Blob blob = (Blob)val;
            InputStream in = blob.getBinaryStream();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            // StringBuffer strBuf = new StringBuffer();
            byte[] buf = new byte[100000];
            int read = 0;
            int count=0;
            while (  (read=in.read(buf)) != -1) {
               baos.write(buf, 0, read);
               count++;
               if (count > 100)
                  throw new IllegalArgumentException("The blob '" + name + "' is too big, already exceeding 10 MB. Will stop processing it");
            }
            in.close();
            ClientProperty prop  = new ClientProperty(name, null, null);
            prop.setValue(new String(baos.toByteArray()));
         }
         catch (Exception ex) {
            throw new Exception("An exception occured when processing '" + name + "'", ex);
         }
      }
      if (val instanceof Timestamp) {
         Timestamp ts = (Timestamp)val;
         return new ClientProperty(name, null, null, ts.toString());
      }
      if (val instanceof BigDecimal) {
         BigDecimal dec = (BigDecimal)val;
         try {
            return new ClientProperty(name, null, null, "" + dec.longValue());
         }
         catch (Exception ex) {
            return new ClientProperty(name, null, null, "" + dec.doubleValue());
         }
      }
      if (val instanceof BigInteger) {
         BigInteger dec = (BigInteger)val;
         return new ClientProperty(name, null, null, "" + dec.longValue());
      }
      if (val instanceof Date) {
         // Date date = (Date)val;
         Timestamp ts = rs.getTimestamp(pos);
         // DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         // String dateTxt = format.format(date);
         String dateTxt = ts.toString();
         return new ClientProperty(name, null, null, dateTxt);
      }
      if (val instanceof Time) {
         Time time = (Time)val;
         return new ClientProperty(name, null, null, "" + time.getTime());
      }
      else {
        
         if (val.getClass().getName().equals("oracle.sql.TIMESTAMP")) {
            Method meth = val.getClass().getMethod("timestampValue", null);
            Object obj = meth.invoke(val, null);
            if (obj instanceof Timestamp) {
               Timestamp ts = (Timestamp)obj;
               return new ClientProperty(name, null, null, ts.toString());
            }
            else {
               return new ClientProperty(name, null, null, rs.getString(pos)); // e.g. oracle.sql.TIMESTAMP containing a byte[]
            }
         }
         else
            return new ClientProperty(name, null, null, rs.getString(pos)); // e.g. oracle.sql.TIMESTAMP containing a byte[]
         //throw new Exception("The object '" + name + "' of type '" + val.getClass().getName() + "' can not be processed since this type is not implemented");
      }
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.qos.ClientProperty

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.