Search in sources :

Example 6 with FullQualifiedName

use of org.apache.olingo.commons.api.edm.FullQualifiedName in project teiid by teiid.

the class TestODataMetadataProcessor method functionMetadata.

static MetadataFactory functionMetadata(String name, CsdlReturnType returnType, Object other) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlFunction func = function(name, returnType);
    CsdlFunctionImport funcImport = new CsdlFunctionImport();
    funcImport.setFunction(new FullQualifiedName("namespace." + name));
    funcImport.setName(name);
    XMLMetadata metadata = buildXmlMetadata(funcImport, func, other);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 7 with FullQualifiedName

use of org.apache.olingo.commons.api.edm.FullQualifiedName in project teiid by teiid.

the class TestODataMetadataProcessor method actionMetadata.

static MetadataFactory actionMetadata(String name, CsdlReturnType returnType, Object other) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlAction func = action(name, returnType);
    CsdlActionImport funcImport = new CsdlActionImport();
    funcImport.setAction(new FullQualifiedName("namespace." + name));
    funcImport.setName(name);
    XMLMetadata metadata = buildXmlMetadata(funcImport, func, other);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 8 with FullQualifiedName

use of org.apache.olingo.commons.api.edm.FullQualifiedName in project teiid by teiid.

the class ODataSchemaBuilder method buildFunction.

static void buildFunction(String schemaName, Procedure proc, ArrayList<CsdlComplexType> complexTypes, ArrayList<CsdlFunction> functions, ArrayList<CsdlFunctionImport> functionImports, CsdlSchema csdlSchema) {
    CsdlFunction edmFunction = new CsdlFunction();
    edmFunction.setName(proc.getName());
    edmFunction.setBound(false);
    ArrayList<CsdlParameter> params = new ArrayList<CsdlParameter>();
    for (ProcedureParameter pp : proc.getParameters()) {
        EdmPrimitiveTypeKind odataType = ODataTypeManager.odataType(pp.getRuntimeType());
        if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
            edmFunction.setReturnType(new CsdlReturnType().setType(odataType.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType())));
            continue;
        }
        if (pp.getType().equals(ProcedureParameter.Type.In) || pp.getType().equals(ProcedureParameter.Type.InOut)) {
            CsdlParameter parameter = buildParameter(pp, odataType);
            addOperationParameterAnnotations(pp, parameter, csdlSchema);
            params.add(parameter);
        }
    }
    edmFunction.setParameters(params);
    // add a complex type for return resultset.
    ColumnSet<Procedure> returnColumns = proc.getResultSet();
    if (returnColumns != null) {
        CsdlComplexType complexType = buildComplexType(proc, returnColumns, csdlSchema);
        complexTypes.add(complexType);
        FullQualifiedName odataType = new FullQualifiedName(schemaName, complexType.getName());
        edmFunction.setReturnType((new CsdlReturnType().setType(odataType).setCollection(true)));
    }
    CsdlFunctionImport functionImport = new CsdlFunctionImport();
    functionImport.setName(proc.getName()).setFunction(new FullQualifiedName(schemaName, proc.getName()));
    addOperationAnnotations(proc, edmFunction, csdlSchema);
    functions.add(edmFunction);
    functionImports.add(functionImport);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) ArrayList(java.util.ArrayList) Procedure(org.teiid.metadata.Procedure) EdmPrimitiveTypeKind(org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind)

Example 9 with FullQualifiedName

use of org.apache.olingo.commons.api.edm.FullQualifiedName in project teiid by teiid.

the class ODataSchemaBuilder method buildAction.

static void buildAction(String schemaName, Procedure proc, ArrayList<CsdlComplexType> complexTypes, ArrayList<CsdlAction> actions, ArrayList<CsdlActionImport> actionImports, CsdlSchema csdlSchema) {
    CsdlAction edmAction = new CsdlAction();
    edmAction.setName(proc.getName());
    edmAction.setBound(false);
    ArrayList<CsdlParameter> params = new ArrayList<CsdlParameter>();
    for (ProcedureParameter pp : proc.getParameters()) {
        EdmPrimitiveTypeKind odatatype = ODataTypeManager.odataType(pp.getRuntimeType());
        if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
            edmAction.setReturnType(new CsdlReturnType().setType(odatatype.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType())));
            continue;
        }
        if (pp.getType().equals(ProcedureParameter.Type.In) || pp.getType().equals(ProcedureParameter.Type.InOut)) {
            CsdlParameter parameter = buildParameter(pp, odatatype);
            addOperationParameterAnnotations(pp, parameter, csdlSchema);
            params.add(parameter);
        }
    }
    edmAction.setParameters(params);
    // add a complex type for return resultset.
    ColumnSet<Procedure> returnColumns = proc.getResultSet();
    if (returnColumns != null) {
        CsdlComplexType complexType = buildComplexType(proc, returnColumns, csdlSchema);
        complexTypes.add(complexType);
        edmAction.setReturnType((new CsdlReturnType().setType(new FullQualifiedName(schemaName, complexType.getName())).setCollection(true)));
    }
    CsdlActionImport actionImport = new CsdlActionImport();
    actionImport.setName(proc.getName()).setAction(new FullQualifiedName(schemaName, proc.getName()));
    addOperationAnnotations(proc, edmAction, csdlSchema);
    actions.add(edmAction);
    actionImports.add(actionImport);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) ArrayList(java.util.ArrayList) Procedure(org.teiid.metadata.Procedure) EdmPrimitiveTypeKind(org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind)

Example 10 with FullQualifiedName

use of org.apache.olingo.commons.api.edm.FullQualifiedName in project teiid by teiid.

the class DocumentNode method findTable.

static Table findTable(EdmEntityType entityType, MetadataStore store) {
    FullQualifiedName fqn = entityType.getFullQualifiedName();
    // remove the vdb name
    String withoutVDB = fqn.getNamespace().substring(fqn.getNamespace().lastIndexOf('.') + 1);
    Schema schema = store.getSchema(withoutVDB);
    return schema.getTable(entityType.getName());
}
Also used : FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) Schema(org.teiid.metadata.Schema)

Aggregations

FullQualifiedName (org.apache.olingo.commons.api.edm.FullQualifiedName)10 ArrayList (java.util.ArrayList)5 Column (org.teiid.metadata.Column)3 Procedure (org.teiid.metadata.Procedure)3 Properties (java.util.Properties)2 XMLMetadata (org.apache.olingo.client.api.edm.xml.XMLMetadata)2 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)2 EdmPrimitiveTypeKind (org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind)2 MetadataFactory (org.teiid.metadata.MetadataFactory)2 ProcedureParameter (org.teiid.metadata.ProcedureParameter)2 Schema (org.teiid.metadata.Schema)2 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)2 LinkedHashMap (java.util.LinkedHashMap)1 KeyRecord (org.teiid.metadata.KeyRecord)1 Table (org.teiid.metadata.Table)1 SPParameter (org.teiid.query.sql.lang.SPParameter)1 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)1 SubqueryFromClause (org.teiid.query.sql.lang.SubqueryFromClause)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1 Reference (org.teiid.query.sql.symbol.Reference)1