Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
72:custom_reports_getting_started_example [2019/02/15 19:28]
ext-bkkr
72:custom_reports_getting_started_example [2019/02/15 19:40] (current)
ext-bkkr
Line 34: Line 34:
 </​code>​ </​code>​
  
-We use the global variable pkit to call  the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getCurrentProject()</​font>​ to get a handle on the project of the current metric. The method returns the current project.+We use the global variable pkit to call the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getCurrentProject()</​font>​ to get a handle on the project of the current metric. The method returns the current project.
  
 Now we call the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getEntities()</​font>​ with the parameter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​containsProcess@SYSTEM</​font>"​ to retrieve the process on this project. The return is an array, but we mostly want to get the current view, we use the first one by [0]. Now we call the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getEntities()</​font>​ with the parameter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​containsProcess@SYSTEM</​font>"​ to retrieve the process on this project. The return is an array, but we mostly want to get the current view, we use the first one by [0].
  
 And now we try to get all Artifacts which are available in the process. So we call <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getEntities()</​font>​ with the parameter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​containsArtifact@SYSTEM</​font>"​ to retrieve the artifacts on this process. As a result we get an array of all artifacts in the variable <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​artifacts</​font>​. And now we try to get all Artifacts which are available in the process. So we call <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getEntities()</​font>​ with the parameter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​containsArtifact@SYSTEM</​font>"​ to retrieve the artifacts on this process. As a result we get an array of all artifacts in the variable <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​artifacts</​font>​.
 +
 +<​code>​
 +for (i = 0; i <​artifacts.length;​ i++) {
 + var artifacts_instances =
 + ​artifacts[i].getEntities("​containsInstance@SYSTEM"​);​
 +</​code>​
 +
 +Now we iterate through all artifacts to get the instances of the artifacts, that means the configuration management controlled files. So we call <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getEntities()</​font>​ with the parameter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​containsInstance@SYSTEM</​font>"​ to retrieve the instances. As a result we get an array of all instances in the variable <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​artifacts_instances</​font>​.
 +
 +<​code>​
 + for (j = 0; j <​artifacts_instances.length;​ j++) {
 + var artifacts_revisions =
 +
 + ​artifacts_instances[j].getEntities("​containsRevision@SYSTEM"​);​
 +</​code>​
 +
 +Now we do the same with the revisions of an instance. Each instance has several revisions. But as you can see later we use only one revision, the latest one. As a result we have a variable with all revisions <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​artifacts_revisions</​font>​.
 +
 +<​code>​
 +if (artifacts_revisions.length == 0) {
 + ​dataset.setColumnValue("​State",​ "no version"​);​
 +} else {
 + ​dataset.setColumnValue("​State",​
 + ​artifacts_revisions[0].getProperty("​state"​));​
 +}
 +</​code>​
 +
 +Now we check if a revision exists for an instance. If not then we fill the State column by calling the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​dataset.setColumnValue()</​font>​ with a string "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​no version</​font>"​. Otherwise we use the value of the first revision. We get the State property of a revision by calling the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​getProperty()</​font>​ with the paramter "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​state</​font>"​.
 +
 +<​code>​
 +dataset.setColumnValue("​DocumentName",​
 + ​artifacts_instances[j].getProperty("​LogicalName"​));​
 +</​code>​
 +
 +We retrieve the document name from the property "​LogicalName"​ and store it in the column with the name "​DocumentName"​.
 +
 +The last action to perform is to save the row by calling the method <font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​dataset.storeResultRow()</​font>​ with the two columns "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​State</​font>"​ and "<​font inherit/​Courier New,​Courier,​monospace;;​inherit;;​inherit>​DocumentName</​font>"​. And we have to this for all artifact'​s and revisions.
 +
 +<​code>​
 +dataset.storeResultRow();​
 +</​code>​