Search in sources :

Example 1 with ConfigurationImpl

use of org.apache.olingo.client.core.ConfigurationImpl in project teiid by teiid.

the class ODataUpdateQuery method buildInsertURL.

public String buildInsertURL(String serviceRoot) throws TranslatorException {
    URIBuilderImpl uriBuilder = new URIBuilderImpl(new ConfigurationImpl(), serviceRoot);
    uriBuilder.appendEntitySetSegment(this.rootDocument.getName());
    if (this.keys.size() == 1) {
        uriBuilder.appendKeySegment(this.keys.values().iterator().next());
    } else if (!this.keys.isEmpty()) {
        uriBuilder.appendKeySegment(this.keys);
    }
    if (!this.complexTables.isEmpty()) {
        uriBuilder.appendPropertySegment(this.complexTables.get(0).getName());
    }
    if (!this.expandTables.isEmpty()) {
        uriBuilder.appendPropertySegment(this.expandTables.get(0).getName());
    }
    URI uri = uriBuilder.build();
    return uri.toString();
}
Also used : URIBuilderImpl(org.apache.olingo.client.core.uri.URIBuilderImpl) ConfigurationImpl(org.apache.olingo.client.core.ConfigurationImpl) URI(java.net.URI)

Example 2 with ConfigurationImpl

use of org.apache.olingo.client.core.ConfigurationImpl in project teiid by teiid.

the class ODataUpdateQuery method buildUpdateSelectionURL.

public String buildUpdateSelectionURL(String serviceRoot) throws TranslatorException {
    URIBuilderImpl uriBuilder = new URIBuilderImpl(new ConfigurationImpl(), serviceRoot);
    uriBuilder.appendEntitySetSegment(this.rootDocument.getName());
    List<String> selection = this.rootDocument.getIdentityColumns();
    uriBuilder.select(selection.toArray(new String[selection.size()]));
    if (!this.expandTables.isEmpty()) {
        ODataDocumentNode use = this.expandTables.get(0);
        List<String> keys = use.getIdentityColumns();
        for (String key : keys) {
            use.appendSelect(key);
        }
        uriBuilder.expandWithOptions(use.getName(), use.getOptions());
    }
    String filter = processFilter(condition);
    if (filter != null) {
        uriBuilder.filter(filter);
    }
    URI uri = uriBuilder.build();
    return uri.toString();
}
Also used : URIBuilderImpl(org.apache.olingo.client.core.uri.URIBuilderImpl) ConfigurationImpl(org.apache.olingo.client.core.ConfigurationImpl) URI(java.net.URI)

Example 3 with ConfigurationImpl

use of org.apache.olingo.client.core.ConfigurationImpl in project teiid by teiid.

the class ODataUpdateQuery method buildUpdateURL.

public String buildUpdateURL(String serviceRoot, List<?> row) {
    URIBuilderImpl uriBuilder = new URIBuilderImpl(new ConfigurationImpl(), serviceRoot);
    uriBuilder.appendEntitySetSegment(this.rootDocument.getName());
    List<String> selection = this.rootDocument.getIdentityColumns();
    if (selection.size() == 1) {
        uriBuilder.appendKeySegment(row.get(0));
    } else if (!selection.isEmpty()) {
        LinkedHashMap<String, Object> keys = new LinkedHashMap<String, Object>();
        for (int i = 0; i < selection.size(); i++) {
            keys.put(selection.get(i), row.get(i));
        }
        uriBuilder.appendKeySegment(keys);
    }
    if (!this.complexTables.isEmpty()) {
        uriBuilder.appendPropertySegment(this.complexTables.get(0).getName());
    }
    if (!this.expandTables.isEmpty()) {
        uriBuilder.appendPropertySegment(this.expandTables.get(0).getName());
        // add keys if present
        DocumentNode use = this.expandTables.get(0);
        List<String> expandSelection = use.getIdentityColumns();
        LinkedHashMap<String, Object> keys = new LinkedHashMap<String, Object>();
        for (int i = 0; i < expandSelection.size(); i++) {
            keys.put(expandSelection.get(i), row.get(selection.size() + i));
        }
        if (!keys.isEmpty()) {
            uriBuilder.appendKeySegment(keys);
        }
    }
    URI uri = uriBuilder.build();
    return uri.toString();
}
Also used : URIBuilderImpl(org.apache.olingo.client.core.uri.URIBuilderImpl) DocumentNode(org.teiid.translator.document.DocumentNode) ConfigurationImpl(org.apache.olingo.client.core.ConfigurationImpl) URI(java.net.URI) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ConfigurationImpl

use of org.apache.olingo.client.core.ConfigurationImpl in project teiid by teiid.

the class ODataSelectQuery method buildURL.

public URIBuilderImpl buildURL(String serviceRoot, List<Column> projectedColumns, Condition condition) throws TranslatorException {
    URIBuilderImpl uriBuilder = new URIBuilderImpl(new ConfigurationImpl(), serviceRoot);
    if (!this.rootDocument.isComplexType()) {
        uriBuilder.appendEntitySetSegment(this.rootDocument.getName());
    }
    if (this.count) {
        uriBuilder.count();
    } else {
        Set<String> columns = processSelect(projectedColumns);
        if (columns.isEmpty()) {
            uriBuilder.select(this.rootDocument.getTable().getPrimaryKey().getColumns().get(0).getName());
        } else {
            uriBuilder.select(columns.toArray(new String[columns.size()]));
        }
    }
    String filter = processFilter(condition);
    if (filter != null) {
        uriBuilder.filter(filter);
    }
    // process navigation tables
    for (ODataDocumentNode use : this.expandTables) {
        uriBuilder.expandWithOptions(use.getName(), use.getOptions());
    }
    if (this.skip != null) {
        uriBuilder.skip(this.skip);
    }
    if (this.top != null) {
        uriBuilder.top(this.top);
    }
    return uriBuilder;
}
Also used : URIBuilderImpl(org.apache.olingo.client.core.uri.URIBuilderImpl) ConfigurationImpl(org.apache.olingo.client.core.ConfigurationImpl)

Aggregations

ConfigurationImpl (org.apache.olingo.client.core.ConfigurationImpl)4 URIBuilderImpl (org.apache.olingo.client.core.uri.URIBuilderImpl)4 URI (java.net.URI)3 LinkedHashMap (java.util.LinkedHashMap)1 DocumentNode (org.teiid.translator.document.DocumentNode)1