Commit 0e24e745 authored by Simon Barner's avatar Simon Barner
Browse files

Remove safety module reference migrator (added in #3104)

Issue-Ref: 3676
Issue-Url: https://af3-developer.fortiss.org/issues/3676

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 7803ddae
......@@ -334,13 +334,4 @@
provider="org.fortiss.af3.requirementspatterns.library.prototypes.PatternsDatabaseLibraryPrototypeProvider">
</modelPrototypeProvider>
</extension>
<extension
point="org.fortiss.tooling.kernel.migrationProvider">
<migrationProvider
migrationProvider="org.fortiss.af3.safetycases.migration.SafetyModuleRefMigrator">
<objectClass
objectClass="org.fortiss.af3.safetycases.model.ModuleRef">
</objectClass>
</migrationProvider>
</extension>
</plugin>
SafetyModuleRefMigrator.java 92f069d3152ecc54abfa7d1024d321b3ee0abdfa GREEN
SolutionDeploymentToCa2HwMigration.java a9ba6f44c7a9aaa913ea6d84a2713c088a070fb8 GREEN
/*-------------------------------------------------------------------------+
| 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.safetycases.migration;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.af3.project.utils.ProjectUtils.getFileProject;
import static org.fortiss.tooling.base.utils.MigrationUtils.migrateConnectorBase;
import static org.fortiss.tooling.base.utils.MigrationUtils.migrateILayoutedModelElement;
import static org.fortiss.tooling.base.utils.MigrationUtils.migrateIModelElement;
import static org.fortiss.tooling.base.utils.MigrationUtils.migrateINamedCommentedElement;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstChildWithType;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.safetyargumentationpackage.model.SafetyArgumentationPackage;
import org.fortiss.af3.safetycases.model.ModuleRef;
import org.fortiss.af3.safetycases.model.SafetyCasesFactory;
import org.fortiss.af3.safetycases.model.SafetyModuleRef;
import org.fortiss.tooling.base.model.base.ConnectorBase;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
*
* @author diewald
*/
public class SafetyModuleRefMigrator implements IMigrationProvider {
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
FileProject fp = getFileProject(modelElement.getRootModelElement());
if(fp == null) {
// If the migrator is executed in the context of a library, the FileProject is null.
return false;
}
for(SafetyArgumentationPackage safetyArgPkg : getChildrenWithType(fp,
SafetyArgumentationPackage.class)) {
if(null != getFirstChildWithType(safetyArgPkg, ModuleRef.class)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
FileProject fp = getFileProject(modelElement.getRootModelElement());
for(ModuleRef moduleRef : getChildrenWithType(fp, ModuleRef.class)) {
SafetyModuleRef safetyModuleRef = SafetyCasesFactory.eINSTANCE.createSafetyModuleRef();
// Properties of the module itself
migrateIModelElement(moduleRef, safetyModuleRef);
migrateINamedCommentedElement(moduleRef, safetyModuleRef);
migrateILayoutedModelElement(moduleRef, safetyModuleRef);
// Connectors etc.
for(ConnectorBase connector : getChildrenWithType(moduleRef, ConnectorBase.class)) {
ConnectorBase newConnector = EcoreUtils.copy(connector);
migrateConnectorBase(connector, newConnector);
safetyModuleRef.getConnectors().add(newConnector);
}
// Containment relations.
safetyModuleRef.getContainedElements().addAll(moduleRef.getContainedElements());
IHierarchicElementContainer container = moduleRef.getContainer();
container.getContainedElements().add(safetyModuleRef);
delete(moduleRef, true);
}
}
}
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