A ShapeProcessingStep that copies data from an IModelItem's tag to the VSDX shape data section.
Remarks
Users have to define an object that maps properties that are stored in the item's tag to the corresponding names of the Property object. It is also possible to use wildcards to automatically copy multiple tag entries.
Example 1:
Given the following tag:
node.tag = {
data: {
firstname: 'Amy',
lastname: 'Kain',
},
}
The user can automatically map both properties using a wildcard nameMap:
{
"data.": ""
}
This processing step will then create two properties: one with 'firstname' as name and 'Amy' as Property.value and one with 'lastname' as name and 'Kain' as value.
Example 2:
Given this tag
node.tag = {
firstname: {
label: 'First Name',
value: 'Amy',
prompt: 'The first name.',
},
}
And this nameMap
{
"firstname": "FirstName"
}
The processing step will create one property with name 'FirstName', Property.label 'First Name', Property.value 'Amy', and Property.prompt 'The first name'.
Example 3:
It is also possible to map property keys that differ from the VSDX cell names
node.tag = {
firstNameLabel: 'First Name',
firstNameValue: 'Amy',
}
Using a nameMap like this:
{
firstNameLabel: "firstname.label"
firstNameValue: "firstname.value"
}
The processing step will now create a property with 'firstname' as name, 'First Name' as Property.label, and 'Amy' as Property.value.
All created properties can be customized further through the callback passed to the constructor.
Example 4:
For generating complex data labels (e.g. containing spaces), a callback function can be used to set the Property.label on the property. This is required, because the ShapeDataProcessingStep only sets the Property.name, which must not contain special characters such as spaces. The VSDX Export will replace special characters in properties like Property.name during the serialization.
node.tag = {
someProperty: 'Some Value',
}
new ShapeDataProcessingStep(
(_, item) => INode.isInstance(item),
{
someProperty: 'Some Property',
},
(property, value, tag) => {
if (!property.label) {
property.label = property.name
}
},
)
This processing step has to be registered to the list of IShapeProcessingSteps of the VsdxExportConfiguration.
Members
Constructors
Initializes a new instance of the ShapeDataProcessingStep class.
Initializes a new instance of the ShapeDataProcessingStep class.
Parameters
- predicate: any
- nameMap: " class="api-link-external" target="_blank">Label" | string>
- callback?: any
A callback function that will be called once for each created property. It gets passed the property, the corresponding entry of the item's tag and the entire tag.
Methods
Defined in
ShapeProcessingStepBase.clearParameters
- shape: Shape
The shape representing the edge.
- sourceConnection: Connection
The source connection representing the source port.
- targetConnection: Connection
The target connection representing the target port.
- edge: IEdge
The edge this shape represents.
- context: ShapeProcessingContext
Overrides
ShapeProcessingStepBase.edgeParameters
- shape: Shape
The shape representing the label.
- ownerShape: Shape
The shape representing the label's owner. In case the owner is a node, this is the container shape of the node.
- label: ILabel
The label this shape represents
- context: ShapeProcessingContext
Overrides
ShapeProcessingStepBase.labelThis method may now set or modify any values of the shape.
Parameters
- shape: Shape
The shape representing the visual appearance of the node.
- containerShape: GroupShape
The shape containing all shapes belonging to this node, including shapes for labels, ports and the shape passed as first argument.
- node: INode
The node this shape represents.
- context: ShapeProcessingContext
Overrides
ShapeProcessingStepBase.nodeSee node.
See node.
Parameters
- shape: Shape
The shape representing the port.
- ownerShape: GroupShape
The shape representing the port's owner. In case the owner is a node, this is the container shape of the node.
- port: IPort
The port this shape represents.
- context: ShapeProcessingContext