Commit 1e1102d0 authored by Saad bin Abid's avatar Saad bin Abid
Browse files

Added new code for constraint every functional requirement should have input(s)/output(s)..

parent 8c3017d8
......@@ -23,6 +23,7 @@ import org.fortiss.af3.mira.constraints.DescriptionAndOrConstraint;
import org.fortiss.af3.mira.constraints.DescriptionConstraint;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
import org.fortiss.af3.mira.constraints.IDConstraint;
import org.fortiss.af3.mira.constraints.IdentifiedInputOutputDefinedConstraint;
import org.fortiss.af3.mira.constraints.MultipleAspectsConstraint;
import org.fortiss.af3.mira.constraints.NameConstraint;
import org.fortiss.af3.mira.constraints.OnlyOneSILConstraint;
......@@ -37,6 +38,7 @@ import org.fortiss.af3.mira.ui.constraints.DescriptionAndOrConstraintUI;
import org.fortiss.af3.mira.ui.constraints.DescriptionConstraintUI;
import org.fortiss.af3.mira.ui.constraints.GlossaryTermDefinitionConstraintUI;
import org.fortiss.af3.mira.ui.constraints.IDConstraintUI;
import org.fortiss.af3.mira.ui.constraints.IdentifiedInputOutputDefinedConstraintUI;
import org.fortiss.af3.mira.ui.constraints.MultipleAspectsConstraintUI;
import org.fortiss.af3.mira.ui.constraints.NameConstraintUI;
import org.fortiss.af3.mira.ui.constraints.OnlyOneSILConstraintUI;
......@@ -113,6 +115,9 @@ public class AF3MiraUIActivator extends AbstractUIPlugin {
GlossaryTermDefinitionConstraintUI.class, GlossaryTermsDefinitionConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(OnlyOneSILConstraintUI.class,
OnlyOneSILConstraint.class);
IConstraintUIService.getInstance().registerConstraintUI(
IdentifiedInputOutputDefinedConstraintUI.class,
IdentifiedInputOutputDefinedConstraint.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 org.fortiss.tooling.kernel.ui.extension.base.ConstraintUIBases;
/**
* UI part of {@link org.fortiss.af3.mira.constraints.AuthorConstraint}
*
* @author saadbinabid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: BFF6930804F28A8F172BBB86BC4E14BE
*/
public class IdentifiedInputOutputDefinedConstraintUI extends
ConstraintUIBases.ConstraintUIBaseAutocheck {
/** {@inheritDoc} */
@Override
public String getDescription() {
// TODO Auto-generated method stub
return "All functional requirements should have \"input(s)/output(s)\" defined";
}
/** {@inheritDoc} */
@Override
public boolean shouldBeManuallyActivated() {
return true;
}
}
......@@ -23,6 +23,7 @@ import org.fortiss.af3.mira.constraints.DescriptionAndOrConstraint;
import org.fortiss.af3.mira.constraints.DescriptionConstraint;
import org.fortiss.af3.mira.constraints.GlossaryTermsDefinitionConstraint;
import org.fortiss.af3.mira.constraints.IDConstraint;
import org.fortiss.af3.mira.constraints.IdentifiedInputOutputDefinedConstraint;
import org.fortiss.af3.mira.constraints.MultipleAspectsConstraint;
import org.fortiss.af3.mira.constraints.NameConstraint;
import org.fortiss.af3.mira.constraints.OnlyOneSILConstraint;
......@@ -78,6 +79,8 @@ public class AF3MiraActivator extends Plugin {
.registerConstraint(GlossaryTermsDefinitionConstraint.class);
IConstraintService.getInstance().registerConstraint(AuthorConstraint.class);
IConstraintService.getInstance().registerConstraint(OnlyOneSILConstraint.class);
IConstraintService.getInstance().registerConstraint(
IdentifiedInputOutputDefinedConstraint.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.createFailStatus;
import static org.fortiss.tooling.kernel.utils.ConstraintsUtils.createSuccessStatus;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.functional.FormalSpecification;
import org.fortiss.af3.project.utils.ConstraintsProjectUtils.AF3ProjectConstraintCheckerBase;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
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 functional requirement has input/output defined.
*
* @author abid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 75E1971AE604133D4BBC4F2D3B499F32
*/
public class IdentifiedInputOutputDefinedConstraint extends AF3ProjectConstraintCheckerBase {
/** {@inheritDoc} */
@Override
public IConstraintInstanceStatus verify(IConstrained constrained) {
Requirement req = (Requirement)constrained;
for(IModelElementSpecification spec : req.getSpecifications()) {
if(spec instanceof FormalSpecification) {
for(IHierarchicElement itr_element : ((IHierarchicElementContainer)spec)
.getContainedElements()) {
Component functionalcomp = (Component)itr_element;
if(functionalcomp.getContainedElements() != null) {
for(IHierarchicElement component : functionalcomp.getContainedElements()) {
Component innerfunccomponent = (Component)component;
if(innerfunccomponent.getInputPorts().size() == 0 ||
innerfunccomponent.getOutputPorts().size() == 0) {
return createFailStatus();
}
}
}
}
}
}
return createSuccessStatus();
}
/** {@inheritDoc} */
@Override
public boolean isApplicable(IConstrained constrained) {
return constrained instanceof Requirement;
}
}
......@@ -35,8 +35,7 @@ import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
/**
* Constraint to ensure that the parameterType of a constraint is non-empty and Set to an
* Appropriate Type.
* Constraint to ensure that the each requirement has only one aspect attached to it.
*
* @author abid
* @author $Author$
......
......@@ -50,7 +50,7 @@ public class OnlyOneSILConstraint extends AF3ProjectConstraintCheckerBase {
/** {@inheritDoc} */
@Override
public final IConstraintInstanceStatus verify(ConstraintInstance ci) {
public IConstraintInstanceStatus verify(ConstraintInstance ci) {
IConstrained constrained = getConstrained(ci);
if(!isApplicable(constrained)) {
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