Overview

This training material expands on the previously existing knowledge of charts by combining it with the SystemWeaver Path Query Language.

Course Type

Suitable for class training or for self study.

Course Length

Two hours to half-day course.

Prerequisites


Introduction

In the prerequisite training material, the basic functionality of this view was presented using the script language. However, combining this knowledge with the SPaQL creates new possibilities for more complexity. This course aims to present some of the possibilities where using the SPaQL provides a different approach to the problem. In other words, there will be very little new material presented in this course and instead it will focus on combining previous knowledge with a different aspect of SystemWeaver.


Charts

Charts are usually a very useful way to present complex data in an easy-to-read manner. Earlier training material showed how to get data from one itemtype at a time using the following code.


<Charts>
    <PieChart>
        <Slices>
            <Slice name="1" caption="Prio 1" color="blue"/>
            <Slice name="2" caption="Prio 2" color="red"/>
            <Slice name="3" caption="Prio 3" color="yellow"/>      
            <Slice name="unknown" caption="Unknown" color="green"/>
        </Slices>
        <Counter>
          <ForEachPart type="XESX">
            <DefObj>
                <ForEachPart type="EXAC">
                    <DefObj>
                        <ForEachPart type="IBAR">
                            <DefObj>
                                <ApplyItemTemplates/>
                             </DefObj>
                        </ForEachPart>
                    </DefObj>
                </ForEachPart>    
            </DefObj>
          </ForEachPart>
        </Counter>
    </PieChart>    
    <ItemTemplate type="RQ">
        <Choose>
            <When test="@PRIO = 1">
                <AddToSlice name="1"/>
            </When>
            <When test="@PRIO = 2">
                <AddToSlice name="2"/>
            </When>                
            <When test="@PRIO = 3">
                <AddToSlice name="3"/>
            </When>  
            <Otherwise>              
                <AddToSlice name="unknown"/>
            </Otherwise>        
        </Choose>  
    </ItemTemplate>
</Charts>





Bildresultat för exercise icon freeExercise 1

  1. Open Item: x0400000000000292.
  2. For the Vehicle Architecture tree, rewrite the above example using the SystemWeaver Path Language.


A Comment on the SystemWeaver Path Language

The Path Language is an immensely powerful tool when used correctly and it will, as seen above, make otherwise tedious tasks seem very simple in comparison to the conventional way of navigating large structures. However, a tool is never without its limitations and this is the case with the Path Language as well. It is a powerful tool for navigation and for some logical operations, but it is not the answer to all problems. The <ItemTemplate> used in the previous example could be replaced with the Path Language operators, but this would make the code harder to read and in some cases harder to maintain. Many times it is preferable and easier to lift out functions and logic to make it more clear what the purpose of the code is. There are exceptions to every case of course and in the exercise above only one itemtype is being evaluated. If there is more than one itemtype, then the script needs to be adapted to include either several <ItemTemplate> and/or to use the <ForEach> loop in an inventive manner depending on the situation at hand.


Bildresultat för exercise icon freeExercise 2

  1. Open Item: x0400000000000292.
  2. Using Exercise 1 as a starting point, for the Vehicle Architecture tree, create a piechart that counts the different itemtypes located below each Application Component.


The result should look similar to the picture below.


What's Next?

We hope that you are satisfied with this training material. You are welcome to send us follow-up questions and/or suggestions on how to improve this material. We recommend the article Combining Knowledge - Tables/Grids and the SPaQL as a next step in the learning process.