Skip to content

Metadata APIs

Common usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Get the in-memory representation represented by a CSDL document
CsdlDocument csdldoc = demoService.getMetadata();
EntityTypeMap typeMap = csdldoc.getEntityTypes();
EntityType productType = typeMap.get("ODataAPI.Event");

//Refresh metadata by getting it again from backend URL
//demoService.refreshMetadata();

//Get entity sets available in DemoService
EntitySetMap esm = csdldoc.getEntitySets();
//["ODataDemo.DemoService/Categories","ODataDemo.DemoService/Products","ODataDemo.DemoService/Suppliers"]
//Returns fully qualified names of entity sets <name space>.<container name>/<entity set name>
StringList entitySets = esm.keys();

//Get fully qualified name of entity container
EntityContainerMap ecm = csdldoc.getEntityContainers();
EntityContainer container = ecm.get("ODataDemo.DemoService");

//Get a specific entity set 
EntitySet products = csdldoc.getEntitySet("Products");

//Get a specific entity set using qualified name
products = csdldoc.getEntitySet("DemoService.Products");
//OR
products = csdldoc.getEntitySet("ODataDemo.DemoService/Products");

//Get entity set via DemoService which will delegate to the in-memory metadata representation
EntitySet products2 = demoService.getEntitySet("Products");
products2 = demoService.getEntitySet("DemoService.Products");

//check if entity set was added since metadata was originally loaded
boolean isNew = products.isExtension();

EntityType productDetail = csdldoc.getEntityType("ODataDemo.Product");
//get entity types defined in a demoService
EntityTypeMap etm   = csdldoc.getEntityTypes();
StringList entityTypes = etm.keys();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Get the in-memory representation represented by a CSDL document
val csdldoc = demoService.metadata
val typeMap = csdldoc.entityTypes
val productType = typeMap.get("ODataAPI.Event")

//Refresh metadata by getting it again from backend URL
//demoService.refreshMetadata()

//Get entity sets available in DemoService
val esm = csdldoc.entitySets
//["ODataDemo.DemoService/Categories","ODataDemo.DemoService/Products","ODataDemo.DemoService/Suppliers"]
//Returns fully qualified names of entity sets <name space>.<container name>/<entity set name>
val entitySets = esm.keys()

//Get fully qualified name of entity container
val ecm = csdldoc.entityContainers
val container = ecm.get("ODataDemo.DemoService")

//Get a specific entity set 
val products = csdldoc.getEntitySet("Products")

//Get a specific entity set using qualified name
val products = csdldoc.getEntitySet("DemoService.Products")
//OR
val products = csdldoc.getEntitySet("ODataDemo.DemoService/Products")

//Get entity set via DemoService which will delegate to the in-memory metadata representation
val products2 = demoService.getEntitySet("Products")
products2 = demoService.getEntitySet("DemoService.Products")

//check if entity set was added since metadata was originally loaded
val isNew = products.isExtension

val productDetail = csdldoc.getEntityType("ODataDemo.Product")
//get entity types defined in a demoService
val etm = csdldoc.entityTypes
val entityTypes = etm.keys()