Package org.teiid.translator

Examples of org.teiid.translator.TranslatorException


    @Override
    public void visit( Like criteria ) {
        try {
            if (isIdColumn(criteria.getLeftExpression())) {
                TranslatorException e = new TranslatorException(SalesForcePlugin.Util.getString("CriteriaVisitor.LIKE.not.supported.on.Id")); //$NON-NLS-1$
                exceptions.add(e);
            }
            if (isMultiSelectColumn(criteria.getLeftExpression())) {
                TranslatorException e = new TranslatorException(SalesForcePlugin.Util.getString("CriteriaVisitor.LIKE.not.supported.on.multiselect")); //$NON-NLS-1$
                exceptions.add(e);
            }
        } catch (TranslatorException e) {
            exceptions.add(e);
        }
View Full Code Here


        criteriaList.add(result.toString());
    }

    private void validateFunction( List<Expression> expressions ) throws TranslatorException {
        if (expressions.size() != 2) {
            throw new TranslatorException(SalesForcePlugin.Util.getString("CriteriaVisitor.invalid.arg.count")); //$NON-NLS-1$
        }
        if (!(expressions.get(0) instanceof ColumnReference)) {
            throw new TranslatorException(SalesForcePlugin.Util.getString("CriteriaVisitor.function.not.column.arg")); //$NON-NLS-1$
        }
        if (!(expressions.get(1) instanceof Literal)) {
            throw new TranslatorException(SalesForcePlugin.Util.getString("CriteriaVisitor.function.not.literal.arg")); //$NON-NLS-1$
        }
    }
View Full Code Here

    protected void loadColumnMetadata( NamedTable group ) throws TranslatorException {
        table = group.getMetadataObject();
        String supportsQuery = table.getProperties().get("Supports Query"); //$NON-NLS-1$
        if (!Boolean.valueOf(supportsQuery)) {
            throw new TranslatorException(table.getNameInSource() + " " + SalesForcePlugin.Util.getString("CriteriaVisitor.query.not.supported")); //$NON-NLS-1$ //$NON-NLS-2$
        }
        List<Column> columnIds = table.getColumns();
        for (Column element : columnIds) {
            // influences queryAll behavior
            if (element.getNameInSource().equals("IsDeleted")) { //$NON-NLS-1$
View Full Code Here

  // right now in the connector capabilities
  private String getDNFromCriteria(Condition criteria)
      throws TranslatorException {
    if (criteria == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaEmptyError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    if (!(criteria instanceof Comparison)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotSimpleError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Comparison compareCriteria = (Comparison)criteria; 
    if (compareCriteria.getOperator() != Operator.EQ) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotEqualsError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression leftExpr = compareCriteria.getLeftExpression();
    if (!(leftExpr instanceof ColumnReference)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaLHSNotElementError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    // call utility method to get NameInSource/Name for element
    String nameLeftExpr = getNameFromElement((ColumnReference)leftExpr);
    if (!(nameLeftExpr.toUpperCase().equals("DN"))) {   //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaSrcColumnError",nameLeftExpr); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression rightExpr = compareCriteria.getRightExpression();
    if (!(rightExpr instanceof Literal)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaRHSNotLiteralError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Object valueRightExpr = ((Literal)rightExpr).getValue();
    if (!(valueRightExpr instanceof java.lang.String)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaRHSNotStringError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    return (String)valueRightExpr;
  }
View Full Code Here

      // Only one table is expected here.
      List<TableReference> fromList = query.getFrom();
      Iterator<TableReference> itr = fromList.iterator();
      if(!itr.hasNext()) {
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.noTablesInFromError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
      }
      TableReference fItm = itr.next();
      if(itr.hasNext()) {
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.multiItemsInFromError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
      }
      String contextName = getContextNameFromFromItem(fItm);
      int searchScope = getSearchScopeFromFromItem(fItm);
      // GHH 20080326 - added check for RESTRICT parameter in
      // NameInSource of from item
      String classRestriction = getRestrictToNamedClass(fItm);
         
      // Parse the WHERE clause.
      // Create an equivalent LDAP search filter.
      List<String> searchStringList = new LinkedList<String>();
      searchStringList = getSearchFilterFromWhereClause(query.getWhere(), searchStringList);
      StringBuilder filterBuilder = new StringBuilder();
      for (String string : searchStringList) {
        filterBuilder.append(string);
      }
      // GHH 20080326 - if there is a class restriction,
      // add it to the search filter
      if (classRestriction != null && classRestriction.trim().length()>0) {
        filterBuilder.insert(0, "(&").append("(objectClass=").append(classRestriction).append("))")//$NON-NLS-1$  //$NON-NLS-2$  //$NON-NLS-3$
      }
     
      // Parse the ORDER BY clause.
      // Create an ordered sort list.
      OrderBy orderBy = query.getOrderBy();
      // Referenced the JNDI standard...arguably, this should not be done inside this
      // class, and we should make our own key class. In practice, this makes things simpler.
      SortKey[] sortKeys = getSortKeysFromOrderByClause(orderBy);
     
      // Parse LIMIT clause.
      // Note that offsets are not supported.
      Limit limit = query.getLimit();
      long countLimit = -1;
      if(limit != null) {
        countLimit = limit.getRowLimit();
      }
     
      // Create Search Details
      LDAPSearchDetails sd = new LDAPSearchDetails(contextName, searchScope, filterBuilder.toString(), attributeList, sortKeys, countLimit, elementList);
      // Search Details logging
      try {
        sd.printDetailsToLog();
      } catch (NamingException nme) {
        final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.searchDetailsLoggingError")//$NON-NLS-1$
        throw new TranslatorException(msg);
      }
     
      return sd;
     
  }
View Full Code Here

      if(contextName.equals("")) {  //$NON-NLS-1$
        contextName = this.executionFactory.getSearchDefaultBaseDN();
      }
    } else {
            final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.groupCountExceededError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    // if the context name is not specified either in Name in Source
    // or in the default connector properties it'll be either
    // null or an empty string
    if(contextName == null || contextName.equals("")) { //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.baseContextNameError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    return contextName;

  }
View Full Code Here

          namedClass = mdIDGroup.getName();
        }
      }
    } else {
            final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.groupCountExceededError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    return namedClass;
  }
View Full Code Here

      } else if(searchScopeString.equals("OBJECT_SCOPE")) {  //$NON-NLS-1$
        searchScope = SearchControls.OBJECT_SCOPE;
      }
    } else {
            final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.groupCountExceededError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    return searchScope;
  }
View Full Code Here

        return "&";   //$NON-NLS-1$
      case OR:
        return "|"; //$NON-NLS-1$
      default:
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.criteriaNotParsableError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
    }
  }
View Full Code Here

        else {
          expressionName = ((Literal)e).getValue().toString();
        }
      } catch (ClassNotFoundException cce) {
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.timestampClassNotFoundError"); //$NON-NLS-1$
        throw new TranslatorException(cce, msg);
      }
       
    } else {
      if(e instanceof AggregateFunction) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IAggregate, but it is not supported. Check capabilities."); //$NON-NLS-1$
      } else if(e instanceof Function) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IFunction, but it is not supported. Check capabilties."); //$NON-NLS-1$
      } else if(e instanceof ScalarSubquery) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IScalarSubquery, but it is not supported. Check capabilties."); //$NON-NLS-1$
      } else if (e instanceof SearchedCase) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Received ISearchedCaseExpression, but it is not supported. Check capabilties."); //$NON-NLS-1$
      }
            final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.unsupportedElementError"); //$NON-NLS-1$
      throw new TranslatorException(msg + e.toString());
    }
    expressionName = escapeReservedChars(expressionName);
    return expressionName;
  }
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.