Search code examples
odatasapui5

How map authorizations (and other sub-infos) in oData structure


This is the base schema of oData EDM: enter image description here thanks for the image Filippo

I have my db structure:

Product (Code, Description, IVA, Price)
|n
|
|
|
|1
Purchase(ID, Product, Customer)

I want expose my data using oData; I can map in a natural way Product and Purchase in two EntitySet: ProductSet and PurchaseSet.

If I require for example all items of ProductSet I receive a collection of 100 products; each product have 4 properties, for example:

{
   Code:01, 
   Description: "blue pen", 
   IVA: "19", 
   Price: "2.99"
}

Ok but based on the user logged, the business logic before oData want send me more information (for example the editable sub property):

{
   Code: {value:01, editable:false}, 
   Description: {value:"blue pen", editable:false}, 
   IVA: {value:19, editable:true}, 
   Price: {value:"2.99", editable:true}
}

(I can't sent the new information in this mode, I have only entity sets and properties...)

What is the right way to map editable infos in EDM? A New Property??


Solution

  • You can achieve this by creating a ComplexType that will have the properties of value and editable. So the properties of your Entity will refer to the ComplexType.