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));
}
}
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);
}
}
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);
}
}
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));
}
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);
}
}
Aggregations