Skip to content

Instantly share code, notes, and snippets.

@ctkjose
Last active August 29, 2015 14:13
Show Gist options
  • Save ctkjose/67ab57176552cbcf6294 to your computer and use it in GitHub Desktop.
Save ctkjose/67ab57176552cbcf6294 to your computer and use it in GitHub Desktop.

Researching OData, and RDF like protocols

OData Microsoft, IBM, SAP, MongoDB

GData Google

RDF W3C

RDFa

http://en.wikipedia.org/wiki/RDFa

RDFa using JSON

https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-json/index.html

http://en.wikipedia.org/wiki/JSON-LD http://json-ld.org

JSON-ld

I realy like JSON-ld for web-services as described in this paper.

{
   "@context": {
      "foaf": "http://xmlns.com/foaf/0.1/", "title": "foaf:title",
      "name": "foaf:name",
      "homepage": {
         "@id": "foaf:workplaceHomepage", "@type": "@id"
      },
   },
   "@id": "http://me.markus-lanthaler.com",   //UID of entry
   "@type": "foaf:Person",                   //the type
   "name": "Markus Lanthaler",               //entry column
   "homepage": "http://www.tugraz.at/"       //entry column
   "title": [                                //entry column
      {"@value":"Dipl.Ing.", "@language":"de"},
      {"@value":"MSc", "@language": "en"} 
   ],
}

Same on the expanded form

   [
      { 
         "@id": "http://me.markus-lanthaler.com", 
         "@type":"http://xmlns.com/foaf/0.1/Person", 
      
         "http://xmlns.com/foaf/0.1/title": [
            {"@value":"Dipl.Ing.", "@language":"de"},
            {"@value":"MSc", "@language": "en"} 
         ],
         "http://xmlns.com/foaf/0.1/name": [ "Markus Lanthaler" ],
         "http://xmlns.com/foaf/0.1/workplaceHomepage": [ { "@id": "http://www.tugraz.at/" } ] 
      }
   ]

OData using JSON format

http://www.odata.org/documentation/odata-version-2-0/json-format/ http://blogs.msdn.com/b/leohu/archive/2013/10/05/odata-and-json-payload-examples.aspx https://github.com/MSOpenTech/odataphpprod https://github.com/Contatta/odataphpprod https://github.com/POData/POData

Generate emx files or a php connector to a mysql db with:

http://odatamysqlphpconnect.codeplex.com https://msdn.microsoft.com/en-us/library/cc982042.aspx

http://sourceforge.net/projects/mysqlodata/

Service document example

{ "d" : { "EntitySets": ["Products", "Categories", "Suppliers"] } }

Collections represent a set of Entries.

Representing Entries

Read an EntitySet

{
   "odata.metadata":"http://services.odata.org/V3/OData/OData.svc/$metadata#Products",
   "value":[
      {
         "ID":0,
         "Name":"Bread",
         "Description":"Whole grain bread",
         "ReleaseDate":"1992-01-01T00:00:00",
         "DiscontinuedDate":null,
         "Rating":4,
         "Price":"2.5"
      },
      {
         "ID":1,
         "Name":"Milk",
         "Description":"Low fat milk",
         "ReleaseDate":"1995-10-01T00:00:00",
         "DiscontinuedDate":null,
         "Rating":3,
         "Price":"3.5"
      },
      {
         "ID":2,
         "Name":"Vint soda",
         "Description":"Americana Variety - Mix of 6 flavors",
         "ReleaseDate":"2000-10-01T00:00:00",
         "DiscontinuedDate":null,
         "Rating":3,
         "Price":"20.9"
      }
    ] //end of values array
  }

Read an Entity

Similar to an EntitySet but metadata is part of the block

{
   "odata.metadata":"http://services.odata.org/V3/OData/OData.svc/$metadata#Products/@Element",
   "ID":2,
   "Name":"Vint soda",
   "Description":"Americana Variety - Mix of 6 flavors",
   "ReleaseDate":"2000-10-01T00:00:00",
   "DiscontinuedDate":null,
   "Rating":3,
   "Price":"20.9"
}

Read Property

{
   "odata.metadata":"http://services.odata.org/V3/OData/OData.svc/$metadata#Edm.String",
   "value":"Americana Variety - Mix of 6 flavors"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment