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


Java ODataEntry.getExpandSelectTree方法代码示例

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


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

示例1: readInlineBuildingEntry

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Test
public void readInlineBuildingEntry() throws Exception {
  // prepare
  String content = readFile("expandedBuilding.xml");
  assertNotNull(content);

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

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

  ODataEntry entry = xec.readEntry(entitySet, reqContent, consumerProperties);
  // validate
  assertNotNull(entry);
  Map<String, Object> properties = entry.getProperties();
  assertEquals("1", properties.get("Id"));
  assertEquals("Room 1", properties.get("Name"));
  assertEquals((short) 1, properties.get("Seats"));
  assertEquals((short) 1, properties.get("Version"));
  //
  ExpandSelectTreeNode expandTree = entry.getExpandSelectTree();
  assertNotNull(expandTree);

  ODataEntry inlineBuilding = (ODataEntry) properties.get("nr_Building");
  Map<String, Object> inlineBuildingProps = inlineBuilding.getProperties();
  assertEquals("1", inlineBuildingProps.get("Id"));
  assertEquals("Building 1", inlineBuildingProps.get("Name"));
  assertNull(inlineBuildingProps.get("Image"));
  assertNull(inlineBuildingProps.get("nb_Rooms"));

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

示例2: createEntity

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Override
public ODataResponse createEntity(final PostUriInfo uriInfo, final InputStream content,
    final String requestContentType, final String contentType) throws ODataException {
  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  final EdmEntityType entityType = entitySet.getEntityType();

  Object data = dataSource.newDataObject(entitySet);
  ExpandSelectTreeNode expandSelectTree = null;

  if (entityType.hasStream()) {
    data = dataSource.createData(entitySet, data);
    dataSource.writeBinaryData(entitySet, data,
        new BinaryData(EntityProvider.readBinary(content), requestContentType));

  } else {
    final EntityProviderReadProperties properties = EntityProviderReadProperties.init()
        .mergeSemantic(false)
        .addTypeMappings(getStructuralTypeTypeMap(data, entityType))
        .build();
    final ODataEntry entryValues = parseEntry(entitySet, content, requestContentType, properties);

    setStructuralTypeValuesFromMap(data, entityType, entryValues.getProperties(), false);

    data = dataSource.createData(entitySet, data);

    createInlinedEntities(entitySet, data, entryValues);

    expandSelectTree = entryValues.getExpandSelectTree();
  }

  // Link back to the entity the target entity set is related to, if any.
  final List<NavigationSegment> navigationSegments = uriInfo.getNavigationSegments();
  if (!navigationSegments.isEmpty()) {
    final List<NavigationSegment> previousSegments = navigationSegments.subList(0, navigationSegments.size() - 1);
    final Object sourceData = retrieveData(
        uriInfo.getStartEntitySet(),
        uriInfo.getKeyPredicates(),
        uriInfo.getFunctionImport(),
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        previousSegments).getFirst();
    final EdmEntitySet previousEntitySet = previousSegments.isEmpty() ?
        uriInfo.getStartEntitySet() : previousSegments.get(previousSegments.size() - 1).getEntitySet();
    dataSource.writeRelation(previousEntitySet, sourceData, entitySet, getStructuralTypeValueMap(data, entityType));
  }

  return ODataResponse.fromResponse(writeEntry(uriInfo.getTargetEntitySet(), expandSelectTree, data, contentType))
      .eTag(constructETag(entitySet, data)).build();
}
 
开发者ID:mibo,项目名称:janos,代码行数:49,代码来源:DataSourceProcessor.java

示例3: createEntity

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
@Override
public ODataResponse createEntity(final PostUriInfo uriInfo, final InputStream content,
    final String requestContentType, final String contentType) throws ODataException {
  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  final EdmEntityType entityType = entitySet.getEntityType();

  Object data = dataSource.newDataObject(entitySet);
  ExpandSelectTreeNode expandSelectTree = null;

  if (entityType.hasStream()) {
    dataSource.createData(entitySet, data);
    dataSource.writeBinaryData(entitySet, data,
        new BinaryData(EntityProvider.readBinary(content), requestContentType));

  } else {
    final EntityProviderReadProperties properties = EntityProviderReadProperties.init()
        .mergeSemantic(false)
        .addTypeMappings(getStructuralTypeTypeMap(data, entityType))
        .build();
    final ODataEntry entryValues = parseEntry(entitySet, content, requestContentType, properties);

    setStructuralTypeValuesFromMap(data, entityType, entryValues.getProperties(), false);

    dataSource.createData(entitySet, data);

    createInlinedEntities(entitySet, data, entryValues);

    expandSelectTree = entryValues.getExpandSelectTree();
  }

  // Link back to the entity the target entity set is related to, if any.
  final List<NavigationSegment> navigationSegments = uriInfo.getNavigationSegments();
  if (!navigationSegments.isEmpty()) {
    final List<NavigationSegment> previousSegments = navigationSegments.subList(0, navigationSegments.size() - 1);
    final Object sourceData = retrieveData(
        uriInfo.getStartEntitySet(),
        uriInfo.getKeyPredicates(),
        uriInfo.getFunctionImport(),
        mapFunctionParameters(uriInfo.getFunctionImportParameters()),
        previousSegments);
    final EdmEntitySet previousEntitySet = previousSegments.isEmpty() ?
        uriInfo.getStartEntitySet() : previousSegments.get(previousSegments.size() - 1).getEntitySet();
    dataSource.writeRelation(previousEntitySet, sourceData, entitySet, getStructuralTypeValueMap(data, entityType));
  }

  return ODataResponse.fromResponse(writeEntry(uriInfo.getTargetEntitySet(), expandSelectTree, data, contentType))
      .eTag(constructETag(entitySet, data)).build();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:49,代码来源:ListsProcessor.java

示例4: readWithInlineContent

import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入方法依赖的package包/类
/** Teams('1')?$expand=nt_Employees */
@Test
public void readWithInlineContent() throws Exception {
  // prepare
  String content = readFile("expanded_team.xml");
  assertNotNull(content);

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

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

  ODataEntry entry = xec.readEntry(entitySet, reqContent, consumerProperties);
  // validate
  assertNotNull(entry);
  Map<String, Object> properties = entry.getProperties();
  assertEquals("1", properties.get("Id"));
  assertEquals("Team 1", properties.get("Name"));
  assertEquals(Boolean.FALSE, properties.get("isScrumTeam"));
  //
  ExpandSelectTreeNode expandTree = entry.getExpandSelectTree();
  assertNotNull(expandTree);
  // TODO: do more testing here
  //
  ODataFeed employeesFeed = (ODataFeed) properties.get("nt_Employees");
  List<ODataEntry> employees = employeesFeed.getEntries();
  assertEquals(3, employees.size());
  //
  ODataEntry employeeNo2 = employees.get(1);
  Map<String, Object> employessNo2Props = employeeNo2.getProperties();
  assertEquals("Frederic Fall", employessNo2Props.get("EmployeeName"));
  assertEquals("2", employessNo2Props.get("RoomId"));
  assertEquals(32, employessNo2Props.get("Age"));
  @SuppressWarnings("unchecked")
  Map<String, Object> emp2Location = (Map<String, Object>) employessNo2Props.get("Location");
  @SuppressWarnings("unchecked")
  Map<String, Object> emp2City = (Map<String, Object>) emp2Location.get("City");
  assertEquals("69190", emp2City.get("PostalCode"));
  assertEquals("Walldorf", emp2City.get("CityName"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:44,代码来源:XmlEntityConsumerTest.java


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