use of org.teiid.olingo.service.ProcedureSQLBuilder.ProcedureReturn in project teiid by teiid.
the class ODataSQLBuilder method visitOperation.
private void visitOperation(EdmOperation operation) {
try {
ProcedureSQLBuilder builder = new ProcedureSQLBuilder(this.metadata, operation, this.parameters, this.params);
ProcedureReturn pp = builder.getReturn();
if (!pp.hasResultSet()) {
NoDocumentNode ndn = new NoDocumentNode();
ndn.setProcedureReturn(pp);
ndn.setQuery(builder.buildProcedureSQL());
this.context = ndn;
} else {
ComplexDocumentNode cdn = ComplexDocumentNode.buildComplexDocumentNode(operation, this.metadata, this.odata, this.nameGenerator, this.aliasedGroups, getUriInfo(), this.parseService);
cdn.setProcedureReturn(pp);
this.context = cdn;
}
} catch (TeiidProcessingException e) {
throw new ODataRuntimeException(e);
}
}
use of org.teiid.olingo.service.ProcedureSQLBuilder.ProcedureReturn in project teiid by teiid.
the class TeiidServiceHandler method invokeOperation.
private <T extends ServiceResponse> void invokeOperation(final OperationRequest request, OperationParameterValueProvider parameters, T response) throws ODataApplicationException, ODataLibraryException {
checkExpand(request.getUriInfo().asUriInfoResource());
final ODataSQLBuilder visitor = new ODataSQLBuilder(odata, getClient().getMetadataStore(), this.prepared, true, request.getODataRequest().getRawBaseUri(), this.serviceMetadata);
visitor.setOperationParameterValueProvider(parameters);
visitor.visit(request.getUriInfo());
final OperationResponseImpl queryResponse;
try {
if (visitor.getContext() instanceof NoDocumentNode) {
NoDocumentNode cdn = (NoDocumentNode) visitor.getContext();
ProcedureReturn procReturn = cdn.getProcedureReturn();
queryResponse = new OperationResponseImpl(procReturn);
getClient().executeCall(cdn.getQuery(), visitor.getParameters(), procReturn, queryResponse);
} else {
Query query = visitor.selectQuery();
queryResponse = (OperationResponseImpl) executeQuery(request, request.isCountRequest(), visitor, query);
}
} catch (Throwable e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.getDefault(), e);
}
/*
try {
MetadataStore store = getClient().getMetadataStore();
ProcedureSQLBuilder builder = new ProcedureSQLBuilder(store.getSchema(schemaName), request);
ProcedureReturn procedureReturn = builder.getReturn();
result = new OperationResponseImpl(procedureReturn);
getClient().executeCall(builder.buildProcedureSQL(), builder.getSqlParameters(), procedureReturn, result);
} catch (SQLException e) {
throw new ODataApplicationException(e.getMessage(),
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.getDefault(), e);
} catch (TeiidException e) {
throw new ODataApplicationException(e.getMessage(),
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.getDefault(), e);
}
*/
final OperationResponseImpl operationResult = queryResponse;
response.accepts(new ServiceResponseVisior() {
@Override
public void visit(PropertyResponse response) throws ODataLibraryException, ODataApplicationException {
Property property = (Property) operationResult.getResult();
Object value = property.getValue();
if (value instanceof SQLXML || value instanceof Blob || value instanceof Clob) {
try {
handleLobResult(getClient().getProperty(Client.CHARSET), value, response);
} catch (SQLException e) {
LogManager.logDetail(LogConstants.CTX_ODATA, e);
response.writeServerError(true);
}
} else {
response.writeProperty(request.getReturnType().getType(), property);
}
}
});
}
Aggregations