Skip to content
Snippets Groups Projects
Commit 1b5d425f authored by Simon Barner's avatar Simon Barner
Browse files

- Register MemoryPerNode and PowerConsumption only for

 * org.fortiss.af3.platform.model.generic.GenericExecutionUnit (changed - from ExecutionUnit)
 * org.fortiss.af3.platform.pikeos.model.Core (as before)

- Add migrators that remove annotation from model elements other than the two mentioned above

- Move registration of MemoryPerNode, PowerConsumption, HardwareCost from af3.exploration.smt to af3.platform
refs 2658
parent 29458c24
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ Export-Package: org.fortiss.tooling.base,
org.fortiss.tooling.base.dnd,
org.fortiss.tooling.base.layout,
org.fortiss.tooling.base.library,
org.fortiss.tooling.base.migration,
org.fortiss.tooling.base.model.base,
org.fortiss.tooling.base.model.base.impl,
org.fortiss.tooling.base.model.base.util,
......
IDMigrationProvider.java 38c9d2df4d810a2875d0e7d56c239af4b72b384c GREEN
RemoveDuplicatedAnnotationsMigrationProvider.java 0af6b49eaea213ee603000f61687405daf020d88 GREEN
RemoveOutdatedAnnotationInstanceMigrationProvider.java f7c31a9c3f2af7178434a8dd3bd56c0b4db820ad YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 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.tooling.base.migration;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.tooling.common.util.LambdaUtils.isAssignableFromAny;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
/**
* {@link IMigrationProvider} that ensures that the annotation of the given {@code annotationType}
* is only kept for the {@link IModelElement} specializations of the given. From all other
* {@link IModelElement} specializations, the annotation instance is removed.
*
* @author barner
*/
public abstract class RemoveOutdatedAnnotationInstanceMigrationProvider<T extends IAnnotatedSpecification>
implements IMigrationProvider {
/** Annotation type for which outdated instances should be removed. */
private Class<T> annotationType;
/** List of {@link IModelElement} types for which annotation should be kept. */
private List<Class<?>> modelElementTypes;
/** Constructor. */
protected RemoveOutdatedAnnotationInstanceMigrationProvider(Class<T> annotationType,
List<Class<?>> modelElementTypes) {
this.annotationType = annotationType;
this.modelElementTypes = modelElementTypes;
}
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
EObject rootModelElement = modelElement.getRootModelElement();
for(T annotation : getChildrenWithType(rootModelElement, annotationType)) {
if(!isAssignableFromAny(modelElementTypes, annotation.getSpecificationOf())) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
EObject rootModelElement = modelElement.getRootModelElement();
for(T annotation : getChildrenWithType(rootModelElement, annotationType)) {
if(!isAssignableFromAny(modelElementTypes, annotation.getSpecificationOf())) {
delete(annotation);
}
}
}
}
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