Commit 81a473f2 authored by Saad bin Abid's avatar Saad bin Abid
Browse files

Added the constraint for checking if the component has a Trace to Requirement.

parent ec1e844f
......@@ -21,6 +21,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.fortiss.af3.mira.constraints.AuthorConstraint;
import org.fortiss.af3.mira.constraints.CheckListReviewConstraint;
import org.fortiss.af3.mira.constraints.ComponentExistsConstraint;
import org.fortiss.af3.mira.constraints.ComponentToRequirementTraceExistsConstraint;
import org.fortiss.af3.mira.constraints.DescriptionAndOrConstraint;
import org.fortiss.af3.mira.constraints.DescriptionConstraint;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
......@@ -41,6 +42,7 @@ import org.fortiss.af3.mira.constraints.TraceNotEmptyConstraint;
import org.fortiss.af3.mira.ui.constraints.AuthorConstraintUI;
import org.fortiss.af3.mira.ui.constraints.CheckListReviewConstraintUI;
import org.fortiss.af3.mira.ui.constraints.ComponentExistsConstraintUI;
import org.fortiss.af3.mira.ui.constraints.ComponentToRequirementTraceExistsConstraintUI;
import org.fortiss.af3.mira.ui.constraints.DescriptionAndOrConstraintUI;
import org.fortiss.af3.mira.ui.constraints.DescriptionConstraintUI;
import org.fortiss.af3.mira.ui.constraints.GlossaryTermDefinitionConstraintUI;
......@@ -138,6 +140,9 @@ public class AF3MiraUIActivator extends AbstractUIPlugin {
ComponentExistsConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(TraceNotEmptyConstraintUI.class,
TraceNotEmptyConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(
ComponentToRequirementTraceExistsConstraintUI.class,
ComponentToRequirementTraceExistsConstraint.class);
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.constraints;
import java.util.Arrays;
import java.util.List;
import org.fortiss.af3.component.model.Component;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.FailedConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.ui.extension.base.ConstraintUIBases.ConstraintUIBaseAutocheck;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService.IFix;
import org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.FixBase;
/**
* UI part of {@link org.fortiss.af3.mira.constraints.ComponentExistsConstraint}
*
* @author abid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 6F29232CC159E38AACDBAFDD48EA0A62
*/
public class ComponentToRequirementTraceExistsConstraintUI extends ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
return "All components should have a trace to requirement";
}
/** {@inheritDoc} */
@Override
public boolean shouldBeManuallyActivated() {
return true;
}
/** {@inheritDoc} */
@Override
public List<IFix> fixes(ConstraintInstance ci, IConstraintInstanceStatus status) {
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Component comp = (Component)ci.getConstraineds().get(0);
if(comp.getName() != null) {
if(comp.getName().isEmpty() == false) {
String fixMessage =
"Traced To field empty for the component: " + comp.getName();
return Arrays.asList(new FixBase(fixMessage, s -> comp.getName().toString()));
}
}
}
return super.fixes(ci, status);
}
}
......@@ -156,7 +156,6 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
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 =
......
......@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Plugin;
import org.fortiss.af3.mira.constraints.AuthorConstraint;
import org.fortiss.af3.mira.constraints.CheckListReviewConstraint;
import org.fortiss.af3.mira.constraints.ComponentExistsConstraint;
import org.fortiss.af3.mira.constraints.ComponentToRequirementTraceExistsConstraint;
import org.fortiss.af3.mira.constraints.DescriptionAndOrConstraint;
import org.fortiss.af3.mira.constraints.DescriptionConstraint;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
......@@ -91,7 +92,8 @@ public class AF3MiraActivator extends Plugin {
IConstraintService.getInstance().registerConstraint(CheckListReviewConstraint.class);
IConstraintService.getInstance().registerConstraint(ComponentExistsConstraint.class);
IConstraintService.getInstance().registerConstraint(TraceNotEmptyConstraint.class);
IConstraintService.getInstance().registerConstraint(
ComponentToRequirementTraceExistsConstraint.class);
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.constraints;
import static org.fortiss.tooling.kernel.utils.ConstraintsUtils.successIfTrue;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.mira.model.ExternalRelationSpecification;
import org.fortiss.af3.project.utils.ConstraintsProjectUtils.AF3ProjectConstraintCheckerBase;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
/**
* Constraint to ensure that the of a Component Architecture contains Components.
*
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: B0E3400E24B5C115D0CBA6EA0D9468D3
*/
public class ComponentToRequirementTraceExistsConstraint extends AF3ProjectConstraintCheckerBase {
/** {@inheritDoc} */
@Override
public IConstraintInstanceStatus verify(IConstrained constrained) {
boolean componentTraceAvailable = false;
Component comp = (Component)constrained;
if(comp.getSpecifications().size() > 0) {
for(IModelElementSpecification c : comp.getSpecifications()) {
if(c instanceof ExternalRelationSpecification) {
componentTraceAvailable = true;
}
}
}
return successIfTrue(componentTraceAvailable == true);
}
/** {@inheritDoc} */
@Override
public boolean isApplicable(IConstrained constrained) {
return constrained instanceof Component;
}
}
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