private void parseCollectionPathExpr(UriInfoImpl uriInfo, final UriResourcePartTyped lastResource) throws UriParserException, UriValidationException { // The initial slash (see grammar) must have been checked and consumed by the caller. if (tokenizer.next(TokenKind.COUNT)) { uriInfo.addResourcePart(new UriResourceCountImpl()); } else if (tokenizer.next(TokenKind.ANY)) { uriInfo.addResourcePart(parseLambdaRest(TokenKind.ANY, lastResource)); } else if (tokenizer.next(TokenKind.ALL)) { uriInfo.addResourcePart(parseLambdaRest(TokenKind.ALL, lastResource)); } else if (tokenizer.next(TokenKind.QualifiedName)) { parseBoundFunction(new FullQualifiedName(tokenizer.getText()), uriInfo, lastResource); } else { throw new UriParserSyntaxException("Unexpected token.", UriParserSyntaxException.MessageKeys.SYNTAX); } }
protected ExpandItemImpl buildExpandItem(final EdmNavigationProperty edmNavigationProperty) { return new ExpandItemImpl() .setResourcePath(new UriInfoImpl() .addResourcePart(new UriResourceNavigationPropertyImpl(edmNavigationProperty))); } }
protected ExpandItemImpl buildExpandItem(final EdmNavigationProperty edmNavigationProperty) { return new ExpandItemImpl() .setResourcePath(new UriInfoImpl() .addResourcePart(new UriResourceNavigationPropertyImpl(edmNavigationProperty))); } }
private void parseDollarIt(UriInfoImpl uriInfo, final EdmType referringType) throws UriParserException, UriValidationException { UriResourceItImpl itResource = new UriResourceItImpl(referringType, false); uriInfo.addResourcePart(itResource); if (tokenizer.next(TokenKind.SLASH)) { final TokenKind tokenKind = ParserHelper.next(tokenizer, TokenKind.QualifiedName, TokenKind.ODataIdentifier); parseMemberExpression(tokenKind, uriInfo, itResource, true); } }
private void parseDollarIt(UriInfoImpl uriInfo, final EdmType referringType) throws UriParserException, UriValidationException { UriResourceItImpl itResource = new UriResourceItImpl(referringType, false); uriInfo.addResourcePart(itResource); if (tokenizer.next(TokenKind.SLASH)) { final TokenKind tokenKind = ParserHelper.next(tokenizer, TokenKind.QualifiedName, TokenKind.ODataIdentifier); parseMemberExpression(tokenKind, uriInfo, itResource, true); } }
private void parseCollectionPathExpr(UriInfoImpl uriInfo, final UriResourcePartTyped lastResource) throws UriParserException, UriValidationException { // The initial slash (see grammar) must have been checked and consumed by the caller. if (tokenizer.next(TokenKind.COUNT)) { uriInfo.addResourcePart(new UriResourceCountImpl()); } else if (tokenizer.next(TokenKind.ANY)) { uriInfo.addResourcePart(parseLambdaRest(TokenKind.ANY, lastResource)); } else if (tokenizer.next(TokenKind.ALL)) { uriInfo.addResourcePart(parseLambdaRest(TokenKind.ALL, lastResource)); } else if (tokenizer.next(TokenKind.QualifiedName)) { parseBoundFunction(new FullQualifiedName(tokenizer.getText()), uriInfo, lastResource); } else { throw new UriParserSyntaxException("Unexpected token.", UriParserSyntaxException.MessageKeys.SYNTAX); } }
private static UriInfoDraftHelperV4 transFormerForDelete(Entity ent,EdmEntityContainer entityContainer,DraftFlow flow) throws ODataApplicationException { String serviceName=entityContainer.getNamespace(); UriInfoDraftHelperV4 _uriT=new UriInfoDraftHelperV4(); //Create the UriInfoForCreate EdmEntitySet entSet=entityContainer.getEntitySet(ent.getType().substring(serviceName.length()+1)); //Recheck what value is being stored here .... UriResourceEntitySetImpl entitySetForDelete = new UriResourceEntitySetImpl(entSet); entitySetForDelete.setKeyPredicates(DraftUtilsV4.extractKeyPredicateRefsEntity(ent, entSet.getEntityType())); //Extract Keys from Entity UriInfo uriInfoForDelete = new UriInfoImpl().addResourcePart(entitySetForDelete); _uriT.setUriInfo(uriInfoForDelete); _uriT.setUriFunction(UriFunction.DELETE); return _uriT; }
public static UriInfoImpl constructDeepReadForDraftRoot(EdmEntitySet entitySet,Map<String,List<String>> draftTree,UriInfo requestUriInfo) throws ODataApplicationException { UriInfoImpl uriInfoForRead=null; if(requestUriInfo!=null) { uriInfoForRead=(UriInfoImpl)requestUriInfo; }else { UriResourceEntitySet entitySetForRead = new UriResourceEntitySetImpl(entitySet); uriInfoForRead = new UriInfoImpl().addResourcePart(entitySetForRead); } ExpandOptionImpl eo=constructDraftTreeExpand(EdmHelper.getEdmEntitySet(uriInfoForRead, null).getEntityType(),(ExpandOptionImpl) uriInfoForRead.getExpandOption(),draftTree); if(eo!=null && eo.getExpandItems()!=null&&!eo.getExpandItems().isEmpty()) { uriInfoForRead.setSystemQueryOption(eo); } return uriInfoForRead; }
final EdmStructuredType typeCast = ParserHelper.parseTypeCast(tokenizer, edm, referencedType); if (typeCast != null) { uriInfo.addResourcePart(new UriResourceStartingTypeFilterImpl(typeCast, true)); ParserHelper.requireNext(tokenizer, TokenKind.SLASH); return name; } else { uriInfo.addResourcePart( property instanceof EdmNavigationProperty ? new UriResourceNavigationPropertyImpl((EdmNavigationProperty) property) : uriInfo.addResourcePart(segment);
final EdmStructuredType typeCast = ParserHelper.parseTypeCast(tokenizer, edm, referencedType); if (typeCast != null) { uriInfo.addResourcePart(new UriResourceStartingTypeFilterImpl(typeCast, true)); ParserHelper.requireNext(tokenizer, TokenKind.SLASH); return name; } else { uriInfo.addResourcePart( property instanceof EdmNavigationProperty ? new UriResourceNavigationPropertyImpl((EdmNavigationProperty) property) : uriInfo.addResourcePart(segment);
final UriResourceEntitySetImpl resource = new UriResourceEntitySetImpl(edm.getEntityContainer().getEntitySet(name)); uriInfo.addResourcePart(resource); if (tokenizer.next(TokenKind.SLASH)) { final TokenKind tokenKind = ParserHelper.next(tokenizer, TokenKind.QualifiedName, TokenKind.ODataIdentifier); uriInfo.addResourcePart(lambdaResource); if (tokenizer.next(TokenKind.SLASH)) { final TokenKind tokenKind = ParserHelper.next(tokenizer, TokenKind.QualifiedName, TokenKind.ODataIdentifier);
private static UriInfoDraftHelperV4 transFormerForCreate(Entity ent,EdmEntityContainer entityContainer,DraftFlow flow) { String serviceName=entityContainer.getNamespace(); UriInfoDraftHelperV4 _uriT=new UriInfoDraftHelperV4(); //Create the UriInfoForCreate EdmEntitySet entSet=entityContainer.getEntitySet(ent.getType().substring(serviceName.length()+1)); //Recheck what value is being stored here .... UriResourceEntitySet entitySetForCreate = new UriResourceEntitySetImpl(entSet); UriInfo uriInfoForCreate = new UriInfoImpl().addResourcePart(entitySetForCreate); //Create the Deserializer //Remove any links and navigation links . We only want to create payload for a single level //ent.getNavigationLinks().clear(); if(flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMNEW)||flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMEXISTING)) { washDraftEntity(ent); } DeserializerResult deserializerResult=DeserializerResultImpl.with().entity(ent).build(); _uriT.setUriInfo(uriInfoForCreate); _uriT.setDeserializerResult(deserializerResult); _uriT.setUriFunction(UriFunction.CREATE); return _uriT; }
private static ExpandOptionImpl constructDraftTreeExpand(EdmEntityType rootEntityType,ExpandOptionImpl eO,Map<String,List<String>> draftTree) { if(eO==null) { eO=new ExpandOptionImpl(); } if(rootEntityType.getNavigationPropertyNames()!=null && !rootEntityType.getNavigationPropertyNames().isEmpty()) { for(String navName:rootEntityType.getNavigationPropertyNames()) { EdmNavigationProperty expandNp=rootEntityType.getNavigationProperty(navName); if(draftTree.get(rootEntityType.getName()).contains(expandNp.getType().getName())) { UriResourceNavigationPropertyImpl adminNaVPropImpl=new UriResourceNavigationPropertyImpl(expandNp); UriInfoImpl uriInfoForExpand = new UriInfoImpl().addResourcePart(adminNaVPropImpl); //Recursively set compositions ExpandOption innerExpandoption=constructDraftTreeExpand(expandNp.getType(),(ExpandOptionImpl) uriInfoForExpand.getExpandOption(),draftTree); if(innerExpandoption!=null) { uriInfoForExpand.setSystemQueryOption(innerExpandoption); ExpandItem eI = new ExpandItemImpl().setResourcePath(uriInfoForExpand).setSystemQueryOption(innerExpandoption); eO.addExpandItem(eI); } } } return eO; } return eO; }
private void parseDollarRoot(UriInfoImpl uriInfo) throws UriParserException, UriValidationException { UriResourceRootImpl rootResource = new UriResourceRootImpl(referringType, true); uriInfo.addResourcePart(rootResource); ParserHelper.requireNext(tokenizer, TokenKind.SLASH); ParserHelper.requireNext(tokenizer, TokenKind.ODataIdentifier); final String name = tokenizer.getText(); UriResourcePartTyped resource = null; final EdmEntitySet entitySet = edm.getEntityContainer().getEntitySet(name); if (entitySet == null) { final EdmSingleton singleton = edm.getEntityContainer().getSingleton(name); if (singleton == null) { throw new UriParserSemanticException("EntitySet or singleton expected.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, name); } else { resource = new UriResourceSingletonImpl(singleton); } } else { ParserHelper.requireNext(tokenizer, TokenKind.OPEN); final List<UriParameter> keyPredicates = ParserHelper.parseKeyPredicate(tokenizer, entitySet.getEntityType(), null, edm, referringType, aliases); resource = new UriResourceEntitySetImpl(entitySet).setKeyPredicates(keyPredicates); } uriInfo.addResourcePart(resource); parseSingleNavigationExpr(uriInfo, resource); }
private void parseDollarRoot(UriInfoImpl uriInfo) throws UriParserException, UriValidationException { UriResourceRootImpl rootResource = new UriResourceRootImpl(referringType, true); uriInfo.addResourcePart(rootResource); ParserHelper.requireNext(tokenizer, TokenKind.SLASH); ParserHelper.requireNext(tokenizer, TokenKind.ODataIdentifier); final String name = tokenizer.getText(); UriResourcePartTyped resource = null; final EdmEntitySet entitySet = edm.getEntityContainer().getEntitySet(name); if (entitySet == null) { final EdmSingleton singleton = edm.getEntityContainer().getSingleton(name); if (singleton == null) { throw new UriParserSemanticException("EntitySet or singleton expected.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, name); } else { resource = new UriResourceSingletonImpl(singleton); } } else { ParserHelper.requireNext(tokenizer, TokenKind.OPEN); final List<UriParameter> keyPredicates = ParserHelper.parseKeyPredicate(tokenizer, entitySet.getEntityType(), null, edm, referringType, aliases); resource = new UriResourceEntitySetImpl(entitySet).setKeyPredicates(keyPredicates); } uriInfo.addResourcePart(resource); parseSingleNavigationExpr(uriInfo, resource); }
private static UriInfoDraftHelperV4 transFormerForUpdate(Entity ent,EdmEntityContainer entityContainer,DraftFlow flow) throws ODataApplicationException { String serviceName=entityContainer.getNamespace(); UriInfoDraftHelperV4 _uriT=new UriInfoDraftHelperV4(); //Create the UriInfoForCreate EdmEntitySet entSet=entityContainer.getEntitySet(ent.getType().substring(serviceName.length()+1)); //Recheck what value is being stored here .... UriResourceEntitySetImpl entitySetForUpdate = new UriResourceEntitySetImpl(entSet); entitySetForUpdate.setKeyPredicates(DraftUtilsV4.extractKeyPredicateRefsEntity(ent, entSet.getEntityType())); //Extract Keys from Entity UriInfo uriInfoForUpdate = new UriInfoImpl().addResourcePart(entitySetForUpdate); //Create the Deserializer //Remove any links and navigation links . We only want to create payload for a single level //ent.getNavigationLinks().clear(); if(flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMEXISTING)) { washDraftEntity(ent); } DeserializerResult deserializerResult=DeserializerResultImpl.with().entity(ent).build(); _uriT.setUriInfo(uriInfoForUpdate); _uriT.setDeserializerResult(deserializerResult); _uriT.setUriFunction(UriFunction.UPDATE); return _uriT; }
type = typeCast; resource.addResourcePart(complexResource); if(streamProperty != null && streamProperty.getType() == EdmPrimitiveTypeFactory. getInstance(EdmPrimitiveTypeKind.Stream)){ resource.addResourcePart(new UriResourcePrimitivePropertyImpl(streamProperty)); }else if (tokenizer.next(TokenKind.STAR)) { item.setIsStar(true); resource.addResourcePart(new UriResourceNavigationPropertyImpl(navigationProperty));
private ExpandItem parseCrossJoinItem(UriTokenizer tokenizer) throws UriParserSemanticException { ExpandItemImpl item = new ExpandItemImpl(); if (tokenizer.next(TokenKind.STAR)) { item.setIsStar(true); } else if (tokenizer.next(TokenKind.ODataIdentifier)) { String entitySetName = tokenizer.getText(); if (crossjoinEntitySetNames.contains(entitySetName)) { UriInfoImpl resource = new UriInfoImpl().setKind(UriInfoKind.resource); final UriResourceEntitySetImpl entitySetResourceSegment = new UriResourceEntitySetImpl(edm.getEntityContainer().getEntitySet(entitySetName)); resource.addResourcePart(entitySetResourceSegment); item.setResourcePath(resource); } else { throw new UriParserSemanticException("Unknown crossjoin entity set.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, entitySetName); } } else { throw new UriParserSemanticException("If the target resource is a crossjoin an entity set is " + "needed as the starting point.", UriParserSemanticException.MessageKeys.UNKNOWN_PART); } return item; }
private ExpandItem parseCrossJoinItem(UriTokenizer tokenizer) throws UriParserSemanticException { ExpandItemImpl item = new ExpandItemImpl(); if (tokenizer.next(TokenKind.STAR)) { item.setIsStar(true); } else if (tokenizer.next(TokenKind.ODataIdentifier)) { String entitySetName = tokenizer.getText(); if (crossjoinEntitySetNames.contains(entitySetName)) { UriInfoImpl resource = new UriInfoImpl().setKind(UriInfoKind.resource); final UriResourceEntitySetImpl entitySetResourceSegment = new UriResourceEntitySetImpl(edm.getEntityContainer().getEntitySet(entitySetName)); resource.addResourcePart(entitySetResourceSegment); item.setResourcePath(resource); } else { throw new UriParserSemanticException("Unknown crossjoin entity set.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, entitySetName); } } else { throw new UriParserSemanticException("If the target resource is a crossjoin an entity set is " + "needed as the starting point.", UriParserSemanticException.MessageKeys.UNKNOWN_PART); } return item; }
public static UriInfoDraftHelperV4 getCreateUriInfoForDraftsOneToOneUsingParent(EdmNavigationProperty navPropParent,Entity parentDraftsEntry,EdmEntityContainer entityContainer) throws ODataApplicationException { Entity childPayload=new Entity(); List<EdmReferentialConstraint> refConstraints = null ; refConstraints = navPropParent.getReferentialConstraints(); if( refConstraints == null || refConstraints.isEmpty() ){ throw new ODataApplicationException ("Unable to create with navigation because the corresponding referential constraint is missing.", HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(),Locale.ENGLISH,"Unable to create with navigation because the corresponding referential constraint is missing"); } refConstraints.forEach(refConstraint->{ // Map of <ChildKey , ParentKey> childPayload.addProperty(new Property(null, refConstraint.getReferencedPropertyName(), ValueType.PRIMITIVE, parentDraftsEntry.getProperty(refConstraint.getPropertyName()).getValue())); }); DeserializerResult deserializerResult=DeserializerResultImpl.with().entity(childPayload).build(); EdmEntitySet entSet=entityContainer.getEntitySet(navPropParent.getType().getName()); UriResourceEntitySet entitySetForCreate = new UriResourceEntitySetImpl(entSet); UriInfo uriInfoForCreate = new UriInfoImpl().addResourcePart(entitySetForCreate); UriInfoDraftHelperV4 _uriT=new UriInfoDraftHelperV4(); _uriT.setUriInfo(uriInfoForCreate); _uriT.setDeserializerResult(deserializerResult); _uriT.setUriFunction(UriFunction.CREATE); return _uriT; }