Commit 3b695724 authored by Saad bin Abid's avatar Saad bin Abid
Browse files

updated the constraints error description, fixed the null pointer error caused...

updated the constraints error description, fixed the null pointer error caused because of the name of the requirement and for the "multipleAspectsConstraint" constraints providing two kinds of fixes. 1) if the requirement has no aspect applied than provide an error that add one aspect (information only) and 2) if there are more than one aspect than provide the split fix to the user
parent 643df7d1
......@@ -56,11 +56,12 @@ public class AuthorConstraintUI extends ConstraintUIBaseAutocheck {
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "Author field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
String splitFix = "Author field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -32,7 +32,7 @@ public class ComponentExistsConstraintUI extends ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
return "All component packages has atleast one component";
return "All component packages has at least one component";
}
/** {@inheritDoc} */
......
......@@ -57,11 +57,13 @@ public class DescriptionAndOrConstraintUI extends ConstraintUIBaseAutocheck {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix =
"Description field cointains \"and/or\" for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix =
"Description field cointains \"and/or\" for requirement: " +
req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -57,10 +57,11 @@ public class DescriptionConstraintUI extends ConstraintUIBaseAutocheck {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "Description field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix = "Description field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -56,11 +56,11 @@ public class IDConstraintUI extends ConstraintUIBaseAutocheck {
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "ID field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix = "ID field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -115,11 +115,64 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Requirement req1 = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
String splitFix =
"Split the requirement per attached aspect for requirement: " +
req1.getRequirementName();
return Arrays.asList(new FixBase(splitFix, s -> splitRequirementperAspect(req1)));
// aspectCounter will count the aspects attached to the requirement
int aspectCounter = 0;
// parameterdefCounter will count the parameterdefinitions attached to the requirement
int parameterdefCounter = 0;
for(IModelElementSpecification spec : req1.getSpecifications()) {
if(spec instanceof TimingRequirement) {
aspectCounter++;
}
if(spec instanceof UseCaseSpecification) {
aspectCounter++;
}
if(spec instanceof FormalSpecification) {
aspectCounter++;
}
if(spec instanceof ModeSpecification) {
aspectCounter++;
}
if(spec instanceof SafetyLevelRequirementSpecification) {
aspectCounter++;
}
if(spec instanceof ParameterDefinition) {
if(parameterdefCounter == 0) {
// if parameterdefinition is not set increase the counter
aspectCounter++;
parameterdefCounter++;
}
// otherwise do nothing as the parameterdefinition is already recorded by
// increasing the counter (i.e., parameterdefCounter++)
}
if(spec instanceof SignalContainerSpecification) {
aspectCounter++;
}
if(spec instanceof DerivedRequirementSpecification) {
aspectCounter++;
}
if(spec instanceof InterfaceBehaviourSpecification) {
aspectCounter++;
}
}
System.out.println("Aspect Counter is .....>>>>>>" + aspectCounter);
// send message to the user to have at least one aspect attached
if(aspectCounter == 0) {
String messageFix =
"Please have at least one aspect applied to the requirement: " +
req1.getRequirementName();
return Arrays.asList(new FixBase(messageFix, s -> req1.getName().toString()));
}
// send message to the user along with the fix when there is more than one aspect
// attached to the requirement
if(aspectCounter > 1) {
String splitFix =
"Split the requirement per applied aspect for the requirement: " +
req1.getRequirementName();
return Arrays.asList(new FixBase(splitFix, s -> splitRequirementperAspect(req1)));
}
}
return super.fixes(ci, status);
}
......
......@@ -56,11 +56,11 @@ public class RationaleConstraintUI extends ConstraintUIBaseAutocheck {
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "Rationale field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix = "Rationale field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -32,7 +32,7 @@ public class RequirementExistsConstraintUI extends ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
return "All requirement packages have atleast one requirement";
return "All requirement packages have at least one requirement";
}
/** {@inheritDoc} */
......@@ -41,19 +41,4 @@ public class RequirementExistsConstraintUI extends ConstraintUIBaseAutocheck {
return true;
}
/** {@inheritDoc} */
// @Override
// public List<IFix> fixes(ConstraintInstance ci, IConstraintInstanceStatus status) {
// if(status instanceof FailedConstraintInstanceStatus) {
// /** get(0) get */
// RequirementsPackage reqpkg = (Requirement)ci.getConstraineds().get(0);
//
// /** Creates a {@link Requirement}. */
// if(req.getName().isEmpty() == false) {
// String splitFix = "Author field empty for requirement: " + req.getName();
// return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
// }
// }
// return super.fixes(ci, status);
// }
}
......@@ -145,10 +145,12 @@ public class SignalConstraintsUI {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "Signal Type field not set for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix =
"Signal Type field not set for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
......
......@@ -57,12 +57,14 @@ public class SourceConstraintUI extends ConstraintUIBaseAutocheck {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
/** Creates a {@link Requirement}. */
if(req.getName().isEmpty() == false) {
String splitFix = "Source field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix = "Source field empty for requirement: " + req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
}
}
Supports Markdown
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