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


Java ODataFeed类代码示例

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


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

示例1: readFeed

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Reads a feed (the content of an EntitySet).
 * 
 * @param resource_path the resource path to the parent of the requested
 *    EntitySet, as defined in {@link #getResourcePath(URI)}.
 * @param query_parameters Query parameters, as defined in {@link URI}.
 * 
 * @return an ODataFeed containing the ODataEntries for the given 
 *    {@code resource_path}.
 * 
 * @throws HttpException if the server emits an HTTP error code.
 * @throws IOException if the connection with the remote service fails.
 * @throws EdmException if the EDM does not contain the given entitySetName.
 * @throws EntityProviderException if reading of data (de-serialization)
 *    fails.
 * @throws UriSyntaxException violation of the OData URI construction rules.
 * @throws UriNotMatchingException URI parsing exception.
 * @throws ODataException encapsulate the OData exceptions described above.
 * @throws InterruptedException if running thread has been interrupted.
 */
public ODataFeed readFeed(String resource_path,
   Map<String, String> query_parameters) throws IOException, ODataException, InterruptedException
{
   if (resource_path == null || resource_path.isEmpty ())
      throw new IllegalArgumentException (
         "resource_path must not be null or empty.");
   
   ContentType contentType = ContentType.APPLICATION_ATOM_XML;
   
   String absolutUri = serviceRoot.toString () + '/' + resource_path;
   
   // Builds the query parameters string part of the URL.
   absolutUri = appendQueryParam (absolutUri, query_parameters);
   
   InputStream content = execute (absolutUri, contentType, "GET");
   
   return EntityProvider.readFeed (contentType.type (),
      getEntitySet (resource_path), content,
      EntityProviderReadProperties.init ().build ());
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:41,代码来源:ODataClient.java

示例2: normalizeInlineEntries

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
  List<ODataEntry> entries = null;
  try {
    for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
      Object inline = oDataEntryProperties.get(navigationPropertyName);
      if (inline instanceof ODataFeed) {
        entries = ((ODataFeed) inline).getEntries();
      } else if (inline instanceof ODataEntry) {
        entries = new ArrayList<ODataEntry>();
        entries.add((ODataEntry) inline);
      }
      if (entries != null) {
        oDataEntryProperties.put(navigationPropertyName, entries);
        entries = null;
      }
    }
  } catch (EdmException e) {
    throw ODataJPARuntimeException
        .throwException(ODataJPARuntimeException.GENERAL
            .addContent(e.getMessage()), e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:JPAEntity.java

示例3: unbalancedPropertyFeedWithSelect

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void unbalancedPropertyFeedWithSelect() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Companys");
  List<Map<String, Object>> originalData = createData(true);
  List<String> selectedPropertyNames = new ArrayList<String>();
  selectedPropertyNames.add("Id");
  selectedPropertyNames.add("Location");
  ExpandSelectTreeNode select =
      ExpandSelectTreeNode.entitySet(entitySet).selectedProperties(selectedPropertyNames).build();
  
  ODataResponse response = new AtomEntityProvider().writeFeed(entitySet, originalData,
      EntityProviderWriteProperties.serviceRoot(BASE_URI).expandSelectTree(select).
      isDataBasedPropertySerialization(true).build());

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init().mergeSemantic(false).build();
  XmlEntityConsumer consumer = new XmlEntityConsumer();
  ODataFeed feed = consumer.readFeed(entitySet, (InputStream) response.getEntity(), readProperties);

  compareList(originalData, feed.getEntries());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:AtomFeedProducerTest.java

示例4: unbalancedPropertyFeedWithSelect

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void unbalancedPropertyFeedWithSelect() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Companys");
  List<Map<String, Object>> originalData = createData(true);
  List<String> selectedPropertyNames = new ArrayList<String>();
  selectedPropertyNames.add("Id");
  selectedPropertyNames.add("Location");
  ExpandSelectTreeNode select =
      ExpandSelectTreeNode.entitySet(entitySet).selectedProperties(selectedPropertyNames).build();
  
  final ODataResponse response = new JsonEntityProvider().writeFeed(entitySet, originalData,
      EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(select).
      isDataBasedPropertySerialization(true).build());

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init().mergeSemantic(false).build();
  JsonEntityConsumer consumer = new JsonEntityConsumer();
  ODataFeed feed = consumer.readFeed(entitySet, (InputStream) response.getEntity(), readProperties);

  compareList(originalData, feed.getEntries());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:JsonFeedEntityProducerTest.java

示例5: roomsFeedWithEtagEntries

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void roomsFeedWithEtagEntries() throws Exception {
  InputStream stream = getFileAsStream("feed_rooms_small.xml");
  assertNotNull(stream);

  ODataFeed feed =
      EntityProvider.readFeed("application/atom+xml", MockFacade.getMockEdm().getDefaultEntityContainer()
          .getEntitySet(
              "Rooms"), stream, DEFAULT_PROPERTIES);
  assertNotNull(feed);

  FeedMetadata feedMetadata = feed.getFeedMetadata();
  assertNotNull(feedMetadata);
  assertNotNull(feedMetadata.getNextLink());

  List<ODataEntry> entries = feed.getEntries();
  assertEquals(3, entries.size());
  ODataEntry singleRoom = entries.get(0);
  EntryMetadata roomMetadata = singleRoom.getMetadata();
  assertNotNull(roomMetadata);

  assertEquals("W/\"1\"", roomMetadata.getEtag());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:XmlFeedConsumerTest.java

示例6: readEmployeesFeedWithInlineCountValid

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void readEmployeesFeedWithInlineCountValid() throws Exception {
  // prepare
  String content = readFile("feed_employees_full.xml");
  assertNotNull(content);

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
  InputStream reqContent = createContentAsStream(content);

  // execute
  XmlEntityConsumer xec = new XmlEntityConsumer();
  EntityProviderReadProperties consumerProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).build();

  ODataFeed feed = xec.readFeed(entitySet, reqContent, consumerProperties);
  assertNotNull(feed);

  FeedMetadata feedMetadata = feed.getFeedMetadata();
  assertNotNull(feedMetadata);

  int inlineCount = feedMetadata.getInlineCount();
  // Null means no inlineCount found
  assertNotNull(inlineCount);

  assertEquals(6, inlineCount);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:XmlFeedConsumerTest.java

示例7: roomsFeedWithRoomsToEmployeesInlineTeams

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Rooms navigate to Employees and has inline entry Teams
 * E.g: Rooms('1')/nr_Employees?$expand=ne_Team
 * @throws Exception
 */
@Test
public void roomsFeedWithRoomsToEmployeesInlineTeams() throws Exception {
  InputStream stream = getFileAsStream("RoomsToEmployeesWithInlineTeams.xml");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  ODataFeed feed =
      EntityProvider.readFeed("application/atom+xml", MockFacade.getMockEdm().getDefaultEntityContainer()
          .getEntitySet(
              "Employees"), stream, readProperties);
  assertNotNull(feed);
  assertEquals(2, feed.getEntries().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, feed);
  for (ODataEntry entry : feed.getEntries()) {
    assertEquals(10, entry.getProperties().size());
    assertEquals(3, ((ODataEntry)entry.getProperties().get("ne_Team")).getProperties().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:29,代码来源:XmlFeedConsumerTest.java

示例8: getExpandedData

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * @param inlineEntries
 * @param feed
 * @param entry
 */
private void getExpandedData(Map<String, Object> inlineEntries, ODataEntry entry) {
  assertNotNull(entry);
  Map<String, ExpandSelectTreeNode> expandNodes = entry.getExpandSelectTree().getLinks();
  for (Entry<String, ExpandSelectTreeNode> expand : expandNodes.entrySet()) {
    assertNotNull(expand.getKey());
    if (inlineEntries.containsKey(expand.getKey() + entry.getMetadata().getId())) {
      if (inlineEntries.get(expand.getKey() + entry.getMetadata().getId()) instanceof ODataFeed) {
        ODataFeed innerFeed = (ODataFeed) inlineEntries.get(expand.getKey() + entry.getMetadata().getId());
        assertNotNull(innerFeed);
        getExpandedData(inlineEntries, innerFeed);
        entry.getProperties().put(expand.getKey(), innerFeed);
      } else if (inlineEntries.get(expand.getKey() + entry.getMetadata().getId()) instanceof ODataEntry) {
        ODataEntry innerEntry = (ODataEntry) inlineEntries.get(expand.getKey() + entry.getMetadata().getId());
        assertNotNull(innerEntry);
        getExpandedData(inlineEntries, innerEntry);
        entry.getProperties().put(expand.getKey(), innerEntry);
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:XmlFeedConsumerTest.java

示例9: readDeltaLink

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void readDeltaLink() throws Exception {
  // prepare
  String content = readFile("feed_with_delta_link.xml");
  assertNotNull(content);

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
  InputStream reqContent = createContentAsStream(content);

  // execute
  XmlEntityConsumer xec = new XmlEntityConsumer();
  EntityProviderReadProperties consumerProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).build();

  ODataFeed feed = xec.readFeed(entitySet, reqContent, consumerProperties);
  assertNotNull(feed);

  FeedMetadata feedMetadata = feed.getFeedMetadata();
  assertNotNull(feedMetadata);

  String deltaLink = feedMetadata.getDeltaLink();
  // Null means no deltaLink found
  assertNotNull(deltaLink);

  assertEquals("http://thisisadeltalink", deltaLink);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:XmlEntityConsumerTest.java

示例10: RoomEntryWithInlineEmployeeInlineTeam

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Room has inline entity to Employees and has inline entry To Team
 * Scenario of 1:n:1 navigation 
 * E.g: Rooms('1')?$expand=nr_Employees/ne_Team
 * @throws Exception
 */
@Test
public void RoomEntryWithInlineEmployeeInlineTeam() throws Exception {
  InputStream stream = getFileAsStream("Room_InlineEmployeesToTeam.xml");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  XmlEntityConsumer xec = new XmlEntityConsumer();
  ODataEntry result =
      xec.readEntry(entitySet, stream, readProperties);
  assertNotNull(result);
  assertEquals(4, result.getProperties().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, result);
  assertEquals(5, result.getProperties().size());
  for (ODataEntry employeeEntry : ((ODataFeed)result.getProperties().get("nr_Employees")).getEntries()) {
    assertEquals(10, employeeEntry.getProperties().size());
    assertEquals(3, ((ODataEntry)employeeEntry.getProperties().get("ne_Team")).getProperties().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:31,代码来源:XmlEntityConsumerTest.java

示例11: RoomEntryWithEmptyInlineEmployeeInlineTeam

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Room has empty inline entity to Employees and has inline entry To Team
 * E.g: Rooms('10')?$expand=nr_Employees/ne_Team
 * @throws Exception
 */
@Test
public void RoomEntryWithEmptyInlineEmployeeInlineTeam() throws Exception {
  InputStream stream = getFileAsStream("Room_EmptyInlineEmployeesToTeam.xml");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  XmlEntityConsumer xec = new XmlEntityConsumer();
  ODataEntry result =
      xec.readEntry(entitySet, stream, readProperties);
  assertNotNull(result);
  assertEquals(4, result.getProperties().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, result);
  assertEquals(5, result.getProperties().size());
  assertEquals(0, ((ODataFeed)result.getProperties().get("nr_Employees")).getEntries().size());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:XmlEntityConsumerTest.java

示例12: RoomEntryWithInlineEmployeeInlineTeam

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Room has inline entity to Employees and has inline entry To Team
 * Scenario of 1:n:1 navigation 
 * E.g: Rooms('1')?$expand=nr_Employees/ne_Team
 * @throws Exception
 */
@Test
public void RoomEntryWithInlineEmployeeInlineTeam() throws Exception {
  InputStream stream = getFileAsStream("JsonRoom_InlineEmployeesToTeam.json");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  JsonEntityConsumer xec = new JsonEntityConsumer();
  ODataEntry result =
      xec.readEntry(entitySet, stream, readProperties);
  assertNotNull(result);
  assertEquals(4, result.getProperties().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, result);
  assertEquals(5, result.getProperties().size());
  for (ODataEntry employeeEntry : ((ODataFeed)result.getProperties().get("nr_Employees")).getEntries()) {
    assertEquals(10, employeeEntry.getProperties().size());
    assertEquals(3, ((ODataEntry)employeeEntry.getProperties().get("ne_Team")).getProperties().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:31,代码来源:JsonEntryConsumerTest.java

示例13: RoomEntryWithEmptyInlineEmployeeInlineTeam

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Room has empty inline entity to Employees and has inline entry To Team
 * E.g: Rooms('10')?$expand=nr_Employees/ne_Team
 * @throws Exception
 */
@Test
public void RoomEntryWithEmptyInlineEmployeeInlineTeam() throws Exception {
  InputStream stream = getFileAsStream("JsonRoom_EmptyInlineEmployeesToTeam.json");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  JsonEntityConsumer xec = new JsonEntityConsumer();
  ODataEntry result =
      xec.readEntry(entitySet, stream, readProperties);
  assertNotNull(result);
  assertEquals(4, result.getProperties().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, result);
  assertEquals(5, result.getProperties().size());
  assertEquals(0, ((ODataFeed)result.getProperties().get("nr_Employees")).getEntries().size());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:JsonEntryConsumerTest.java

示例14: emptyFeed

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
@Test
public void emptyFeed() throws Exception {
  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
  String content = "{\"d\":{\"results\":[]}}";
  InputStream contentBody = createContentAsStream(content);

  // execute
  JsonEntityConsumer xec = new JsonEntityConsumer();
  ODataFeed feed = xec.readFeed(entitySet, contentBody, DEFAULT_PROPERTIES);
  assertNotNull(feed);

  List<ODataEntry> entries = feed.getEntries();
  assertNotNull(entries);
  assertEquals(0, entries.size());

  FeedMetadata feedMetadata = feed.getFeedMetadata();
  assertNotNull(feedMetadata);
  assertNull(feedMetadata.getInlineCount());
  assertNull(feedMetadata.getNextLink());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:JsonFeedConsumerTest.java

示例15: roomsFeedWithRoomInlineEmployeesInlineBuildings

import org.apache.olingo.odata2.api.ep.feed.ODataFeed; //导入依赖的package包/类
/**
 * Rooms has an inline feed Employees and Rooms has Inline entry Buildings
 * E.g: Rooms?$expand=nr_Employees,nr_Building
 * Empty Inline entity is also part of payload
 * @throws Exception
 */
@Test
public void roomsFeedWithRoomInlineEmployeesInlineBuildings() throws Exception {
  InputStream stream = getFileAsStream("JsonRooms_InlineEmployees_InlineBuilding.json");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  JsonEntityConsumer xec = new JsonEntityConsumer();
  ODataDeltaFeed feed = xec.readDeltaFeed(entitySet, stream, readProperties);
  assertNotNull(feed);
  assertEquals(3, feed.getEntries().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, feed);
  for (ODataEntry entry : feed.getEntries()) {
    assertEquals(6, entry.getProperties().size());
    for (ODataEntry employeeEntry : ((ODataFeed)entry.getProperties().get("nr_Employees")).getEntries()) {
      assertEquals(9, employeeEntry.getProperties().size());
    }
    assertEquals(3, ((ODataEntry)entry.getProperties().get("nr_Building")).getProperties().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:32,代码来源:JsonFeedConsumerTest.java


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