The DTM (and all) excel exports are written in a markdown language called Java Excel Template Translator (JETT).
The most fundamental keys to understanding and the most important takeaway from the DTM export file are that:
Therefore, when exporting, the groovy script "runs first" and the data it collects and defines is then placed in the resulting file by the templating language.
As such, it doesn't actually matter what cell the script is placed into (unless you're return-ing data to the cell). For example, currently the script return-s an empty string viz. return ""—the last line—leading to an empty cell. Theoretically, you could return "hello world" and populate the cell thusly.
There is a list of pre-defined variables ("primitives") from Codebeamer's export context that are given by Codebeamer for free. The ones that we make use of in the groovy script are:
itemsfieldsissueReferencesuserThe swagger api is located at https://<CODEBEAMER_BASE_URL>/cb/v3/swagger/editor.spr. If you're ever stuck about variable names or properties, you can find them there.
While editing the groovy script, if it contains syntax error or unhandled exception, it will abort—leading to the variables being undefined when the template begins render. The following error will be displayed during export:
Unexpected error:Null value or expected variable missing in expression "${unMapSize.get(item.id)}". inside tag "span" (net.sf.jett.tag.SpanTag), at Sheet1!B9 (originally at Sheet1!B9) inside tag "forEach" (net.sf.jett.tag.ForEachTag), at Sheet1!B8 (originally at Sheet1!B8)If the variable appears to be defined, the issue is most likely that a groovy syntax error was made.
Edit the .groovy file in a text editor and add it to the excel template spreadsheet. Avoid editing directly inside the spreadsheet. The recommended editor for editing groovy is Visual Studio Code with the code-groovy language support extension. Opening the file in Visual Studio Code will provide basic syntax highlighting to help read the code.
Edit JETT in an HTML or XML file extension for syntax highlighting and formatting.
There are a plethora of online resources that teach the basics of groovy. Notable idiomatic groovy techniques used in the export script are:
Closures
Map literals
Built-in iterator methods
Elvis operator
Null-safe method and variable access
Here is the official documentation on learning groovy. Since there is currently no mock codebeamer environment that defines the codebeamer utilities, trial and error is necessary for evaluating scripts.
diItem data structure (this is clearly demarcated in the file) inside groovy.Create a new TreeMap where all of the other global declarations called unFolderMap. This will keep track of the parents in the tracker tree for grouping.
Pass this folder map to the design input handler function handleDesignInput.
Update the function definition to accept the folder as a parameter
Add the folder name to the unFolderMap for top-level JETT access.
Inside the DTM-Start.xlsx file:
Add the updated groovy script to cell L8. (press f2 when the cell is highlighted, Ctrl+a to select all the text, paste the contents of the groovy script)
Move all the JETT cells down one row to row 9
Move the outer-most <jt:forEach> tag to cell B8
Nest a <jt:span> tag that references the data and expands right 10 columns to fill the width of the template document.
Stylize as necessary.
Export
If everything was done correctly, for every User Need, its parent directory should be displayed on export.