use of org.teiid.core.TeiidException in project teiid by teiid.
the class ODataSQLBuilder method visit.
@Override
public void visit(FilterOption info) {
ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor(this.context, this.prepared, getUriInfo(), this.metadata, this.odata, this.nameGenerator, this.params, this.parseService);
Expression filter = null;
try {
filter = visitor.getExpression(info.getExpression());
} catch (TeiidException e) {
this.exceptions.add(e);
}
// Here Lambda operation may have joined a table and changed the context.
this.context = visitor.getEntityResource();
this.context.addCriteria(filter);
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class ODataSQLBuilder method visit.
@Override
public void visit(UriResourceNavigation info) {
EdmNavigationProperty property = info.getProperty();
try {
DocumentNode joinResource = DocumentNode.build(property.getType(), info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, true, getUriInfo(), parseService);
this.context.joinTable(joinResource, property, JoinType.JOIN_INNER);
// In the context of canonical queries if key predicates are available then do not set the criteria
if (joinResource.getCriteria() == null) {
joinResource.addCriteria(this.context.getCriteria());
}
this.context = joinResource;
this.navigation = true;
} catch (TeiidException e) {
this.exceptions.add(e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class ODataExpressionToSQLVisitor method visit.
@Override
public void visit(Literal expr) {
try {
Object value = null;
if (expr.getText() != null && !expr.getText().equalsIgnoreCase("null")) {
String type = expr.getType().getFullQualifiedName().getFullQualifiedNameAsString();
value = ODataTypeManager.parseLiteral(type, expr.getText());
}
if (this.prepared) {
if (value == null) {
this.stack.add(new Constant(value));
} else {
Function ref = new Function(CONVERT, new org.teiid.query.sql.symbol.Expression[] { new Reference(this.params.size()), new Constant(DataTypeManager.getDataTypeName(value.getClass())) });
stack.add(ref);
this.params.add(new SQLParameter(value, JDBCSQLTypeInfo.getSQLTypeFromClass(value.getClass().getName())));
}
} else {
this.stack.add(new Constant(value));
}
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class ODataExpressionToSQLVisitor method visit.
@Override
public void visit(UriResourceLambdaVariable resource) {
try {
if (this.ctxLambda == null) {
DocumentNode lambda = DocumentNode.build((EdmEntityType) resource.getType(), null, this.metadata, this.odata, this.nameGenerator, false, this.uriInfo, this.parseService);
lambda.setGroupSymbol(new GroupSymbol(resource.getVariableName(), lambda.getFullName()));
this.ctxLambda = lambda;
}
this.ctxExpression = ctxLambda;
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TeiidServiceHandler method upsertStreamProperty.
@Override
public void upsertStreamProperty(DataRequest request, String entityETag, InputStream streamContent, NoContentResponse response) throws ODataLibraryException, ODataApplicationException {
UpdateResponse updateResponse = null;
EdmProperty edmProperty = request.getUriResourceProperty().getProperty();
try {
ODataSQLBuilder visitor = new ODataSQLBuilder(this.odata, getClient().getMetadataStore(), this.prepared, false, request.getODataRequest().getRawBaseUri(), this.serviceMetadata);
visitor.visit(request.getUriInfo());
Update update = visitor.updateStreamProperty(edmProperty, streamContent);
updateResponse = getClient().executeUpdate(update, visitor.getParameters());
} catch (SQLException | TeiidException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.getDefault(), e);
}
if (updateResponse != null && updateResponse.getUpdateCount() > 0) {
response.writeNoContent();
} else {
response.writeNotModified();
}
}
Aggregations