当前位置: 首页>>代码示例>>Java>>正文


Java GetEntitySetUriInfo类代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo的典型用法代码示例。如果您正苦于以下问题:Java GetEntitySetUriInfo类的具体用法?Java GetEntitySetUriInfo怎么用?Java GetEntitySetUriInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GetEntitySetUriInfo类属于org.apache.olingo.odata2.api.uri.info包,在下文中一共展示了GetEntitySetUriInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readOptimizedFilter

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void readOptimizedFilter() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
  Edm edm = EdmMock.createMockEdm();

  FilterExpression exp = UriParserImpl.parseFilter(edm, edm.getEntityType("RefScenario", "Room"), "Version gt 105");
  Mockito.when(uriInfo.getFilter()).thenReturn(exp);

  List<Room> results = createRooms(1, 10);
  ReadResult<Room> readResult = ReadResult.forResult(results).filterApplied().build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(10, parsedResults.size());
  Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:22,代码来源:DataSourceProcessorTest.java

示例2: readOrder

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void readOrder() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
  Edm edm = EdmMock.createMockEdm();

  OrderByExpression exp = UriParserImpl.parseOrderBy(edm, edm.getEntityType("RefScenario", "Room"), "Name");
  Mockito.when(uriInfo.getOrderBy()).thenReturn(exp);

  List<Room> results = createRooms(1, 10);
  Collections.reverse(results);
  ReadResult<Room> readResult = ReadResult.forResult(results).build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(10, parsedResults.size());
  Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:23,代码来源:DataSourceProcessorTest.java

示例3: optimizedReadOrder

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void optimizedReadOrder() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
  Edm edm = EdmMock.createMockEdm();

  OrderByExpression exp = UriParserImpl.parseOrderBy(edm, edm.getEntityType("RefScenario", "Room"), "Name");
  Mockito.when(uriInfo.getOrderBy()).thenReturn(exp);

  List<Room> results = createRooms(1, 10);
  Collections.shuffle(results);
  ReadResult<Room> readResult = ReadResult.forResult(results).orderApplied().build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(10, parsedResults.size());
  Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:23,代码来源:DataSourceProcessorTest.java

示例4: readFilter

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void readFilter() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
  Edm edm = EdmMock.createMockEdm();

  FilterExpression exp = UriParserImpl.parseFilter(edm, edm.getEntityType("RefScenario", "Room"), "Version gt 105");
  Mockito.when(uriInfo.getFilter()).thenReturn(exp);

  List<Room> results = createRooms(1, 10);
  ReadResult<Room> readResult = ReadResult.forResult(results).build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(5, parsedResults.size());
  Assert.assertEquals("Room with id: 10", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(4).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:22,代码来源:DataSourceProcessorTest.java

示例5: readSkip

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void readSkip() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");

  Mockito.when(uriInfo.getSkip()).thenReturn(5);
  Mockito.when(uriInfo.getSkipToken()).thenReturn("2");

  List<Room> results = createRooms(1, 10);
  ReadResult<Room> readResult = ReadResult.forResult(results).build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(3, parsedResults.size());
  Assert.assertEquals("Room with id: 7", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(2).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:21,代码来源:DataSourceProcessorTest.java

示例6: readOptimizedSkip

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void readOptimizedSkip() throws Exception {
  GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");

  Mockito.when(uriInfo.getSkip()).thenReturn(5);
  Mockito.when(uriInfo.getSkipToken()).thenReturn("2");

  List<Room> results = createRooms(1, 10);
  ReadResult<Room> readResult = ReadResult.forResult(results).skipApplied().build();
  Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
      .thenReturn((ReadResult)readResult);

  ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");

  StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
  List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
  Assert.assertEquals(10, parsedResults.size());
  Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
  Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
 
开发者ID:mibo,项目名称:janos,代码行数:21,代码来源:DataSourceProcessorTest.java

示例7: getInlineCountForNonFilterQueryEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
    final GetEntitySetUriInfo resultsView) {
  // when $skip and/or $top is present with $inlinecount, first get the total count
  Integer count = null;
  if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
    if (resultsView.getSkip() != null || resultsView.getTop() != null) {
      count = edmEntityList.size();
      // Now update the list
      if (resultsView.getSkip() != null) {
        // Index checks to avoid IndexOutOfBoundsException
        if (resultsView.getSkip() > edmEntityList.size()) {
          edmEntityList.clear();
          return count;
        }
        edmEntityList.subList(0, resultsView.getSkip()).clear();
      }
      if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
        final List<Map<String, Object>> edmEntitySubList =
            new ArrayList<Map<String, Object>>(edmEntityList.subList(0, resultsView.getTop()));
        edmEntityList.retainAll(edmEntitySubList);
      }
    }
  }// Inlinecount of None is handled by default - null
  return count;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:ODataJPAResponseBuilderDefault.java

示例8: handlePaging

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
private List<Object> handlePaging(final List<Object> result, final GetEntitySetUriInfo uriParserResultView) {
  if (result == null) {
    return null;
  }
  JPAPageBuilder pageBuilder = new JPAPageBuilder();
  pageBuilder.pageSize(oDataJPAContext.getPageSize())
      .entities(result)
      .skipToken(uriParserResultView.getSkipToken());

  // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
  if (uriParserResultView.getSkip() != null && uriParserResultView.getInlineCount() == null) {
    pageBuilder.skip(uriParserResultView.getSkip().intValue());
  }

  if (uriParserResultView.getTop() != null && uriParserResultView.getInlineCount() == null) {
    pageBuilder.top(uriParserResultView.getTop().intValue());
  }

  JPAPage page = pageBuilder.build();
  oDataJPAContext.setPaging(page);

  return page.getPagedEntities();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:JPAProcessorImpl.java

示例9: build

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
public JPAQueryInfo build(GetEntitySetUriInfo uriInfo) throws ODataJPARuntimeException {
  JPAQueryInfo queryInfo = new JPAQueryInfo();
  Query query = null;
  try {
    ODataJPATombstoneEntityListener listener = getODataJPATombstoneEntityListener((UriInfo) uriInfo);
    if (listener != null) {
      query = listener.getQuery(uriInfo, em);
    }
    if (query == null) {
      query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntitySet);
    } else {
      queryInfo.setTombstoneQuery(true);
    }
  } catch (Exception e) {
    throw ODataJPARuntimeException.throwException(
        ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
  }
  queryInfo.setQuery(query);
  return queryInfo;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:JPAQueryBuilder.java

示例10: getEntitySetUriInfo

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
private GetEntitySetUriInfo getEntitySetUriInfo() {

    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.getSkipToken()).andReturn("5");
    EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
    EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
    EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
    EasyMock.expect(objUriInfo.getCustomQueryOptions()).andStubReturn(null);
    EasyMock.expect(objUriInfo.getNavigationSegments()).andStubReturn(new ArrayList<NavigationSegment>());
    EasyMock.replay(objUriInfo);
    return objUriInfo;
  }
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:JPAProcessorImplTest.java

示例11: Test

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Test
public void Test() {

  EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
  try {
    EasyMock.expect(edmEntitySet.getName()).andReturn("SalesOrder");
    EasyMock.replay(edmEntitySet);
  } catch (EdmException e) {
    fail("Not Expected");
  }
  GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
  EasyMock.expect(resultsView.getTargetEntitySet()).andReturn(edmEntitySet);
  EasyMock.replay(resultsView);
  JPATombstoneCallBack tombStoneCallBack = new JPATombstoneCallBack("/sample/", resultsView, "1");

  TombstoneCallbackResult result = tombStoneCallBack.getTombstoneCallbackResult();
  assertEquals("/sample/SalesOrder?!deltatoken=1", result.getDeltaLink());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:JPATombstoneCallBackTest.java

示例12: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType)
    throws ODataException {
  final EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build();

  final List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();

  for (final HashMap<String, String> record : records) {
    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));
    }

    values.add(data);
  }

  final ODataResponse response =
      EntityProvider.writeFeed(contentType, uriInfo.getTargetEntitySet(), values, properties);

  return response;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:MapProcessor.java

示例13: testGetRequest

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的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

示例14: readEntitySet

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriParserResultView, final String contentType)
		throws ODataException {
	authorization.check(READ, uriParserResultView);
	ODataResponse oDataResponse = null;
	augmentFilter((UriInfoImpl) uriParserResultView);
	try {
		oDataJPAContext.setODataContext(getContext());
		List<Object> jpaEntities = jpaProcessor.process(uriParserResultView);
           jpaEntities = enrichEntities(uriParserResultView, jpaEntities);
           for(Object jpaEntity : jpaEntities){
               if (jpaEntity instanceof Mentor) {
			    if (!authorization.isMentor() && !authorization.isProjectMember()) {

                   }else{
                       ((Mentor) jpaEntity).setPublicLongitude(((Mentor) jpaEntity).getLongitude());
                       ((Mentor) jpaEntity).setPublicLatitude(((Mentor) jpaEntity).getLatitude());
                   }

               }
           }
		oDataResponse = responseBuilder.build(uriParserResultView, jpaEntities, contentType);
	} finally {
		close();
	}
	return oDataResponse;
}
 
开发者ID:sapmentors,项目名称:lemonaid,代码行数:28,代码来源:ODataJPAProcessor.java

示例15: getQuery

import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo; //导入依赖的package包/类
@Override
public Query getQuery(GetEntitySetUriInfo uriInfo, EntityManager em) {
	Query query = null;
	try {
		query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntitySet, em);
	} catch (Exception e) {
		logger.error("Exception while building query in getQuery(); no query could be generated");
		query = null;
	}
	logger.info("GetEntitySet query: " + query.toString());
	return query;
}
 
开发者ID:SAP,项目名称:cloud-olingo-identity-ochat,代码行数:13,代码来源:ConversationQueryListener.java


注:本文中的org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。