@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 UriType getUriTypeForValue(final UriResource secondLastPathSegment) throws UriValidationException { UriType uriType; switch (secondLastPathSegment.getKind()) { case primitiveProperty: uriType = UriType.propertyPrimitiveValue; break; case entitySet: case navigationProperty: case singleton: uriType = UriType.mediaStream; break; case function: UriResourceFunction uriFunction = (UriResourceFunction) secondLastPathSegment; final EdmFunction function = uriFunction.getFunction(); uriType = function.getReturnType().getType().getKind() == EdmTypeKind.ENTITY ? UriType.mediaStream : UriType.propertyPrimitiveValue; break; default: throw new UriValidationException( "Unexpected kind in path segment before $value: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_VALUE, secondLastPathSegment.toString()); } return uriType; }
eInfo = new ReadEntityInfo(); eInfo.setFqName(entity.getFullQualifiedName().getFullQualifiedNameAsString()); eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); entity = startUriRes.getEntityType(); eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()); eInfo.setFqName(entity.getFullQualifiedName().getFullQualifiedNameAsString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation); if (subUriResourceParts.get(0).getKind().name().equals("value") || ((subUriResourceParts.get(0).getKind().name().equals("primitiveProperty")) && (subUriResourceParts.get(0) instanceof UriResourcePrimitiveProperty) && (((UriResourcePrimitiveProperty)subUriResourceParts.get(0)).getType().getFullQualifiedName().getFullQualifiedNameAsString().equals("Edm.Stream"))))// Then dont execute setEntityNavigated if (subUriResourceParts.get(0).getKind().name().equals("value") || ((subUriResourceParts.get(0).getKind().name().equals("primitiveProperty")) && (subUriResourceParts.get(0) instanceof UriResourcePrimitiveProperty) && (((UriResourcePrimitiveProperty)subUriResourceParts.get(0)).getType().getFullQualifiedName().getFullQualifiedNameAsString().equals("Edm.Stream"))))// Then dont execute setEntityNavigated && uriResourceParts.subList(1, uriResourceParts.size()).get(0).getKind().name().equals("primitiveProperty") && !((UriResourcePrimitiveProperty)uriResourceParts.subList(1, uriResourceParts.size()).get(0)).getType().getFullQualifiedName().getFullQualifiedNameAsString().equals("Edm.Stream"))
eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()); eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation);
private boolean isCollection(final UriResource pathSegment) throws UriValidationException { if (pathSegment instanceof UriResourcePartTyped) { return ((UriResourcePartTyped) pathSegment).isCollection(); } else { throw new UriValidationException( "Path segment is not an instance of UriResourcePartTyped but " + pathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, pathSegment.toString()); } }
eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()+DraftUtilsV4.DRAFTS_TABLE_NAME_SUFFIX); eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation);
private boolean isCollection(final UriResource pathSegment) throws UriValidationException { if (pathSegment instanceof UriResourcePartTyped) { return ((UriResourcePartTyped) pathSegment).isCollection(); } else { throw new UriValidationException( "Path segment is not an instance of UriResourcePartTyped but " + pathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, pathSegment.toString()); } }
private void checkNavigationPathSupported(final List<UriResource> resourceParts) throws ODataApplicationException { for (final UriResource resourceItem : resourceParts) { if (resourceItem.getKind() != UriResourceKind.complexProperty && resourceItem.getKind() != UriResourceKind.primitiveProperty && resourceItem.getKind() != UriResourceKind.navigationProperty && resourceItem.getKind() != UriResourceKind.entitySet && resourceItem.getKind() != UriResourceKind.value) throw new ODataJPAProcessorException(ODataJPAProcessorException.MessageKeys.NOT_SUPPORTED_RESOURCE_TYPE, HttpStatusCode.NOT_IMPLEMENTED, resourceItem.getKind().toString()); } }
private UriType getUriTypeForValue(final UriResource secondLastPathSegment) throws UriValidationException { UriType uriType; switch (secondLastPathSegment.getKind()) { case primitiveProperty: uriType = UriType.propertyPrimitiveValue; break; case entitySet: case navigationProperty: case singleton: uriType = UriType.mediaStream; break; case function: UriResourceFunction uriFunction = (UriResourceFunction) secondLastPathSegment; final EdmFunction function = uriFunction.getFunction(); uriType = function.getReturnType().getType().getKind() == EdmTypeKind.ENTITY ? UriType.mediaStream : UriType.propertyPrimitiveValue; break; default: throw new UriValidationException( "Unexpected kind in path segment before $value: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_VALUE, secondLastPathSegment.toString()); } return uriType; }
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 static JPAAssociationPath determineAssoziation(final JPAEntityType jpaEntity, final List<UriResource> uriResourceParts) throws ODataJPAQueryException { final StringBuilder pathName = new StringBuilder(); int i = 0; while (uriResourceParts.get(i) != null && !(uriResourceParts.get(i) instanceof UriResourceLambdaAny || uriResourceParts.get(i) instanceof UriResourceLambdaAll || uriResourceParts.get(i) instanceof UriResourceCount)) { pathName.append(uriResourceParts.get(i).toString()); pathName.append(JPAPath.PATH_SEPERATOR); i++; } pathName.deleteCharAt(pathName.lastIndexOf(JPAPath.PATH_SEPERATOR)); try { return jpaEntity.getCollectionAttribute(pathName.toString()).asAssociation(); } catch (ODataJPAModelException e) { throw new ODataJPAQueryException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } }
private boolean isAction(final UriInfo uriInfo) { List<UriResource> uriResourceParts = uriInfo.getUriResourceParts(); return !uriResourceParts.isEmpty() && UriResourceKind.action == uriResourceParts.get(uriResourceParts.size() - 1).getKind(); }
private UriType getUriTypeForCount(final UriResource secondLastPathSegment) throws UriValidationException { UriType uriType; switch (secondLastPathSegment.getKind()) { case entitySet: case navigationProperty: throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString());
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 String getSelectString(final SelectItem selectItem) { if (selectItem.isStar()) { if (selectItem.getAllOperationsInSchemaNameSpace() == null) { return "*"; } else { return selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*"; } } else { final StringBuilder tmp = new StringBuilder(); for (UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) { if (tmp.length() > 0) { tmp.append('/'); } tmp.append(resourcePart.toString()); } return tmp.toString(); } }
private boolean isAction(final UriInfo uriInfo) { List<UriResource> uriResourceParts = uriInfo.getUriResourceParts(); return !uriResourceParts.isEmpty() && UriResourceKind.action == uriResourceParts.get(uriResourceParts.size() - 1).getKind(); }
private UriType getUriTypeForCount(final UriResource secondLastPathSegment) throws UriValidationException { UriType uriType; switch (secondLastPathSegment.getKind()) { case entitySet: case navigationProperty: throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString());
} 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 String getSelectString(final SelectItem selectItem) { if (selectItem.isStar()) { if (selectItem.getAllOperationsInSchemaNameSpace() == null) { return "*"; } else { return selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*"; } } else { final StringBuilder tmp = new StringBuilder(); for (UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) { if (tmp.length() > 0) { tmp.append('/'); } tmp.append(resourcePart.toString()); } return tmp.toString(); } }