Skip to content
Snippets Groups Projects
Commit d535b917 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

- Move the ComponentDiverseImplRef annotation from the application to the exploration.alg plugin.

parent 859739c0
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,18 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.fortiss.af3.exploration.alg.ExplorationAlgActivator
Require-Bundle: org.fortiss.tooling.base.ui;visibility:=reexport,
org.fortiss.af3.safety;bundle-version="2.9.0";visibility:=reexport,
org.fortiss.af3.safety;visibility:=reexport;bundle-version="2.9.0",
org.fortiss.tooling.kernel;visibility:=reexport,
org.fortiss.af3.schedule;visibility:=reexport,
org.fortiss.af3.exploration;bundle-version="2.10.0";visibility:=reexport
org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.fortiss.tooling.base;visibility:=reexport,
org.fortiss.af3.component;visibility:=reexport,
org.fortiss.af3.exploration.alg;visibility:=reexport,
org.fortiss.af3.exploration;visibility:=reexport;bundle-version="2.10.0",
org.fortiss.af3.expression;visibility:=reexport,
org.fortiss.af3.platform;visibility:=reexport,
org.fortiss.af3.project;visibility:=reexport
Export-Package: com.google.common.annotations,
com.google.common.base,
com.google.common.base.internal,
......@@ -105,6 +114,9 @@ Export-Package: com.google.common.annotations,
org.fortiss.af3.exploration.model.time.util,
org.fortiss.af3.exploration.model.util,
org.fortiss.af3.exploration.moea.model,
org.fortiss.af3.exploration.moea.model.annotation,
org.fortiss.af3.exploration.moea.model.annotation.impl,
org.fortiss.af3.exploration.moea.model.annotation.util,
org.fortiss.af3.exploration.moea.model.feature,
org.fortiss.af3.exploration.moea.model.feature.impl,
org.fortiss.af3.exploration.moea.model.feature.util,
......
......@@ -52,6 +52,16 @@
<eClassifiers xsi:type="ecore:EClass" name="VoterType" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//VoterType_t"/>
</eClassifiers>
<eSubpackages name="annotation" nsURI="http://www.fortiss.org/af3/exploration/moea/annotation"
nsPrefix="org-fortiss-af3-exploration-moea-annotation">
<eClassifiers xsi:type="ecore:EClass" name="ComponentDiverseImplRef" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IAnnotatedSpecification platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="{@link IAnnotatedSpecification} providing a reference to a set of differing implementations of the specified {@link Component}, hence providing diverse implementations."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="componentRef" upperBound="-1"
eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/>
</eClassifiers>
</eSubpackages>
<eSubpackages name="feature" nsURI="http://www.fortiss.org/af3/exploration/moea/feature"
nsPrefix="org-fortiss-af3-exploration-moea-feature">
<eClassifiers xsi:type="ecore:EClass" name="SafetyExploration" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IExplorationFeature">
......
......@@ -28,6 +28,13 @@
<genClasses ecoreClass="moea.ecore#//VoterType">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//VoterType/type"/>
</genClasses>
<nestedGenPackages prefix="Annotation" basePackage="org.fortiss.af3.exploration.moea.model"
disposableProviderFactory="true" ecorePackage="moea.ecore#//annotation">
<genClasses ecoreClass="moea.ecore#//annotation/ComponentDiverseImplRef">
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference moea.ecore#//annotation/ComponentDiverseImplRef/componentRef"/>
</genClasses>
</nestedGenPackages>
<nestedGenPackages prefix="Feature" basePackage="org.fortiss.af3.exploration.moea.model"
disposableProviderFactory="true" ecorePackage="moea.ecore#//feature">
<genDataTypes ecoreDataType="moea.ecore#//feature/ISafetyFunctionAdapter"/>
......
......@@ -13,6 +13,8 @@
<extension-point id="evaluator" name="Evaluator" schema="schema/evaluator.exsd"/>
<extension-point id="repairModule" name="RepairModule" schema="schema/repairModule.exsd"/>
<extension-point id="constraintTransformationModule" name="Constraint Transformation Module" schema="schema/constraintTransformationModule.exsd"/>
<!-- Value providers for the annotation classes -->
<extension
point="org.fortiss.tooling.base.annotation">
<annotation
......@@ -21,6 +23,9 @@
modelElementClass="org.fortiss.af3.platform.model.ExecutionUnit">
</modelElementClass>
</annotation>
<annotation binding="org.fortiss.af3.exploration.alg.annotation.valueprovider.ComponentImplDiversityRefValueProvider">
<modelElementClass modelElementClass="org.fortiss.af3.component.model.Component"/>
</annotation>
</extension>
<extension
......@@ -78,6 +83,14 @@
genModel="model/moea.genmodel"/>
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated moea -->
<package
uri="http://www.fortiss.org/af3/exploration/moea/annotation"
class="org.fortiss.af3.exploration.moea.model.annotation.AnnotationPackage"
genModel="model/moea.genmodel"/>
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated moea -->
<package
......
/*--------------------------------------------------------------------------+
$Id: ComponentImplDiversityRefValueProvider.java 1804 2015-11-19 14:28:47Z barner $
| |
| Copyright 2014 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.exploration.alg.annotation.valueprovider;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
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.exploration.moea.model.annotation.AnnotationPackage;
import org.fortiss.af3.exploration.moea.model.annotation.ComponentDiverseImplRef;
import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureDescriptor;
import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureValueProviderBase;
import org.fortiss.tooling.base.annotation.valueprovider.IAnnotationValueProvider;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
/**
* {@link IAnnotationValueProvider} for referencing {@link Component}s that represent a diverse
* implementation of a component that is part of a functional description of a
* {@link ComponentArchitecture}
*
* @author barner
* @author $Author: barner $
* @version $Rev: 1804 $
* @ConQAT.Rating YELLOW Hash: FA4D4457C9F251312DCA6CA2AEF45DA0
*/
public class ComponentImplDiversityRefValueProvider extends
EStructuralFeatureValueProviderBase<ComponentDiverseImplRef> {
/**
* {@link EStructuralFeatureDescriptor} that filters the available objects to be selected for
* the reference provided by this annotation.
*/
private static class DiversityRefFilterEStructuralFeatureDescriptor extends
EStructuralFeatureDescriptor {
/** Constructs a new {@link DiversityRefFilterEStructuralFeatureDescriptor}. */
public DiversityRefFilterEStructuralFeatureDescriptor(EReference eReference,
EReferenceScope eReferenceScope) {
super(eReference, eReferenceScope);
}
/** {@inheritDoc} */
@Override
public boolean isAvailableObject(EObject obj, IAnnotatedSpecification specification,
EObject modelElement) {
// Only offer only Components
if(!(obj instanceof Component)) {
return false;
}
Component refComponent = (Component)obj;
// Allow references to Components implementing diversity only if the "abstract", i.e.
// the referencing, Component is atomic.
if(modelElement instanceof Component &&
ComponentArchitectureUtils.isAtomicComponent((Component)modelElement)) {
ComponentArchitecture targetCompArch =
getParentElement(obj, ComponentArchitecture.class, false);
// Check, whether the the parent ComponentArchitcture is the component pool (via the
// name of the top-level Component).
if(targetCompArch != null &&
targetCompArch.getTopComponent().getName().contains("Component Pool")) {
// Do not allow self references inside the component pool.
ComponentArchitecture sourceCompArch =
getParentElement(modelElement, ComponentArchitecture.class, false);
if(sourceCompArch != null && sourceCompArch != targetCompArch) {
// Only return diverse Component implementations if the referenced Component
// is a sub-element of a Component in the Component Pool. (2nd layer)
if(getDistToTopLevel(refComponent, targetCompArch) == 1) {
return true;
}
}
}
}
return false;
}
}
/**
* Returns the "level" in the hierarchy of a "pure" {@link ComponentArchitecture} i.e. a
* {@link ComponentArchitecture} consisting only of {@link Component}s. The {@link Component}s
* contained in the top level component are considered to be at level 0.
*/
private static int getDistToTopLevel(Component comp, ComponentArchitecture compArch) {
if(comp == compArch.getTopComponent()) {
return -1;
}
Component parentComp = comp.getParentComponent();
int level = 0;
while(parentComp != null && parentComp != compArch.getTopComponent()) {
parentComp = parentComp.getParentComponent();
level++;
}
return level;
}
/** {@link EStructuralFeature}s managed by this {@link IAnnotationValueProvider}. */
private static Map<String, EStructuralFeatureDescriptor> createStructuralFeatureDescriptorMap() {
Map<String, EStructuralFeatureDescriptor> rval =
new HashMap<String, EStructuralFeatureDescriptor>();
rval.put(IAnnotationValueProvider.DEFAULT_KEY,
new DiversityRefFilterEStructuralFeatureDescriptor(
AnnotationPackage.Literals.COMPONENT_DIVERSE_IMPL_REF__COMPONENT_REF,
EStructuralFeatureDescriptor.EReferenceScope.PROJECT));
return Collections.unmodifiableMap(rval);
}
/** Constructs a value provider for the (derived) {@link ComponentDiverseImplRef} annotation. */
public ComponentImplDiversityRefValueProvider() {
super(AnnotationPackage.Literals.COMPONENT_DIVERSE_IMPL_REF,
createStructuralFeatureDescriptorMap());
}
/** {@inheritDoc} */
@Override
public String getAnnotationName(ComponentDiverseImplRef specification) {
return "Diverse Implementations";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment