Package org.apache.olingo.odata2.api.ep

Examples of org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties$ODataEntityProviderPropertiesBuilder


    callbacks.put("aCallback", new MyCallback(null, null));
    ExpandSelectTreeNode expandSelectTree = new ExpandSelectTreeNodeImpl();
    URI selfLink = new URI("http://some.uri");
    Map<String, Map<String, Object>> links = new HashMap<String, Map<String, Object>>();
    links.put("aNavigationProperty", Collections.<String, Object> emptyMap());
    final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
        .callbacks(callbacks)
        .expandSelectTree(expandSelectTree)
        .inlineCount(1)
        .inlineCountType(InlineCount.ALLPAGES)
        .nextLink("http://localhost")
        .selfLink(selfLink)
        .includeSimplePropertyType(true)
        .additionalLinks(links)
        .omitJsonWrapper(true)
        .contentOnly(true)
        .build();

    assertEquals("Wrong amount of callbacks.", 1, properties.getCallbacks().size());
    assertTrue("No callback found.", properties.getCallbacks().containsKey("aCallback"));
    assertEquals("Wrong expand select tree.", expandSelectTree, properties.getExpandSelectTree());
    assertEquals("Wrong self link.", selfLink, properties.getSelfLink());
    assertEquals("Wrong base uri.", "http://localhost:80/", properties.getServiceRoot().toASCIIString());
    assertEquals("Wrong inline count type.", InlineCount.ALLPAGES, properties.getInlineCountType());
    assertEquals("Wrong inline count.", Integer.valueOf(1), properties.getInlineCount());
    assertEquals("Wrong nextLink", "http://localhost", properties.getNextLink());
    assertTrue("Simple property types should be true", properties.isIncludeSimplePropertyType());
    assertEquals(Collections.emptyMap(), properties.getAdditionalLinks().get("aNavigationProperty"));
    assertTrue("Json Wrapper should be omitted", properties.isOmitJsonWrapper());
    assertTrue("ContentOnlyFlag should be set", properties.isContentOnly());
  }
View Full Code Here


    callbacks.put("aCallback", new MyCallback(null, null));
    ExpandSelectTreeNode expandSelectTree = new ExpandSelectTreeNodeImpl();
    URI selfLink = new URI("http://some.uri");
    Map<String, Map<String, Object>> links = new HashMap<String, Map<String, Object>>();
    links.put("aNavigationProperty", Collections.<String, Object> emptyMap());
    final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
        .callbacks(callbacks)
        .expandSelectTree(expandSelectTree)
        .inlineCount(1)
        .inlineCountType(InlineCount.ALLPAGES)
        .nextLink("http://localhost")
        .selfLink(selfLink)
        .includeSimplePropertyType(true)
        .additionalLinks(links)
        .omitJsonWrapper(true)
        .contentOnly(true)
        .build();

    //
    final EntityProviderWriteProperties fromProperties =
        EntityProviderWriteProperties.fromProperties(properties).build();

    //
    assertEquals(1, fromProperties.getCallbacks().size());
    assertTrue(fromProperties.getCallbacks().containsKey("aCallback"));
    assertEquals(expandSelectTree, fromProperties.getExpandSelectTree());
    assertEquals(selfLink, fromProperties.getSelfLink());
    assertEquals("Wrong base uri.", "http://localhost:80/", fromProperties.getServiceRoot().toASCIIString());
    assertEquals("Wrong inline count type.", InlineCount.ALLPAGES, fromProperties.getInlineCountType());
    assertEquals("Wrong inline count.", Integer.valueOf(1), fromProperties.getInlineCount());
    assertEquals("Wrong nextLink", "http://localhost", fromProperties.getNextLink());
    assertTrue("Simple property types should be true", fromProperties.isIncludeSimplePropertyType());
    assertEquals(Collections.emptyMap(), fromProperties.getAdditionalLinks().get("aNavigationProperty"));
    assertTrue("Json Wrapper should be omitted", properties.isOmitJsonWrapper());
    assertTrue("ContentOnlyFlag should be set", properties.isContentOnly());
  }
View Full Code Here

    List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
    for (final Object entryData : data) {
      values.add(getStructuralTypeValueMap(entryData, entityType));
    }

    final EntityProviderWriteProperties feedProperties = EntityProviderWriteProperties
        .serviceRoot(context.getPathInfo().getServiceRoot())
        .inlineCountType(inlineCountType)
        .inlineCount(count)
        .expandSelectTree(UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand()))
        .callbacks(getCallbacks(data, entityType))
View Full Code Here

      }
      values.add(entryValues);
    }

    ODataContext context = getContext();
    final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
        .serviceRoot(context.getPathInfo().getServiceRoot())
        .inlineCountType(uriInfo.getInlineCount())
        .inlineCount(count)
        .build();
View Full Code Here

    for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) {
      values.put(property.getName(), valueAccess.getPropertyValue(data, property));
    }

    ODataContext context = getContext();
    final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
        .serviceRoot(context.getPathInfo().getServiceRoot())
        .build();

    final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink");
View Full Code Here

      value = getStructuralTypeValueMap(data, (EdmStructuralType) type);
    }

    ODataContext context = getContext();

    final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
        .serviceRoot(context.getPathInfo().getServiceRoot()).build();

    final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeFunctionImport");

    final ODataResponse response =
View Full Code Here

      final T data, final String contentType) throws ODataException, EntityProviderException {
    final EdmEntityType entityType = entitySet.getEntityType();
    final Map<String, Object> values = getStructuralTypeValueMap(data, entityType);

    ODataContext context = getContext();
    EntityProviderWriteProperties writeProperties = EntityProviderWriteProperties
        .serviceRoot(context.getPathInfo().getServiceRoot())
        .expandSelectTree(expandSelectTree)
        .callbacks(getCallbacks(data, entityType))
        .build();
View Full Code Here

            ((OnWriteFeedContent) callback).retrieveFeedResult((WriteFeedCallbackContext) context);
        List<Map<String, Object>> inlineData = result.getFeedData();
        if (inlineData == null) {
          inlineData = new ArrayList<Map<String, Object>>();
        }
        final EntityProviderWriteProperties inlineProperties = result.getInlineProperties();
        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

    locationData.put("City", cityData);
    locationData.put("Country", "Calisota");
    employeeData.put("Location", locationData);

    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
View Full Code Here

    selectedProperties.add("TeamId");
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");

    ExpandSelectTreeNode expandSelectTreeNode =
        ExpandSelectTreeNode.entitySet(entitySet).selectedProperties(selectedProperties).build();
    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .expandSelectTree(expandSelectTreeNode).build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties$ODataEntityProviderPropertiesBuilder

Copyright © 2018 www.massapicom. 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.