本文整理汇总了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));
}
示例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();
}
示例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();
}
示例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"));
}