public static UriInfoImpl constructDeepReadForDraftRoot(EdmEntitySet edmEntitySet, String serviceName) throws ODataException { UriInfoImpl uriInfoForRead = new UriInfoImpl(); uriInfoForRead.setStartEntitySet(edmEntitySet); uriInfoForRead.setTargetEntitySet(edmEntitySet); Map<String,List<String>> draftTree = CSNUtil.getDraftTree(serviceName); List<ArrayList<NavigationPropertySegment>> expandOption = new ArrayList<>(); constructDraftTreeExpand(edmEntitySet, serviceName, draftTree, new ArrayList<>(), expandOption); uriInfoForRead.setExpand(expandOption); return uriInfoForRead; }
public static UriInfoImpl constructDeepReadForRoot(EdmEntitySet edmEntitySet, String serviceName, List<KeyPredicate> keyPredicates) throws ODataException { UriInfoImpl uriInfoForRead = new UriInfoImpl(); uriInfoForRead.setStartEntitySet(edmEntitySet); uriInfoForRead.setTargetEntitySet(edmEntitySet); Map<String,List<String>> compositionTree = CSNUtil.getCompositionTree(serviceName, edmEntitySet.getName()); List<ArrayList<NavigationPropertySegment>> expandOption = new ArrayList<>(); constructTreeExpand(edmEntitySet, serviceName, compositionTree, new ArrayList<>(), expandOption); uriInfoForRead.setKeyPredicates(keyPredicates); uriInfoForRead.setTargetType(edmEntitySet.getEntityType()); uriInfoForRead.setExpand(expandOption); return uriInfoForRead; }
private UriInfoImpl getDeleteUriInfo(UriInfoImpl uriInfoForRead, String navigationName, Map<String, Object> navigatedData, boolean isDraft) throws EdmException { UriInfoImpl uriInfoForDelete = new UriInfoImpl(); EdmEntitySet entitySet = this.getTargetEntitySetFromNavigation(uriInfoForRead, navigationName); if(entitySet != null) { List<KeyPredicate> keyPredicates = this.getKeys(entitySet, navigatedData, isDraft); uriInfoForDelete.setStartEntitySet(entitySet); uriInfoForDelete.setTargetEntitySet(entitySet); uriInfoForDelete.setKeyPredicates(keyPredicates); } return uriInfoForDelete; }
public static UriInfoDraftHelperV2 getCreateUriInfoForDraftsOneToOneUsingParent(EdmNavigationProperty navPropParent, Map<String, Object> parentDraftsEntry, EdmEntityContainer entityContainer, Map<String, Object> navigatedContent) throws ODataApplicationException { try{ Map<String, Object> childPayload = new HashMap<>(); EdmReferentialConstraint refConstraint = navPropParent.getRelationship().getReferentialConstraint(); if(refConstraint == null){ throw new ODataApplicationException(CREATE_REF_CONSTRAINT_MISSING, Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, CREATE_REF_CONSTRAINT_MISSING); } // Map of <ChildKey , ParentKey> Map<String, String> refConstraintsMap = getReferenceMap(refConstraint); for (Map.Entry<String, String> entry : refConstraintsMap.entrySet()) { childPayload.put(entry.getKey(), parentDraftsEntry.get(entry.getValue())); } childPayload.putAll(navigatedContent); ODataEntryImpl content = new ODataEntryImpl(childPayload, null, null, null, false); EdmEntitySet entSet = entityContainer.getEntitySet(navPropParent.getType().getName()); UriInfoImpl uriInfoForCreate = new UriInfoImpl(); uriInfoForCreate.setStartEntitySet(entSet); uriInfoForCreate.setTargetEntitySet(entSet); UriInfoDraftHelperV2 uriT = new UriInfoDraftHelperV2(); uriT.setUriInfo(uriInfoForCreate); uriT.setContent(content); uriT.setUriFunction(UriFunction.CREATE); return uriT; }catch(EdmException ee){ logger.debug(ee.getMessage(), ee); throw new ODataApplicationException(ee.getMessage(), Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, ee.getMessage()); } }
private static UriInfoDraftHelperV2 transFormerForDelete(Map<String, Object> ent, EdmEntitySet entSet) throws ODataException { UriInfoDraftHelperV2 uriT=new UriInfoDraftHelperV2(); //Create the UriInfoForCreate //Extract Keys from Entity UriInfoImpl uriInfoForDelete = new UriInfoImpl(); uriInfoForDelete.setStartEntitySet(entSet); uriInfoForDelete.setTargetEntitySet(entSet); uriInfoForDelete.setKeyPredicates(DraftUtilsV2.extractKeyPredicateRefsEntity(ent, entSet.getEntityType())); uriT.setUriInfo(uriInfoForDelete); uriT.setUriFunction(UriFunction.DELETE); return uriT; }
private void handleEntitySet(final EdmEntitySet entitySet, final String keyPredicate) throws UriSyntaxException, UriNotMatchingException, EdmException { final EdmEntityType entityType = entitySet.getEntityType(); uriResult.setTargetType(entityType); uriResult.setTargetEntitySet(entitySet); if (keyPredicate == null) { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI1); } else { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI15); } else { throw new UriSyntaxException(UriSyntaxException.ENTITYSETINSTEADOFENTITY.addContent(entitySet.getName())); } } } else { uriResult.setKeyPredicates(parseKey(keyPredicate, entityType)); if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI2); } else { handleNavigationPathOptions(); } } }
private void handleEntitySet(final EdmEntitySet entitySet, final String keyPredicate) throws UriSyntaxException, UriNotMatchingException, EdmException { final EdmEntityType entityType = entitySet.getEntityType(); uriResult.setTargetType(entityType); uriResult.setTargetEntitySet(entitySet); if (keyPredicate == null) { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI1); } else { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI15); } else { throw new UriSyntaxException(UriSyntaxException.ENTITYSETINSTEADOFENTITY.addContent(entitySet.getName())); } } } else { uriResult.setKeyPredicates(parseKey(keyPredicate, entityType)); if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI2); } else { handleNavigationPathOptions(); } } }
private void handleEntitySet(final EdmEntitySet entitySet, final String keyPredicate) throws UriSyntaxException, UriNotMatchingException, EdmException { final EdmEntityType entityType = entitySet.getEntityType(); uriResult.setTargetType(entityType); uriResult.setTargetEntitySet(entitySet); if (keyPredicate == null) { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI1); } else { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI15); } else { throw new UriSyntaxException(UriSyntaxException.ENTITYSETINSTEADOFENTITY.addContent(entitySet.getName())); } } } else { uriResult.setKeyPredicates(parseKey(keyPredicate, entityType)); if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI2); } else { handleNavigationPathOptions(); } } }
private void addNavigationSegment(final String keyPredicateName, final EdmNavigationProperty navigationProperty) throws UriSyntaxException, EdmException { final EdmEntitySet targetEntitySet = uriResult.getTargetEntitySet().getRelatedEntitySet(navigationProperty); final EdmEntityType targetEntityType = targetEntitySet.getEntityType(); uriResult.setTargetEntitySet(targetEntitySet); uriResult.setTargetType(targetEntityType); NavigationSegmentImpl navigationSegment = new NavigationSegmentImpl(); navigationSegment.setEntitySet(targetEntitySet); navigationSegment.setNavigationProperty(navigationProperty); if (keyPredicateName != null) { navigationSegment.setKeyPredicates(parseKey(keyPredicateName, targetEntityType)); } uriResult.addNavigationSegment(navigationSegment); }
private void addNavigationSegment(final String keyPredicateName, final EdmNavigationProperty navigationProperty) throws UriSyntaxException, EdmException { final EdmEntitySet targetEntitySet = uriResult.getTargetEntitySet().getRelatedEntitySet(navigationProperty); final EdmEntityType targetEntityType = targetEntitySet.getEntityType(); uriResult.setTargetEntitySet(targetEntitySet); uriResult.setTargetType(targetEntityType); NavigationSegmentImpl navigationSegment = new NavigationSegmentImpl(); navigationSegment.setEntitySet(targetEntitySet); navigationSegment.setNavigationProperty(navigationProperty); if (keyPredicateName != null) { navigationSegment.setKeyPredicates(parseKey(keyPredicateName, targetEntityType)); } uriResult.addNavigationSegment(navigationSegment); }
private void addNavigationSegment(final String keyPredicateName, final EdmNavigationProperty navigationProperty) throws UriSyntaxException, EdmException { final EdmEntitySet targetEntitySet = uriResult.getTargetEntitySet().getRelatedEntitySet(navigationProperty); final EdmEntityType targetEntityType = targetEntitySet.getEntityType(); uriResult.setTargetEntitySet(targetEntitySet); uriResult.setTargetType(targetEntityType); NavigationSegmentImpl navigationSegment = new NavigationSegmentImpl(); navigationSegment.setEntitySet(targetEntitySet); navigationSegment.setNavigationProperty(navigationProperty); if (keyPredicateName != null) { navigationSegment.setKeyPredicates(parseKey(keyPredicateName, targetEntityType)); } uriResult.addNavigationSegment(navigationSegment); }
clone.setTargetEntitySet(createView.getStartEntitySet()); clone.getNavigationSegments().clear(); clone.setTargetType(clone.getTargetEntitySet().getEntityType());
uriInfoForParentRead.setTargetEntitySet(uriInfo.getStartEntitySet()); uriInfoForParentRead.setKeyPredicates(uriInfo.getKeyPredicates()); IDataProviderResponse parentDraftResponse = draftProvider.readDataFromDraftsTable( EdmEntitySet navigationCreateEntitySet = EDMHelper.getEdmEntitySet((UriInfo)uriInfo, HeaderUtil.getlocale(context)); uriInfoForNavigationCreate.setStartEntitySet(navigationCreateEntitySet); uriInfoForNavigationCreate.setTargetEntitySet(navigationCreateEntitySet);
private static UriInfoDraftHelperV2 transFormerForCreate(Map<String, Object> ent, EdmEntitySet entSet, DraftFlow flow) { UriInfoDraftHelperV2 uriT=new UriInfoDraftHelperV2(); //Create the UriInfoForCreate UriInfoImpl uriInfoForCreate = new UriInfoImpl(); uriInfoForCreate.setStartEntitySet(entSet); uriInfoForCreate.setTargetEntitySet(entSet); //Create the Deserializer //Remove any links and navigation links . We only want to create payload for a single level if(flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMNEW)||flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMEXISTING)) { washDraftEntity(ent); } //Clean up navigation properties as Olingo V2 insert doesn't allow them. ODataEntryImpl data = new ODataEntryImpl(washNavigationEntity(ent), null, null, null, false); uriT.setUriInfo(uriInfoForCreate); uriT.setContent(data); uriT.setUriFunction(UriFunction.CREATE); return uriT; }
private static UriInfoDraftHelperV2 transFormerForUpdate(Map<String, Object> ent, EdmEntitySet entSet, DraftFlow flow) throws ODataException { UriInfoDraftHelperV2 uriT=new UriInfoDraftHelperV2(); //Create the uriInfoForUpdate //Extract Keys from Entity UriInfoImpl uriInfoForUpdate = new UriInfoImpl(); uriInfoForUpdate.setStartEntitySet(entSet); uriInfoForUpdate.setTargetEntitySet(entSet); uriInfoForUpdate.setKeyPredicates(DraftUtilsV2.extractKeyPredicateRefsEntity(ent, entSet.getEntityType())); //Create the Deserializer //Remove any links and navigation links . We only want to create payload for a single level if(flow.equals(DraftFlow.DRAFT_ACTIVATE_FROMEXISTING)) { washDraftEntity(ent); } //Clean up navigation properties as Olingo V2 update doesn't allow them. ODataEntryImpl data = new ODataEntryImpl(washNavigationEntity(ent), null, null, null, false); uriT.setUriInfo(uriInfoForUpdate); uriT.setContent(data); uriT.setUriFunction(UriFunction.UPDATE); return uriT; }