@Override public Object visitMember(Member member) throws ExpressionVisitException, ODataApplicationException { List<UriResource> uriPartsWithinLambda = member.getResourcePath().getUriResourceParts(); String propertyPath = uriPartsWithinLambda.get(1).getSegmentValue(); if(uriPartsWithinLambda.size() > 2){ List<UriResource> restOfUri = uriPartsWithinLambda.subList(2, uriPartsWithinLambda.size()); for(UriResource uPa : restOfUri) { propertyPath += "."; propertyPath += uPa.getSegmentValue(); }} return convertToUpperCaseIfRequired(propertyPath); }
private void validateIsSingleton(HttpMethod method) throws ODataHandlerException { final int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1; final UriResource pathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); if (pathSegment instanceof UriResourceNavigation && uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1) instanceof UriResourceEntitySet && ((UriResourceEntitySet) uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1)).getEntitySet() .getRelatedBindingTarget( pathSegment.getSegmentValue()) instanceof EdmSingleton) { throwMethodNotAllowed(method); } }
private void validateIsSingleton(HttpMethod method) throws ODataHandlerException { final int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1; final UriResource pathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); if (pathSegment instanceof UriResourceNavigation && uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1) instanceof UriResourceEntitySet && ((UriResourceEntitySet) uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1)).getEntitySet() .getRelatedBindingTarget( pathSegment.getSegmentValue()) instanceof EdmSingleton) { throwMethodNotAllowed(method); } }
} else { resource = resourceParts.get(resourceParts.size() - 3); matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ? isFoundExpandItem(type, matched, resource) : false; expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 2)); matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ? isFoundExpandItem(type, matched, resource) : false; expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 1));
} else { resource = resourceParts.get(resourceParts.size() - 3); matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ? isFoundExpandItem(type, matched, resource) : false; expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 2)); matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ? isFoundExpandItem(type, matched, resource) : false; expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 1));
private void buildSelectionAddNavigationAndSelect(final UriInfoResource uriResource, final List<JPAPath> jpaPathList, final SelectOption select) throws ODataApplicationException, ODataJPAModelException { final UriResource last = !uriResource.getUriResourceParts().isEmpty() ? uriResource.getUriResourceParts().get( uriResource.getUriResourceParts().size() - 1) : null; final boolean targetIsCollection = (last != null && last instanceof UriResourceProperty && ((UriResourceProperty) last).isCollection()); final String pathPrefix = Util.determineProptertyNavigationPrefix(uriResource.getUriResourceParts()); if (Util.VALUE_RESOURCE.equals(pathPrefix)) jpaPathList.addAll(buildPathValue(jpaEntity)); else if (select == null || select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) { if (pathPrefix == null || pathPrefix.isEmpty()) copyNonCollectionProperties(jpaPathList, buildEntityPathList(jpaEntity)); else { expandPath(jpaEntity, jpaPathList, pathPrefix, targetIsCollection); } } else { for (SelectItem sItem : select.getSelectItems()) { String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); expandPath(jpaEntity, jpaPathList, pathPrefix.isEmpty() ? pathItem : pathPrefix + "/" + pathItem, targetIsCollection); } } }
for (SelectItem sItem : select.getSelectItems()) { final String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); final JPAPath selectItemPath = jpaEntity.getPath(pathPrefix.isEmpty() ? pathItem : pathPrefix + JPAPath.PATH_SEPERATOR + pathItem);
private void requireMediaResourceInCaseOfEntity(UriResource resource) throws UriParserSemanticException { // If the resource is an entity or navigatio if (resource instanceof UriResourceEntitySet && !((UriResourceEntitySet) resource).getEntityType().hasStream() || resource instanceof UriResourceNavigation && !((EdmEntityType) ((UriResourceNavigation) resource).getType()).hasStream()) { throw new UriParserSemanticException("$value on entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } // Functions can also deliver an entity. In this case we have to check if the returned entity is a media resource if (resource instanceof UriResourceFunction) { EdmType returnType = ((UriResourceFunction) resource).getFunction().getReturnType().getType(); //Collection check is above so not needed here if (returnType instanceof EdmEntityType && !((EdmEntityType) returnType).hasStream()) { throw new UriParserSemanticException("$value on returned entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } } }
pathTillLambda.append(convertToUpperCaseIfRequired(uriResourceParts.get(i).getSegmentValue())); if (i != uriResourceParts.size() - 2) { pathTillLambda.append(".");
private void requireMediaResourceInCaseOfEntity(UriResource resource) throws UriParserSemanticException { // If the resource is an entity or navigatio if (resource instanceof UriResourceEntitySet && !((UriResourceEntitySet) resource).getEntityType().hasStream() || resource instanceof UriResourceNavigation && !((EdmEntityType) ((UriResourceNavigation) resource).getType()).hasStream()) { throw new UriParserSemanticException("$value on entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } // Functions can also deliver an entity. In this case we have to check if the returned entity is a media resource if (resource instanceof UriResourceFunction) { EdmType returnType = ((UriResourceFunction) resource).getFunction().getReturnType().getType(); //Collection check is above so not needed here if (returnType instanceof EdmEntityType && !((EdmEntityType) returnType).hasStream()) { throw new UriParserSemanticException("$value on returned entity is only allowed on media resources.", UriParserSemanticException.MessageKeys.NOT_A_MEDIA_RESOURCE, resource.getSegmentValue()); } } }
for (SelectItem sItem : select.getSelectItems()) { String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); pathItem = pathPrefix == null || pathPrefix.isEmpty() ? pathItem : pathPrefix + JPAPath.PATH_SEPERATOR + pathItem;
entity = startUriRes.getEntityType(); eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()); eInfo.setFqName(entity.getFullQualifiedName().getFullQualifiedNameAsString()); if (parentAssociation != null) {
eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString());
eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()+DraftUtilsV4.DRAFTS_TABLE_NAME_SUFFIX);