本文整理汇总了Java中org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo类的典型用法代码示例。如果您正苦于以下问题:Java GetEntityUriInfo类的具体用法?Java GetEntityUriInfo怎么用?Java GetEntityUriInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetEntityUriInfo类属于org.apache.olingo.odata2.api.uri.info包,在下文中一共展示了GetEntityUriInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(final GetEntityUriInfo uriInfo, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments());
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
if (!appliesFilter(entitySet, data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final ExpandSelectTreeNode expandSelectTreeNode =
UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand());
return ODataResponse.fromResponse(writeEntry(entitySet, expandSelectTreeNode, data, contentType))
.build();
}
示例2: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(final GetEntityUriInfo 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())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final ExpandSelectTreeNode expandSelectTreeNode =
UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand());
ODataResponse odr =
ODataResponse.fromResponse(writeEntry(uriInfo.getTargetEntitySet(), expandSelectTreeNode, data, contentType))
.build();
return odr;
}
示例3: getEntityProviderProperties
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
ExpandSelectTreeNode expandSelectTree = null;
try {
entityFeedPropertiesBuilder =
EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
.getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
} catch (ODataException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
return entityFeedPropertiesBuilder.build();
}
示例4: build
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
public Query build(GetEntityUriInfo uriInfo) throws ODataJPARuntimeException {
Query query = null;
try {
ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
if (listener != null) {
query = listener.getQuery(uriInfo, em);
}
if (query == null) {
query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntity);
}
} catch (Exception e) {
throw ODataJPARuntimeException.throwException(
ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
return query;
}
示例5: getEntityUriInfo
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
private GetEntityUriInfo getEntityUriInfo() throws EdmException {
GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
EasyMock.expect(edmEntityType.getName()).andStubReturn("");
EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
EasyMock.expect(getEntityView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
EasyMock.replay(startEdmEntityType, startEdmEntitySet);
EasyMock.replay(edmEntityType, edmEntitySet);
EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
EasyMock.expect(getEntityView.getNavigationSegments()).andStubReturn(navigationSegments);
EasyMock.replay(getEntityView);
return getEntityView;
}
示例6: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(final GetEntityUriInfo uriInfo, final String contentType) throws ODataException {
final EntityProviderWriteProperties properties =
EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build();
// query
final String mappedKeyName =
(String) uriInfo.getTargetEntitySet().getEntityType().getKeyProperties().get(0).getMapping().getObject();
final String keyValue = uriInfo.getKeyPredicates().get(0).getLiteral();
final int index = indexOf(mappedKeyName, keyValue);
if ((index < 0) || (index > records.size())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY.addContent(keyValue));
}
final HashMap<String, String> record = records.get(index);
final HashMap<String, Object> data = new HashMap<String, Object>();
for (final String pName : uriInfo.getTargetEntitySet().getEntityType().getPropertyNames()) {
final EdmProperty property = (EdmProperty) uriInfo.getTargetEntitySet().getEntityType().getProperty(pName);
final String mappedPropertyName = (String) property.getMapping().getObject();
data.put(pName, record.get(mappedPropertyName));
}
final ODataResponse response =
EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), data, properties);
return response;
}
示例7: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException {
HashMap<String, Object> data = new HashMap<String, Object>();
if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
if ("2".equals(uriInfo.getKeyPredicates().get(0).getLiteral())) {
data.put("EmployeeId", "1");
data.put("TeamId", "420");
}
ODataContext context = getContext();
EntityProviderWriteProperties writeProperties =
EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();
return EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
} else {
throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
}
}
示例8: testGetRequest
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
private HttpResponse testGetRequest(final String uriExtension, final String acceptHeader,
final HttpStatusCodes expectedStatus, final String expectedContentType)
throws ClientProtocolException, IOException, ODataException {
// prepare
ODataResponse expectedResponse = ODataResponse.contentHeader(expectedContentType).entity("Test passed.").build();
when(processor.readMetadata(any(GetMetadataUriInfo.class), any(String.class))).thenReturn(expectedResponse);
when(processor.readEntity(any(GetEntityUriInfo.class), any(String.class))).thenReturn(expectedResponse);
when(processor.readEntitySet(any(GetEntitySetUriInfo.class), any(String.class))).thenReturn(expectedResponse);
HttpGet getRequest = new HttpGet(URI.create(getEndpoint().toString() + uriExtension));
getRequest.setHeader(HttpHeaders.ACCEPT, acceptHeader);
// execute
HttpResponse response = getHttpClient().execute(getRequest);
// validate
assertEquals(expectedStatus.getStatusCode(), response.getStatusLine().getStatusCode());
Header[] contentTypeHeaders = response.getHeaders("Content-Type");
assertEquals("Found more then one content type header in response.", 1, contentTypeHeaders.length);
assertEquals("Received content type does not match expected.", expectedContentType, contentTypeHeaders[0]
.getValue());
assertEquals("Received status code does not match expected.", expectedStatus.getStatusCode(), response
.getStatusLine().getStatusCode());
//
return response;
}
示例9: test404HttpNotFound
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Test
public void test404HttpNotFound() throws Exception {
when(processor.readEntity(any(GetEntityUriInfo.class), any(String.class))).thenThrow(
new ODataNotFoundException(ODataNotFoundException.ENTITY));
final HttpResponse response = executeGetRequest("Managers('199')");
assertEquals(HttpStatusCodes.NOT_FOUND.getStatusCode(), response.getStatusLine().getStatusCode());
final String content = StringHelper.inputStreamToString(response.getEntity().getContent());
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put("a", Edm.NAMESPACE_M_2007_08);
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
assertXpathExists("/a:error/a:code", content);
assertXpathValuesEqual("\"" + MessageService.getMessage(Locale.ENGLISH, ODataNotFoundException.ENTITY).getText()
+ "\"", "/a:error/a:message", content);
}
示例10: genericHttpExceptions
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Test
public void genericHttpExceptions() throws Exception {
disableLogging();
final List<ODataHttpException> toTestExceptions = getHttpExceptionsForTest();
int firstKey = 1;
for (final ODataHttpException oDataException : toTestExceptions) {
final String key = String.valueOf(firstKey++);
final Matcher<GetEntityUriInfo> match = new EntityKeyMatcher(key);
when(processor.readEntity(Matchers.argThat(match), any(String.class))).thenThrow(oDataException);
final HttpResponse response = executeGetRequest("Managers('" + key + "')");
assertEquals("Expected status code does not match for exception type '"
+ oDataException.getClass().getSimpleName() + "'.",
oDataException.getHttpStatus().getStatusCode(), response.getStatusLine().getStatusCode());
final String content = StringHelper.inputStreamToString(response.getEntity().getContent());
Map<String, String> prefixMap = new HashMap<String, String>();
prefixMap.put("a", Edm.NAMESPACE_M_2007_08);
XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
assertXpathExists("/a:error/a:code", content);
}
}
示例11: getQuery
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public Query getQuery(GetEntityUriInfo uriInfo, EntityManager em) {
Query query = null;
try {
query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntity, em);
} catch (Exception e) {
logger.error("Exception while building query in getQuery(); no query could be generated");
query = null;
}
logger.info("GetEntity query: " + query.toString());
return query;
}
示例12: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException {
String filterID = uriInfo.getKeyPredicates().get(0).getLiteral();
SearchRequest filter = filterManager.getSearchRequestById(Long.parseLong(filterID));
switch (uriInfo.getNavigationSegments().size()) {
case 0:
ODataFilter oDataFilter = new ODataFilter(filter, serviceRoot);
return EntityProvider.writeEntry(contentType, uriInfo.getStartEntitySet(), oDataFilter.getOData(), propertiesBuilder.build());
}
throw new ODataNotImplementedException();
}
示例13: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException
{
String issueKey = uriInfo.getKeyPredicates().get(0).getLiteral();
Issue issue = issueManager.getIssueObject(issueKey);
switch (uriInfo.getNavigationSegments().size()) {
case 0:
ODataIssue odataIssue = new ODataIssue(issue, serviceRoot);
return EntityProvider.writeEntry(contentType, uriInfo.getStartEntitySet(), odataIssue.getOData(), propertiesBuilder.build());
}
throw new ODataNotImplementedException();
}
示例14: readEntity
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException
{
String entitySet = uriInfo.getStartEntitySet().getName();
if ( entitySet.equals("Issues") ) {
return issueProcessor.readEntity(uriInfo, contentType);
} else if ( entitySet.equals("Filters") ) {
return filterProcessor.readEntity(uriInfo, contentType);
}
throw new ODataNotImplementedException();
}
示例15: setResultsView
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Override
protected void setResultsView(final Object resultsView) {
if (resultsView instanceof GetEntityUriInfo) {
entityView = (GetEntityUriInfo) resultsView;
}
}