use of org.teiid.metadata.Procedure 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);
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class TestODataMetadataProcessor method testFunction.
@Test
public void testFunction() throws Exception {
CsdlReturnType returnType = new CsdlReturnType();
returnType.setType("Edm.String");
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 TestDataEntitySchemaBuilder method testArrayType.
@Test
public void testArrayType() throws Exception {
ModelMetaData model = new ModelMetaData();
model.setName("nw");
model.setModelType(Type.PHYSICAL);
MetadataFactory mf = new MetadataFactory("northwind", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), model);
EdmDataServices edm = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new FileReader(UnitTestUtil.getTestDataFile("arraytest.xml"))));
ODataMetadataProcessor metadataProcessor = new ODataMetadataProcessor();
// $NON-NLS-1$
PropertiesUtils.setBeanProperties(metadataProcessor, mf.getModelProperties(), "importer");
metadataProcessor.getMetadata(mf, edm);
Column c = mf.getSchema().getTable("G2").getColumnByName("e3");
assertEquals("integer[]", c.getRuntimeType());
Procedure p = mf.getSchema().getProcedure("ARRAYITERATE");
assertEquals("varbinary[]", p.getParameters().get(0).getRuntimeType());
assertEquals("varbinary", p.getResultSet().getColumns().get(0).getRuntimeType());
// String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class SalesForceExecutionFactory method createProcedureExecution.
@Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, SalesforceConnection connection) throws TranslatorException {
Procedure metadataObject = command.getMetadataObject();
String nativeQuery = metadataObject.getProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, false);
if (nativeQuery != null) {
return new DirectQueryExecution(command.getArguments(), command, connection, metadata, executionContext, nativeQuery, false);
}
return new ProcedureExecutionParentImpl(command, connection, metadata, executionContext);
}
use of org.teiid.metadata.Procedure in project teiid by teiid.
the class SalesForceMetadataProcessor method addProcedrues.
public static void addProcedrues(MetadataFactory metadataFactory) {
// $NON-NLS-1$
Procedure p1 = metadataFactory.addProcedure("GetUpdated");
// $NON-NLS-1$
p1.setAnnotation("Gets the updated objects");
// $NON-NLS-1$
ProcedureParameter param = metadataFactory.addProcedureParameter("ObjectName", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p1);
// $NON-NLS-1$
param.setAnnotation("ObjectName");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("StartDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
// $NON-NLS-1$
param.setAnnotation("Start Time");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("EndDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
// $NON-NLS-1$
param.setAnnotation("End Time");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("LatestDateCovered", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
// $NON-NLS-1$
param.setAnnotation("Latest Date Covered");
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("ID", TypeFacility.RUNTIME_NAMES.STRING, p1);
// $NON-NLS-1$
Procedure p2 = metadataFactory.addProcedure("GetDeleted");
// $NON-NLS-1$
p2.setAnnotation("Gets the deleted objects");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("ObjectName", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("ObjectName");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("StartDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("Start Time");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("EndDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("End Time");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("EarliestDateAvailable", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("Earliest Date Available");
// $NON-NLS-1$
param = metadataFactory.addProcedureParameter("LatestDateCovered", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
// $NON-NLS-1$
param.setAnnotation("Latest Date Covered");
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("ID", TypeFacility.RUNTIME_NAMES.STRING, p2);
// $NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("DeletedDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p2);
}
Aggregations