[WIP] Added a handler for ODE models This commit adds a handler for Open Dependability Exchange (ODE) models. Change-Id: I4393d62e1026eb4419622d797148571899dae7d5
diff --git a/bundles/org.eclipse.capra.handler.ode/.classpath b/bundles/org.eclipse.capra.handler.ode/.classpath new file mode 100644 index 0000000..bc6087a --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/.classpath
@@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath>
diff --git a/bundles/org.eclipse.capra.handler.ode/.project b/bundles/org.eclipse.capra.handler.ode/.project new file mode 100644 index 0000000..1555d2e --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/.project
@@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.capra.handler.ode</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + </natures> +</projectDescription>
diff --git a/bundles/org.eclipse.capra.handler.ode/META-INF/MANIFEST.MF b/bundles/org.eclipse.capra.handler.ode/META-INF/MANIFEST.MF new file mode 100644 index 0000000..cb04880 --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Localization: plugin +Bundle-Name: %Bundle-Name +Bundle-Vendor: %Bundle-Vendor +Bundle-SymbolicName: org.eclipse.capra.handler.ode;singleton:=true +Bundle-Version: 0.8.1.qualifier +Require-Bundle: ode, + org.eclipse.capra.core, + org.eclipse.core.resources +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.capra.handler.ode
diff --git a/bundles/org.eclipse.capra.handler.ode/build.properties b/bundles/org.eclipse.capra.handler.ode/build.properties new file mode 100644 index 0000000..9478594 --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/build.properties
@@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2016, 2020 Chalmers | University of Gothenburg, rt-labs and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v20.html +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation +# Chalmers | University of Gothenburg - additional features, updated API +############################################################################### +source.. = src/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties
diff --git a/bundles/org.eclipse.capra.handler.ode/plugin.properties b/bundles/org.eclipse.capra.handler.ode/plugin.properties new file mode 100644 index 0000000..58e0e45 --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/plugin.properties
@@ -0,0 +1,17 @@ +############################################################################### +# Copyright (c) 2016, 2020 Chalmers | University of Gothenburg, rt-labs and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v20.html +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation +# Chalmers | University of Gothenburg - additional features, updated API +############################################################################### +# + +Bundle-Name = Eclipse Capra Handler for ODE Models +Bundle-Vendor = Eclipse Capra
diff --git a/bundles/org.eclipse.capra.handler.ode/plugin.xml b/bundles/org.eclipse.capra.handler.ode/plugin.xml new file mode 100644 index 0000000..b2a12bf --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/plugin.xml
@@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<!-- + Copyright (c) 2016, 2020 Chalmers | University of Gothenburg, rt-labs and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v2.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Contributors: + Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation + Chalmers | University of Gothenburg - additional features, updated API + --> + +<plugin> + <extension + id="org.eclipse.capra.handler.ode.OdeHandler" + point="org.eclipse.capra.configuration.artifactHandlers"> + <artifactHandler + class="org.eclipse.capra.handler.ode.OdeHandler"> + </artifactHandler> + </extension> + +</plugin>
diff --git a/bundles/org.eclipse.capra.handler.ode/pom.xml b/bundles/org.eclipse.capra.handler.ode/pom.xml new file mode 100644 index 0000000..b539dd3 --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/pom.xml
@@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + Copyright (c) 2016, 2020 Chalmers | University of Gothenburg, rt-labs and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v2.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Contributors: + Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation + Chalmers | University of Gothenburg - additional features, updated API + --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <relativePath>../../pom.xml</relativePath> + <groupId>org.eclipse.capra</groupId> + <artifactId>parent</artifactId> + <version>0.8.1-SNAPSHOT</version> + </parent> + + <artifactId>org.eclipse.capra.handler.ode</artifactId> + <packaging>eclipse-plugin</packaging> + +</project>
diff --git a/bundles/org.eclipse.capra.handler.ode/src/org/eclipse/capra/handler/ode/OdeHandler.java b/bundles/org.eclipse.capra.handler.ode/src/org/eclipse/capra/handler/ode/OdeHandler.java new file mode 100644 index 0000000..d2cce45 --- /dev/null +++ b/bundles/org.eclipse.capra.handler.ode/src/org/eclipse/capra/handler/ode/OdeHandler.java
@@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2016, 2020 Chalmers | University of Gothenburg, rt-labs and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation + * Chalmers | University of Gothenburg - additional features, updated API + *******************************************************************************/ +package org.eclipse.capra.handler.ode; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.capra.core.adapters.Connection; +import org.eclipse.capra.core.handlers.AbstractArtifactHandler; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.emf.ecore.EObject; + +import top.argumentation.ArgumentAsset; +import top.base.Element; +import top.base.ModelElement; + +/** + * An artifact handler to create traces to and from Open Dependability Exchange + * (ODE) models. The ODE meta-model was specified by the DEIS research project + * and can be used to, among other things, specify safety assurance cases. + * <p> + * The official version of the Eclipse implementation of the ODE meta-model can + * be found at {@link https://github.com/DEIS-Project-EU/DDI-Scripting-Tools}. + * + * @author Jan-Philipp Steghöfer + * + */ +public class OdeHandler extends AbstractArtifactHandler<Element> { + + @Override + public EObject createWrapper(Element artifact, EObject artifactModel) { + return artifact; + } + + @Override + public Element resolveWrapper(EObject wrapper) { + return (Element) wrapper; + } + + @Override + public String getDisplayName(Element artifact) { + if (artifact instanceof ArgumentAsset) { + try { + return ((ArgumentAsset) artifact).getDescription().getContent().getValue().get(0).getContent(); + } catch (NullPointerException npe) { + // Deliberately do nothing and fall back to the standard behaviour + } + } + if (artifact instanceof ModelElement) { + try { + return ((ModelElement) artifact).getName().getContent(); + } catch (NullPointerException npe) { + // Deliberately do nothing and fall back to the standard behaviour + } + } + + EObject sel = this.resolveWrapper(artifact); + return org.eclipse.capra.core.helpers.EMFHelper.getIdentifier(sel); + } + + @Override + public String generateMarkerMessage(IResourceDelta delta, String wrapperUri) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<Connection> addInternalLinks(EObject investigatedElement, List<String> selectedRelationshipTypes) { + // TODO: Include internal links: AssertedInference, AssertedEvidence, + // AssertedContext, etc. + return Collections.emptyList(); + } + + @Override + public boolean isThereAnInternalTraceBetween(EObject first, EObject second) { + // TODO Auto-generated method stub + return false; + } + +}