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 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 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 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 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 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 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; }
ObjectNode node = nodeFactory.objectNode() .put(NODE_TYPE_NAME, segment.getKind().toString()) .put(NAME_NAME, segment.toString()) .put(TYPE_NAME, getType(segment)); if (segment instanceof UriResourceEntitySet) { segments.add(nodeFactory.objectNode() .put(NODE_TYPE_NAME, segment.getKind().toString()) .put(NAME_NAME, segment.toString()) .putNull(TYPE_NAME));
ObjectNode node = nodeFactory.objectNode() .put(NODE_TYPE_NAME, segment.getKind().toString()) .put(NAME_NAME, segment.toString()) .put(TYPE_NAME, getType(segment)); if (segment instanceof UriResourceEntitySet) { segments.add(nodeFactory.objectNode() .put(NODE_TYPE_NAME, segment.getKind().toString()) .put(NAME_NAME, segment.toString()) .putNull(TYPE_NAME));
eInfo = new ReadEntityInfo(); eInfo.setFqName(entity.getFullQualifiedName().getFullQualifiedNameAsString()); eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); eInfo.setFqName(entity.getFullQualifiedName().getFullQualifiedNameAsString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation);
gen.writeStartObject(); gen.writeStringField("uriResourceKind", resource.getKind().toString()); gen.writeStringField("segment", resource.toString()); if (resource instanceof UriResourcePartTyped) { appendType(gen, "type", ((UriResourcePartTyped) resource).getType());
gen.writeStartObject(); gen.writeStringField("uriResourceKind", resource.getKind().toString()); gen.writeStringField("segment", resource.toString()); if (resource instanceof UriResourcePartTyped) { appendType(gen, "type", ((UriResourcePartTyped) resource).getType());
eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation);
eInfo.setEntityName(currentUri.toString()); if (parentAssociation != null) { eInfo.setParententityName(parentAssociation); } else { eInfo.setParententityName(currentUri.toString()); eInfo.setParententityName(parentAssociation + ALIASHLP + currentUri.toString()); } else { eInfo.setParententityName(parentAssociation);
default: throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString());
default: throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString());