Commit 99b76131 authored by Dongyue Mou's avatar Dongyue Mou
Browse files

Excluded the requirements from the ConstraintChecker

refs 65
parent 5879050c
......@@ -34,3 +34,9 @@ Require-Bundle: org.fortiss.af3.micro;bundle-version="1.0.0";visibility:=reexpor
Bundle-ActivationPolicy: lazy
Bundle-NativeCode: lib/com4j-x86.dll
Bundle-Activator: org.fortiss.af3.mira.AF3MiraActivator
Import-Package: org.eclipse.core.resources,
org.eclipse.jface.dialogs,
org.eclipse.jface.viewers,
org.eclipse.jface.window,
org.eclipse.swt.graphics,
org.eclipse.swt.widgets
......@@ -22,6 +22,7 @@ import java.util.ArrayList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.Scenario;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
......@@ -39,29 +40,33 @@ public class RequirementAlternateScenarioRedundantChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D,M) */
ArrayList<Scenario> scenarioList = new ArrayList<Scenario>();
// Compares the scenarios of a UseCase to each other, according to their
// names
for (IHierarchicElement he : modelElement.getContainedElements()) {
if (he instanceof Scenario) {
Scenario sc = (Scenario) he;
if (modelElement instanceof UseCase) {
ArrayList<Scenario> scenarioList = new ArrayList<Scenario>();
// Compares the scenarios of a UseCase to each other, according to
// their
// names
for (IHierarchicElement he : modelElement.getContainedElements()) {
if (he instanceof Scenario) {
Scenario sc = (Scenario) he;
for (int i = 0; i < scenarioList.size(); i++) {
if (!(sc.getName() == null || sc.getName().trim().length() == 0)
&& sc.getName()
.trim()
.equals(scenarioList.get(i).getName()
.trim())) {
String violation = "The both alternative Scenarios of Use Case "
+ modelElement.getId()
+ " have the same name: \""
+ sc.getName()
+ "\" (E2.5)";
return new RequirementConstraintViolation(modelElement,
violation);
for (int i = 0; i < scenarioList.size(); i++) {
if (!(sc.getName() == null || sc.getName().trim()
.length() == 0)
&& sc.getName()
.trim()
.equals(scenarioList.get(i).getName()
.trim())) {
String violation = "The both alternative Scenarios of Use Case "
+ modelElement.getId()
+ " have the same name: \""
+ sc.getName()
+ "\" (E2.5)";
return new RequirementConstraintViolation(
modelElement, violation);
}
}
scenarioList.add(sc);
}
scenarioList.add(sc);
}
}
return null;
......
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -35,18 +36,20 @@ public class RequirementComprehensiveDescripedChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (C) */
if (modelElement.getAuthor() == null
|| modelElement.getAuthor().trim().isEmpty()
|| modelElement.getRationale() == null
|| modelElement.getRationale().trim().isEmpty()
|| modelElement.getSources() == null
|| modelElement.getSources().trim().isEmpty()) {
String violation = "One or more of the fields: author, rationale and source of Use Case "
+ modelElement.getId()
+ " is not comprehensively described(E1.5)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getAuthor() == null
|| modelElement.getAuthor().trim().isEmpty()
|| modelElement.getRationale() == null
|| modelElement.getRationale().trim().isEmpty()
|| modelElement.getSources() == null
|| modelElement.getSources().trim().isEmpty()) {
String violation = "One or more of the fields: author, rationale and source of Use Case "
+ modelElement.getId()
+ " is not comprehensively described(E1.5)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -39,26 +39,28 @@ public class RequirementConflictChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
for (IConnector iC : modelElement.getConnectorsList()) {
for (IConnection i : iC.getOutgoingList()) {
if (i instanceof ConflictedRequirementRelation) {
if (i.getTarget().eContainer() instanceof UseCase) {
if (checkConflict((UseCase) modelElement, (UseCase) i
.getTarget().eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " and "
+ ((UseCase) i.getTarget().eContainer())
.getId() + " are conflicted (E9.1)";
return new RequirementConstraintViolation(
modelElement, violation);
if (modelElement instanceof UseCase) {
for (IConnector iC : modelElement.getConnectorsList()) {
for (IConnection i : iC.getOutgoingList()) {
if (i instanceof ConflictedRequirementRelation) {
if (i.getTarget().eContainer() instanceof UseCase) {
if (checkConflict((UseCase) modelElement,
(UseCase) i.getTarget().eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " and "
+ ((UseCase) i.getTarget().eContainer())
.getId()
+ " are conflicted (E9.1)";
return new RequirementConstraintViolation(
modelElement, violation);
}
}
}
}
}
}
}
return null;
}
......
......@@ -40,25 +40,26 @@ public class RequirementDeclinedSourceChecker extends RequirementCheckerBase {
Requirement modelElement) {
/** (CMP) */
if (modelElement.getStatus().equals(RequirementStatus.DECLINED)) {
for (IConnector iCSource : modelElement.getConnectorsList()) {
for (IConnection iConnect : iCSource.getIncomingList()) {
if (iConnect instanceof RefinementRequirementRelationImpl) {
if (iConnect.getSource().eContainer() instanceof UseCase) {
if (checkIfDeclined((UseCase) iConnect.getSource()
.eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " has a source UseCase which is declined, but is not declinded itself (E10.3)";
return new RequirementConstraintViolation(
modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getStatus().equals(RequirementStatus.DECLINED)) {
for (IConnector iCSource : modelElement.getConnectorsList()) {
for (IConnection iConnect : iCSource.getIncomingList()) {
if (iConnect instanceof RefinementRequirementRelationImpl) {
if (iConnect.getSource().eContainer() instanceof UseCase) {
if (checkIfDeclined((UseCase) iConnect
.getSource().eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " has a source UseCase which is declined, but is not declinded itself (E10.3)";
return new RequirementConstraintViolation(
modelElement, violation);
}
}
}
}
}
}
}
return null;
}
......
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -35,13 +36,15 @@ public class RequirementDescriptionIsEmptyChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement.getDescription() == null
|| modelElement.getDescription().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no description (E1.4)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getDescription() == null
|| modelElement.getDescription().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no description (E1.4)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -34,13 +35,15 @@ public class RequirementNameIsEmptyChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement.getName() == null
|| modelElement.getName().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no name (E1.4)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getName() == null
|| modelElement.getName().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no name (E1.4)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -34,12 +35,14 @@ public class RequirementPriorityIsEmptyChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement.getPriority() == null) {
String violation = "Use Case " + modelElement.getId()
+ " has no priority assigned (E8)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getPriority() == null) {
String violation = "Use Case " + modelElement.getId()
+ " has no priority assigned (E8)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -43,28 +43,32 @@ public class RequirementRedundantDescriptionChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
Analysis root = (Analysis) modelElement.eContainer();
for (IHierarchicElement he : root.getContainedElementsList()) {
if (he instanceof UseCase)
useCaseList.add((UseCase) he);
}
if (modelElement instanceof UseCase) {
Analysis root = (Analysis) modelElement.eContainer();
for (IHierarchicElement he : root.getContainedElementsList()) {
if (he instanceof UseCase)
useCaseList.add((UseCase) he);
}
/** (D) */
for (int i = 0; i < useCaseList.size(); i++) {
if (!(modelElement.getDescription() == null
|| modelElement.getDescription().trim().length() == 0 || useCaseList
.get(i).getDescription() == null)
&& modelElement
.getDescription()
.trim()
.equalsIgnoreCase(
useCaseList.get(i).getDescription().trim())) {
String violation = "Use Case with ID: " + modelElement.getId()
+ " and ID: " + useCaseList.get(i).getId()
+ " have both the same description: \""
+ modelElement.getDescription() + "\" (E2.1)";
return new RequirementConstraintViolation(modelElement,
violation);
/** (D) */
for (int i = 0; i < useCaseList.size(); i++) {
if (!(modelElement.getDescription() == null
|| modelElement.getDescription().trim().length() == 0 || useCaseList
.get(i).getDescription() == null)
&& modelElement
.getDescription()
.trim()
.equalsIgnoreCase(
useCaseList.get(i).getDescription()
.trim())) {
String violation = "Use Case with ID: "
+ modelElement.getId() + " and ID: "
+ useCaseList.get(i).getId()
+ " have both the same description: \""
+ modelElement.getDescription() + "\" (E2.1)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
}
return null;
......
......@@ -47,7 +47,8 @@ public class RequirementRedundantNameAndActorChecker extends
Analysis root = (Analysis) modelElement.eContainer();
for (IHierarchicElement he : root.getContainedElementsList()) {
if (he instanceof UseCase)
if (he instanceof UseCase
&& ((UseCase) he).getId() != modelElement.getId())
useCaseList.add((UseCase) he);
}
......
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -34,12 +35,14 @@ public class RequirementStatusIsAnalyzedChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (M) */
if (modelElement.getStatus().getValue() < 2) {
String violation = "Use Case " + modelElement.getId()
+ " is not analyzed yet (E7.2)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getStatus().getValue() < 2) {
String violation = "Use Case " + modelElement.getId()
+ " is not analyzed yet (E7.2)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -34,12 +35,14 @@ public class RequirementStatusIsEmptyChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (P) */
if (modelElement.getStatus() == null) {
String violation = "Use Case " + modelElement.getId()
+ " has no status assigned (E7.2)";
return new RequirementConstraintViolation(modelElement, violation);
if (modelElement instanceof UseCase) {
if (modelElement.getStatus() == null) {
String violation = "Use Case " + modelElement.getId()
+ " has no status assigned (E7.2)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
......@@ -43,26 +43,29 @@ public class RequirementUseCaseActorsAssignedChecker extends
Requirement modelElement) {
/** (CMP) */
ArrayList<Actor> scenarioStepActorList = new ArrayList<Actor>();
for (IHierarchicElement he : modelElement.getContainedElements()) {
if (he instanceof ScenarioImpl) {
for (IHierarchicElement st : he.getContainedElementsList()) {
if (st instanceof ScenarioStep)
scenarioStepActorList.add(((ScenarioStep) st)
.getActor());
if (modelElement instanceof UseCase) {
ArrayList<Actor> scenarioStepActorList = new ArrayList<Actor>();
for (IHierarchicElement he : modelElement.getContainedElements()) {
if (he instanceof ScenarioImpl) {
for (IHierarchicElement st : he.getContainedElementsList()) {
if (st instanceof ScenarioStep)
scenarioStepActorList.add(((ScenarioStep) st)
.getActor());
}
}
}
}
if (!scenarioStepActorList.isEmpty()
&& !scenarioStepActorList.containsAll(((UseCase) modelElement)
.getActorList())) {
String violation = "Use Case "
+ modelElement.getId()
+ " contains actors which are not assigned to any scenario step (E9.3)";
return new RequirementConstraintViolation(modelElement, violation);
if (!scenarioStepActorList.isEmpty()
&& !scenarioStepActorList
.containsAll(((UseCase) modelElement)
.getActorList())) {
String violation = "Use Case "
+ modelElement.getId()
+ " contains actors which are not assigned to any scenario step (E9.3)";
return new RequirementConstraintViolation(modelElement,
violation);
}
}
return null;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment