Skip to Content
0
Jul 22, 2016 at 03:39 PM

XS OData Services based on XSDS managed entities

158 Views

Hi,

I wonder if it is possible, to build XS OData Services based on XSDS (XS Data Services) managed entities.

asume a CDS entity named post is defined at .hdbdd file.

CDS

entity post {

key pid: Integer not null;

Title: String(63) not null;

Text: text;

Author: association [1] to user;

Parent: association [0..1] to post;

Rating: Integer;

Created: UTCDateTime;

//Comments: association [0..*] to comment via backlink Parent; //One-to-Many Associations via backlink

//Tags: association [0..*] to ds_comments via entity tags_by_post; //Many-to-Many Associations via entity

Replies: Association[*] to post on Replies.Parent.pid = pid; //Unmanaged Associations (can be defined at XSDS too)

};

XSDS

As One-to-Many Associations via backlink and Many-to-Many Associations via entity are not supported yet at cds, these Associations are defined using XSDS.

var Post = XSDS.$importEntity("sap.hana.democontent.xsds", "bboard.post", {

//One-to-Many Associations

Comments: {

$association: {

$entity: "sap.hana.democontent.xsds::bboard.comment",

$viaBacklink: "Parent"

}

},

// Many-to-Many Associations

Tags: {

$association: {

$entity: "sap.hana.democontent.xsds::bboard.tag",

$viaEntity: "sap.hana.democontent.xsds::bboard.tags_by_post",

$source: "post",

$target: "tag",

}

},

XSOData

so is it possible to create an XS OData service which is based on Post managed entity and inherits all the associations and metadata defined at cds and xsds level?

Kind regards

Rouzbeh