Modifying links to DataMiner objects
In a custom operator, you can modify the metadata that links DataMiner objects to a row. This metadata allows you to feed the objects in Dashboards and Low-Code Apps to other components.
To add, remove, or modify a DataMiner object link, use the Metadata property of the editable row.
Example
The following custom operator links GQI rows to DataMiner views based on a column that contains the view ID.
using Skyline.DataMiner.Analytics.GenericInterface;
using Skyline.DataMiner.Net;
[GQIMetaData(Name = "Link to view")]
public sealed class LinkToViewOperator : IGQIRowOperator, IGQIInputArguments
{
private readonly GQIColumnDropdownArgument _viewIDColumnArgument;
private GQIColumn<int> _viewIDColumn;
public LinkToViewOperator()
{
_viewIDColumnArgument = new GQIColumnDropdownArgument("View id column")
{
IsRequired = true,
Types = new[] { GQIColumnType.Int },
};
}
public GQIArgument[] GetInputArguments() => new[] { _viewIDColumnArgument };
public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
{
_viewIDColumn = (GQIColumn<int>)args.GetArgumentValue(_viewIDColumnArgument);
return default;
}
public void HandleRow(GQIEditableRow row)
{
// Retrieve the view id from this row
if (!row.TryGetValue(_viewIDColumn, out int viewID))
return;
// Wrap it in a ViewID object ref
var objectRef = new ViewID(viewID);
// Create a new metadata instance for the object
var objectRefMetadata = new ObjectRefMetadata { Object = objectRef };
// Link it to the row
row.Metadata = new GenIfRowMetadata(new[] { objectRefMetadata });
}
}
Caution
Although it is technically possible to modify the existing metadata instances, this can in some cases lead to undefined behavior and is therefore strongly discouraged.
If you need to modify existing links, you should create new instances and treat the existing instance as immutable.