Commit a94e1976 authored by Levi Lucio's avatar Levi Lucio
Browse files

added constraint to check if each functional requirement has at least one...

added constraint to check if each functional requirement has at least one non-functional req attached to it
parent 8ee4d275
......@@ -25,6 +25,7 @@ import org.fortiss.af3.mira.constraints.ComponentNameMeaningfulConstraint;
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.FunctionalReqsHaveOneNonFunctionalReq;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
import org.fortiss.af3.mira.constraints.IDConstraint;
import org.fortiss.af3.mira.constraints.IdentifiedInputOutputDefinedConstraint;
......@@ -48,6 +49,7 @@ import org.fortiss.af3.mira.ui.constraints.ComponentNameMeaningfulConstraintUI;
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.FunctionalReqsHaveOneNonFunctionalReqUI;
import org.fortiss.af3.mira.ui.constraints.GlossaryTermDefinitionConstraintUI;
import org.fortiss.af3.mira.ui.constraints.IDConstraintUI;
import org.fortiss.af3.mira.ui.constraints.IdentifiedInputOutputDefinedConstraintUI;
......@@ -73,7 +75,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*
* @ConQAT.Rating YELLOW Hash: 0C00FF0CE8C7482641740063B3DFB4B7
* @ConQAT.Rating YELLOW Hash: CE9A0A555762666D3B294B18F13DA5B3
*/
public class AF3MiraUIActivator extends AbstractUIPlugin {
......@@ -152,6 +154,9 @@ public class AF3MiraUIActivator extends AbstractUIPlugin {
RequirementImplementedCorrectlyConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(
ComponentNameMeaningfulConstraintUI.class, ComponentNameMeaningfulConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(
FunctionalReqsHaveOneNonFunctionalReqUI.class,
FunctionalReqsHaveOneNonFunctionalReq.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.mira.model.Requirement;
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.AuthorConstraint}
*
* @author abid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: B4325D420B9E84641748D23771397221
*/
public class FunctionalReqsHaveOneNonFunctionalReqUI extends ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
return "All functional requirements should have at least one non-functional aspect defined";
}
/** {@inheritDoc} */
@Override
public boolean shouldBeManuallyActivated() {
return true;
}
/** {@inheritDoc} */
@Override
public List<IFix> fixes(ConstraintInstance ci, IConstraintInstanceStatus status) {
if(status instanceof FailedConstraintInstanceStatus) {
/** get(0) get */
Requirement req = (Requirement)ci.getConstraineds().get(0);
if(req.getName() != null) {
if(req.getName().isEmpty() == false) {
String splitFix =
"Please define one non-functional aspect for the requirement: " +
req.getName();
return Arrays.asList(new FixBase(splitFix, s -> req.getName().toString()));
}
}
}
return super.fixes(ci, status);
}
}
<!--
$Id$
@version $Rev$
@ConQAT.Rating GREEN Hash: CD360F30E8AF832ABB7ED286FA8B4F8C
@ConQAT.Rating YELLOW Hash: ACB184AE607CECCEB3C099D33D50B068
-->
<body>
Package for plugin activator
......
......@@ -302,17 +302,21 @@
<eLiterals name="Hardware" value="3" literal="Hardware"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SafetyLevelRequirementSpecification"
eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/>
<eClassifiers xsi:type="ecore:EClass" name="ModeSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement #//NonFunctionalRequirement"/>
<eClassifiers xsi:type="ecore:EClass" name="ModeSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement">
<eStructuralFeatures xsi:type="ecore:EReference" name="modes" upperBound="-1"
eType="#//Mode" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DerivedRequirementSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification"/>
<eClassifiers xsi:type="ecore:EClass" name="DerivedRequirementSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement"/>
<eClassifiers xsi:type="ecore:EClass" name="Trace" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstrained">
<eStructuralFeatures xsi:type="ecore:EReference" name="targets" upperBound="-1"
eType="#//Requirement"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Mode" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement"/>
<eClassifiers xsi:type="ecore:EClass" name="FunctionalRequirement" abstract="true"
interface="true"/>
<eClassifiers xsi:type="ecore:EClass" name="NonFunctionalRequirement" abstract="true"
interface="true"/>
<eSubpackages name="usecase" nsURI="http://www.fortiss.org/af3/mira/usecase" nsPrefix="org-fortiss-af3-mira-usecase">
<eClassifiers xsi:type="ecore:EClass" name="UseCase" eSuperTypes="#//Requirement platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElementContainer #//usecase/UseCaseSpecification">
<eOperations name="getScopeSpecification" eType="#//usecase/ScopeSpecification">
......@@ -402,7 +406,7 @@
<eClassifiers xsi:type="ecore:EClass" name="InputSpecification" eSuperTypes="#//RequirementSpecification"/>
<eClassifiers xsi:type="ecore:EClass" name="Inputs" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedElement"/>
<eClassifiers xsi:type="ecore:EClass" name="Outputs" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedElement"/>
<eClassifiers xsi:type="ecore:EClass" name="UseCaseSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
<eClassifiers xsi:type="ecore:EClass" name="UseCaseSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement">
<eStructuralFeatures xsi:type="ecore:EReference" name="actor" lowerBound="1"
upperBound="-1" eType="#//usecase/Actor" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="trigger" eType="#//usecase/Trigger"
......@@ -464,7 +468,7 @@
</eSubpackages>
<eSubpackages name="functional" nsURI="http://www.fortiss.org/af3/mira/functional"
nsPrefix="org-fortiss-af3-mira-functional">
<eClassifiers xsi:type="ecore:EClass" name="FormalSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/HierarchicElementBase platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionScope platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeScope platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
<eClassifiers xsi:type="ecore:EClass" name="FormalSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/HierarchicElementBase platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionScope platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeScope platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//FunctionalRequirement">
<eOperations name="getTopComponent" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return FormalSpecificationStaticImpl.getTopComponent(this);"/>
......@@ -531,8 +535,8 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="signals" upperBound="-1"
eType="#//functional/Signal"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SignalContainerSpecification" eSuperTypes="#//functional/ISignalsContainer platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification"/>
<eClassifiers xsi:type="ecore:EClass" name="FunctionalSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
<eClassifiers xsi:type="ecore:EClass" name="SignalContainerSpecification" eSuperTypes="#//functional/ISignalsContainer platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement"/>
<eClassifiers xsi:type="ecore:EClass" name="FunctionalSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//FunctionalRequirement">
<eStructuralFeatures xsi:type="ecore:EReference" name="functionalComponent"
upperBound="-1" eType="#//functional/FunctionalComponent" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="relatedTo" upperBound="-1"
......@@ -685,7 +689,7 @@
<eLiterals name="ThenAlways" value="1" literal="Then always (state)"/>
<eLiterals name="ThenOnce" value="2" literal="Then once (event)"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="InterfaceBehaviourSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
<eClassifiers xsi:type="ecore:EClass" name="InterfaceBehaviourSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement">
<eStructuralFeatures xsi:type="ecore:EReference" name="trigger" eType="#//interfacebehaviour/Trigger"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="precondition" eType="#//interfacebehaviour/ICondition"
......@@ -734,7 +738,7 @@
</eClassifiers>
</eSubpackages>
<eSubpackages name="timing" nsURI="http://www.fortiss.org/af3/mira/timing" nsPrefix="org-fortiss-af3-mira-timing">
<eClassifiers xsi:type="ecore:EClass" name="TimingRequirement" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification">
<eClassifiers xsi:type="ecore:EClass" name="TimingRequirement" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification #//NonFunctionalRequirement">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="propertyType" eType="#//timing/TimePropertyType"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="timeFrame" eType="#//timing/TimeFrame"
containment="true"/>
......
......@@ -154,6 +154,8 @@
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference mira.ecore#//Trace/targets"/>
</genClasses>
<genClasses ecoreClass="mira.ecore#//Mode"/>
<genClasses image="false" ecoreClass="mira.ecore#//FunctionalRequirement"/>
<genClasses image="false" ecoreClass="mira.ecore#//NonFunctionalRequirement"/>
<nestedGenPackages prefix="Usecase" basePackage="org.fortiss.af3.mira.model" disposableProviderFactory="true"
ecorePackage="mira.ecore#//usecase">
<genEnums typeSafeEnumCompatible="false" ecoreEnum="mira.ecore#//usecase/ScenarioStepActionType">
......
......@@ -25,6 +25,7 @@ import org.fortiss.af3.mira.constraints.ComponentNameMeaningfulConstraint;
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.FunctionalReqsHaveOneNonFunctionalReq;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
import org.fortiss.af3.mira.constraints.IDConstraint;
import org.fortiss.af3.mira.constraints.IdentifiedInputOutputDefinedConstraint;
......@@ -49,7 +50,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle.
*
* @ConQAT.Rating YELLOW Hash: A1552F3D2DBF59A0BF7362667C07EB02
* @ConQAT.Rating YELLOW Hash: A534E5F26356DF537C3DA2C5217D5BD4
*/
public class AF3MiraActivator extends Plugin {
......@@ -100,6 +101,8 @@ public class AF3MiraActivator extends Plugin {
RequirementImplementedCorrectlyConstraint.class);
IConstraintService.getInstance()
.registerConstraint(ComponentNameMeaningfulConstraint.class);
IConstraintService.getInstance().registerConstraint(
FunctionalReqsHaveOneNonFunctionalReq.class);
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2017 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.eclipse.emf.common.util.EList;
import org.fortiss.af3.mira.model.FunctionalRequirement;
import org.fortiss.af3.mira.model.NonFunctionalRequirement;
import org.fortiss.af3.mira.model.Requirement;
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;
/**
*
* @author levilucio
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 4F3CADC7FAAA0DDA749EEA1BD41A05E9
*/
public class FunctionalReqsHaveOneNonFunctionalReq extends AF3ProjectConstraintCheckerBase {
/** If the requirement is functional then check if it has at least one non-functional aspect */
@Override
public IConstraintInstanceStatus verify(IConstrained constrained) {
Requirement req = (Requirement)constrained;
EList<IModelElementSpecification> specs = req.getSpecifications();
for(IModelElementSpecification spec : req.getSpecifications()) {
if(spec instanceof NonFunctionalRequirement) {
return successIfTrue(true);
}
}
return successIfTrue(false);
}
/** {@inheritDoc} */
@Override
public boolean isApplicable(IConstrained constrained) {
if(constrained instanceof Requirement) {
EList<IModelElementSpecification> specs =
((Requirement)constrained).getSpecifications();
for(IModelElementSpecification iModelElementSpecification : specs) {
if(iModelElementSpecification instanceof FunctionalRequirement) {
return true;
}
}
}
return false;
}
}
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