Difference between revisions of "HowTo:Provide system definitions with a custom plugin"
m |
m (→Prerequisites) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | |||
+ | |||
This tutorial explains how to provide any kind of preconfigured {{UBIK}} data (system definitions) using a custom plugin. | This tutorial explains how to provide any kind of preconfigured {{UBIK}} data (system definitions) using a custom plugin. | ||
+ | |||
+ | == General concept == | ||
+ | |||
+ | When rolling out a {{UBIK}} customizing into a (productive) environment, there is always the challenge regarding the transportation of the data model and basic data. | ||
+ | The sustainable solution is to deliver versioned packages of system definitions in plugins, because that allows for easy deployment and upgrade, and for the direct application of state-of-the-art software development strategies for plugin development. | ||
+ | |||
+ | {{UBIK}} plugins are detected when an Environment is initialized, and the user is prompted with a database upgrade if necessary. The technical maintenance of the database is automatic and allows for arbitrary adaptations. | ||
+ | The plugin developer can decide whether to make meta definitions immutable or further customizable by the user. Custom scripts can be executed everytime the Environment is connected or just during an upgrade. | ||
+ | |||
+ | == Prerequisites == | ||
+ | |||
+ | To understand the code, knowledge about the {{UBIK}} ER-model and the plugin injection mechanism is required. | ||
+ | |||
+ | [[Category:How-To|Provide system definitions with a custom plugin]] | ||
+ | [[Category:Module|Provide system definitions with a custom plugin]] | ||
+ | |||
+ | == Instructions == | ||
<!-- DO NOT REMOVE THIS -->{{Template:HowTo/Begin}}<!-- DO NOT REMOVE THIS --> | <!-- DO NOT REMOVE THIS -->{{Template:HowTo/Begin}}<!-- DO NOT REMOVE THIS --> | ||
Line 7: | Line 26: | ||
The Plugin hosts a SystemDefinitionProvider, which in turn gives access to a set of versioned SystemDefinitions. The latter can contain any kind of {{UBIK}} data like MetaClasses, MetaProperties, instances of any type and scripts to execute when the package is installed or initialized. | The Plugin hosts a SystemDefinitionProvider, which in turn gives access to a set of versioned SystemDefinitions. The latter can contain any kind of {{UBIK}} data like MetaClasses, MetaProperties, instances of any type and scripts to execute when the package is installed or initialized. | ||
− | [[File: | + | [[File:Systemdefinitions2.drawio.png]] |
= Create a new plugin = | = Create a new plugin = | ||
Line 249: | Line 268: | ||
set | set | ||
{ | { | ||
− | + | // do nothing | |
} | } | ||
} | } | ||
Line 280: | Line 299: | ||
public const string NS_MY_PLUGIN = "System.MyPlugin; | public const string NS_MY_PLUGIN = "System.MyPlugin; | ||
− | public static Guid PROPERTY_UID_MYPROPERTY = Guid.Parse("d90b50e0-17d9-40ac-b89d-18f4a01cd5cb"); | + | public static readonly Guid PROPERTY_UID_MYPROPERTY = Guid.Parse("d90b50e0-17d9-40ac-b89d-18f4a01cd5cb"); |
public const string PROPERTY_NAME_MYPROPERTY = "LK_LOCATION"; | public const string PROPERTY_NAME_MYPROPERTY = "LK_LOCATION"; | ||
Line 384: | Line 403: | ||
set | set | ||
{ | { | ||
− | + | // do nothing | |
} | } | ||
} | } | ||
Line 536: | Line 555: | ||
#endregion Version | #endregion Version | ||
− | + | ||
// ... | // ... | ||
Line 550: | Line 569: | ||
#endregion System Meta Classes | #endregion System Meta Classes | ||
+ | |||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
+ | = Create a new MetaProxy = | ||
+ | |||
+ | MetaProxies are managed very similarly to MetaClasses, but the MetaProxyProperties are slightly more complex because they require additional information like the UIDs for the import and export versions of itself, the target property in {{UBIK}}, etc. | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
+ | <div style="font-weight:bold;line-height:1.6;">SystemDesignMetaProxy template code</div> | ||
+ | <div class="mw-collapsible-content"> | ||
+ | <syntaxhighlight lang="csharp"> | ||
+ | namespace UBIK.MyPlugin | ||
+ | { | ||
+ | public class MyProxyMetaClass : SystemDesignMetaProxy | ||
+ | { | ||
+ | public static Guid UID = GuidUtility.MY_PROXY; | ||
+ | private const string NAME = "MYPROXY"; | ||
+ | private const string NAMESPACE = "System.MyPlugin"; | ||
+ | private const string DESCRIPTION = "My meta proxy"; | ||
+ | |||
+ | public MyProxyMetaClass(UBIKEnvironment environment) | ||
+ | { | ||
+ | InitUidAndEnvironment(UID, environment); | ||
+ | InitStrings(NAME, NAMESPACE, DESCRIPTION); | ||
+ | |||
+ | SetModuleId(MyPlugin.ID); | ||
+ | |||
+ | List<Guid> metaProperties = new List<Guid>(); | ||
+ | // regular meta properties | ||
+ | DefineMetaProperties(metaProperties); | ||
+ | |||
+ | List<MetaProxyPropertyInfo> metaProxyPropertyInfos = new List<MetaProxyPropertyInfo>(); | ||
+ | metaProxyPropertyInfos.Add(new MetaProxyPropertyInfo(environment, MyProxyMetaProperties.PROXY_PROPERTY_UID_MYPROPERTY, true, -1, ProxyUpdateModes.BiDirectional, MyMetaProperties.PROPERTY_UID_MYPROPERTY, "My property")); | ||
+ | |||
+ | DefineMetaProxyProperties(metaProxyPropertyInfos); | ||
+ | } | ||
+ | |||
+ | public override MetaClass MetaClass | ||
+ | { | ||
+ | get | ||
+ | { | ||
+ | return this.Environment.GetSystemMetaClass(SystemObjects.METAPROXY); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | public override MetaClass Inheritance | ||
+ | { | ||
+ | get | ||
+ | { | ||
+ | return this.Environment.GetSystemMetaClass(SystemObjects.PROXY_ROOT); | ||
+ | } | ||
+ | set | ||
+ | { | ||
+ | // do nothing | ||
+ | } | ||
+ | } | ||
+ | |||
+ | public override MetaClassTypes ClassType | ||
+ | { | ||
+ | get | ||
+ | { | ||
+ | return MetaClassTypes.Proxy; | ||
+ | } | ||
+ | set | ||
+ | { | ||
+ | // do nothing | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
+ | <div style="font-weight:bold;line-height:1.6;">SystemDesignMetaProxyProperty template code</div> | ||
+ | <div class="mw-collapsible-content"> | ||
+ | <syntaxhighlight lang="csharp"> | ||
+ | namespace UBIK.MyPlugin | ||
+ | { | ||
+ | public class MyMetaProxyProperties | ||
+ | { | ||
+ | public const string NS_MY_PLUGIN = "System.MyPlugin"; | ||
+ | public const int STR_LEN_MED = 255; | ||
+ | |||
+ | public static UBIKClassList<MetaProperty> DefineSystemMetaProperties(UBIKEnvironment environment) | ||
+ | { | ||
+ | UBIKClassList<MetaProperty> metaProperties = new UBIKClassList<MetaProperty>(); | ||
+ | |||
+ | SystemDesignMetaProxyProperty myMetaProxyProperty = new SystemDesignMetaProxyProperty(environment, | ||
+ | GuidUtility.MPP_MYPROPERTY, // assuming the ids are documented in a class GuidUtility | ||
+ | MyMetaProperties.PROPERTY_NAME_MYPROPERTY, | ||
+ | NAMESPACE, | ||
+ | PropertyTypes.String, | ||
+ | GuidUtility.MPP_MYPROPERTY_VIRTUAL_PROPERTIES[0], | ||
+ | GuidUtility.MPP_MYPROPERTY_VIRTUAL_PROPERTIES[1]); | ||
+ | myMetaProxyProperty.MetaAttribute = environment.GetSystemMetaClass(SystemObjects.PROXYATTRIBUTE); | ||
+ | myMetaProxyProperty.SetStringLen(STR_LEN_MED); | ||
+ | proxyProperties.Add(myMetaProxyProperty); | ||
+ | |||
+ | return metaProperties; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
+ | <div style="font-weight:bold;line-height:1.6;">SystemDefinitions adaptations</div> | ||
+ | <div class="mw-collapsible-content"> | ||
+ | <syntaxhighlight lang="csharp"> | ||
+ | namespace UBIK.MyPlugin | ||
+ | { | ||
+ | public class MySystemDefinitions_V100 : SystemDefinitionsBase | ||
+ | { | ||
+ | // ... | ||
+ | |||
+ | #region System Meta Classes | ||
+ | |||
+ | public override UBIKClassList<MetaClass> DefineSystemMetaClasses(UBIKEnvironment environment) | ||
+ | { | ||
+ | UBIKClassList<MetaClass> metaClasses = new UBIKClassList<MetaClass>(); | ||
+ | |||
+ | MyProxyMetaClass myBaseClass = new MyProxyMetaClass(environment); | ||
+ | metaClasses.Add(myBaseClass); | ||
+ | |||
+ | return metaClasses; | ||
+ | } | ||
+ | |||
+ | #endregion System Meta Classes | ||
+ | |||
+ | #region System Meta Properties | ||
+ | |||
+ | public override UBIKClassList<MetaProperty> DefineSystemMetaProperties(UBIKEnvironment environment) | ||
+ | { | ||
+ | UBIKClassList<MetaProperty> result = new UBIKClassList<MetaProperty>(); | ||
+ | result.AddRangeUnique(MyMetaProxyProperties.DefineSystemMetaProperties(environment)); | ||
+ | return result; | ||
+ | } | ||
+ | |||
+ | #endregion System Meta Properties | ||
// ... | // ... | ||
Line 562: | Line 725: | ||
* [[HowTo:Create_UBIK_Module|Create your own module]] | * [[HowTo:Create_UBIK_Module|Create your own module]] | ||
+ | |||
+ | [[Category:How-To]] | ||
+ | [[Category:Module]] | ||
[[Category:How-To|Provide system definitions with a custom plugin]] | [[Category:How-To|Provide system definitions with a custom plugin]] | ||
[[Category:Module|Provide system definitions with a custom plugin]] | [[Category:Module|Provide system definitions with a custom plugin]] |
Latest revision as of 15:12, 25 November 2024
This tutorial explains how to provide any kind of preconfigured UBIK® data (system definitions) using a custom plugin.
General concept
When rolling out a UBIK® customizing into a (productive) environment, there is always the challenge regarding the transportation of the data model and basic data. The sustainable solution is to deliver versioned packages of system definitions in plugins, because that allows for easy deployment and upgrade, and for the direct application of state-of-the-art software development strategies for plugin development.
UBIK® plugins are detected when an Environment is initialized, and the user is prompted with a database upgrade if necessary. The technical maintenance of the database is automatic and allows for arbitrary adaptations. The plugin developer can decide whether to make meta definitions immutable or further customizable by the user. Custom scripts can be executed everytime the Environment is connected or just during an upgrade.
Prerequisites
To understand the code, knowledge about the UBIK® ER-model and the plugin injection mechanism is required.