The Campus Nexus Student Metadata OData feed and how to extend it using a custom Data Annotator

Upon starting Campus Nexus Student the UI (user interface) will make a call to an OData feed that provides it with information about tables, fields, objects and navigational structures.

The feed is located at:

http://[Server]/Cmc.Nexus.Web/ds/campusnexus/$metadata

The OData feed has a structure that is similar to one shown below:

The details included in this OData feed are extracted directly from the generated models in the solution.

For example, a partial section of the metadata for the EntityType “StudentCourseStatusChange” is as follows:

The values shown above are generated directly from the values in the data model shown below:

As you can see from the generated model in Cmc.Nexus.Models.Academics.StudentCourseStatusChange, the attributes and properties of the fields in this model are automatically used to create the Odata feed.

The job of creating the metadeta, is performed by the Cmc.Core.Models.ModelAnnotator which simply takes advantage and extends the capabilities built into:

– System.Web.OData.Builder.ODataConventionModelBuilder
– Microsoft.Odata.Edm.IEdmModel

Now, how do we add additional custom properties to the Odata feed that may be data-driven?

In order to provide this capability, we have created the capability to create a “inject” a custom ODataAnnotator instance into the Cmc.Core.Models.ModelAnnotator.

When the ModelAnnotator finds an instance of a custom ODataAnnotator is available, it will proceed to insert the logic of that custom annotator into the process of creating the OData feed.

In Campus Nexus, we have created a custom Data Annotator that takes advantage of this capability. It will insert the value of [ cmcedm:RequiredSystems=”ui” ] for all XML Elements in the feed that have been configured on the “syDictionary” to have a value of [UiRequired = 1]

To test this capability, you simply follow these steps:

1)  Open the SQL table “syDictionary”
2)  Find a record in this table that matches a table + field in the the OData feed
3)  Update the field “UiRequired” for that table + field
* The “UiRequired” field is a boolean. Simply change its value to 1

Once this is completed, restart the Campus Nexus Solution. You will notice that the XML Element in the OData feed that relates to the Table + Field which you selected are now showing the following value:

 

Leave a Reply

Skip to toolbar