use of org.teiid.metadata.Procedure 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.metadata.Procedure 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.metadata.Procedure in project teiid by teiid.
the class TestODataMetadataProcessor method testSchema.
@Test
public void testSchema() throws Exception {
translator = new ODataExecutionFactory();
translator.start();
MetadataFactory mf = tripPinMetadata();
TransformationMetadata metadata = getTransformationMetadata(mf, this.translator);
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
MetadataFactory mf2 = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
QueryParser.getQueryParser().parseDDL(mf2, ddl);
Procedure p = mf.getSchema().getProcedure("ResetDataSource");
assertNotNull(p);
assertEquals(0, p.getParameters().size());
}
use of org.teiid.metadata.Procedure 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.metadata.Procedure in project teiid by teiid.
the class ODataProcedureExecution method execute.
@Override
public void execute() throws TranslatorException {
try {
String parameters = getQueryParameters(this.command);
InputStream response = null;
Procedure procedure = this.command.getMetadataObject();
if (isFunction(procedure)) {
String URI = buildFunctionURL(this.command, parameters);
response = executeQuery("GET", URI, null, null, new HttpStatusCode[] { HttpStatusCode.OK });
handleResponse(procedure, URI, response);
} else {
String URI = this.command.getProcedureName();
response = executeQuery("POST", URI, parameters, null, new HttpStatusCode[] { HttpStatusCode.OK });
handleResponse(procedure, URI, response);
}
} catch (ODataDeserializerException e) {
throw new TranslatorException(e);
} catch (EdmPrimitiveTypeException e) {
throw new TranslatorException(e);
}
}
Aggregations