Search in sources :

Example 76 with TranslatorException

use of org.teiid.translator.TranslatorException in project teiid by teiid.

the class MongoDBUpdateVisitor method visit.

@Override
public void visit(AndOr obj) {
    if (!this.mongoDoc.isMerged() || this.mongoDoc.isMerged() && this.mongoDoc.getMergeAssociation() != Association.MANY) {
        super.visit(obj);
        return;
    }
    append(obj.getLeftCondition());
    append(obj.getRightCondition());
    boolean valid = false;
    if (this.onGoingExpression.size() >= 2) {
        DBObject right = (DBObject) this.onGoingExpression.pop();
        DBObject left = (DBObject) this.onGoingExpression.pop();
        switch(obj.getOperator()) {
            case AND:
                this.onGoingExpression.push(QueryBuilder.start().and(left, right).get());
                break;
            case OR:
                this.onGoingExpression.push(QueryBuilder.start().or(left, right).get());
                break;
        }
        valid = true;
    }
    if (this.onGoingPullCriteria.size() >= 2) {
        DBObject pullRight = this.onGoingPullCriteria.pop();
        DBObject pullLeft = this.onGoingPullCriteria.pop();
        switch(obj.getOperator()) {
            case AND:
                this.onGoingPullCriteria.push(QueryBuilder.start().and(pullLeft, pullRight).get());
                break;
            case OR:
                this.onGoingPullCriteria.push(QueryBuilder.start().or(pullLeft, pullRight).get());
                break;
        }
        valid = true;
    }
    if (!valid && obj.getOperator() == Operator.OR) {
        this.pullException = new TranslatorException(MongoDBPlugin.Event.TEIID18029, MongoDBPlugin.Util.gs(MongoDBPlugin.Event.TEIID18029));
    }
}
Also used : TranslatorException(org.teiid.translator.TranslatorException)

Example 77 with TranslatorException

use of org.teiid.translator.TranslatorException in project teiid by teiid.

the class OlapExecutionFactory method unwrap.

private OlapConnection unwrap(Connection conn) throws TranslatorException {
    try {
        OlapWrapper wrapper = conn.unwrap(OlapWrapper.class);
        OlapConnection olapConn = wrapper.unwrap(OlapConnection.class);
        return olapConn;
    } catch (SQLException e) {
        throw new TranslatorException(e);
    }
}
Also used : OlapWrapper(org.olap4j.OlapWrapper) SQLException(java.sql.SQLException) OlapConnection(org.olap4j.OlapConnection) TranslatorException(org.teiid.translator.TranslatorException)

Example 78 with TranslatorException

use of org.teiid.translator.TranslatorException in project teiid by teiid.

the class OlapQueryExecution method execute.

@Override
public void execute() throws TranslatorException {
    try {
        stmt = this.connection.createStatement();
        cellSet = stmt.executeOlapQuery(mdxQuery);
        CellSetAxis rowAxis = this.cellSet.getAxes().get(Axis.ROWS.axisOrdinal());
        rowPositionIterator = rowAxis.iterator();
        columnsAxis = cellSet.getAxes().get(Axis.COLUMNS.axisOrdinal());
        colWidth = rowAxis.getAxisMetaData().getHierarchies().size() + this.columnsAxis.getPositions().size();
    } catch (SQLException e) {
        throw new TranslatorException(e);
    }
}
Also used : CellSetAxis(org.olap4j.CellSetAxis) SQLException(java.sql.SQLException) TranslatorException(org.teiid.translator.TranslatorException)

Example 79 with TranslatorException

use of org.teiid.translator.TranslatorException in project teiid by teiid.

the class JPQLSelectVisitor method handleJoin.

private JoinTable handleJoin(Join.JoinType joinType, NamedTable left, JoinTable right) throws TranslatorException {
    // first we need to find correct parent for the left
    JoinTable withParent = handleJoin(joinType, left, right.getParent(), false);
    JoinTable withChild = handleJoin(joinType, left, right.getChild(), false);
    NamedTable parent = (withParent.getParent() != null) ? withParent.getParent() : withChild.getParent();
    if (parent != null) {
        return handleJoin(joinType, left, parent, true);
    }
    throw new TranslatorException(JPAPlugin.Util.gs(JPAPlugin.Event.TEIID14006));
}
Also used : NamedTable(org.teiid.language.NamedTable) TranslatorException(org.teiid.translator.TranslatorException)

Example 80 with TranslatorException

use of org.teiid.translator.TranslatorException in project teiid by teiid.

the class JPQLUpdateExecution method handleInsert.

private Object handleInsert(Insert insert) throws TranslatorException {
    try {
        String entityClassName = insert.getTable().getMetadataObject().getProperty(JPAMetadataProcessor.ENTITYCLASS, false);
        Object entity = ReflectionHelper.create(entityClassName, null, this.executionContext.getCommandContext().getVDBClassLoader());
        List<ColumnReference> columns = insert.getColumns();
        List<Expression> values = ((ExpressionValueSource) insert.getValueSource()).getValues();
        if (columns.size() != values.size()) {
            throw new TranslatorException(JPAPlugin.Util.gs(JPAPlugin.Event.TEIID14007));
        }
        for (int i = 0; i < columns.size(); i++) {
            Column column = columns.get(i).getMetadataObject();
            Object value = values.get(i);
            // do not add the derived columns
            String name = column.getProperty(JPAMetadataProcessor.KEY_ASSOSIATED_WITH_FOREIGN_TABLE, false);
            if (name == null) {
                if (value instanceof Literal) {
                    Literal literalValue = (Literal) value;
                    PropertiesUtils.setBeanProperty(entity, column.getName(), literalValue.getValue());
                } else {
                    PropertiesUtils.setBeanProperty(entity, column.getName(), value);
                }
            }
        }
        return entity;
    } catch (TeiidException e) {
        throw new TranslatorException(e);
    }
}
Also used : Expression(org.teiid.language.Expression) Column(org.teiid.metadata.Column) Literal(org.teiid.language.Literal) TranslatorException(org.teiid.translator.TranslatorException) ColumnReference(org.teiid.language.ColumnReference) ExpressionValueSource(org.teiid.language.ExpressionValueSource) TeiidException(org.teiid.core.TeiidException)

Aggregations

TranslatorException (org.teiid.translator.TranslatorException)227 ArrayList (java.util.ArrayList)51 Column (org.teiid.metadata.Column)47 List (java.util.List)32 Table (org.teiid.metadata.Table)30 IOException (java.io.IOException)26 SQLException (java.sql.SQLException)26 ResourceException (javax.resource.ResourceException)26 Test (org.junit.Test)16 Expression (org.teiid.language.Expression)16 Literal (org.teiid.language.Literal)16 DataNotAvailableException (org.teiid.translator.DataNotAvailableException)16 Blob (java.sql.Blob)15 Argument (org.teiid.language.Argument)13 DBObject (com.mongodb.DBObject)11 HashMap (java.util.HashMap)11 ColumnReference (org.teiid.language.ColumnReference)11 ExecutionContext (org.teiid.translator.ExecutionContext)11 BasicDBObject (com.mongodb.BasicDBObject)10 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)10