本文整理汇总了Java中org.apache.olingo.odata2.api.ep.entry.ODataEntry类的典型用法代码示例。如果您正苦于以下问题:Java ODataEntry类的具体用法?Java ODataEntry怎么用?Java ODataEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataEntry类属于org.apache.olingo.odata2.api.ep.entry包,在下文中一共展示了ODataEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
/**
* Reads an entry (an Entity, a property, a complexType, ...).
*
* @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 ODataEntry 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 ODataEntry readEntry(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.readEntry(contentType.type (),
getEntitySet (resource_path), content,
EntityProviderReadProperties.init ().build ());
}
示例2: testReadEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Test
public void testReadEntry() throws Exception {
final TestOlingo2ResponseHandler<ODataEntry> responseHandler = new TestOlingo2ResponseHandler<ODataEntry>();
olingoApp.read(edm, TEST_MANUFACTURER, null, responseHandler);
ODataEntry entry = responseHandler.await();
LOG.info("Single Entry: {}", prettyPrint(entry));
responseHandler.reset();
olingoApp.read(edm, TEST_CAR, null, responseHandler);
entry = responseHandler.await();
LOG.info("Single Entry: {}", prettyPrint(entry));
responseHandler.reset();
final Map<String, String> queryParams = new HashMap<String, String>();
queryParams.put(SystemQueryOption.$expand.toString(), CARS);
olingoApp.read(edm, TEST_MANUFACTURER, queryParams, responseHandler);
ODataEntry entryExpanded = responseHandler.await();
LOG.info("Single Entry with expanded Cars relation: {}", prettyPrint(entryExpanded));
}
示例3: readEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
public ODataEntry readEntry(String serviceUri, String contentType,
String entitySetName, String keyValue, SystemQueryOptions options)
throws IllegalStateException, IOException, EdmException,
EntityProviderException {
EdmEntityContainer entityContainer = readEdm()
.getDefaultEntityContainer();
logger.info("Entity container is => " + entityContainer.getName());
String absolutUri = createUri(serviceUri, entitySetName, keyValue,
options);
InputStream content = executeGet(absolutUri, contentType);
return EntityProvider.readEntry(contentType,
entityContainer.getEntitySet(entitySetName), content,
EntityProviderReadProperties.init().build());
}
示例4: parseEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
private ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content,
final String requestContentType, final EntityProviderReadProperties properties) throws ODataBadRequestException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readEntry");
ODataEntry entryValues;
try {
entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, properties);
} catch (final EntityProviderException e) {
throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
}
context.stopRuntimeMeasurement(timingHandle);
return entryValues;
}
示例5: readSimpleBuildingEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Test
public void readSimpleBuildingEntry() throws Exception {
ODataEntry result = prepareAndExecuteEntry(SIMPLE_ENTRY_BUILDING, "Buildings", DEFAULT_PROPERTIES);
// verify
Map<String, Object> properties = result.getProperties();
assertNotNull(properties);
assertEquals("1", properties.get("Id"));
assertEquals("Building 1", properties.get("Name"));
assertNull(properties.get("Image"));
assertNull(properties.get("nb_Rooms"));
List<String> associationUris = result.getMetadata().getAssociationUris("nb_Rooms");
assertEquals(1, associationUris.size());
assertEquals("http://localhost:8080/ReferenceScenario.svc/Buildings('1')/nb_Rooms", associationUris.get(0));
checkMediaDataInitial(result.getMediaMetadata());
}
示例6: updateEntity
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Override
public ODataResponse updateEntity(final PutMergePatchUriInfo uriInfo, final InputStream content,
final String requestContentType, final boolean merge, final String contentType) throws ODataException {
Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments());
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
final EdmEntityType entityType = entitySet.getEntityType();
final EntityProviderReadProperties properties = EntityProviderReadProperties.init()
.mergeSemantic(merge)
.addTypeMappings(getStructuralTypeTypeMap(data, entityType))
.build();
final ODataEntry entryValues = parseEntry(entitySet, content, requestContentType, properties);
setStructuralTypeValuesFromMap(data, entityType, entryValues.getProperties(), merge);
return ODataResponse.newBuilder().eTag(constructETag(entitySet, data)).build();
}
示例7: normalizeInlineEntries
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的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);
}
}
示例8: extractLinkURI
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<String> extractLinkURI(ODataEntry oDataEntry, String navigationPropertyName) {
List<String> links = new ArrayList<String>();
String link = null;
Object object = oDataEntry.getProperties().get(navigationPropertyName);
if (object == null) {
return links;
}
if (object instanceof ODataEntry) {
link = ((ODataEntry) object).getMetadata().getUri();
if (!link.isEmpty()) {
links.add(link);
}
} else {
for (ODataEntry entry : (List<ODataEntry>) object) {
link = entry.getMetadata().getUri();
if (link != null && link.isEmpty() == false) {
links.add(link);
}
}
}
return links;
}
示例9: mockODataEntryWithNullValue
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
public static ODataEntry mockODataEntryWithNullValue(final String entityName) {
ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
Map<String, Object> propertiesMap = mockODataEntryProperties(entityName);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MINT, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MCHAR, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_CLOB, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_ENUM, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MBLOB, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MCARRAY, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MC, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MCHARARRAY, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MDATETIME, null);
propertiesMap.put(JPATypeMock.PROPERTY_NAME_MSTRING, null);
EasyMock.expect(oDataEntry.getProperties()).andReturn(propertiesMap).anyTimes();
enhanceMockODataEntry(oDataEntry, false, new ArrayList<String>());
EasyMock.replay(oDataEntry);
return oDataEntry;
}
示例10: readSimpleTeamEntry
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Test
public void readSimpleTeamEntry() throws Exception {
ODataEntry result = prepareAndExecuteEntry(SIMPLE_ENTRY_TEAM, "Teams", DEFAULT_PROPERTIES);
Map<String, Object> properties = result.getProperties();
assertNotNull(properties);
assertEquals("1", properties.get("Id"));
assertEquals("Team 1", properties.get("Name"));
assertEquals(Boolean.FALSE, properties.get("isScrumTeam"));
assertNull(properties.get("nt_Employees"));
List<String> associationUris = result.getMetadata().getAssociationUris("nt_Employees");
assertEquals(1, associationUris.size());
assertEquals("http://localhost:8080/ReferenceScenario.svc/Teams('1')/nt_Employees", associationUris.get(0));
checkMediaDataInitial(result.getMediaMetadata());
}
示例11: innerFeedNoMediaResourceWithCallbackContainsNextLinkAndCount
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Test
public void innerFeedNoMediaResourceWithCallbackContainsNextLinkAndCount() throws Exception {
ODataEntry outerEntry =
prepareAndExecuteEntry(BUILDING_WITH_INLINE_ROOMS_NEXTLINK_AND_COUNT, "Buildings", DEFAULT_PROPERTIES);
ODataFeed innerRoomFeed = (ODataFeed) outerEntry.getProperties().get("nb_Rooms");
assertNotNull(innerRoomFeed);
List<ODataEntry> rooms = innerRoomFeed.getEntries();
assertNotNull(rooms);
assertEquals(1, rooms.size());
FeedMetadata roomsMetadata = innerRoomFeed.getFeedMetadata();
assertEquals(Integer.valueOf(1), roomsMetadata.getInlineCount());
assertEquals("nextLink", roomsMetadata.getNextLink());
}
示例12: readEntryWithNullProperty
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的package包/类
@Test
public void readEntryWithNullProperty() throws Exception {
final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
final String content = "{\"Id\":\"99\",\"Seats\":null}";
for (final boolean merge : new boolean[] { false, true }) {
final ODataEntry result = new JsonEntityConsumer().readEntry(entitySet, createContentAsStream(content),
EntityProviderReadProperties.init().mergeSemantic(merge).build());
final Map<String, Object> properties = result.getProperties();
assertNotNull(properties);
assertEquals(2, properties.size());
assertEquals("99", properties.get("Id"));
assertTrue(properties.containsKey("Seats"));
assertNull(properties.get("Seats"));
assertTrue(result.getMetadata().getAssociationUris("nr_Employees").isEmpty());
checkMediaDataInitial(result.getMediaMetadata());
}
}
示例13: RoomEntryWithInlineEmployeeInlineTeam
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的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());
}
}
示例14: 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());
}
示例15: getExpandedData
import org.apache.olingo.odata2.api.ep.entry.ODataEntry; //导入依赖的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);
}
}
}
}