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


Java WriteEntryCallbackContext类代码示例

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


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

示例1: retrieveEntryResult

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Override
public WriteEntryCallbackResult retrieveEntryResult(WriteEntryCallbackContext context)
      throws ODataApplicationException
{
   EntityProviderWriteProperties inlineProperties = EntityProviderWriteProperties
         .serviceRoot(this.serviceRoot)
         .expandSelectTree(context.getCurrentExpandSelectTreeNode())
         .build();

   WriteEntryCallbackResult result = new WriteEntryCallbackResult();
   result.setInlineProperties(inlineProperties);

   List<Map<String, Object>> data = getData(context);
   if (data.size() > 1)
   {
      throw new IllegalStateException("cannot expand a feed as an entity");
   }
   if (data.size() == 1)
   {
      result.setEntryData(data.get(0));
   }

   return result;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:25,代码来源:Expander.java

示例2: retrieveEntryResult

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Override
public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context) {
  WriteEntryCallbackResult result = new WriteEntryCallbackResult();
  try {
    if ("Employees".equals(context.getSourceEntitySet().getName())) {
      if ("ne_Room".equals(context.getNavigationProperty().getName())) {
        HashMap<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
        for (String navPropName : context.getSourceEntitySet().getRelatedEntitySet(context.getNavigationProperty())
            .getEntityType().getNavigationPropertyNames()) {
          callbacks.put(navPropName, this);
        }
        EntityProviderWriteProperties inlineProperties =
            EntityProviderWriteProperties.serviceRoot(baseUri).callbacks(callbacks).expandSelectTree(
                context.getCurrentExpandSelectTreeNode()).build();
        result.setEntryData(dataProvider.getRoomData());
        result.setInlineProperties(inlineProperties);
      } else if ("ne_Team".equals(context.getNavigationProperty().getName())) {
        result.setEntryData(null);
      }
    }
  } catch (EdmException e) {
    throw new ODataRuntimeException("EdmException:", e);
  }
  return result;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:MyCallback.java

示例3: getWriteEntryCallBackContext

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
public static WriteEntryCallbackContext getWriteEntryCallBackContext() {
  WriteEntryCallbackContext writeContext = new WriteEntryCallbackContext();
  writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
  writeContext.setNavigationProperty(mockNavigationProperty());
  writeContext.setSourceEntitySet(mockSourceEntitySet());
  writeContext.setEntryData(getEntryData());
  return writeContext;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:9,代码来源:EdmMockUtil.java

示例4: expandSelectedTeamEmptyDataMap

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Test
public void expandSelectedTeamEmptyDataMap() throws Exception {
  ExpandSelectTreeNode selectTree = getSelectExpandTree("Employees('1')", "ne_Team", "ne_Team");

  HashMap<String, ODataCallback> callbacksEmployee = new HashMap<String, ODataCallback>();
  OnWriteEntryContent callback = new OnWriteEntryContent() {

    @Override
    public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
        throws ODataApplicationException {
      WriteEntryCallbackResult result = new WriteEntryCallbackResult();
      result.setInlineProperties(DEFAULT_PROPERTIES);
      result.setEntryData(new HashMap<String, Object>());
      return result;
    }
  };
  callbacksEmployee.put("ne_Team", callback);
  EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.serviceRoot(BASE_URI).expandSelectTree(selectTree).callbacks(callbacksEmployee)
          .build();
  AtomEntityProvider provider = createAtomEntityProvider();
  ODataResponse response =
      provider.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"),
          employeeData, properties);

  String xmlString = verifyResponse(response);
  verifyNavigationProperties(xmlString, F, F, T);
  assertXpathNotExists("/a:entry/m:properties", xmlString);
  assertXpathExists(teamXPathString + "/m:inline", xmlString);
  assertXpathNotExists(teamXPathString + "/m:inline/a:entry", xmlString);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:32,代码来源:XmlExpandProducerTest.java

示例5: retrieveEntryResult

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Override
public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
    throws ODataApplicationException {
  WriteEntryCallbackResult writeEntryCallbackResult = new WriteEntryCallbackResult();
  EntityProviderWriteProperties inlineProperties =
      EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).expandSelectTree(
          context.getCurrentExpandSelectTreeNode()).build();
  writeEntryCallbackResult.setInlineProperties(inlineProperties);
  Map<String, Object> buildingData = new HashMap<String, Object>();
  buildingData.put("Id", "1");
  buildingData.put("Name", "BuildingName");
  writeEntryCallbackResult.setEntryData(buildingData);
  return writeEntryCallbackResult;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:15,代码来源:ExpandSelectProducerWithBuilderTest.java

示例6: retrieveEntryResult

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Override
public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
    throws ODataApplicationException {
  WriteEntryCallbackResult result = new WriteEntryCallbackResult();
  result.setEntryData(null);
  result.setInlineProperties(DEFAULT_PROPERTIES);
  return result;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:9,代码来源:JsonEntryEntityProducerTest.java

示例7: entryWithExpandedEntry

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Test
public void entryWithExpandedEntry() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  Map<String, Object> roomData = new HashMap<String, Object>();
  roomData.put("Id", "1");
  roomData.put("Version", 1);

  ExpandSelectTreeNode node1 = createRoomNode();

  class EntryCallback implements OnWriteEntryContent {
    @Override
    public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
        throws ODataApplicationException {
      Map<String, Object> buildingData = new HashMap<String, Object>();
      buildingData.put("Id", "1");
      WriteEntryCallbackResult result = new WriteEntryCallbackResult();
      result.setEntryData(buildingData);
      result.setInlineProperties(DEFAULT_PROPERTIES);
      return result;
    }
  }
  EntryCallback callback = new EntryCallback();
  Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
  callbacks.put("nr_Building", callback);

  final ODataResponse response =
      new JsonEntityProvider().writeEntry(entitySet, roomData,
          EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(node1)
              .callbacks(callbacks).build());
  final String json = verifyResponse(response);
  assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Rooms('1')\","
      + "\"uri\":\"" + BASE_URI + "Rooms('1')\",\"type\":\"RefScenario.Room\",\"etag\":\"W/\\\"1\\\"\"},"
      + "\"nr_Building\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Buildings('1')\","
      + "\"uri\":\"" + BASE_URI + "Buildings('1')\",\"type\":\"RefScenario.Building\"},"
      + "\"Id\":\"1\",\"Name\":null,\"Image\":null,"
      + "\"nb_Rooms\":{\"__deferred\":{\"uri\":\"" + BASE_URI + "Buildings('1')/nb_Rooms\"}}}}}",
      json);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:39,代码来源:JsonEntryEntityProducerTest.java

示例8: appendInlineEntry

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
private void appendInlineEntry(final XMLStreamWriter writer, final String navigationPropertyName,
    final EntityInfoAggregator eia, final Map<String, Object> data) throws EntityProviderException,
    XMLStreamException, EdmException {

  if (eia.getExpandedNavigationPropertyNames().contains(navigationPropertyName)) {
    if (properties.getCallbacks() != null && properties.getCallbacks().containsKey(navigationPropertyName)) {

      EdmNavigationProperty navProp = (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
      WriteEntryCallbackContext context = new WriteEntryCallbackContext();
      context.setSourceEntitySet(eia.getEntitySet());
      context.setCurrentWriteProperties(properties);
      context.setNavigationProperty(navProp);
      context.setEntryData(data);
      ExpandSelectTreeNode subNode = properties.getExpandSelectTree().getLinks().get(navigationPropertyName);
      context.setCurrentExpandSelectTreeNode(subNode);

      ODataCallback callback = properties.getCallbacks().get(navigationPropertyName);
      if (callback == null) {
        throw new EntityProviderProducerException(EntityProviderException.EXPANDNOTSUPPORTED);
      }
      WriteEntryCallbackResult result;
      try {
        result = ((OnWriteEntryContent) callback).retrieveEntryResult(context);
      } catch (ODataApplicationException e) {
        throw new EntityProviderProducerException(EntityProviderException.COMMON, e);
      }
      Map<String, Object> inlineData = result.getEntryData();
      
      // This statement is used for the client use case. Flag should never be set on server side
      if (properties.isOmitInlineForNullData() && (inlineData == null || inlineData.isEmpty())) {
        return;
      }

      writer.writeStartElement(Edm.NAMESPACE_M_2007_08, FormatXml.M_INLINE);
      if (inlineData != null && !inlineData.isEmpty()) {
        EntityProviderWriteProperties inlineProperties = result.getInlineProperties();
        EdmEntitySet inlineEntitySet = eia.getEntitySet().getRelatedEntitySet(navProp);
        AtomEntryEntityProducer inlineProducer = new AtomEntryEntityProducer(inlineProperties);
        EntityInfoAggregator inlineEia =
            EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree());
        inlineProducer.append(writer, inlineEia, inlineData, false, false);
      }

      writer.writeEndElement();
    }
  }

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:49,代码来源:AtomEntryEntityProducer.java

示例9: unbalancedPropertyEntryWithInlineEntry

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Test
public void unbalancedPropertyEntryWithInlineEntry() throws Exception {
  ExpandSelectTreeNode selectTree = getSelectExpandTree("Rooms('1')", "nr_Building", "nr_Building");

  Map<String, Object> roomData = new HashMap<String, Object>();
  roomData.put("Id", "1");
  roomData.put("Name", "Neu Schwanstein");
  roomData.put("Seats", new Integer(20));
  
  class EntryCallback implements OnWriteEntryContent {
    @Override
    public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
        throws ODataApplicationException {
      Map<String, Object> buildingData = new HashMap<String, Object>();
      buildingData.put("Id", "1");
      buildingData.put("Name", "Building1");
      
      WriteEntryCallbackResult result = new WriteEntryCallbackResult();
      result.setEntryData(buildingData);
      EntityProviderWriteProperties inlineProperties =
          EntityProviderWriteProperties.serviceRoot(BASE_URI).expandSelectTree(
              context.getCurrentExpandSelectTreeNode()).build();
      result.setInlineProperties(inlineProperties);
      return result;
    }
  }
  EntryCallback callback = new EntryCallback();
  Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
  callbacks.put("nr_Building", callback);
  
  EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.serviceRoot(BASE_URI).expandSelectTree(selectTree).callbacks(callbacks).
      isDataBasedPropertySerialization(true).build();
  AtomEntityProvider provider = createAtomEntityProvider();
  ODataResponse response =
      provider.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"), roomData,
          properties);

  String xmlString = verifyResponse(response);
  assertXpathNotExists("/a:entry/m:properties", xmlString);
  assertXpathExists("/a:entry/a:link", xmlString);
  verifyBuilding(buildingXPathString, xmlString);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:44,代码来源:AtomEntryProducerTest.java

示例10: unbalancedPropertyEntryWithInlineEntry

import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext; //导入依赖的package包/类
@Test
public void unbalancedPropertyEntryWithInlineEntry() throws Exception {
  final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  Map<String, Object> roomData = new HashMap<String, Object>();
  roomData.put("Id", "1");
  roomData.put("Version", 1);

  ExpandSelectTreeNode node1 = createRoomNode();

  class EntryCallback implements OnWriteEntryContent {
    @Override
    public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
        throws ODataApplicationException {
      Map<String, Object> buildingData = new HashMap<String, Object>();
      buildingData.put("Id", "1");
      buildingData.put("Name", "Building1");
      WriteEntryCallbackResult result = new WriteEntryCallbackResult();
      result.setEntryData(buildingData);
      result.setInlineProperties(context.getCurrentWriteProperties());
      return result;
    }
  }
  EntryCallback callback = new EntryCallback();
  Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
  callbacks.put("nr_Building", callback);

  final ODataResponse response =
      new JsonEntityProvider().writeEntry(entitySet, roomData,
          EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(node1)
              .callbacks(callbacks).isDataBasedPropertySerialization(true).build());
  assertNotNull(response);
  assertNotNull(response.getEntity());
  assertNull("EntitypProvider must not set content header", response.getContentHeader());

  final String json = StringHelper.inputStreamToString((InputStream) response.getEntity());
  assertNotNull(json);
  assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Rooms('1')\",\"uri\":\"" + BASE_URI + "Rooms('1')\","
      + "\"type\":\"RefScenario.Room\",\"etag\":\"W/\\\"1\\\"\"},\"Id\":\"1\",\"Version\":1,"
      + "\"nr_Building\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Buildings('1')\","
      + "\"uri\":\"" + BASE_URI + "Buildings('1')\",\"type\":\"RefScenario.Building\"},"
      + "\"Id\":\"1\",\"Name\":\"Building1\"}}}", json);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:43,代码来源:JsonEntryEntityProducerTest.java


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