Search in sources :

Example 1 with EdmComplexType

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

the class ComplexDocumentNode method addAllColumns.

@Override
protected void addAllColumns(boolean onlyPK) {
    for (final Column column : procedure.getResultSet().getColumns()) {
        if (column.isSelectable()) {
            EdmReturnType returnType = procedureReturn.getReturnType();
            EdmComplexType complexType = (EdmComplexType) returnType.getType();
            EdmPropertyImpl edmProperty = (EdmPropertyImpl) complexType.getProperty(column.getName());
            addProjectedColumn(new ElementSymbol(column.getName(), getGroupSymbol()), edmProperty.getType(), edmProperty, edmProperty.isCollection());
        }
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) EdmReturnType(org.apache.olingo.commons.api.edm.EdmReturnType) Column(org.teiid.metadata.Column) EdmComplexType(org.apache.olingo.commons.api.edm.EdmComplexType) EdmPropertyImpl(org.apache.olingo.commons.core.edm.EdmPropertyImpl)

Example 2 with EdmComplexType

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

the class OperationResponseImpl method getComplexProperty.

private ComplexValue getComplexProperty(ResultSet rs) throws SQLException {
    HashMap<Integer, Property> properties = new HashMap<Integer, Property>();
    for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
        Object value = rs.getObject(i + 1);
        String propName = rs.getMetaData().getColumnLabel(i + 1);
        EdmElement element = ((EdmComplexType) this.procedureReturn.getReturnType().getType()).getProperty(propName);
        if (!(element instanceof EdmProperty) && !((EdmProperty) element).isPrimitive()) {
            throw new SQLException(new TeiidNotImplementedException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16024)));
        }
        EdmPropertyImpl edmProperty = (EdmPropertyImpl) element;
        Property property;
        try {
            property = EntityCollectionResponse.buildPropery(propName, (SingletonPrimitiveType) edmProperty.getType(), edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isCollection(), value);
            properties.put(i, property);
        } catch (IOException e) {
            throw new SQLException(e);
        } catch (TeiidProcessingException e) {
            throw new SQLException(e);
        }
    }
    // filter those columns out.
    return createComplex("result", properties.values());
}
Also used : HashMap(java.util.HashMap) SQLException(java.sql.SQLException) IOException(java.io.IOException) EdmElement(org.apache.olingo.commons.api.edm.EdmElement) EdmComplexType(org.apache.olingo.commons.api.edm.EdmComplexType) EdmPropertyImpl(org.apache.olingo.commons.core.edm.EdmPropertyImpl) TeiidProcessingException(org.teiid.core.TeiidProcessingException) SingletonPrimitiveType(org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType) EdmProperty(org.apache.olingo.commons.api.edm.EdmProperty) Property(org.apache.olingo.commons.api.data.Property) EdmProperty(org.apache.olingo.commons.api.edm.EdmProperty)

Example 3 with EdmComplexType

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

the class ComplexDocumentNode method addProjectedColumn.

@Override
protected void addProjectedColumn(final String columnName, final Expression expr) {
    EdmReturnType returnType = procedureReturn.getReturnType();
    EdmComplexType complexType = (EdmComplexType) returnType.getType();
    EdmPropertyImpl edmProperty = (EdmPropertyImpl) complexType.getProperty(columnName);
    addProjectedColumn(expr, edmProperty.getType(), edmProperty, edmProperty.isCollection());
}
Also used : EdmReturnType(org.apache.olingo.commons.api.edm.EdmReturnType) EdmComplexType(org.apache.olingo.commons.api.edm.EdmComplexType) EdmPropertyImpl(org.apache.olingo.commons.core.edm.EdmPropertyImpl)

Aggregations

EdmComplexType (org.apache.olingo.commons.api.edm.EdmComplexType)3 EdmPropertyImpl (org.apache.olingo.commons.core.edm.EdmPropertyImpl)3 EdmReturnType (org.apache.olingo.commons.api.edm.EdmReturnType)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Property (org.apache.olingo.commons.api.data.Property)1 EdmElement (org.apache.olingo.commons.api.edm.EdmElement)1 EdmProperty (org.apache.olingo.commons.api.edm.EdmProperty)1 SingletonPrimitiveType (org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 Column (org.teiid.metadata.Column)1 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)1