Git Product home page Git Product logo

odata-example's Introduction

This is an example project that demonstrates the different capabilities in the SDL OData framework.

Starting the Service

There are several ways to start the OData Service, in this demo we have made this even easier by adding a demo class.

From Maven

It is quite easy to run the example service from the command line, the example utilises Spring-Boot which allows running the service using a single packed jar.

In order to run the example, in the cloned git repository execute the following maven command:

mvn -f example-service/pom.xml spring-boot:run

From Your favorite IDE

In order to execute the Example service in your IDE, please execute the following the Java Main method in class:

com.sdl.odata.example.service.ServiceContainer

Creating Example Content

The example service by default has only one Person in the dataset "Darkwing Duck", in order to add more example content in the service the following steps can be used. This also demonstrates how the OData service allows data creation.

In order to create some content the below sample content can be used to post data to the OData Service. Example command to create Mickey as a Person in the service, using a sample json file:

curl -i -X POST -d @src/samples/mickey.json http://localhost:8080/example.svc/Persons --header "Content-Type:application/json"

The content structure that is posted looks as follows:

{
    "@odata.context" : "http://localhost:8080/example.svc/$metadata#/Persons/$entity",  
    "@odata.id" : "/Persons(55)",  
    "id" : 55,  
    "firstName" : "Mickey",  
    "lastName" : "Mouse",  
    "age" : 83  
}

We also have two more Persons (Donald and Scrooge), which you can post as following:

curl -i -X POST -d @src/samples/donald.json http://localhost:8080/example.svc/Persons --header "Content-Type:application/json"
curl -i -X POST -d @src/samples/scrooge.json http://localhost:8080/example.svc/Persons --header "Content-Type:application/json"

odata-example's People

Contributors

oregu avatar renarj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odata-example's Issues

Create branch for 2.0.5-SNAPSHOT

I added support for $limit, $count and field projections in my fork, but changes are based on new code of sdl.odata:2.0.5-SNAPSHOT.

Please add branch for those changes, so I can push there, until official release.

Creating user defined function

Hi,
I am new to sdl and odata and i want to implement some user defined functions to perform some operations. Hence, can you please guide on how can i create it? Currently i have got this code and tweaked it with my local database. select and other operations are working fine but i am not able to understand how can i create the user defined functions and what all odata classes/libraries would be required for the same?

Thanks in advance!!

Does $select=* or $select=<entity-propertyName> to retrieve a subset feature implemented ?

Request URL : http://localhost:8080/myservice.svc/PersonNames?$select=last_name

Response

metadata:code1800/metadata:code
metadata:messageThis type of option is not supported for queries: SelectOption(List(PathSelectItem(None,TerminalPropertySelectPathSegment(last_name))))/metadata:message
/metadata:error

We need to use this feature . This is stopping us from using your framework. Please share your thoughts

Functions missing from metadata document?

Within the example, we have two classes registered in the data model(EntityServiceRegistar;49):
oDataEdmRegistry.registerClasses(Lists.newArrayList( Person.class, GetAverageAge.class ));

I expect a function to be present within the metadata document( in Schema SDL.OData.Example) like this:
<Function Name="GetAverageAge"> <ReturnType Type="Edm.Double"/> </Function>

Here is what I see: metadata.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.