Creating an Annotation/Comment Report
This example reads all annotations from all sub workspaces of the current one.
1. Create a report with a Stages Data Source and a Data Set.
2. Create the following Data Set result columns:
Name | Type |
---|---|
Project | String |
Element | String |
ElementSubtype | String |
AnnotationName | String |
Description | String |
Timestamp | String |
LastChangeUser | String |
ElementId | String |
ElementType | String |
3. Copy the Data Set script from the example into your Data Set.
function getChildren(project){ var myprojects = project.getEntities("hierarchy::hierarchic@LOCAL,targetrole=children"); for each (myproject in myprojects) { saveColumn(myproject); getChildren(myproject); } } function existsInArray (element, array){ for (var i = 0; i <array.length; i++){ if (element.equals(array[i])){ return true; } } return false; } function saveColumn(project){ //Step 1: get project id, name and the process var id = project.getProperty("Id"); var projectName = project.getProperty("Name"); var process = project.getEntities("containsProcess@SYSTEM")[0]; //Step 2: get all annotations of the process if (process != null){ //get all elementtypes if ( process.getPkitClass().isAssociationValid("containsAnnotation::MODEL@SYSTEM")) { var allAnnotations = process.getEntities("containsAnnotation@SYSTEM"); for each (annotation in allAnnotations){ var importantAssocNames = new Array(); var allAssocsForAnnotation = annotation.getPkitClass().getAssociations(); if (allAssocsForAnnotation.length> 0) { //go through all assocs, filter out the ones we don't need and duplicates for each (assoc in allAssocsForAnnotation) { if ((assoc.getName() != "containsElement::MODEL@SYSTEM") && (assoc.getName() != "containsAnnotation::MODEL@SYSTEM")){ if (existsInArray(assoc.getName(),importantAssocNames)!=true){ importantAssocNames.push(assoc.getName()); } } } //go through all important assocs of the annotation, get the associated elements, their subtype, etc for each (oneImportantAssocName in importantAssocNames){ var elements = annotation.getEntities(oneImportantAssocName); for each (element in elements){ var elementType = element.getProperty("Type"); if (element.getProperty("SubType") == undefined){ var propertyPath = process.getProperty("Type") +".process.element.type.singular." + elementType.toLowerCase(); } else{ var propertyPath = process.getProperty("Type") +".process.element.type.singular." + elementType.toLowerCase() + "." + element.getProperty("SubType"); } dataset.setColumnValue("Project",projectName); dataset.setColumnValue("Element",element.getProperty("DisplayName")); dataset.setColumnValue("ElementSubtype",properties_de.getProperty(propertyPath)); dataset.setColumnValue("AnnotationName",annotation.getProperty("DisplayName")); dataset.setColumnValue("Description",annotation.getProperty("Description")); dataset.setColumnValue("Timestamp",annotation.getProperty("Timestamp")); dataset.setColumnValue("LastChangeUser",annotation.getProperty("LastChangeUser")); dataset.setColumnValue("ElementId",element.getProperty("Id")); dataset.setColumnValue("ElementType",elementType); dataset.storeResultRow(); } } } } }} } /////////// Start of script /////////// //properties_en = new Properties(); properties_de = new Properties(); //stream_en = new FileInputStream("tomcat/webapps/pkit/WEB-INF/classes/ LocalPKit.properties"); stream_de = new FileInputStream("tomcat/webapps/pkit/WEB-INF/classes/ LocalPKit_de.properties"); //properties_en.load(stream_en); properties_de.load(stream_de); //stream_en.close(); stream_de.close(); var currentProject = pkit.getCurrentProject(); saveColumn(currentProject); /* Iterate through all subprojects */ getChildren(currentProject);