Extension Model

Extension Model is used for the case that application users want to configure fields of their data online and get them working in UI form to CRUD without re-compilation and services restart. Generally, Extension Model in RapidWebDev supports the following features,
  • SAAS architect.
  • Metadata type inheritance.
  • 6 Dynamic field types are supported, Text, Integer, Decimal, Date Time, Enumeration and Hierarchy.
  • Dynamic data validation.
  • Linq2SQL Integration.
  • Fast write-read performance.
  • UI to configure metadata with fields.
  • ASP.NET web control to manipulate form into UI mapping to a metadata type.

Architect

The RapidWebDev extension model is coupling to Linq2SQL. When developers want to make a business data table be extensive, they have to add 2 extra columns into the business table as “ExtensionDataTypeId Guid” and “ExtensionData NVarChar (MAX)”. The Linq2SQL entity class should implement the interface IExtensionObject. We suggest that should inherit from the abstract class AbstractExtensionObject instead which has basic implementation already. And the Linq2SQL data context has to implement the class ExtensionDataContext which intercepts submit action for entities which implemented the interface IExtensionObject. The interception serializes dynamic properties of the entities to xml and sets xml to concrete property “ExtensionData”. Then the interceptor saves the entities into database by Linq2SQL data context.

When developers get extensive entities from database, the serialized xml from dynamic properties are retrieved back as string in the property “ExtensionData” of entities initially. The xml string is lazy de-serialized to dynamic property dictionary when developers first access dynamic properties through indexer.

This design makes write-read extensive entities in high performance. Developers don’t need to worry about the performance especially bulk getting the extensive entities and binding them to UI.


Metadata Data Model

In RapidWebDev Extension Model, there are 2 data tables to store metadata named ObjectMetadata and FieldMetadata with prefix “ext”. Object metadata stores object definition includes name, SAAS application isolation, inheritance and version. Field metadata stores field definitions of an object in object metadata includes field name, type, ordinal and validation metric. See the data model diagram as below.


Metadata API

The interface IMetadataApi contains all functionalities on managing metadata with field definition in RapidWebDev Extension Model. DLinqMetadataApi is the default implementation based on Linq2SQL. There are two critic interfaces related to IMetadataApi, they’re IObjectMetadata and IFieldMetadata.

The interface IObjectMetadata describes only information of the extension object definition but not includes any field definition. Developers need to resolve field metadata of an object metadata through IMetadataApi by object metadata ID.

The interface IFieldMetadata relates field definition. By now we have 6 supported field types which are String, Integer, Decimal, DateTime, Enumeration and Hierarchy. They maps to xml elements defined in the schema FieldMetadata.xsd. All field metadata has three common properties, Name, IsRequired and Ordinal. Besides, there are different properties for each type for data validation. They’re
  • String: MaxLength, MinLength, Default and Regex
  • DateTime: DefaultValue, MaxValue and MinValue.
  • Integer: MaxValue, MinValue and Default
  • Decimal: MaxValue, MinValue and Default
  • Enumeration: SelectionMode
  • Hierarchy: SelectionMode
Please refer to Unit Test cases on how to use metadata API in detail.

Metadata Management UI

Extension Model also provides mature metadata management UI. Users can define fields for special object metadata at runtime and they also can preview the dynamic data input form there.

The following path is the dynamic page configuration used to render metadata management UI. Users only need to pass different object metadata ID into the dynamic page as query string parameter “MetadataDataTypeId” to manage different object metadata.

\\Web\Spring\DynamicPage\ExtensionModel\ExtensionFieldMetadataManagement.dp.xml

Data Input Form Control

Extension Model provides ASP.NET web control “ExtensionDataForm” to render data input form for an extension object. Developers can use the control at anywhere of their detail panel template or ASP.NET page with setting an object metadata ID. Then at server side it’s quite easy to set extension object properties to UI or resolve extension object properties from UI input. Take following code snippet as an example.

<My:ExtensionDataForm ID="UserExtensionDataForm" runat="server" />

// When developers create a new user from client post, here set user extension properties from ExtensionDataForm.
// Developers don’t need to take care of what dynamic properties there are in this way.
UserObject userObject = new UserObject();
this.UserExtensionDataForm.SetObjectPropertiesFromControlValues(userObject);

Samples

See samples at test cases located in \\Tests\ExtensionModel\.

Last edited Dec 21, 2009 at 12:12 PM by eungeliu, version 2

Comments

No comments yet.