本文整理汇总了Java中org.apache.olingo.server.api.uri.UriResource.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java UriResource.getKind方法的具体用法?Java UriResource.getKind怎么用?Java UriResource.getKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.server.api.uri.UriResource
的用法示例。
在下文中一共展示了UriResource.getKind方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperties
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Get's properties from {@link #groupBy} for aggregation query.
*
* @param groupBy
* groupBy instance
* @return list of properties
* @throws ODataApplicationException
* if any error occurred
*/
private static List<String> getProperties(GroupBy groupBy) throws ODataApplicationException {
List<String> groupByProperties = new ArrayList<>();
for (GroupByItem item : groupBy.getGroupByItems()) {
List<UriResource> path = item.getPath();
if (path.size() > 1) {
throwNotImplemented("Grouping by navigation property is not supported yet.");
}
UriResource resource = path.get(0);
if (resource.getKind() == UriResourceKind.primitiveProperty) {
groupByProperties.add(resource.getSegmentValue());
} else {
throwNotImplemented("Grouping by complex type is not supported yet.");
}
}
return groupByProperties;
}
示例2: getSelectList
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Returns the list of fields from URL.
* @param uriInfo uri info
* @return fields fields from URL
*/
protected List<String> getSelectList(UriInfo uriInfo) {
List<String> result = new ArrayList<>();
SelectOption selectOption = uriInfo.getSelectOption();
if (selectOption != null) {
List<SelectItem> selectItems = selectOption.getSelectItems();
for (SelectItem selectItem : selectItems) {
List<UriResource> selectParts = selectItem.getResourcePath().getUriResourceParts();
String fieldName = selectParts.get(selectParts.size() - 1).getSegmentValue();
result.add(fieldName);
}
} else {
List<UriResource> resourceParts = uriInfo.getUriResourceParts();
if (resourceParts.size() > 1) {
UriResource lastResource = resourceParts.get(resourceParts.size() - 1);
if (lastResource.getKind() == UriResourceKind.primitiveProperty) {
result.add(((UriResourceProperty) lastResource).getProperty().getName());
}
}
}
return result;
}
示例3: addSegmentQuery
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Method adds query depending on current and next URI resource segment.
*
* @param segment
* current segment
* @param nextSegment
* next segment
* @return casted queryBuilder
* @throws ODataApplicationException
* if any error occurred
*/
@SuppressWarnings("unchecked")
public T addSegmentQuery(UriResource segment, UriResource nextSegment)
throws ODataApplicationException {
ElasticEdmEntityType type = (ElasticEdmEntityType) ((UriResourcePartTyped) segment)
.getType();
String esType = type.getESType();
List<String> ids = collectIds(segment);
if (nextSegment == null) {
addIdQuery(esType, ids);
} else {
if (nextSegment.getKind() == UriResourceKind.primitiveProperty) {
addIdQuery(esType, ids);
} else {
if (((UriResourceNavigationPropertyImpl) nextSegment).getProperty()
.isCollection()) {
addParentQuery(esType, ids);
} else {
addChildQuery(esType, ids);
}
}
}
return (T) this;
}
示例4: validatePropertyOperations
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
throws UriValidationException {
final List<UriResource> parts = uriInfo.getUriResourceParts();
final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
if (last != null
&& (last.getKind() == UriResourceKind.primitiveProperty
|| last.getKind() == UriResourceKind.complexProperty
|| (last.getKind() == UriResourceKind.value
&& previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
final EdmProperty property = ((UriResourceProperty)
(last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
if (method == HttpMethod.PATCH && property.isCollection()) {
throw new UriValidationException("Attempt to patch collection property.",
UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
}
if (method == HttpMethod.DELETE && !property.isNullable()) {
throw new UriValidationException("Attempt to delete non-nullable property.",
UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
}
}
}
示例5: getBaseRequestInfo
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Gets base request info that is need for all requests. It goes through all
* URI resource parts and build query for each segment, the last entity set
* from resource segment is metadata entity of type to search. It returns
* {@link Query} with index, type, and query builder for search, and last
* entity set from resource parts.
*
* @param uriInfo
* URI info
* @return base request
* @throws ODataApplicationException
* OData app exception
*/
public BaseRequest getBaseRequestInfo(UriInfo uriInfo) throws ODataApplicationException {
List<UriResource> resourceParts = uriInfo.getUriResourceParts();
ElasticEdmEntitySet responseEntitySet = (ElasticEdmEntitySet) getFirstResourceEntitySet(
uriInfo);
Iterator<UriResource> iterator = resourceParts.iterator();
while (iterator.hasNext()) {
UriResource segment = iterator.next();
if (segment.getKind() == UriResourceKind.primitiveProperty) {
break;
}
if (segment.getKind() == UriResourceKind.navigationProperty) {
responseEntitySet = getNavigationTargetEntitySet(responseEntitySet,
(UriResourceNavigation) segment);
} else if (segment.getKind() != UriResourceKind.entitySet) {
throwNotImplemented();
}
if (iterator.hasNext()) {
int nextIndex = resourceParts.indexOf(segment) + 1;
queryBuilder.addSegmentQuery(segment, resourceParts.get(nextIndex));
} else {
queryBuilder.addSegmentQuery(segment, null);
}
}
queryBuilder.addFilter(getFilterQuery(uriInfo)).addFilter(getSearchQuery(uriInfo));
return new BaseRequest(
new Query(responseEntitySet.getESIndex(),
new String[] { responseEntitySet.getESType() }, queryBuilder.build(), null),
responseEntitySet, null);
// TODO: pass pagination info here, and reuse in child (in request
// creators)
}
示例6: getMetricsAggQueries
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Get's and creates metrics aggregation queries from {@link Aggregate} in
* URL.
*
* @param aggregations
* list of aggregations
* @return list of queries
* @throws ODataApplicationException
* if any error occurred
*/
protected List<AggregationBuilder> getMetricsAggQueries(List<Aggregate> aggregations)
throws ODataApplicationException {
List<AggregateExpression> expressions = aggregations.stream()
.flatMap(agg -> agg.getExpressions().stream()).collect(Collectors.toList());
List<AggregationBuilder> aggs = new ArrayList<>();
for (AggregateExpression aggExpression : expressions) {
try {
if (aggExpression.getInlineAggregateExpression() != null) {
throwNotImplemented(
"Aggregate for navigation or complex type fields is not supported.");
}
String alias = aggExpression.getAlias();
Expression expr = aggExpression.getExpression();
if (expr != null) {
String field = ((PrimitiveMember) expr.accept(getExpressionVisitor()))
.getField();
aggs.add(getAggQuery(aggExpression.getStandardMethod(), alias, field));
metricAliases.add(alias);
} else {
List<UriResource> path = aggExpression.getPath();
if (path.size() > 1) {
throwNotImplemented(
"Aggregate for navigation or complex type fields is not supported.");
}
UriResource resource = path.get(0);
if (resource.getKind() == UriResourceKind.count) {
countAlias = alias;
}
}
} catch (ExpressionVisitException e) {
throw new ODataRuntimeException(e);
}
}
return aggs;
}
示例7: visit
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
@Override
public void visit(SelectOption option) {
if (this.selectionComplete) {
return;
}
if (option == null) {
// default select columns
addAllColumns();
}
else {
for (SelectItem si:option.getSelectItems()) {
if (si.isStar()) {
addAllColumns();
continue;
}
UriResource resource = ResourcePropertyCollector.getUriResource(si.getResourcePath());
if (resource.getKind() != UriResourceKind.primitiveProperty) {
this.exceptions.add(new TeiidException(ODataPlugin.Event.TEIID16025, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16025)));
continue;
}
UriResourcePrimitiveProperty primitiveProp = (UriResourcePrimitiveProperty)resource;
addSelectColumn(new ElementSymbol(primitiveProp.getProperty().getName(), this.edmEntityTableGroup));
}
}
}
示例8: validatePath
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
private void validatePath(final UriInfoResource uriInfo) throws ODataApplicationException {
final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
for (final UriResource segment : resourcePaths.subList(1, resourcePaths.size())) {
final UriResourceKind kind = segment.getKind();
if (kind != UriResourceKind.navigationProperty
&& kind != UriResourceKind.primitiveProperty
&& kind != UriResourceKind.complexProperty
&& kind != UriResourceKind.count
&& kind != UriResourceKind.value
&& kind != UriResourceKind.function) {
throw new ODataApplicationException("Invalid resource type.",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
}
}
示例9: isPreLastResourcePrimitive
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
private boolean isPreLastResourcePrimitive() {
UriResource preLastResource = resourceParts.get(resourceParts.size() - 2);
return preLastResource.getKind() == UriResourceKind.primitiveProperty;
}
示例10: visit
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
@Override
public void visit(Member expr) {
ResourcePropertyCollector visitor = new ResourcePropertyCollector();
visitor.visit(expr.getResourcePath());
UriResource resource = visitor.getResource();
if (resource.getKind() == UriResourceKind.primitiveProperty) {
this.stack.add(new ElementSymbol(((UriResourceProperty) resource)
.getProperty().getName(), context
.getEdmEntityTableGroup()));
} else if (resource.getKind() == UriResourceKind.navigationProperty) {
EdmNavigationProperty navigation = ((UriResourceNavigation) resource).getProperty();
EdmEntityType type = navigation.getType();
if (!visitor.isCount()) {
this.exceptions.add(new TeiidException(ODataPlugin.Event.TEIID16028, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16028)));
}
GroupSymbol navGroup = new GroupSymbol(context.getNextAliasGroup(), type.getNamespace() + "." + type.getName());//$NON-NLS-1$
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null))));
query.setFrom(new From(Arrays.asList(new UnaryFromClause(navGroup))));
Criteria criteria = null;
for (ForeignKey fk : context.getEdmEntityTable().getForeignKeys()) {
if (fk.getName().equals(navigation.getName())) {
List<String> lhsColumns = ODataSQLBuilder.getColumnNames(fk.getColumns());
List<String> rhsColumns = fk.getReferenceColumns();
for (int i = 0; i < lhsColumns.size(); i++) {
if (criteria == null) {
criteria = new CompareCriteria(new ElementSymbol(lhsColumns.get(i),context.getEdmEntityTableGroup()),
CompareCriteria.EQ, new ElementSymbol(rhsColumns.get(i), navGroup));
} else {
Criteria subcriteria = new CompareCriteria(new ElementSymbol(lhsColumns.get(i), context.getEdmEntityTableGroup()),
CompareCriteria.EQ, new ElementSymbol(rhsColumns.get(i), navGroup));
criteria = new CompoundCriteria(CompoundCriteria.AND, criteria, subcriteria);
}
}
break;
}
}
query.setCriteria(criteria);
this.stack.add(new ScalarSubquery(query));
}
}
示例11: handleResourceDispatching
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
private void handleResourceDispatching(final ODataRequest request, final ODataResponse response)
throws ODataApplicationException, ODataLibraryException {
final int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1;
final UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
switch (lastPathSegment.getKind()) {
case action:
checkMethod(request.getMethod(), HttpMethod.POST);
handleActionDispatching(request, response, (UriResourceAction) lastPathSegment);
break;
case function:
checkMethod(request.getMethod(), HttpMethod.GET);
handleFunctionDispatching(request, response, (UriResourceFunction) lastPathSegment);
break;
case entitySet:
case navigationProperty:
handleEntityDispatching(request, response,
((UriResourcePartTyped) lastPathSegment).isCollection(), isEntityOrNavigationMedia(lastPathSegment));
break;
case singleton:
handleSingleEntityDispatching(request, response, isSingletonMedia(lastPathSegment), true);
break;
case count:
checkMethod(request.getMethod(), HttpMethod.GET);
handleCountDispatching(request, response, lastPathSegmentIndex);
break;
case primitiveProperty:
handlePrimitiveDispatching(request, response,
((UriResourceProperty) lastPathSegment).isCollection());
break;
case complexProperty:
handleComplexDispatching(request, response,
((UriResourceProperty) lastPathSegment).isCollection());
break;
case value:
handleValueDispatching(request, response, lastPathSegmentIndex);
break;
case ref:
handleReferenceDispatching(request, response, lastPathSegmentIndex);
break;
default:
throw new ODataHandlerException(NOT_IMPLEMENTED_MESSAGE,
ODataHandlerException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
}
}
示例12: extractInformation
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
private EdmBindingTarget extractInformation(final UriInfo uriInfo) throws PreconditionException {
EdmBindingTarget lastFoundEntitySetOrSingleton = null;
int counter = 0;
for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) {
switch (uriResourcePart.getKind()) {
case function:
lastFoundEntitySetOrSingleton = getEntitySetFromFunctionImport((UriResourceFunction) uriResourcePart);
break;
case singleton:
lastFoundEntitySetOrSingleton = ((UriResourceSingleton) uriResourcePart).getSingleton();
break;
case entitySet:
lastFoundEntitySetOrSingleton = getEntitySet((UriResourceEntitySet) uriResourcePart);
break;
case navigationProperty:
lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton,
(UriResourceNavigation) uriResourcePart);
break;
case primitiveProperty:
case complexProperty:
break;
case value:
case action:
// This should not be possible since the URI Parser validates this but to be sure we throw an exception.
if (counter != uriInfo.getUriResourceParts().size() - 1) {
throw new PreconditionException("$value or Action must be the last segment in the URI.",
PreconditionException.MessageKeys.INVALID_URI);
}
break;
default:
lastFoundEntitySetOrSingleton = null;
break;
}
if (lastFoundEntitySetOrSingleton == null) {
// Once we loose track of the entity set there is no way to retrieve it.
break;
}
counter++;
}
return lastFoundEntitySetOrSingleton;
}
示例13: getUriTypeForResource
import org.apache.olingo.server.api.uri.UriResource; //导入方法依赖的package包/类
/**
* Determines the URI type for a resource path.
* The URI parser has already made sure that there are enough segments for a given type of the last segment,
* but don't try to extract always the second-to-last segment, it could cause an {@link IndexOutOfBoundsException}.
*/
private UriType getUriTypeForResource(final List<UriResource> segments) throws UriValidationException {
final UriResource lastPathSegment = segments.get(segments.size() - 1);
UriType uriType;
switch (lastPathSegment.getKind()) {
case count:
uriType = getUriTypeForCount(segments.get(segments.size() - 2));
break;
case action:
uriType = getUriTypeForAction(lastPathSegment);
break;
case complexProperty:
uriType = getUriTypeForComplexProperty(lastPathSegment);
break;
case entitySet:
case navigationProperty:
uriType = getUriTypeForEntitySet(lastPathSegment);
break;
case function:
uriType = getUriTypeForFunction(lastPathSegment);
break;
case primitiveProperty:
uriType = getUriTypeForPrimitiveProperty(lastPathSegment);
break;
case ref:
uriType = getUriTypeForRef(segments.get(segments.size() - 2));
break;
case singleton:
uriType = UriType.entity;
break;
case value:
uriType = getUriTypeForValue(segments.get(segments.size() - 2));
break;
default:
throw new UriValidationException("Unsupported uriResource kind: " + lastPathSegment.getKind(),
UriValidationException.MessageKeys.UNSUPPORTED_URI_RESOURCE_KIND, lastPathSegment.getKind().toString());
}
return uriType;
}