Jump to: navigation, search

Difference between revisions of "UBIK Actions"


(Created page with "{{UBIK}} Actions provide the possibility to configure a programmatic method to perform for a {{UBIK}} object. = Purpose = In some cases it is required to define a range of a...")
(No difference)

Revision as of 21:23, 11 December 2023

UBIK® Actions provide the possibility to configure a programmatic method to perform for a UBIK® object.

Purpose

In some cases it is required to define a range of actions to be available for a UBIK® MetaClass or instance. For example, if the user should be provided with a custom selection of actions to perform for an object. UBIK® Actions are the representation of such an executable action, and they can be put into relation to a MetaClass, so that one can evaluate a list of eligible actions for any MetaClass. In earlier UBIK® versions, Workflows were used for this purpose. However, since UBIK® version 4, Microsoft WF workflows have fallen increasingly out of favor because support for WF Workflows was abandoned in Microsoft's netstandard framework, which UBIK® relies on. Thus, UBIK® Actions can be seen as the designated replacement for WF Workflows in UBIK®.

E-R Model

The core of UBIK® Actions consists of a C# interface and a relationship between MetaClasses and Actions. Additionally, there are several convenience utilities to accommodate the definition and configuration of Actions.

IUBIKAction Interface and SYSREL_METACLASS_ACTION Relationship

The IUBIKAction interface guarantees the following methods:

namespace UBIK.Kernel
{
    public interface IUBIKAction
    {
        bool IsApplicable(BaseClass obj);
        void Perform(BaseClass obj);
    }
}

Further, the UBIK® Relationship SYSREL_METACLASS_ACTION is used to relate MetaClasses to any UBIK® object implementing that interface.

SYSCLS_ACTION Classification and ACTION MetaClass

To add the IUBIKAction C# interface to the custom code of a UBIK® MetaClass, the classification SYSCLS_ACTION can be assigned to a MetaClass that should define Actions. The ACTION MetaClass has this classification by default and provides a basic implementation for the configuration of a target method. Similar to the obsolete Workflow MetaClass, it provides Boolean properties to flag an Action either for instances or MetaClasses. Also, it has two string properties for the identification of a target method and the class it is defined in:

ACTION properties
Property name Data type Meaning
RUNONINSTANCE Boolean Whether this Action should be performed on instances of related MetaClasses
RUNONMETACLASS Boolean Whether this Action should be performed on related MetaClasses themselves
METHODNAME String The name of the method to perform with this Action
METHODOWNER String The full type name (with namespace in the form of com.example.TypeName) providing the method to perform with this Action

Restrictions for the target class and method The UBIK® object to perform this action for must be specified for the target class and method, and the target class and method must be accessible. This means both the class and the method must be public. Also, either the method or the class constructor must take a BaseClass as a parameter. Static methods and classes are also supported. In case of a non-static method, the owning class must have a public constructor without parameters or with a single BaseClass parameter. The DLL containing the target method (UBIK® custom code is also supported) must be available to UBIK®, for example in the Injection folder.

Triggering UBIK® Actions

UBIK® Actions are available in some of our products' UI, for example in the MaTaP AdminTool's context menu for project instances. However, they can also be accessed programmatically, for example with the following snippet executing all actions for an instance:

public void PerformAllRelevantActions(BaseClass instance)
{
    MetaClass mc = instance.MetaClass;
    UBIKClassList<RelationalObject> actions = mc.RelatesTo(mc.Environment.GetSystemRelation(SystemObjects.SYSREL_METACLASS_ACTION));
    foreach (RelationalObject ro in actions)
    {
        IUBIKAction action = ro as IUBIKAction;
        if (action != null && action.IsApplicable(instance))
        {
            action.Perform(instance);
        }
    }
}