use of org.teiid.core.TeiidProcessingException 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.core.TeiidProcessingException in project teiid by teiid.
the class ODataSQLBuilder method selectWithEntityKey.
// TODO: allow the generated key building.
public Query selectWithEntityKey(EdmEntityType entityType, Entity entity, Map<String, Object> generatedKeys, List<ExpandNode> expand) throws TeiidException {
Table table = findTable(entityType.getName(), this.metadata);
DocumentNode resource = new DocumentNode(table, new GroupSymbol(table.getFullName()), entityType);
resource.setFromClause(new UnaryFromClause(new GroupSymbol(table.getFullName())));
resource.addAllColumns(false);
this.context = resource;
Query query = this.context.buildQuery();
processExpand(expand, resource, query, 1);
Criteria criteria = null;
KeyRecord pk = ODataSchemaBuilder.getIdentifier(table);
for (Column c : pk.getColumns()) {
Property prop = entity.getProperty(c.getName());
Constant right = null;
if (prop != null) {
right = new Constant(ODataTypeManager.convertToTeiidRuntimeType(c.getJavaType(), prop.getValue(), null));
} else {
Object value = generatedKeys.get(c.getName());
if (value == null) {
throw new TeiidProcessingException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16016, entityType.getName()));
}
right = new Constant(value);
}
ElementSymbol left = new ElementSymbol(c.getName(), this.context.getGroupSymbol());
if (criteria == null) {
criteria = new CompareCriteria(left, AbstractCompareCriteria.EQ, right);
} else {
CompareCriteria rightCC = new CompareCriteria(left, AbstractCompareCriteria.EQ, right);
criteria = new CompoundCriteria(CompoundCriteria.AND, criteria, rightCC);
}
}
query.setCriteria(criteria);
return query;
}
use of org.teiid.core.TeiidProcessingException in project teiid by teiid.
the class OperationResponseImpl method setReturnValue.
@Override
public void setReturnValue(Object returnValue) throws SQLException {
try {
EdmReturnType returnType = this.procedureReturn.getReturnType();
this.returnValue = // $NON-NLS-1$
EntityCollectionResponse.buildPropery(// $NON-NLS-1$
"return", (SingletonPrimitiveType) returnType.getType(), returnType.getPrecision(), returnType.getScale(), returnType.isCollection(), returnValue);
} catch (TeiidProcessingException e) {
throw new SQLException(e);
} catch (IOException e) {
throw new SQLException(e);
}
}
use of org.teiid.core.TeiidProcessingException in project teiid by teiid.
the class LocalClient method getVDBInternal.
private VDBMetaData getVDBInternal() throws SQLException, TeiidProcessingException {
if (this.vdb == null) {
LocalServerConnection lsc = (LocalServerConnection) getConnection().getServerConnection();
vdb = lsc.getWorkContext().getVDB();
if (vdb == null) {
throw new TeiidRuntimeException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16001, this.vdbName, this.vdbVersion));
}
this.vdb = vdb;
}
if (vdb.getStatus() != Status.ACTIVE) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID31099, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31099, vdb, vdb.getStatus()));
}
return this.vdb;
}
use of org.teiid.core.TeiidProcessingException in project teiid by teiid.
the class CorsFilter method doFilter.
/**
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpReq = (HttpServletRequest) request;
HttpServletResponse httpResp = (HttpServletResponse) response;
if (isOptionsMethod(httpReq) && !hasOriginHeader(httpReq)) {
ODataFilter.writeError(request, new TeiidProcessingException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16056)), httpResp, 400);
return;
}
if (isPreflightRequest(httpReq)) {
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Origin", httpReq.getHeader("Origin"));
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Credentials", "true");
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Max-Age", "1800");
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE");
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Headers", "Content-Type,Accept,Origin,Authorization");
httpResp.setStatus(204);
} else {
if (hasOriginHeader(httpReq)) {
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Origin", httpReq.getHeader("Origin"));
// $NON-NLS-1$ //$NON-NLS-2$
httpResp.setHeader("Access-Control-Allow-Credentials", "true");
}
chain.doFilter(httpReq, httpResp);
}
}
Aggregations