Search in sources :

Example 1 with EdmType

use of org.odata4j.edm.EdmType in project teiid by teiid.

the class ODataUpdateVisitor method readProperty.

private OProperty<?> readProperty(Column column, Object value) {
    if (value instanceof Array) {
        EdmType componentType = ODataTypeManager.odataType(column.getRuntimeType());
        if (componentType instanceof EdmCollectionType) {
            componentType = ((EdmCollectionType) componentType).getItemType();
        }
        OCollection.Builder<OObject> b = OCollections.newBuilder(componentType);
        List<Expression> values = ((Array) value).getExpressions();
        for (int i = 0; i < values.size(); i++) {
            Literal literal = (Literal) values.get(i);
            b.add(OSimpleObjects.create((EdmSimpleType<?>) componentType, literal.getValue()));
        }
        return OProperties.collection(column.getName(), new EdmCollectionType(CollectionKind.Collection, componentType), b.build());
    } else {
        Literal literal = (Literal) value;
        return OProperties.simple(column.getName(), literal.getValue());
    }
}
Also used : Array(org.teiid.language.Array) EdmType(org.odata4j.edm.EdmType) Expression(org.teiid.language.Expression) OCollection(org.odata4j.core.OCollection) Literal(org.teiid.language.Literal) EdmCollectionType(org.odata4j.edm.EdmCollectionType) EdmSimpleType(org.odata4j.edm.EdmSimpleType) OObject(org.odata4j.core.OObject)

Aggregations

OCollection (org.odata4j.core.OCollection)1 OObject (org.odata4j.core.OObject)1 EdmCollectionType (org.odata4j.edm.EdmCollectionType)1 EdmSimpleType (org.odata4j.edm.EdmSimpleType)1 EdmType (org.odata4j.edm.EdmType)1 Array (org.teiid.language.Array)1 Expression (org.teiid.language.Expression)1 Literal (org.teiid.language.Literal)1