Commit b01468b0 authored by Sabine Teufl's avatar Sabine Teufl
Browse files

architectural improvement because of code review

refs 1589
parent 762aca1f
......@@ -23,10 +23,10 @@ import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.ui.utils.SelectionDialogUtils.openComponentSingleSelectDialog;
import static org.fortiss.af3.mira.ui.utils.SelectionDialogUtils.openComponentsMultiSelectDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createExternalRelationSpecification;
import static org.fortiss.af3.mira.utils.MiraUtils.getAssociatedComponentArchitectures;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
......@@ -46,7 +46,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 8368094D537991C69CC4C2FDB7C542ED
* @ConQAT.Rating YELLOW Hash: 03C7603491ADCBE7E798FBA5B9A34141
*/
public final class ConnectExternalRelationToComponentAction extends
EObjectActionBase<ExternalRelation> {
......@@ -76,8 +76,8 @@ public final class ConnectExternalRelationToComponentAction extends
/** {@inheritDoc} */
@Override
public void run() {
List<ComponentArchitecture> arch =
getAssociatedComponentArchitectures(getTarget().getAnalysis());
EList<ComponentArchitecture> arch =
getTarget().getAnalysis().getAssociatedComponentArchitectures();
if(arch == null) {
openError(shell, "Component Architecture", "Cannot find a Component Architecture!");
......@@ -91,7 +91,8 @@ public final class ConnectExternalRelationToComponentAction extends
selected = (Component)spec.getSpecificationOf();
}
final Component component = openComponentSingleSelectDialog(shell.getShell(), arch, selected);
final Component component =
openComponentSingleSelectDialog(shell.getShell(), arch, selected);
if(component == null || component == selected) {
return;
}
......
......@@ -22,10 +22,8 @@ import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.ui.utils.SelectionDialogUtils.openComponentSingleSelectDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createScopeSpecification;
import static org.fortiss.af3.mira.utils.MiraUtils.getAssociatedComponentArchitectures;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
......@@ -41,7 +39,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: F3479BFB7473C0C4416D12EC1DB0A8DE
* @ConQAT.Rating YELLOW Hash: 1B9F3B2D6556790249CB5B113B7B6DFF
*/
public final class ConnectUseCaseScopeToComponentAction extends EObjectActionBase<UseCase> {
......@@ -58,8 +56,8 @@ public final class ConnectUseCaseScopeToComponentAction extends EObjectActionBas
/** {@inheritDoc} */
@Override
public void run() {
List<ComponentArchitecture> arch =
getAssociatedComponentArchitectures(getTarget().getAnalysis());
EList<ComponentArchitecture> arch =
getTarget().getAnalysis().getAssociatedComponentArchitectures();
if(arch == null) {
openError(shell, "Component Architecture", "Cannot find Component Architecture!");
return;
......@@ -72,7 +70,8 @@ public final class ConnectUseCaseScopeToComponentAction extends EObjectActionBas
selected = (Component)spec.getSpecificationOf();
}
final Component component = openComponentSingleSelectDialog(shell.getShell(), arch, selected);
final Component component =
openComponentSingleSelectDialog(shell.getShell(), arch, selected);
if(component == null || component == selected) {
return;
}
......
......@@ -44,6 +44,11 @@
<eTypeArguments eClassifier="#//RequirementsContainer"/>
</eGenericType>
</eOperations>
<eOperations name="getAssociatedComponentArchitectures" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//ComponentArchitecture">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return AnalysisStaticImpl.getAssociatedComponentArchitectures(this);"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="requirementRelation" upperBound="-1"
eType="#//RequirementRelation" containment="true" eOpposite="#//RequirementRelation/analysis"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="requirementRelationStatus"
......@@ -75,6 +80,11 @@
<details key="body" value="return RequirementStaticImpl.getRequirementsPackage(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getRequirementShortInfo" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return RequirementStaticImpl.getRequirementShortInfo(this);"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="rationale" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="author" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
......
......@@ -21,6 +21,7 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.ExternalRelation;
import org.fortiss.af3.mira.model.Requirement;
......@@ -28,6 +29,7 @@ import org.fortiss.af3.mira.model.RequirementsContainer;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.requirementSource.RequirementSource;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
/**
* Static implementation of {@link Analysis}
......@@ -40,33 +42,44 @@ import org.fortiss.af3.mira.model.usecase.UseCase;
public class AnalysisStaticImpl {
/** Return all contained {@link Requirement} list */
public static EList<Requirement> getRequirementsList(Analysis analysis) {
static EList<Requirement> getRequirementsList(Analysis analysis) {
return getChildrenWithType(analysis, Requirement.class);
}
/** Return all contained {@link UseCase} list */
public static EList<UseCase> getUseCaseList(Analysis analysis) {
static EList<UseCase> getUseCaseList(Analysis analysis) {
return getChildrenWithType(analysis, UseCase.class);
}
/** Return {@link Glossary} list */
public static EList<Glossary> getGlossariesList(Analysis analysis) {
static EList<Glossary> getGlossariesList(Analysis analysis) {
return pickInstanceOf(Glossary.class, analysis.getContainedElements());
}
/** Return {@link RequirementSource} list */
public static EList<RequirementSource> getRequirementSourceList(Analysis analysis) {
static EList<RequirementSource> getRequirementSourceList(Analysis analysis) {
return pickInstanceOf(RequirementSource.class, analysis.getContainedElements());
}
/** Return {@link RequirementsContainer} list */
public static EList<RequirementsContainer> getRequirementsContainersList(Analysis analysis) {
static EList<RequirementsContainer> getRequirementsContainersList(Analysis analysis) {
return pickInstanceOf(RequirementsContainer.class, analysis.getContainedElements());
}
/** Return {@link ExternalRelation} list */
public static EList<ExternalRelation> getExternalRelationsList(Analysis analysis) {
static EList<ExternalRelation> getExternalRelationsList(Analysis analysis) {
return pickInstanceOf(ExternalRelation.class, analysis.getContainedElements());
}
/** Return the associated {@link ComponentArchitecture}s */
static EList<ComponentArchitecture> getAssociatedComponentArchitectures(Analysis analysis) {
EList<ComponentArchitecture> arch =
pickInstanceOf(ComponentArchitecture.class, analysis.eContainer().eContents());
if(arch == null) {
arch =
(EList<ComponentArchitecture>)KernelModelElementUtils.getRootElements(analysis,
ComponentArchitecture.class);
}
return arch;
}
}
......@@ -3,8 +3,11 @@
*/
package org.fortiss.af3.mira.model.impl;
import static org.fortiss.af3.mira.utils.MiraUtils.getDisplayTypeFor;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.Formatter;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
......@@ -24,8 +27,7 @@ import org.fortiss.af3.mira.model.functional.FormalSpecification;
class RequirementStaticImpl {
/** Return the {@link Analysis} of the {@link Requirement} */
// TODO: methods can be package-private (i.e. remove public)
public static Analysis getAnalysis(Requirement requirement) {
static Analysis getAnalysis(Requirement requirement) {
if(requirement.getContainer() instanceof Analysis) {
return (Analysis)requirement.getContainer();
}
......@@ -33,12 +35,12 @@ class RequirementStaticImpl {
}
/** Return {@link FormalSpecification} list */
public static EList<FormalSpecification> getFormalSpecifications(Requirement requirement) {
static EList<FormalSpecification> getFormalSpecifications(Requirement requirement) {
return pickInstanceOf(FormalSpecification.class, requirement.getContainedElements());
}
/** Return {@link RequirementsContainer}, which contains the given {@link Requirement} */
public static RequirementsContainer getRequirementsContainer(Requirement requirement) {
static RequirementsContainer getRequirementsContainer(Requirement requirement) {
if(requirement.getContainer() instanceof RequirementsContainer) {
return (RequirementsContainer)requirement.getContainer();
}
......@@ -49,10 +51,21 @@ class RequirementStaticImpl {
}
/** Return {@link RequirementsPackage}, which immediately contains the given {@link Requirement} */
public static RequirementsPackage getRequirementsPackage(Requirement requirement) {
static RequirementsPackage getRequirementsPackage(Requirement requirement) {
if(requirement.getContainer() instanceof RequirementsPackage) {
return (RequirementsPackage)requirement.getContainer();
}
return null;
}
/**
* Get a short description of requirement: "type ID".
*
* @param req
* the requirement
* @return the formatted short info
*/
static String getRequirementShortInfo(Requirement req) {
return new Formatter().format("%s %s", getDisplayTypeFor(req), req.getReqId()).toString();
}
}
......@@ -27,7 +27,6 @@ import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootEl
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Formatter;
import java.util.List;
import org.apache.commons.lang.StringUtils;
......@@ -37,7 +36,6 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.component.utils.ComponentArchitectureUtils;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.mira.AF3MiraActivator;
......@@ -75,7 +73,6 @@ import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.element.IModelElementReference;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
/**
* Utility methods for accessing Mira model.
......@@ -112,23 +109,6 @@ public class MiraUtils {
/** editor priority for second editor */
public static final int SECONDEDITORPRIORITY = 1;
/**
* Return the associated {@link ComponentArchitecture}s to this {@link Analysis}
*
* @param analysis
* the {@link Analysis}
* @return the associated {@link ComponentArchitecture} List
*/
public static List<ComponentArchitecture>
getAssociatedComponentArchitectures(Analysis analysis) {
List<ComponentArchitecture> arch =
pickInstanceOf(ComponentArchitecture.class, analysis.eContainer().eContents());
if(arch == null) {
arch = KernelModelElementUtils.getRootElements(analysis, ComponentArchitecture.class);
}
return arch;
}
/**
* Remove the {@link RequirementRelation}s and {@link ExternalRelation}s from {@link EObject}s
*
......@@ -359,17 +339,6 @@ public class MiraUtils {
return "Not an object for requirements analysis";
}
/**
* Get a short description of requirement: "type ID".
*
* @param req
* the requirement
* @return the formatted short info
*/
public static String getRequirementShortInfo(Requirement req) {
return new Formatter().format("%s %s", getDisplayTypeFor(req), req.getReqId()).toString();
}
/**
* Get a short description of requirements: "type ID, tye ID, ...".
*
......@@ -380,7 +349,7 @@ public class MiraUtils {
public static String getRequirementsShortInfo(List<Requirement> reqs) {
List<String> infos = new ArrayList<String>();
for(Requirement req : reqs) {
infos.add(getRequirementShortInfo(req));
infos.add(req.getRequirementShortInfo());
}
return org.conqat.lib.commons.string.StringUtils.concat(infos, ",");
......
......@@ -17,7 +17,6 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.verification;
import static org.fortiss.af3.mira.utils.MiraUtils.getRequirementShortInfo;
import static org.fortiss.af3.mira.utils.MiraUtils.getRequirementsShortInfo;
import static org.fortiss.tooling.base.utils.BaseModelElementUtils.getIndex;
......@@ -34,7 +33,7 @@ import org.fortiss.af3.mira.model.usecase.UseCase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: DC42F8F5D60EFA2E3174126C0279BC5E
* @ConQAT.Rating GREEN Hash: 69DB80D31C05966B95E3DC7918D62F24
*/
public class ConstraintMessage {
......@@ -43,15 +42,16 @@ public class ConstraintMessage {
Requirement req1, Requirement req2) {
return new RequirementConstraintViolation<Requirement>(req1,
"%s and %s have both the same description: %s (E2.1)",
getRequirementShortInfo(req1), getRequirementShortInfo(req2), req1.getDescription());
req1.getRequirementShortInfo(), req2.getRequirementShortInfo(),
req1.getDescription());
}
/** Creates the violation for requirements with duplicated name. */
public static RequirementConstraintViolation<Requirement> createSameNameViolation(
Requirement req1, Requirement req2) {
return new RequirementConstraintViolation<Requirement>(req1,
"%s and %s have both the same title: %s (E2.1)", getRequirementShortInfo(req1),
getRequirementShortInfo(req2), req1.getName());
"%s and %s have both the same title: %s (E2.1)", req1.getRequirementShortInfo(),
req2.getRequirementShortInfo(), req1.getName());
}
/** Creates the violation for requirements with duplicated actors. */
......@@ -59,7 +59,7 @@ public class ConstraintMessage {
Requirement req1, Requirement req2) {
return new RequirementConstraintViolation<Requirement>(req1,
"%s and %s have both the same title: %s and the same actors (E2.2)",
getRequirementShortInfo(req1), getRequirementShortInfo(req2), req1.getName());
req1.getRequirementShortInfo(), req2.getRequirementShortInfo(), req1.getName());
}
/** Creates the violation for requirements with conflicted relation. */
......@@ -75,42 +75,42 @@ public class ConstraintMessage {
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s has a source which is declined, but is not declinded itself (E10.3)",
getRequirementShortInfo(req));
req.getRequirementShortInfo());
}
/** Creates the violation for requirements without status. */
public static RequirementConstraintViolation<Requirement> createEmptyStatusViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s has no status assigned (E7.2)", getRequirementShortInfo(req));
"%s has no status assigned (E7.2)", req.getRequirementShortInfo());
}
/** Creates the violation for requirements without priority. */
public static RequirementConstraintViolation<Requirement> createEmptyPriorityViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s has no priority assigned (E8)", getRequirementShortInfo(req));
"%s has no priority assigned (E8)", req.getRequirementShortInfo());
}
/** Creates the violation for requirements without name. */
public static RequirementConstraintViolation<Requirement> createEmtpyNameViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req, "%s has no title (E1.4)",
getRequirementShortInfo(req));
req.getRequirementShortInfo());
}
/** Creates the violation for requirements without description. */
public static RequirementConstraintViolation<Requirement> createEmptyDescriptionViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req, "%s has no description (E1.4)",
getRequirementShortInfo(req));
req.getRequirementShortInfo());
}
/** Creates the violation for requirements without source. */
public static RequirementConstraintViolation<Requirement> createEmptySourceViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s: source is not comprehensively described (E1.5)", getRequirementShortInfo(req));
"%s: source is not comprehensively described (E1.5)", req.getRequirementShortInfo());
}
/** Creates the violation for requirements without rationale. */
......@@ -118,21 +118,21 @@ public class ConstraintMessage {
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s: rationale is not comprehensively described (E1.5)",
getRequirementShortInfo(req));
req.getRequirementShortInfo());
}
/** Creates the violation for requirements without author. */
public static RequirementConstraintViolation<Requirement> createEmptyAuthorViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s: author is not comprehensively described (E1.5)", getRequirementShortInfo(req));
"%s: author is not comprehensively described (E1.5)", req.getRequirementShortInfo());
}
/** Creates the violation for requirements without any analysis. */
public static RequirementConstraintViolation<Requirement> createNotAnalyzedViolation(
Requirement req) {
return new RequirementConstraintViolation<Requirement>(req,
"%s is not analyzed yet (E7.2)", getRequirementShortInfo(req));
"%s is not analyzed yet (E7.2)", req.getRequirementShortInfo());
}
/** Creates the violation for scenarios with duplicated steps. */
......@@ -141,7 +141,7 @@ public class ConstraintMessage {
return new RequirementConstraintViolation<Scenario>(
scenario,
"The scenario steps with ID: %d and ID: %d of %s have both the same action: %s (E2.4)",
getIndex(step1), getIndex(step2), getRequirementShortInfo(scenario.getUseCase()),
getIndex(step1), getIndex(step2), scenario.getUseCase().getRequirementShortInfo(),
step1.getAction());
}
......@@ -149,7 +149,7 @@ public class ConstraintMessage {
public static RequirementConstraintViolation<UseCase> createUnusedActorViolation(UseCase uc) {
return new RequirementConstraintViolation<UseCase>(uc,
"%s contains actors which are not assigned to any scenario step (E9.3)",
getRequirementShortInfo(uc));
uc.getRequirementShortInfo());
}
/** Creates the violation for scenarios with duplicated names. */
......@@ -157,6 +157,6 @@ public class ConstraintMessage {
Scenario scenario, UseCase usecase) {
return new RequirementConstraintViolation<Scenario>(scenario,
"There exist alternative scenarios of %s with the same name: %s (E2.5)",
getRequirementShortInfo(usecase), scenario.getName());
usecase.getRequirementShortInfo(), scenario.getName());
}
}
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