Repair Action

When using a HeuristicCritique? we are often faced with the following reaction: If you can find that problem, why cannot you fix it? The concept of RepairAction shall allow to do that. And this page explains how it is done.

Add some triggers

Repair Actions should be defined in the description of a heuristic as hyperlink. As an example we define here a simple heuristic critique that only asks whether a given requirement is security relevan (useful for training a Bayesian Classifier).

Teaser: Is this a Security-Relevant Requirements?

Description: <p>Please classify this requirement so the Bayesian Classifier can improve.</p>
  <li><a href="repairAction=learn-in:%d">yes, this is a security-relevant requirement</a>
  <li><a href="repairAction=learn-out:%d">no, this requirement is not security relevant</a>

for(var i = 0; i < project.getAllElements().length ; i++){
	var element = project.getAllElements()[i];
		var attribute = element.getAttribute("Text");
		contextList.addContext(project, element, "Text");

The important part is the hyperlink reference repairAction=learn-in:%d: repairAction tells HeRA that we are defining one here. learn-in is an action name that will be passed to the Javascript-Code-Fragment that should perform the RepairAction. %d is important, as HeRA will store here a reference number to the specific critique when creating the html-code for the critique view. This allow HeRA to find the ModelElemt? referenced by this HeuristicCritique?.

Add the RepairAction

Now that the trigger is defined, we can encode the RepairAction. Similar to the HeuristicRule? this is done in Javascript. In the ExperienceBaseView? click on the WizardIcon? to open an editor for the repair action. Then paste something like the following code:

sysout.println("Doing " + action + " on " + modelElement);
var classifier = nlp.getLearningClassifier("coord");
if ("learn-in".equals(action)) {
} else if ("learn-out".equals(action)) {

The first line generates some output to the console. It also introduces the most important variables in the scope of an RepairAction: the action as defined in the hyperlink above (e.g. learn-in) and the modelElement the RepairAction should work on.