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


Java EntityProviderReadProperties类代码示例

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


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

示例1: readFeed

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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: readEntry

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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 ());
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:40,代码来源:ODataClient.java

示例3: readEntry

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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());
}
 
开发者ID:SAP,项目名称:C4CODATAAPIDEVGUIDE,代码行数:17,代码来源:ServiceTicketODataConsumer.java

示例4: updateEntity

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:ListsProcessor.java

示例5: parseEntry

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:ListsProcessor.java

示例6: readEntryNullProperty

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
@Test
public void readEntryNullProperty() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
  final String content = EMPLOYEE_1_XML.replace("<d:EntryDate>1999-01-01T00:00:00</d:EntryDate>",
      "<d:EntryDate m:null='true' />");
  InputStream contentBody = createContentAsStream(content);

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

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

示例7: readFunctionImport

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
@Override
public Object readFunctionImport(final EdmFunctionImport functionImport, InputStream content,
    final EntityProviderReadProperties properties) throws EntityProviderException {
  try {
    if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) {
      return new XmlEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties);
    } else {
      final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport);
      return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ?
        new XmlEntityConsumer().readCollection(info, content, properties) :
        new XmlEntityConsumer().readProperty(info, content, properties).get(info.getName());
    }
  } catch (final EdmException e) {
    throw new EntityProviderException(e.getMessageReference(), e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:AtomEntityProvider.java

示例8: RoomEntryWithInlineEmployeeInlineTeam

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

示例9: RoomEntryWithEmptyInlineEmployeeInlineTeam

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

示例10: handleStartedTag

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
private void handleStartedTag(final XMLStreamReader reader, final EntityInfoAggregator eia,
    final EntityProviderReadProperties readProperties)
    throws EntityProviderException, XMLStreamException, EdmException {

  currentHandledStartTagName = reader.getLocalName();

  if (FormatXml.ATOM_ID.equals(currentHandledStartTagName)) {
    readId(reader);
  } else if (FormatXml.ATOM_ENTRY.equals(currentHandledStartTagName)) {
    readEntry(reader);
  } else if (FormatXml.ATOM_LINK.equals(currentHandledStartTagName)) {
    readLink(reader, eia, readProperties);
  } else if (FormatXml.ATOM_CONTENT.equals(currentHandledStartTagName)) {
    readContent(reader, eia, readProperties);
  } else if (FormatXml.M_PROPERTIES.equals(currentHandledStartTagName)) {
    readProperties(reader, eia, readProperties);
  } else if (!readProperties.getMergeSemantic()) {
    readCustomElement(reader, currentHandledStartTagName, eia, readProperties);
  } else {
    skipStartedTag(reader);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:XmlEntryConsumer.java

示例11: createInlineProperties

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
/**
 * Create {@link EntityProviderReadProperties} which can be used for reading of inline properties/entrys of navigation
 * links within
 * this current read entry.
 * 
 * @param readProperties
 * @param navigationProperty
 * @return
 * @throws EntityProviderException
 */
private EntityProviderReadProperties createInlineProperties(final EntityProviderReadProperties readProperties,
    final EdmNavigationProperty navigationProperty) throws EntityProviderException {
  final OnReadInlineContent callback = readProperties.getCallback();

  EntityProviderReadProperties currentReadProperties = EntityProviderReadProperties.initFrom(readProperties).build();
  if (callback == null) {
    return currentReadProperties;
  } else {
    try {
      return callback.receiveReadProperties(currentReadProperties, navigationProperty);
    } catch (ODataApplicationException e) {
      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
          .getSimpleName()), e);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:XmlEntryConsumer.java

示例12: readFeed

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
/**
 * 
 * @param reader
 * @param eia
 * @param readProperties
 * @return {@link ODataDeltaFeed} object
 * @throws EntityProviderException
 */
public ODataDeltaFeed readFeed(final XMLStreamReader reader, final EntityInfoAggregator eia,
    final EntityProviderReadProperties readProperties) throws EntityProviderException {
  try {
    // read xml tag
    reader.require(XMLStreamConstants.START_DOCUMENT, null, null);
    reader.nextTag();

    // read feed tag
    reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_FEED);
    Map<String, String> foundPrefix2NamespaceUri = extractNamespacesFromTag(reader);
    foundPrefix2NamespaceUri.putAll(readProperties.getValidatedPrefixNamespaceUris());
    checkAllMandatoryNamespacesAvailable(foundPrefix2NamespaceUri);
    EntityProviderReadProperties entryReadProperties =
        EntityProviderReadProperties.initFrom(readProperties).addValidatedPrefixes(foundPrefix2NamespaceUri).build();

    // read feed data (metadata and entries)
    return readFeedData(reader, eia, entryReadProperties);
  } catch (XMLStreamException e) {
    throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
        .getSimpleName()), e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:31,代码来源:XmlFeedConsumer.java

示例13: readEntryWithNullProperty

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的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());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:JsonEntryConsumerTest.java

示例14: readFunctionImport

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
@Override
public Object readFunctionImport(final EdmFunctionImport functionImport, final InputStream content,
    final EntityProviderReadProperties properties) throws EntityProviderException {
  try {
    if (functionImport.getReturnType().getType().getKind() == EdmTypeKind.ENTITY) {
      return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY
          ? new JsonEntityConsumer().readFeed(functionImport.getEntitySet(), content, properties)
          : new JsonEntityConsumer().readEntry(functionImport.getEntitySet(), content, properties);
    } else {
      final EntityPropertyInfo info = EntityInfoAggregator.create(functionImport);
      return functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY ?
          new JsonEntityConsumer().readCollection(info, content, properties) :
          new JsonEntityConsumer().readProperty(info, content, properties).get(info.getName());
    }
  } catch (final EdmException e) {
    throw new EntityProviderException(e.getMessageReference(), e);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:JsonEntityProvider.java

示例15: complexPropertyNullValueNotAllowedButNotValidated

import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties; //导入依赖的package包/类
@Test
public void complexPropertyNullValueNotAllowedButNotValidated() throws Exception {
  final String xml = "<Location xmlns=\"" + Edm.NAMESPACE_D_2007_08
      + "\" m:null=\"true\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\" />";
  EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee")
      .getProperty("Location");
  EdmFacets facets = mock(EdmFacets.class);
  when(facets.isNullable()).thenReturn(false);
  when(property.getFacets()).thenReturn(facets);
  final EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);

  final Map<String, Object> resultMap = new XmlPropertyConsumer()
      .readProperty(createReaderForTest(xml, true), property, readProperties);
  assertFalse(resultMap.isEmpty());
  assertNull(resultMap.get("Location"));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:XmlPropertyConsumerTest.java


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