Search in sources :

Example 1 with OProperty

use of org.odata4j.core.OProperty in project teiid by teiid.

the class ODataUpdateVisitor method visit.

@Override
public void visit(Insert obj) {
    // $NON-NLS-1$
    this.method = "POST";
    this.entity = obj.getTable().getMetadataObject();
    this.uri = this.entity.getName();
    final List<OProperty<?>> props = new ArrayList<OProperty<?>>();
    int elementCount = obj.getColumns().size();
    for (int i = 0; i < elementCount; i++) {
        Column column = obj.getColumns().get(i).getMetadataObject();
        List<Expression> values = ((ExpressionValueSource) obj.getValueSource()).getValues();
        OProperty<?> property = readProperty(column, values.get(i));
        props.add(property);
    }
    this.payload = props;
}
Also used : OProperty(org.odata4j.core.OProperty) Column(org.teiid.metadata.Column) Expression(org.teiid.language.Expression) ArrayList(java.util.ArrayList) ExpressionValueSource(org.teiid.language.ExpressionValueSource)

Example 2 with OProperty

use of org.odata4j.core.OProperty in project teiid by teiid.

the class ODataUpdateVisitor method visit.

@Override
public void visit(Update obj) {
    // $NON-NLS-1$
    this.method = "PUT";
    this.entity = obj.getTable().getMetadataObject();
    visitNode(obj.getTable());
    // only pk are allowed, no other criteria not allowed
    obj.setWhere(buildEntityKey(obj.getWhere()));
    // this will build with entity keys
    this.uri = getEnitityURL();
    if (this.uri.indexOf('(') == -1) {
        this.exceptions.add(new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17011, this.filter.toString())));
    }
    if (this.filter.length() > 0) {
        this.exceptions.add(new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17009, this.filter.toString())));
    }
    final List<OProperty<?>> props = new ArrayList<OProperty<?>>();
    int elementCount = obj.getChanges().size();
    for (int i = 0; i < elementCount; i++) {
        Column column = obj.getChanges().get(i).getSymbol().getMetadataObject();
        OProperty<?> property = readProperty(column, obj.getChanges().get(i).getValue());
        props.add(property);
    }
    this.payload = props;
}
Also used : OProperty(org.odata4j.core.OProperty) Column(org.teiid.metadata.Column) ArrayList(java.util.ArrayList) TranslatorException(org.teiid.translator.TranslatorException)

Aggregations

ArrayList (java.util.ArrayList)2 OProperty (org.odata4j.core.OProperty)2 Column (org.teiid.metadata.Column)2 Expression (org.teiid.language.Expression)1 ExpressionValueSource (org.teiid.language.ExpressionValueSource)1 TranslatorException (org.teiid.translator.TranslatorException)1