Difference between revisions of "HowTo:Provide system definitions with a custom plugin"
m (→Prerequisites) |
|||
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. | ||
Line 14: | Line 12: | ||
To understand the code, knowledge about the {{UBIK}} ER-model and the plugin injection mechanism is required. | To understand the code, knowledge about the {{UBIK}} ER-model and the plugin injection mechanism is required. | ||
− | |||
− | |||
− | |||
== Instructions == | == Instructions == | ||
Line 719: | Line 714: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</div></div> | </div></div> | ||
+ | |||
+ | = Create a system classification = | ||
+ | |||
+ | Here's an example for the definition of a system classification. | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
+ | <div style="font-weight:bold;line-height:1.6;">SystemClassification template code</div> | ||
+ | <div class="mw-collapsible-content"> | ||
+ | <syntaxhighlight lang="csharp"> | ||
+ | namespace UBIK.MyPlugin | ||
+ | { | ||
+ | public class MyClassification : SystemClassification | ||
+ | { | ||
+ | public static Guid GUID = new Guid("aa9cc5cb-f676-4b60-b39d-eab7a8bcc66e"); | ||
+ | |||
+ | public MyClassification(UBIKEnvironment environment) | ||
+ | : base(GUID, environment) | ||
+ | { | ||
+ | this.CodedName = "MYCLS"; | ||
+ | this.CodedNamespace = "System.MyPlugin"; | ||
+ | this.CodedDescription = "My classification"; | ||
+ | |||
+ | // Derives from SystemDesignMetaClass, see above for metaproperty definition | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </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 Classifications | ||
+ | |||
+ | public override UBIKClassList<MetaClass> DefineSystemClassifications(UBIKEnvironment environment) | ||
+ | { | ||
+ | return new UBIKClassList<MetaClass>() | ||
+ | { | ||
+ | new MyClassification(environment) | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | #endregion System Classifications | ||
+ | |||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
+ | = Create a system SelectiveList = | ||
+ | |||
+ | Here's an example for the definition of a system selective list. | ||
+ | |||
+ | <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 Selective Lists | ||
+ | |||
+ | public override UBIKClassList<SelectiveList> DefineSystemSelectiveLists(UBIKEnvironment environment) | ||
+ | { | ||
+ | UBIKClassList<SelectiveList> selectiveLists = new UBIKClassList<SelectiveList>(); | ||
+ | |||
+ | SystemSelectiveList fromEnum = new SystemSelectiveList(environment, typeof(MyEnumType)); // MyEnumType should be an integer enum | ||
+ | fromEnum.SetUID(GuidUtility.SLFROMENUM); | ||
+ | selectiveLists.Add(fromEnum); | ||
+ | |||
+ | SystemSelectiveList customList = new SystemSelectiveList(environment); | ||
+ | customList.SetItemValueType(PropertyTypes.String); | ||
+ | customList.AddSelectiveItem("any object of supported type", "description"); | ||
+ | customList.Name = "SL_STR"; | ||
+ | customList.SetUID(GuidUtility.SLSTR); | ||
+ | selectiveLists.Add(customList); | ||
+ | |||
+ | return selectiveLists; | ||
+ | } | ||
+ | |||
+ | #endregion System Selective Lists | ||
+ | |||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
+ | = Perform pre- or postprocessing scripts = | ||
+ | |||
+ | In some cases, one has to perform an action before the database is adjusted, or postprocess the upgrade. | ||
+ | It is also possible to execute code whenever the environment is initialized, even if no upgrade was necessary. | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;"> | ||
+ | <div style="font-weight:bold;line-height:1.6;">Scripting template code</div> | ||
+ | <div class="mw-collapsible-content"> | ||
+ | <syntaxhighlight lang="csharp"> | ||
+ | namespace UBIK.MyPlugin | ||
+ | { | ||
+ | public class MySystemDefinitions_V100 : SystemDefinitionsBase | ||
+ | { | ||
+ | // ... | ||
+ | |||
+ | public override void PreProcessDatabaseUpdate(Version previousVersion, UBIKEnvironment environment) | ||
+ | { | ||
+ | base.PreProcessDatabaseUpdate(previousVersion, environment); | ||
+ | |||
+ | // This code will be executed whenever the system is upgraded, | ||
+ | // before a schema upgrade for this SystemDefinitions package | ||
+ | } | ||
+ | |||
+ | public override void PostProcessDatabaseUpdate(Version previousVersion, UBIKEnvironment environment) | ||
+ | { | ||
+ | base.PostProcessDatabaseUpdate(previousVersion, environment); | ||
+ | |||
+ | // This code will be executed whenever the system is upgraded, | ||
+ | // after a schema upgrade and before content initialization and upgrade | ||
+ | // for this SystemDefinitions package | ||
+ | } | ||
+ | |||
+ | public override void InitializeSystemContent(UBIKEnvironment env) | ||
+ | { | ||
+ | base.InitializeSystemContent(env); | ||
+ | |||
+ | // This code will be executed whenever the system is initialized, | ||
+ | // after an optional schema upgrade and before an optional content adaptation | ||
+ | // for this SystemDefinitions package | ||
+ | } | ||
+ | |||
+ | public override void UpdateSystemContent(UBIKEnvironment env) | ||
+ | { | ||
+ | base.UpdateSystemContent(env); | ||
+ | |||
+ | // This code will be executed whenever the system is upgraded, | ||
+ | // after all other steps for this SystemDefinitions package | ||
+ | } | ||
+ | |||
+ | // ... | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | </div></div> | ||
+ | |||
<!-- DO NOT REMOVE THIS -->{{Template:HowTo/End}}<!-- DO NOT REMOVE THIS --> | <!-- DO NOT REMOVE THIS -->{{Template:HowTo/End}}<!-- DO NOT REMOVE THIS --> | ||
Line 725: | Line 874: | ||
* [[HowTo:Create_UBIK_Module|Create your own module]] | * [[HowTo:Create_UBIK_Module|Create your own 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]] |
Revision as of 14:32, 26 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.