use of org.apache.olingo.client.core.uri.URIBuilderImpl 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();
}
use of org.apache.olingo.client.core.uri.URIBuilderImpl 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();
}
use of org.apache.olingo.client.core.uri.URIBuilderImpl in project teiid by teiid.
the class ODataSQLVisitor method buildURL.
public String buildURL(String serviceRoot) throws TranslatorException {
URIBuilderImpl uriBuilder = this.odataQuery.buildURL(serviceRoot, this.projectedColumns, LanguageUtil.combineCriteria(this.conditionFragments));
if (this.orderBy.length() > 0) {
uriBuilder.orderBy(this.orderBy.toString());
}
URI uri = uriBuilder.build();
return uri.toString();
}
use of org.apache.olingo.client.core.uri.URIBuilderImpl 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();
}
use of org.apache.olingo.client.core.uri.URIBuilderImpl 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;
}
Aggregations