Examples of WriteEntryCallbackResult


Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    WriteEntryCallbackContext writeFeedContext = EdmMockUtil.getWriteEntryCallBackContext();
    try {
      Field field = callBack.getClass().getDeclaredField("nextEntitySet");
      field.setAccessible(true);
      field.set(callBack, EdmMockUtil.mockTargetEntitySet());
      WriteEntryCallbackResult result = callBack.retrieveEntryResult(writeFeedContext);
      assertEquals(1, result.getEntryData().size());
    } catch (SecurityException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (NoSuchFieldException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

  }

  @Override
  public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
      throws ODataApplicationException {
    WriteEntryCallbackResult result = new WriteEntryCallbackResult();
    Map<String, Object> entry = context.getEntryData();
    Map<String, Object> edmPropertyValueMap = null;
    List<EdmNavigationProperty> currentNavPropertyList = null;
    Map<String, ExpandSelectTreeNode> navigationLinks = null;
    JPAEntityParser jpaResultParser = new JPAEntityParser();
    EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
    try {
      Object inlinedEntry = entry.get(currentNavigationProperty.getName());
      if (nextEntitySet == null) {
        nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
      }
      edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(inlinedEntry, nextEntitySet.getEntityType());
      result.setEntryData(edmPropertyValueMap);
      navigationLinks = context.getCurrentExpandSelectTreeNode().getLinks();
      if (navigationLinks.size() > 0) {
        currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
        EdmNavigationProperty nextNavProperty =
            getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty());
        if (nextNavProperty != null) {
          currentNavPropertyList.add(nextNavProperty);
        }
        HashMap<String, Object> navigationMap =
            jpaResultParser.parse2EdmNavigationValueMap(inlinedEntry, currentNavPropertyList);
        edmPropertyValueMap.putAll(navigationMap);
        result.setEntryData(edmPropertyValueMap);
      }
      result.setInlineProperties(getInlineEntityProviderProperties(context));
    } catch (EdmException e) {
      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
    } catch (ODataJPARuntimeException e) {
      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

        final EntityInfoAggregator inlineEntityInfo =
            EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree());
        new JsonFeedEntityProducer(inlineProperties).append(writer, inlineEntityInfo, inlineData, false);

      } else {
        final WriteEntryCallbackResult result =
            ((OnWriteEntryContent) callback).retrieveEntryResult((WriteEntryCallbackContext) context);
        Map<String, Object> inlineData = result.getEntryData();
        if (inlineData != null && !inlineData.isEmpty()) {
          final EntityProviderWriteProperties inlineProperties = result.getInlineProperties();
          final EntityInfoAggregator inlineEntityInfo =
              EntityInfoAggregator.create(inlineEntitySet, inlineProperties.getExpandSelectTree());
          new JsonEntryEntityProducer(inlineProperties).append(writer, inlineEntityInfo, inlineData, false);
        } else {
          jsonStreamWriter.unquotedValue("null");
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    class EntryCallback implements OnWriteEntryContent {
      @Override
      public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
          throws ODataApplicationException {
        WriteEntryCallbackResult result = new WriteEntryCallbackResult();
        result.setEntryData(null);
        result.setInlineProperties(DEFAULT_PROPERTIES);
        return result;
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    class EntryCallback implements OnWriteEntryContent {
      @Override
      public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
          throws ODataApplicationException {
        WriteEntryCallbackResult result = new WriteEntryCallbackResult();
        result.setEntryData(new HashMap<String, Object>());
        result.setInlineProperties(DEFAULT_PROPERTIES);
        return result;
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

      @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;
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    class EntryCallback implements OnWriteEntryContent {
      @Override
      public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
          throws ODataApplicationException {
        WriteEntryCallbackResult result = new WriteEntryCallbackResult();
        result.setEntryData(null);
        result.setInlineProperties(DEFAULT_PROPERTIES);
        return result;
      }
    }
    EntryCallback callback = new EntryCallback();
    Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    class EntryCallback implements OnWriteEntryContent {
      @Override
      public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
          throws ODataApplicationException {
        WriteEntryCallbackResult result = new WriteEntryCallbackResult();
        result.setEntryData(new HashMap<String, Object>());
        result.setInlineProperties(DEFAULT_PROPERTIES);
        return result;
      }
    }
    EntryCallback callback = new EntryCallback();
    Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

      @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>();
View Full Code Here

Examples of org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult

    public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
        throws ODataApplicationException {
      try {
        final EdmEntityType entityType =
            context.getSourceEntitySet().getRelatedEntitySet(context.getNavigationProperty()).getEntityType();
        WriteEntryCallbackResult result = new WriteEntryCallbackResult();
        Object relatedData;
        try {
          relatedData = readRelatedData(context);
        } catch (final ODataNotFoundException e) {
          relatedData = null;
        }

        if (relatedData == null) {
          result.setEntryData(Collections.<String, Object> emptyMap());
        } else {
          result.setEntryData(getStructuralTypeValueMap(relatedData, entityType));

          EntityProviderWriteProperties inlineProperties =
              EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).callbacks(
                  getCallbacks(relatedData, entityType)).expandSelectTree(context.getCurrentExpandSelectTreeNode())
                  .build();
          result.setInlineProperties(inlineProperties);
        }
        return result;
      } catch (final ODataException e) {
        throw new ODataApplicationException(e.getLocalizedMessage(), Locale.ROOT, e);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.