本文整理汇总了Java中org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo类的典型用法代码示例。如果您正苦于以下问题:Java GetEntityUriInfo类的具体用法?Java GetEntityUriInfo怎么用?Java GetEntityUriInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetEntityUriInfo类属于org.apache.olingo.odata2.api.uri.info包,在下文中一共展示了GetEntityUriInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:ListsProcessor.java
示例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;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:ListsProcessor.java
示例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();
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:18,代码来源:ODataJPAResponseBuilderDefault.java
示例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;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:JPAQueryBuilder.java
示例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;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:JPQLBuilderFactoryTest.java
示例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;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:MapProcessor.java
示例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);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:InvalidDataInScenarioTest.java
示例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;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:AcceptHeaderTypeTest.java
示例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);
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:HttpExceptionResponseTest.java
示例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);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:HttpExceptionResponseTest.java
示例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;
}
开发者ID:SAP,项目名称:cloud-olingo-identity-ochat,代码行数:14,代码来源:ConversationQueryListener.java
示例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();
}
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:14,代码来源:FilterProcessor.java
示例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();
}
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:14,代码来源:IssueProcessor.java
示例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();
}
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:12,代码来源:JiraODataProcessor.java
示例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;
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:8,代码来源:JPQLSelectSingleContext.java
示例16: create
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
public void create(final EdmEntitySet entitySet, final ODataEntry oDataEntry,
final List<String> navigationPropertyNames)
throws ODataJPARuntimeException,
ODataJPAModelException {
List<Object> targetJPAEntities = new ArrayList<Object>();
try {
for (String navPropertyName : navigationPropertyNames) {
List<String> links = oDataEntry.getMetadata().getAssociationUris(navPropertyName);
if (links == null || links.isEmpty() == true) {
links = extractLinkURI(oDataEntry, navPropertyName);
}
if (links != null && links.isEmpty() == false) {
EdmNavigationProperty navProperty = (EdmNavigationProperty) entitySet.getEntityType()
.getProperty(
navPropertyName);
for (String link : links) {
UriInfo bindingUriInfo = parser.parseBindingLink(link, new HashMap<String, String>());
targetJPAEntity = jpaProcessor.process((GetEntityUriInfo) bindingUriInfo);
if (targetJPAEntity != null) {
targetJPAEntities.add(targetJPAEntity);
}
}
if (!targetJPAEntities.isEmpty()) {
linkJPAEntities(targetJPAEntities, sourceJPAEntity, navProperty);
}
targetJPAEntities.clear();
}
}
} catch (EdmException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:37,代码来源:JPALink.java
示例17: getEntityUriInfo
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
private GetEntityUriInfo getEntityUriInfo() {
GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
try {
EasyMock.expect(getEntityView.getExpand()).andStubReturn(null);
EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SO_ID));
EasyMock.expect(edmEntityType.getMapping()).andStubReturn((EdmMapping) getEdmMappingMockedObj(SALES_ORDER));
EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
EasyMock.replay(edmEntityType, edmEntitySet);
EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
EasyMock.expect(getEntityView.getNavigationSegments()).andReturn(navigationSegments);
EasyMock.expect(getEntityView.getStartEntitySet()).andReturn(edmEntitySet);
EasyMock.replay(getEntityView);
} catch (EdmException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
return getEntityView;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:39,代码来源:ODataJPADefaultProcessorTest.java
示例18: buildGetEntityTest
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Test
public void buildGetEntityTest() {
try {
assertNotNull(builder.build((GetEntityUriInfo) mockURIInfoWithListener(false)));
} catch (ODataException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:9,代码来源:JPAQueryBuilderTest.java
示例19: buildQueryGetEntityTest
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Test
public void buildQueryGetEntityTest() {
EdmMapping mapping = (EdmMapping) mockMapping();
try {
assertNotNull(builder.build((GetEntityUriInfo) mockURIInfo(mapping)));
} catch (ODataException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:10,代码来源:JPAQueryBuilderTest.java
示例20: buildQueryValueNormalizeTest
import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo; //导入依赖的package包/类
@Test
public void buildQueryValueNormalizeTest() {
EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping();
try {
assertNotNull(builder.build((GetEntityUriInfo) mockURIInfo(mapping)));
} catch (ODataException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:10,代码来源:JPAQueryBuilderTest.java
注:本文中的org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论