use of org.odata4j.edm.EdmComplexType in project teiid by teiid.
the class BaseQueryExecution method executeWithComplexReturn.
protected ODataEntitiesResponse executeWithComplexReturn(String method, String uri, String payload, String complexTypeName, EdmDataServices edsMetadata, String eTag, Status... expectedStatus) throws TranslatorException {
Map<String, List<String>> headers = getDefaultHeaders();
if (eTag != null) {
// $NON-NLS-1$
headers.put("If-Match", Arrays.asList(eTag));
}
if (payload != null) {
// $NON-NLS-1$ //$NON-NLS-2$
headers.put("Content-Type", Arrays.asList("application/atom+xml"));
}
BinaryWSProcedureExecution execution = executeDirect(method, uri, payload, headers);
for (Status status : expectedStatus) {
if (status.getStatusCode() == execution.getResponseCode()) {
if (execution.getResponseCode() != Status.NO_CONTENT.getStatusCode()) {
Blob blob = (Blob) execution.getOutputParameterValues().get(0);
// ODataVersion version = getDataServiceVersion((String)execution.getResponseHeader(ODataConstants.Headers.DATA_SERVICE_VERSION));
EdmComplexType complexType = edsMetadata.findEdmComplexType(complexTypeName);
if (complexType == null) {
throw new RuntimeException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17016, complexType));
}
try {
return parserComplex(StaxUtil.newXMLEventReader(new InputStreamReader(blob.getBinaryStream())), complexType, edsMetadata);
} catch (SQLException e) {
throw new TranslatorException(ODataPlugin.Event.TEIID17010, e, e.getMessage());
}
}
// this is success with no-data
return new ODataEntitiesResponse();
}
}
// throw an error
return new ODataEntitiesResponse(buildError(execution));
}
Aggregations