Package org.teiid.translator

Examples of org.teiid.translator.TranslatorException


    // we'll return in a ConnectorException
    try {
      ldapCtx.destroySubcontext(distinguishedName);
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailed",distinguishedName,ne.getExplanation()); //$NON-NLS-1$
      throw new TranslatorException(msg);
    // don't remember why I added this generic catch of Exception,
    // but it does no harm...
    } catch (Exception e) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailedUnexpected",distinguishedName); //$NON-NLS-1$
      throw new TranslatorException(e, msg);
    }
  }
View Full Code Here


      // get right expression - if it is not a literal we
      // can't handle that so throw an exception
      rightExpr = setClause.getValue();
      if (!(rightExpr instanceof Literal)) {
              final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.valueNotLiteralError",nameLeftElement); //$NON-NLS-1$
        throw new TranslatorException(msg);
    }
      valueRightExpr = ((Literal)rightExpr).getValue();
      // add in the modification as a replacement - meaning
      // any existing value(s) for this attribute will
      // be replaced by the new value.  If the attribute
      // didn't exist, it will automatically be created
      // TODO - since null is a valid attribute
      // value, we don't do any special handling of it right
      // now.  But maybe null should mean to delete an
      // attribute?
            updateMods[i] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(nameLeftElement, valueRightExpr));
    }
    // just try to update an LDAP entry using the DN and
    // attributes specified in the UPDATE operation.  If it isn't
    // legal, we'll get a NamingException back, whose explanation
    // we'll return in a ConnectorException
    try {
      ldapCtx.modifyAttributes(distinguishedName, updateMods);
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.updateFailed",distinguishedName,ne.getExplanation()); //$NON-NLS-1$
      throw new TranslatorException(msg);
    // don't remember why I added this generic catch of Exception,
    // but it does no harm...
    } catch (Exception e) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.updateFailedUnexpected",distinguishedName); //$NON-NLS-1$
      throw new TranslatorException(e, msg);
    }
  }
View Full Code Here

          LogManager.logDetail(LogConstants.CTX_CONNECTOR,  getLogPreamble(), "Executing Query:", finalQuery); //$NON-NLS-1$
          results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
        }
      }
    } catch (ResourceException e) {
      throw new TranslatorException(e);
    }
  }
View Full Code Here

          for(Iterator<Object[]> i = result.iterator(); i.hasNext(); ) {
            resultBatch.add(Arrays.asList(i.next()));
          }
        }
      } catch (ResourceException e) {
        throw new TranslatorException(e);
      }
    }
View Full Code Here

        } else {
          parent = parent.getParent();
          if(parent instanceof Table) {
            table = (Table)parent;
          } else {
            throw new TranslatorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
          }
        }
        if(table.getNameInSource().equals(sObjectName)) {
          Integer index = visitor.getSelectSymbolIndex(sObjectName + ':' + element.getNameInSource());
          // id gets dropped from the result if it is not the
          // first field in the querystring. Add it back in.
          if (null == index) {
            if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
              setElementValueInColumn(j, sObject.getElementsByTagName(SF_ID), row);
            } else {
              throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.missing.field")+ element.getNameInSource()); //$NON-NLS-1$
            }
          } else {
            Object cell;
            cell = sObject.getElementsByTagName("sf:" + element.getNameInSource()).item(0); //$NON-NLS-1$
            setElementValueInColumn(j, cell, row);
View Full Code Here

          // first field in the querystring. Add it back in.
          if (null == index) {
            if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
              setValueInColumn(j, sObject.getId(), result);
            } else {
              throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.missing.field")+ element.getNameInSource()); //$NON-NLS-1$
            }
          } else {
            Object cell;
            cell = getCellDatum(element, (Element)fields.get(index));
            setValueInColumn(j, cell, result);
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  private Object getCellDatum(Column element, Element elem) throws TranslatorException {
    if(!element.getNameInSource().equals(elem.getLocalName())) {
      throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.column.mismatch1") + element.getNameInSource() + SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.column.mismatch2") + elem.getLocalName()); //$NON-NLS-1$ //$NON-NLS-2$
    }
    String value = elem.getTextContent();
    Object result = null;
    Class type = element.getJavaType();
   
    if(type.equals(String.class)) {
      result = value;
    }
    else if (type.equals(Boolean.class)) {
      result = Boolean.valueOf(value);
    } else if (type.equals(Double.class)) {
      if (null != value) {
        if(!value.isEmpty()) {
          result = Double.valueOf(value);
        }
      }
    } else if (type.equals(Integer.class)) {
      if (null != value) {
        if(!value.isEmpty()) {
          result = Integer.valueOf(value);
        }
      }
    } else if (type.equals(java.sql.Date.class)) {
      if (null != value) {
        if(!value.isEmpty()) {
          result = java.sql.Date.valueOf(value);
        }
      }
    } else if (type.equals(java.sql.Timestamp.class)) {
      if (null != value) {
        if(!value.isEmpty()) {
          try {
            Date date = Util.getSalesforceDateTimeFormat().parse(value);
            result = new Timestamp(date.getTime());
          } catch (ParseException e) {
            throw new TranslatorException(e, SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.datatime.parse") + value); //$NON-NLS-1$
          }
        }
      }
    } else {
      result = value;
View Full Code Here

      ProcedureExecutionParent procedureExecutionParent) throws TranslatorException {
    this.parent = procedureExecutionParent;
    try {
      factory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
      throw new TranslatorException(e.getMessage());
    }
  }
View Full Code Here

      tempCalendar.setTime(endTime);
      XMLGregorianCalendar endCalendar = factory.newXMLGregorianCalendar(tempCalendar);
     
      deletedResult = parent.getConnection().getDeleted(objectName, startCalendar, endCalendar);
    } catch (ResourceException e) {
      throw new TranslatorException(e);
   
  }
View Full Code Here

      ProcedureExecutionParent procedureExecutionParent) throws TranslatorException {
    this.parent = procedureExecutionParent;
    try {
      factory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
      throw new TranslatorException(e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of org.teiid.translator.TranslatorException

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.