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


Java ODataEntry.getMetadata方法代码示例

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


在下文中一共展示了ODataEntry.getMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: roomsFeedWithEtagEntries

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的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

示例2: readCustomizableFeedMappings

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readCustomizableFeedMappings() throws Exception {
  XmlEntityConsumer xec = new XmlEntityConsumer();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos");
  InputStream reqContent = createContentAsStream(PHOTO_XML);
  ODataEntry result =
      xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(false).build());

  // verify
  EntryMetadata entryMetadata = result.getMetadata();
  assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId());

  Map<String, Object> data = result.getProperties();
  assertEquals("Образ", data.get("Содержание"));
  assertEquals("Photo1", data.get("Name"));
  assertEquals("image/png", data.get("Type"));
  assertNull(data.get("ignore"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:XmlEntityConsumerTest.java

示例3: readCustomizableFeedMappingsWithMergeSemantic

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readCustomizableFeedMappingsWithMergeSemantic() throws Exception {
  XmlEntityConsumer xec = new XmlEntityConsumer();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos");
  InputStream reqContent = createContentAsStream(PHOTO_XML);
  ODataEntry result =
      xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build());

  // verify
  EntryMetadata entryMetadata = result.getMetadata();
  assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId());

  Map<String, Object> data = result.getProperties();
  assertEquals("Photo1", data.get("Name"));
  assertEquals("image/png", data.get("Type"));
  // ignored customizable feed mapping
  assertNull(data.get("Содержание"));
  assertNull(data.get("ignore"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:XmlEntityConsumerTest.java

示例4: readIncompleteEntry

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readIncompleteEntry() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  InputStream reqContent = createContentAsStream(ROOM_1_XML);
  final ODataEntry result =
      new XmlEntityConsumer().readEntry(entitySet, reqContent, EntityProviderReadProperties.init().build());

  final EntryMetadata entryMetadata = result.getMetadata();
  assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId());
  assertEquals("W/\"1\"", entryMetadata.getEtag());
  assertNull(entryMetadata.getUri());

  final MediaMetadata mediaMetadata = result.getMediaMetadata();
  assertEquals(HttpContentType.APPLICATION_XML, mediaMetadata.getContentType());
  assertNull(mediaMetadata.getSourceLink());
  assertNull(mediaMetadata.getEditLink());
  assertNull(mediaMetadata.getEtag());

  final Map<String, Object> properties = result.getProperties();
  assertEquals(1, properties.size());
  assertEquals("1", properties.get("Id"));
  assertFalse(properties.containsKey("Seats"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:24,代码来源:XmlEntityConsumerTest.java

示例5: readSimpleRoomEntry

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readSimpleRoomEntry() throws Exception {
  ODataEntry roomEntry = prepareAndExecuteEntry(SIMPLE_ENTRY_ROOM, "Rooms", DEFAULT_PROPERTIES);

  // verify
  Map<String, Object> properties = roomEntry.getProperties();
  assertEquals(4, properties.size());

  assertEquals("1", properties.get("Id"));
  assertEquals("Room 1", properties.get("Name"));
  assertEquals((short) 1, properties.get("Seats"));
  assertEquals((short) 1, properties.get("Version"));

  List<String> associationUris = roomEntry.getMetadata().getAssociationUris("nr_Employees");
  assertEquals(1, associationUris.size());
  assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Employees", associationUris.get(0));

  associationUris = roomEntry.getMetadata().getAssociationUris("nr_Building");
  assertEquals(1, associationUris.size());
  assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Building", associationUris.get(0));

  EntryMetadata metadata = roomEntry.getMetadata();
  assertEquals("W/\"1\"", metadata.getEtag());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:JsonEntryConsumerTest.java

示例6: readWithInlineContentEmployeeRoomEntry

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
/**
 * Read an inline Room at an Employee
 * 
 * @throws Exception
 */
@Test
public void readWithInlineContentEmployeeRoomEntry() throws Exception {

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

  // execute
  XmlEntityConsumer xec = new XmlEntityConsumer();
  ODataEntry employee =
      xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build());

  // validate
  assertNotNull(employee);
  Map<String, Object> properties = employee.getProperties();
  assertEquals("1", properties.get("EmployeeId"));
  assertEquals("Walter Winter", properties.get("EmployeeName"));
  EntryMetadata employeeMetadata = employee.getMetadata();
  assertNotNull(employeeMetadata);
  assertEquals("W/\"1\"", employeeMetadata.getEtag());

  // Inline
  ODataEntry room = (ODataEntry) properties.get("ne_Room");
  Map<String, Object> roomProperties = room.getProperties();
  assertEquals(4, roomProperties.size());
  assertEquals("1", roomProperties.get("Id"));
  assertEquals("Room 1", roomProperties.get("Name"));
  assertEquals(Short.valueOf("1"), roomProperties.get("Seats"));
  assertEquals(Short.valueOf("1"), roomProperties.get("Version"));
  EntryMetadata roomMetadata = room.getMetadata();
  assertNotNull(roomMetadata);
  assertEquals("W/1", roomMetadata.getEtag());
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:38,代码来源:XmlEntityConsumerTest.java

示例7: readIncompleteEntryMerge

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readIncompleteEntryMerge() throws Exception {
  XmlEntityConsumer xec = new XmlEntityConsumer();

  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  InputStream reqContent = createContentAsStream(ROOM_1_XML);
  ODataEntry result =
      xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build());

  // verify
  EntryMetadata entryMetadata = result.getMetadata();
  assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId());
  assertEquals("W/\"1\"", entryMetadata.getEtag());
  assertEquals(null, entryMetadata.getUri());

  MediaMetadata mediaMetadata = result.getMediaMetadata();
  assertEquals("application/xml", mediaMetadata.getContentType());
  assertEquals(null, mediaMetadata.getSourceLink());
  assertEquals(null, mediaMetadata.getEditLink());
  assertEquals(null, mediaMetadata.getEtag());

  Map<String, Object> properties = result.getProperties();
  assertEquals(1, properties.size());
  assertEquals("1", properties.get("Id"));

  assertEquals("Rooms('1')/nr_Building", result.getMetadata().getAssociationUris("nr_Building").get(0));
  assertEquals("Rooms('1')/nr_Employees", result.getMetadata().getAssociationUris("nr_Employees").get(0));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:29,代码来源:XmlEntityConsumerTest.java

示例8: readEntryAtomProperties

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readEntryAtomProperties() throws Exception {
  // prepare
  EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
  InputStream contentBody = createContentAsStream(EMPLOYEE_1_XML);

  // execute
  XmlEntityConsumer xec = new XmlEntityConsumer();
  ODataEntry result =
      xec.readEntry(entitySet, contentBody, EntityProviderReadProperties.init().mergeSemantic(true).build());

  // verify
  EntryMetadata metadata = result.getMetadata();
  assertEquals("http://localhost:19000/Employees('1')", metadata.getId());
  assertEquals("W/\"1\"", metadata.getEtag());
  List<String> associationUris = metadata.getAssociationUris("ne_Room");
  assertEquals(1, associationUris.size());
  assertEquals("Employees('1')/ne_Room", associationUris.get(0));
  associationUris = metadata.getAssociationUris("ne_Manager");
  assertEquals(1, associationUris.size());
  assertEquals("Employees('1')/ne_Manager", associationUris.get(0));
  associationUris = metadata.getAssociationUris("ne_Team");
  assertEquals(1, associationUris.size());
  assertEquals("Employees('1')/ne_Team", associationUris.get(0));

  assertEquals(null, metadata.getUri());

  MediaMetadata mm = result.getMediaMetadata();
  assertEquals("Employees('1')/$value", mm.getSourceLink());
  assertEquals("mmEtag", mm.getEtag());
  assertEquals("application/octet-stream", mm.getContentType());
  assertEquals("Employees('1')/$value", mm.getEditLink());

  Map<String, Object> data = result.getProperties();
  assertEquals(9, data.size());
  assertEquals("1", data.get("EmployeeId"));
  assertEquals("Walter Winter", data.get("EmployeeName"));
  assertEquals("1", data.get("ManagerId"));
  assertEquals("1", data.get("RoomId"));
  assertEquals("1", data.get("TeamId"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:42,代码来源:XmlEntityConsumerTest.java


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