Search in sources :

Example 1 with EdmElement

use of org.apache.olingo.commons.api.edm.EdmElement 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)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Property (org.apache.olingo.commons.api.data.Property)1 EdmComplexType (org.apache.olingo.commons.api.edm.EdmComplexType)1 EdmElement (org.apache.olingo.commons.api.edm.EdmElement)1 EdmProperty (org.apache.olingo.commons.api.edm.EdmProperty)1 EdmPropertyImpl (org.apache.olingo.commons.core.edm.EdmPropertyImpl)1 SingletonPrimitiveType (org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1