Parameter is an well-established functionality in SystemWeaver that enables Architects to parameterize configurable views (i.e., graph, grid, chart and report) so that a certain view can work for different items. In addition to being able to use Parameters with items, it is also possible to use it with string, integer and boolean data types. This article provides examples of how to use Parameters with these types.
Prerequisites
- Familiar with the SystemWeaver meta model building blocks (e.g., Items, Parts and Attributes)
- An installation of the SystemWeaver Explorer client (swExplorer)
- Knowledge of XML
- Assignment of the SW Architect role in the server
- Completed the Parameterized Reports Training
You must use the optional "as" attribute in the Parameter definition to indicate "String", "Boolean", or "Integer". If as is not defined, it will default to "Item".
Only parameters of type Item are added to contexts. Other parameter values are only available through variables.
Example Parameter Configurations
For Type String
<Parameters> <Parameter caption="Section" name="p1" as="String" > <Values> <ForEach select="['One', 'Two', 'Three']"> <AddValue/> </ForEach> </Values> </Parameter> </Parameters>
For Type Boolean
<Parameters> <Parameter caption="Section" name="p1" as="Boolean" > <Values> <ForEach select="[true, false]"> <AddValue/> </ForEach> </Values> </Parameter> </Parameters>
For Type Integer
<Parameters> <Parameter caption="Section" name="p1" as="Integer" > <Values> <ForEach select="[1, 2, 3]"> <AddValue/> </ForEach> </Values> </Parameter> </Parameters>
Example Use Case for String Data Type
Below is a use case for a String data type for parameter. The use case is to provide end users with different views of Unallocated design (functions design), where the user can choose to see:
- Detailed function design (with function boundary), or
- Overall components design (without function boundary), orĀ
- Simplified functions design (only connection between functions)
It is possible to use more than one parameter of different types, but for the simplicity of this example we are just using one parameter of type String.
Example Meta Model
Example Graph XML Configuration
<Graph> <Parameters> <Parameter caption="Design function boundary" name="p1" as="String" > <Values> <ForEach select="[ 'Overall Components Design', 'Detailed Functions Design', 'Simplified Functions Design']"> <AddValue/> </ForEach> </Values> </Parameter> </Parameters> <NodeStyles> <NodeStyle name="SWC" fillColor="#fbdbd7" fillColor2="#ffffff" borderThickness="4" borderColor="#000000" /> </NodeStyles> <Node> <Choose> <!--Detailed function design (with function boundary)--> <When test="$p1='Detailed Functions Design'"> <ForEach select="/ITAP"> <Node> <ApplyTemplate name="Components"/> </Node> </ForEach> </When> <!--Overall components design (without function boundary)--> <When test="$p1='Overall Components Design'"> <ForEach select="/ITAP"> <ApplyTemplate name="Components"/> </ForEach> </When> <!--Simplified functions design (only connection between functions)--> <When test="$p1='Simplified Functions Design'"> <ForEach select="/ITAP"> <Node> <ApplyTemplate name="externalPorts"/> </Node> </ForEach> </When> </Choose> </Node> <Template name="Components"> <ForEach select="/ITFC"> <Node style="SWC"> <ApplyTemplate name="PortConnections"/> </Node> </ForEach> </Template> <Template name="PortConnections"> <ForEach select="/ARPP"> <OutPort connection="."/> </ForEach> <ForEach select="/ARRP"> <InPort connection="."/> </ForEach> </Template> <Template name="externalPorts"> <Variable name="externalInPort" as="Items" select="INPORTS:=/ITFC/ARRP; OUTPORTS:=/ITFC/ARPP; INPORTS[not . in OUTPORTS] "/> <Variable name="externalOutPort" as="Items" select="OUTPORTS:=/ITFC/ARPP; INPORTS:=/ITFC/ARRP; OUTPORTS[not . in INPORTS] "/> <ForEach select="$externalOutPort"> <OutPort connection="."/> </ForEach> <ForEach select="$externalInPort"> <InPort connection="."/> </ForEach> </Template> </Graph>
Example Graph Result
Parameter=Overall Components Design (without function boundary)
Parameter=Detailed Functions Design (with function boundary)
Parameter=Simplified Functions Design (only connection between functions)
Example Grid XML Configuration
The example above can be done using grid, chart or report. Below is a grid example.
<Grid> <Parameters> <Parameter caption="Design function boundary" name="p1" as="String" > <Values> <ForEach select="[ 'Overall Components Design', 'Detailed Functions Design', 'Simplified Functions Design']"> <AddValue/> </ForEach> </Values> </Parameter> </Parameters> <Columns> <!--Detailed function design (with function boundary)--> <If test="$p1='Detailed Functions Design'"> <ItemNameColumn caption="Design Function" width="200" objectName="DesignFunction" cellMerge="true" /> <ItemNameColumn caption="Component" width="200" objectName="Component" cellMerge="true" /> </If> <!--Overall components design (without function boundary)--> <If test="$p1='Overall Components Design'"> <ItemNameColumn caption="Component" width="200" objectName="Component" cellMerge="true" /> </If> <!--Simplified functions design (only connection between functions)--> <If test="$p1='Simplified Functions Design'"> <ItemNameColumn caption="Design Function" width="200" objectName="DesignFunction" cellMerge="true" /> </If> <ItemNameColumn caption="#{? if $p1='Simplified Functions Design' then 'External Port' else 'Port'}" width="150" objectName="Port" icon="true" /> <TypeColumn caption="Port Type" width="100" objectName="Port" /> </Columns> <Choose> <!--Detailed function design (with design function)--> <When test="$p1='Detailed Functions Design'"> <ApplyTemplate name="DesignFunction"/> </When> <!--Overall components design (without design function)--> <When test="$p1='Overall Components Design'"> <ForEach select="/ITAP"> <ApplyTemplate name="Components"/> </ForEach> </When> <!--Simplified functions design (only connection between designfunctions)--> <When test="$p1='Simplified Functions Design'"> <ForEach select="/ITAP"> <RowObject name="DesignFunction"> <ApplyTemplate name="externalPorts"/> </RowObject> </ForEach> </When> </Choose> <Template name="DesignFunction"> <ForEach select="/ITAP"> <RowObject name="DesignFunction"> <ApplyTemplate name="Components"/> </RowObject> </ForEach> </Template> <Template name="Components"> <ForEach select="/ITFC"> <RowObject name="Component"> <ApplyTemplate name="PortConnections"/> </RowObject> </ForEach> </Template> <Template name="PortConnections"> <ForEach select="/part::ARPP"> <RowObject name="Port"> <Row/> </RowObject> </ForEach> <ForEach select="/part::ARRP"> <RowObject name="Port"> <Row/> </RowObject> </ForEach> </Template> <Template name="externalPorts"> <Variable name="externalInPort" as="Items" select="INPORTS:=/ITFC/ARRP; OUTPORTS:=/ITFC/ARPP; INPORTS[not . in OUTPORTS] "/> <Variable name="externalOutPort" as="Items" select="OUTPORTS:=/ITFC/ARPP; INPORTS:=/ITFC/ARRP; OUTPORTS[not . in INPORTS] "/> <ForEach select="/ITFC/part::ARPP[/defobj:: in $externalOutPort]"> <RowObject name="Port"> <DefObj> <Row/> </DefObj> </RowObject> </ForEach> <ForEach select="/ITFC/part::ARRP[/defobj:: in $externalInPort]"> <RowObject name="Port"> <DefObj> <Row/> </DefObj> </RowObject> </ForEach> </Template> </Grid>