@SuppressWarnings("unchecked") final Map<String, Object> linkMap = (Map<String, Object>) content; response = EntityProvider.writeLink(responseContentType, targetLinkEntitySet, linkMap, linkProperties); break;
@Override public ODataResponse readEntityLink(final GetEntityLinkUriInfo 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); } final EdmEntitySet entitySet = uriInfo.getTargetEntitySet(); Map<String, Object> values = new HashMap<String, Object>(); for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { values.put(property.getName(), valueAccess.getPropertyValue(data, property)); } ODataContext context = getContext(); final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties .serviceRoot(context.getPathInfo().getServiceRoot()) .build(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink"); final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).build(); }
@SuppressWarnings("unchecked") final Map<String, Object> linkMap = (Map<String, Object>) content; response = EntityProvider.writeLink(responseContentType, targetLinkEntitySet, linkMap, linkProperties); break;
@Override public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriInfo, final String contentType) throws ODataException { final Object data = retrieveData( uriInfo.getStartEntitySet(), uriInfo.getKeyPredicates(), uriInfo.getFunctionImport(), mapFunctionParameters(uriInfo.getFunctionImportParameters()), uriInfo.getNavigationSegments()); // if (!appliesFilter(data, uriInfo.getFilter())) if (data == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } final EdmEntitySet entitySet = uriInfo.getTargetEntitySet(); Map<String, Object> values = new HashMap<String, Object>(); for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { values.put(property.getName(), valueAccess.getPropertyValue(data, property)); } ODataContext context = getContext(); final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties .serviceRoot(context.getPathInfo().getServiceRoot()) .build(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink"); final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).build(); }
@Override public ODataResponse readEntityLink(final GetEntityLinkUriInfo 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); } final EdmEntitySet entitySet = uriInfo.getTargetEntitySet(); Map<String, Object> values = new HashMap<String, Object>(); for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) { values.put(property.getName(), valueAccess.getPropertyValue(data, property)); } ODataContext context = getContext(); final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties .serviceRoot(context.getPathInfo().getServiceRoot()) .build(); final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink"); final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties); context.stopRuntimeMeasurement(timingHandle); return ODataResponse.fromResponse(response).build(); }
@Override public ODataResponse build(final GetEntityLinkUriInfo resultsView, final Object jpaEntity, final String contentType) throws ODataNotFoundException, ODataJPARuntimeException { if (jpaEntity == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } EdmEntityType edmEntityType = null; ODataResponse odataResponse = null; try { EdmEntitySet entitySet = resultsView.getTargetEntitySet(); edmEntityType = entitySet.getEntityType(); Map<String, Object> edmPropertyValueMap = null; JPAEntityParser jpaResultParser = new JPAEntityParser(); edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties()); EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot()) .build(); ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties); odataResponse = ODataResponse.fromResponse(response).build(); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); } return odataResponse; }
@Override public ODataResponse build(final GetEntityLinkUriInfo resultsView, final Object jpaEntity, final String contentType) throws ODataNotFoundException, ODataJPARuntimeException { if (jpaEntity == null) { throw new ODataNotFoundException(ODataNotFoundException.ENTITY); } EdmEntityType edmEntityType = null; ODataResponse odataResponse = null; try { EdmEntitySet entitySet = resultsView.getTargetEntitySet(); edmEntityType = entitySet.getEntityType(); Map<String, Object> edmPropertyValueMap = null; JPAEntityParser jpaResultParser = new JPAEntityParser(oDataJPAContext, (UriInfo) resultsView); edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties(), edmEntityType); EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot()) .build(); ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties); odataResponse = ODataResponse.fromResponse(response).build(); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e); } return odataResponse; }