use of org.teiid.translator.odata4.ODataMetadataProcessor.ODataType in project teiid by teiid.
the class TestODataMetadataProcessor method testAction.
@Test
public void testAction() throws Exception {
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("Edm.String");
MetadataFactory mf = actionMetadata("invoke", returnType, null);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(3, p.getParameters().size());
assertNull(p.getResultSet());
assertNotNull(getReturnParameter(p));
ProcedureParameter pp = getReturnParameter(p);
assertEquals("string", pp.getRuntimeType());
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.ACTION, type);
}
use of org.teiid.translator.odata4.ODataMetadataProcessor.ODataType in project teiid by teiid.
the class TestODataMetadataProcessor method testFunctionReturnComplexCollection.
@Test
public void testFunctionReturnComplexCollection() throws Exception {
CsdlComplexType complex = complexType("Address");
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("namespace.Address");
returnType.setCollection(true);
MetadataFactory mf = functionMetadata("invoke", returnType, complex);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(2, p.getParameters().size());
assertNotNull(p.getResultSet());
assertNull(getReturnParameter(p));
ColumnSet<Procedure> table = p.getResultSet();
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.FUNCTION, type);
type = ODataType.valueOf(table.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.COMPLEX_COLLECTION, type);
}
use of org.teiid.translator.odata4.ODataMetadataProcessor.ODataType in project teiid by teiid.
the class TestODataMetadataProcessor method testFunctionReturnPrimitiveCollection.
@Test
public void testFunctionReturnPrimitiveCollection() throws Exception {
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("Edm.String");
returnType.setCollection(true);
MetadataFactory mf = functionMetadata("invoke", returnType, null);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(3, p.getParameters().size());
assertNull(p.getResultSet());
assertNotNull(getReturnParameter(p));
ProcedureParameter pp = getReturnParameter(p);
assertEquals("string[]", pp.getRuntimeType());
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.FUNCTION, type);
}
use of org.teiid.translator.odata4.ODataMetadataProcessor.ODataType in project teiid by teiid.
the class ODataProcedureExecution method handleResponse.
private void handleResponse(final Procedure procedure, final String baseUri, final InputStream payload) throws TranslatorException, ODataDeserializerException {
if (procedure.getResultSet() != null) {
ODataType type = ODataType.valueOf(procedure.getResultSet().getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
this.response = new ODataResponse(payload, type, new DocumentNode()) {
@Override
public InputStream nextBatch(java.net.URI uri) throws TranslatorException {
return executeSkipToken(uri, baseUri, new HttpStatusCode[] { HttpStatusCode.OK });
}
};
} else if (getReturnParameter() != null) {
// this is scalar result
JsonDeserializer parser = new JsonDeserializer(false);
Property property = parser.toProperty(payload).getPayload();
if (property.isCollection()) {
this.returnValue = property.asCollection();
} else {
this.returnValue = property.asPrimitive();
}
}
}
use of org.teiid.translator.odata4.ODataMetadataProcessor.ODataType in project teiid by teiid.
the class TestODataMetadataProcessor method testFunctionReturnComplex.
@Test
public void testFunctionReturnComplex() throws Exception {
CsdlComplexType complex = complexType("Address");
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("namespace.Address");
MetadataFactory mf = functionMetadata("invoke", returnType, complex);
Procedure p = mf.getSchema().getProcedure("invoke");
assertNotNull(p);
assertEquals(2, p.getParameters().size());
assertNotNull(p.getResultSet());
assertNull(getReturnParameter(p));
ColumnSet<Procedure> table = p.getResultSet();
ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.FUNCTION, type);
type = ODataType.valueOf(table.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
assertEquals(ODataType.COMPLEX, type);
}
Aggregations