org.apache.olingo.odata2.api.uri.info.DeleteUriInfo Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.uri.info.DeleteUriInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse deleteEntityMedia(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { final Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } dataSource.writeBinaryData(uriInfo.getTargetEntitySet(), data, new BinaryData(null, null)); return ODataResponse.newBuilder().build(); }
Example #2
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); valueAccess.setPropertyValue(data, property, null); valueAccess.setMappingValue(data, property.getMapping(), null); return ODataResponse.newBuilder().build(); }
Example #3
Source File: User.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
@Override public void deleteLink(DeleteUriInfo link) throws ODataException { EdmEntitySet target_es = link.getTargetEntitySet(); if (!target_es.getName().equals(Model.PRODUCT.getName())) { throw new ODataException("Cannot create link from Users to " + target_es.getName()); } String pdt_uuid_s = link.getTargetKeyPredicates().get(0).getLiteral(); fr.gael.dhus.database.object.Product pta = PRODUCT_SERVICE.getProduct(pdt_uuid_s); if (pta == null) { throw new InvalidKeyException(pdt_uuid_s, this.getClass().getSimpleName()); } PRODUCTCART_SERVICE.removeProductFromCart(this.user.getUUID(), pta.getId()); }
Example #4
Source File: Processor.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
@Override public ODataResponse deleteEntityLink(DeleteUriInfo uri_info, String content_type) throws ODataException { // uriInfo#getNavigationSegments() does not return a shallow copy. List<NavigationSegment> lns = new ArrayList<>(uri_info.getNavigationSegments().size()); lns.addAll(uri_info.getNavigationSegments()); // Removes the target for navigation purposes. if (!lns.isEmpty()) { lns.remove(lns.size()-1); } AbstractEntity entity = Navigator.<AbstractEntity>navigate(uri_info.getStartEntitySet(), uri_info.getKeyPredicates().get(0), lns, AbstractEntity.class); // Deletes. entity.deleteLink(uri_info); return ODataResponse.newBuilder().build(); }
Example #5
Source File: JPAProcessorImplTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private DeleteUriInfo getDeletetUriInfo() { UriInfo objUriInfo = EasyMock.createMock(UriInfo.class); EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet()); EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet()); EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null); EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression()); EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop()); EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip()); EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount()); EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter()); EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates()); EasyMock.expect(objUriInfo.isLinks()).andStubReturn(false); EasyMock.expect(objUriInfo.getNavigationSegments()).andStubReturn(new ArrayList<NavigationSegment>()); EasyMock.replay(objUriInfo); return objUriInfo; }
Example #6
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final List<EdmProperty> propertyPath = uriInfo.getPropertyPath(); final EdmProperty property = propertyPath.get(propertyPath.size() - 1); data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1)); valueAccess.setPropertyValue(data, property, null); valueAccess.setMappingValue(data, property.getMapping(), null); return ODataResponse.newBuilder().build(); }
Example #7
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse deleteEntityMedia(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { final Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } dataSource.writeBinaryData(uriInfo.getTargetEntitySet(), data, new BinaryData(null, null)); return ODataResponse.newBuilder().build(); }
Example #8
Source File: JPAProcessorImpl.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public Object process(DeleteUriInfo uriParserResultView, final String contentType) throws ODataJPAModelException, ODataJPARuntimeException { if (uriParserResultView instanceof DeleteUriInfo) { if (((UriInfo) uriParserResultView).isLinks()) { return deleteLink(uriParserResultView); } } Object selectedObject = readEntity(new JPAQueryBuilder(oDataJPAContext).build(uriParserResultView)); if (selectedObject != null) { try{ boolean isLocalTransaction = setTransaction(); em.remove(selectedObject); em.flush(); if (isLocalTransaction) { oDataJPAContext.getODataJPATransaction().commit(); } } catch(PersistenceException e){ em.getTransaction().rollback(); throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e); } } return selectedObject; }
Example #9
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(DeleteUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo); if (listener != null) { query = listener.getQuery(uriInfo, em); JPQLContext jpqlContext = JPQLContext.getJPQLContext(); query = getParameterizedQueryForListeners(jpqlContext, query); } if (query == null) { query = buildQuery((UriInfo) uriInfo, UriInfoType.Delete); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #10
Source File: ODataJPADefaultProcessorTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private DeleteUriInfo getDeletetUriInfo() { UriInfo objUriInfo = EasyMock.createMock(UriInfo.class); EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet()); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(objUriInfo.getNavigationSegments()).andReturn(navSegments).anyTimes(); EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet()); EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null); EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression()); EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop()); EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip()); EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount()); EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter()); EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates()); EasyMock.expect(objUriInfo.isLinks()).andStubReturn(false); EasyMock.replay(objUriInfo); return objUriInfo; }
Example #11
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void buildDeleteEntityTest() { try { assertNotNull(builder.build((DeleteUriInfo) mockURIInfoWithListener(false))); } catch (ODataException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
Example #12
Source File: ODataJPAProcessor.java From lemonaid with MIT License | 5 votes |
@Override public ODataResponse deleteEntityLink(final DeleteUriInfo uriParserResultView, final String contentType) throws ODataException { authorization.check(DELETE, uriParserResultView); try { oDataJPAContext.setODataContext(getContext()); jpaProcessor.process(uriParserResultView, contentType); return ODataResponse.newBuilder().build(); } finally { close(); } }
Example #13
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void buildDeleteEntityTestWithoutListener() { try { EdmMapping mapping = (EdmMapping) mockMapping(); assertNotNull(builder.build((DeleteUriInfo) mockURIInfoForDeleteAndPut(mapping))); } catch (ODataException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
Example #14
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private DeleteUriInfo mockURIInfoForDeleteAndPut(EdmMapping mapping) throws EdmException { UriInfo uriInfo = EasyMock.createMock(UriInfo.class); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); List<KeyPredicate> keyPreds = new ArrayList<KeyPredicate>(); EdmProperty edmProperty1 = mockEdmProperty(mapping, "Decimal"); keyPreds.add(mockKeyPredicate(edmProperty1, "1234.7")); EdmProperty edmProperty2 = mockEdmProperty(mapping, "Int64"); keyPreds.add(mockKeyPredicate(edmProperty2, "1234567899")); EdmProperty edmProperty3 = mockEdmProperty(mapping, "Double"); keyPreds.add(mockKeyPredicate(edmProperty3, "12349")); EdmProperty edmProperty4 = mockEdmProperty(mapping, "Int32"); keyPreds.add(mockKeyPredicate(edmProperty4, "12349")); EdmProperty edmProperty5 = mockEdmProperty(mapping, "Single"); keyPreds.add(mockKeyPredicate(edmProperty5, "12349")); EdmProperty edmProperty6 = mockEdmProperty(mapping, "SByte"); keyPreds.add(mockKeyPredicate(edmProperty6, "-123")); EdmProperty edmProperty7 = mockEdmProperty(mapping, "Binary"); keyPreds.add(mockKeyPredicate(edmProperty7, getBinaryData())); EdmProperty edmProperty8 = mockEdmProperty(mapping, "uuid"); keyPreds.add(mockKeyPredicate(edmProperty8, "56fe79b1-1c88-465b-b309-32bf8b8f6800")); EasyMock.expect(uriInfo.getKeyPredicates()).andStubReturn(keyPreds); EasyMock.replay(edmEntityType, edmEntitySet, uriInfo); return uriInfo; }
Example #15
Source File: ODataJPADefaultProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType) throws ODataException { ODataResponse oDataResponse = null; try { oDataJPAContext.setODataContext(getContext()); Object deletedObj = jpaProcessor.process(uriParserResultView, contentType); oDataResponse = responseBuilder.build(uriParserResultView, deletedObj); } finally { close(); } return oDataResponse; }
Example #16
Source File: ODataJPADefaultProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntityLink(final DeleteUriInfo uriParserResultView, final String contentType) throws ODataException { try { oDataJPAContext.setODataContext(getContext()); jpaProcessor.process(uriParserResultView, contentType); return ODataResponse.newBuilder().build(); } finally { close(); } }
Example #17
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntity(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { dataSource.deleteData( uriInfo.getStartEntitySet(), mapKey(uriInfo.getKeyPredicates())); return ODataResponse.newBuilder().build(); }
Example #18
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntityLink(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { final List<NavigationSegment> navigationSegments = uriInfo.getNavigationSegments(); final List<NavigationSegment> previousSegments = navigationSegments.subList(0, navigationSegments.size() - 1); final Object sourceData = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), previousSegments); final EdmEntitySet entitySet = previousSegments.isEmpty() ? uriInfo.getStartEntitySet() : previousSegments.get(previousSegments.size() - 1).getEntitySet(); final EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet(); final Map<String, Object> keys = mapKey(uriInfo.getTargetKeyPredicates()); final Object targetData = dataSource.readRelatedData(entitySet, sourceData, targetEntitySet, keys); // if (!appliesFilter(targetData, uriInfo.getFilter())) if (targetData == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } dataSource.deleteRelation(entitySet, sourceData, targetEntitySet, keys); return ODataResponse.newBuilder().build(); }
Example #19
Source File: JPALinkTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private DeleteUriInfo mockDeleteURIInfo(boolean isReverse) throws ODataException, NoSuchMethodException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { DeleteUriInfo uriInfo = EasyMock.createMock(DeleteUriInfo.class); EasyMock.expect(uriInfo.getNavigationSegments()).andReturn(mockNavigationSegments(isReverse)).anyTimes(); EasyMock.replay(uriInfo); return uriInfo; }
Example #20
Source File: ODataJPAProcessor.java From lemonaid with MIT License | 5 votes |
@Override public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType) throws ODataException { authorization.check(DELETE, uriParserResultView); ODataResponse oDataResponse = null; try { oDataJPAContext.setODataContext(getContext()); Object deletedObj = jpaProcessor.process(uriParserResultView, contentType); deletedObj = enrichEntity(uriParserResultView, deletedObj); oDataResponse = responseBuilder.build(uriParserResultView, deletedObj); } finally { close(); } return oDataResponse; }
Example #21
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntity(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { dataSource.deleteData( uriInfo.getStartEntitySet(), mapKey(uriInfo.getKeyPredicates())); return ODataResponse.newBuilder().build(); }
Example #22
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse deleteEntityLink(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { final List<NavigationSegment> navigationSegments = uriInfo.getNavigationSegments(); final List<NavigationSegment> previousSegments = navigationSegments.subList(0, navigationSegments.size() - 1); final Object sourceData = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), previousSegments); final EdmEntitySet entitySet = previousSegments.isEmpty() ? uriInfo.getStartEntitySet() : previousSegments.get(previousSegments.size() - 1).getEntitySet(); final EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet(); final Map<String, Object> keys = mapKey(uriInfo.getTargetKeyPredicates()); final Object targetData = dataSource.readRelatedData(entitySet, sourceData, targetEntitySet, keys); if (targetData == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } dataSource.deleteRelation(entitySet, sourceData, targetEntitySet, keys); return ODataResponse.newBuilder().build(); }
Example #23
Source File: ODataJPAResponseBuilderDefault.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse build(final DeleteUriInfo deleteUriInfo, final Object deletedObject) throws ODataJPARuntimeException, ODataNotFoundException { if (deletedObject == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build(); }
Example #24
Source File: JPAProcessorImpl.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private Object deleteLink(final DeleteUriInfo uriParserResultView) throws ODataJPARuntimeException { JPALink link = new JPALink(oDataJPAContext); link.delete(uriParserResultView); link.save(); return link.getTargetJPAEntity(); }
Example #25
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Override public Query getQuery(DeleteUriInfo uriInfo, EntityManager em) { return query; }
Example #26
Source File: JPAProcessorMockAbstract.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Override public Object process(DeleteUriInfo deleteuriInfo, String contentType) throws ODataJPAModelException, ODataJPARuntimeException { // TODO Auto-generated method stub return null; }
Example #27
Source File: JPAProcessorImplTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Override public Query getQuery(DeleteUriInfo uriInfo, EntityManager em) { return query; }
Example #28
Source File: ODataSingleProcessor.java From olingo-odata2 with Apache License 2.0 | 4 votes |
/** * @see EntitySimplePropertyValueProcessor */ @Override public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { throw new ODataNotImplementedException(); }
Example #29
Source File: ODataSingleProcessor.java From olingo-odata2 with Apache License 2.0 | 4 votes |
/** * @see EntityMediaProcessor */ @Override public ODataResponse deleteEntityMedia(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { throw new ODataNotImplementedException(); }
Example #30
Source File: ODataSingleProcessor.java From olingo-odata2 with Apache License 2.0 | 4 votes |
/** * @see EntityLinkProcessor */ @Override public ODataResponse deleteEntityLink(final DeleteUriInfo uriInfo, final String contentType) throws ODataException { throw new ODataNotImplementedException(); }