olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject [18/18] git commit: [OLINGO-337] merge origin/master
Date Tue, 08 Jul 2014 08:17:36 GMT
[OLINGO-337] merge origin/master


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/233651a8
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/233651a8
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/233651a8

Branch: refs/heads/olingo337
Commit: 233651a8bf9512592a1904f74c05d4b6071af0ba
Parents: 811fff5 f117154
Author: Stephan Klevenz <stephan.klevenz@sap.com>
Authored: Tue Jul 8 10:16:48 2014 +0200
Committer: Stephan Klevenz <stephan.klevenz@sap.com>
Committed: Tue Jul 8 10:16:48 2014 +0200

----------------------------------------------------------------------
 .../olingo/commons/api/format/AcceptType.java   |  3 +++
 .../tecsvc/processor/SampleJsonProcessor.java   | 28 +++++++++++---------
 2 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/233651a8/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/AcceptType.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/233651a8/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index ffb8d7f,b3dc02d..8d43276
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@@ -61,9 -58,12 +61,10 @@@ public class SampleJsonProcessor implem
    }
  
    @Override
-   public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo,
String format) {
+   public void readCollection(final ODataRequest request, final ODataResponse response, final
UriInfo uriInfo,
+       final ContentType requestedContentType) {
      long time = System.nanoTime();
  
 -    EntitySet entitySet = createEntitySet();
 -
      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
      time = System.nanoTime();
      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
@@@ -78,50 -79,26 +79,51 @@@
    }
  
    @Override
-   public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
String format) {
+   public void readEntity(final ODataRequest request, final ODataResponse response, final
UriInfo uriInfo,
+       final ContentType requestedContentType) {
      long time = System.nanoTime();
 -    Entity entity = createEntity();
  
      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
      time = System.nanoTime();
      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
 -    response.setContent(serializer.entity(
 -        edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
 -            .getEntitySet("ESAllPrim").getEntityType(),
 -        entity,
 -        ContextURL.getInstance(URI.create("dummyContextURL"))));
 +    EdmEntityType entityType = getEntityType(uriInfo);
 +    Entity entity = createEntity(entityType);
 +
 +    response.setContent(serializer.entity(entityType, entity,
-             getContextUrl(request, entityType)));
++        getContextUrl(request, entityType)));
      LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
  
      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
    }
  
 -  protected Entity createEntity() {
 +  private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
 +    return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
 +  }
 +
 +  public EdmEntityType getEntityType(UriInfo uriInfo) {
 +    return getEntitySet(uriInfo).getEntityType();
 +  }
 +
 +  public EdmEntitySet getEntitySet(UriInfo uriInfo) {
 +    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
-     if(resourcePaths.isEmpty()) {
++    if (resourcePaths.isEmpty()) {
 +      throw new RuntimeException("Invalid resource path.");
 +    }
-     String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
++    String entitySetName = resourcePaths.get(resourcePaths.size() - 1).toString();
 +    return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-             .getEntitySet(entitySetName);
++        .getEntitySet(entitySetName);
 +  }
 +
 +  protected Entity createEntity(EdmEntityType entityType) {
 +    boolean complex = (entityType.getName().contains("Comp"));
-     if(entityType.getName().contains("Coll")) {
++    if (entityType.getName().contains("Coll")) {
 +      return createEntityWithCollection(complex);
 +    }
 +    return createEntity(complex);
 +  }
 +
 +  protected Entity createEntity(boolean complex) {
      Entity entity = new EntityImpl();
      Property property = new PropertyImpl();
      property.setName("PropertyString");
@@@ -135,95 -112,15 +137,95 @@@
      propertyGuid.setName("PropertyGuid");
      propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
      entity.getProperties().add(propertyGuid);
 +
-     if(complex) {
++    if (complex) {
 +      entity.addProperty(createComplexProperty());
 +    }
 +
      return entity;
    }
  
 -  protected EntitySet createEntitySet() {
 +  protected Entity createEntityWithCollection(boolean complex) {
 +    Entity entity = new EntityImpl();
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    Property property = new PropertyImpl();
 +    property.setName("CollPropertyString");
 +    property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
 +    entity.getProperties().add(property);
 +    entity.getProperties().add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("CollPropertyGuid");
 +    propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(),
UUID.randomUUID()));
 +    entity.getProperties().add(propertyGuid);
 +
-     if(complex) {
++    if (complex) {
 +      entity.addProperty(createCollectionOfComplexProperty());
 +    }
 +
 +    return entity;
 +  }
 +
 +  protected Property createComplexProperty() {
 +    List<Property> properties = new ArrayList<Property>();
 +    Property property = new PropertyImpl();
 +    property.setName("PropertyString");
 +    property.setValue(ValueType.PRIMITIVE, "dummyValue");
 +    properties.add(property);
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    properties.add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("PropertyGuid");
 +    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties.add(propertyGuid);
 +
 +    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
-             properties);
++        properties);
 +  }
 +
 +  protected Property createCollectionOfComplexProperty() {
 +    List<Property> properties = new ArrayList<Property>();
 +    Property property = new PropertyImpl();
 +    property.setName("PropertyString");
 +    property.setValue(ValueType.PRIMITIVE, "dummyValue");
 +    properties.add(property);
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    properties.add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("PropertyGuid");
 +    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties.add(propertyGuid);
 +
 +    List<Property> properties2 = new ArrayList<Property>();
 +    Property property2 = new PropertyImpl();
 +    property2.setName("PropertyString");
 +    property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
 +    properties2.add(property2);
 +    Property property2Int = new PropertyImpl();
 +    property2Int.setName("PropertyInt16");
 +    property2Int.setValue(ValueType.PRIMITIVE, 44);
 +    properties2.add(property2Int);
 +    Property property2Guid = new PropertyImpl();
 +    property2Guid.setName("PropertyGuid");
 +    property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties2.add(property2Guid);
 +
 +    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
-             Arrays.asList(properties, properties2));
++        Arrays.asList(properties, properties2));
 +  }
 +
 +  protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
      EntitySet entitySet = new EntitySetImpl();
 -    entitySet.setCount(4242);
 -    entitySet.setNext(URI.create("nextLinkURI"));
 -    for (int i = 0; i < 1000; i++) {
 -      entitySet.getEntities().add(createEntity());
 +    int count = (int) ((Math.random() * 50) + 1);
 +    entitySet.setCount(count);
 +    entitySet.setNext(URI.create(baseUri + "nextLink"));
 +    for (int i = 0; i < count; i++) {
 +      entitySet.getEntities().add(createEntity(edmEntityType));
      }
      return entitySet;
    }


Mime
View raw message