Skip to content

Commit

Permalink
[2011] Prevent 1.2.0 session opening without migration
Browse files Browse the repository at this point in the history
Change-Id: I99028908a00b03a90cf65a9be352a4316f00c0ca
Signed-off-by: Philippe DUL <philippe.dul@thalesgroup.com>
  • Loading branch information
pdulth committed May 15, 2018
1 parent 41810fd commit 3567d92
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 201 deletions.
Expand Up @@ -5,13 +5,10 @@ Bundle-SymbolicName: org.polarsys.capella.common.platform.sirius.ted;singleton:=
Bundle-Version: 1.3.0.qualifier
Bundle-Vendor: %providerName
Export-Package: org.polarsys.capella.common.platform.sirius.ted
Require-Bundle: org.eclipse.gmf.runtime.emf.core,
org.eclipse.sirius;visibility:=reexport,
Require-Bundle: org.eclipse.sirius;visibility:=reexport,
org.eclipse.sirius.common;visibility:=reexport,
org.eclipse.sirius.ecore.extender;visibility:=reexport,
org.polarsys.capella.common.ef;visibility:=reexport,
org.polarsys.kitalpha.ad.metadata,
org.polarsys.kitalpha.ad.viewpoint
org.polarsys.capella.common.ef;visibility:=reexport
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: org.polarsys.capella.common.platform.sirius.ted.PlatformSiriusTedActivator
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<!--
Copyright (c) 2006, 2014 THALES GLOBAL SERVICES.
Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
Expand All @@ -13,6 +13,7 @@
<plugin>
<extension-point id="semanticEditingDomainProviders" name="SemanticEditingDomain Providers" schema="schema/semanticEditingDomainProviders.exsd"/>
<extension-point id="derivedSemanticResourceProvider" name="Derived Semantic Resource Provider" schema="schema/derivedSemanticResourceProvider.exsd"/>
<extension-point id="metadataProvider" name="Metadata Resource Provider" schema="schema/metadataProvider.exsd"/>
<extension
point="org.eclipse.emf.transaction.editingDomains">
<editingDomain
Expand Down
@@ -0,0 +1,117 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.polarsys.capella.common.platform.sirius.ted" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.polarsys.capella.common.platform.sirius.ted" id="metadataProvider" name="MetadataProvider"/>
</appInfo>
<documentation>
Add capability to check consistency of loaded models on a Sirius Session created by org.polarsys.capella.common.platform.sirius.ted.SiriusSessionFactory
</documentation>
</annotation>

<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="metadataProvider"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="metadataProvider">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
Add capability to check consistency of loaded models on a Sirius Session created by org.polarsys.capella.common.platform.sirius.ted.SiriusSessionFactory
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.polarsys.capella.common.platform.sirius.ted.IMetadataProvider"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>

<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>

<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>

<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>

<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
Copyright (c) 2018 THALES GLOBAL SERVICES.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
Thales - initial API and implementation
</documentation>
</annotation>

</schema>
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.common.platform.sirius.ted;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.business.api.session.Session;

/**
* Add capability to check consistency of loaded models on a Sirius Session
* created by org.polarsys.capella.common.platform.sirius.ted.SiriusSessionFactory
*/
public interface IMetadataProvider {

/**
* For a given model file (model, aird, afm), retrieve if the model is fully compatible with the current platform.
* Checks current platform version and viewpoints.
*/
public IStatus checkMetadata(IFile file);

/**
* For a given AFM file loaded in a resourceSet, retrieve if the model is fully compatible with the current platform.
* Checks current platform version and viewpoints.
*/
public IStatus checkMetadata(URI sessionResourceURI, ResourceSet set);

/**
* Register the given resource to the current session
*/
public void registerMetadataResource(Resource resource, final Session session, final IProgressMonitor monitor);

/**
* Creates the AFM metadata resource</br>
* (This resource will only be created when the aird resource does not exist yet, if the aird resource already exists
* then a model migration shall be done)
*
* @param domain
* @param resourceURI
* @param monitor
* @return the created resource (may be null if the resource does not belong to a Capella project)
*/
public Resource createMetadataResource(TransactionalEditingDomain domain, URI resourceURI,
IProgressMonitor monitor);

}
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 THALES GLOBAL SERVICES.
* Copyright (c) 2016, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -15,8 +15,10 @@
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.polarsys.capella.common.platform.sirius.ted.messages"; //$NON-NLS-1$

@Deprecated
public static String NoMetadataException_Message;

@Deprecated
public static String WrongCapellaVersionException_Message;

static {
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 THALES GLOBAL SERVICES.
* Copyright (c) 2016, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -14,39 +14,44 @@

public class MetadataException extends RuntimeException {

private IStatus status;

public MetadataException() {
super();
}

public IStatus getStatus() {
return status;
}

public MetadataException(IStatus status) {
this(childMessages(status), status);
}

public MetadataException(String message, IStatus status) {
super(message);
this.status = status;
}

protected static String childMessages(IStatus status) {
String result = "";
int i = 0;
for (IStatus child : status.getChildren()) {
result += child.getMessage();
if (i < status.getChildren().length - 1) {
result += "\n";
}
if (i < status.getChildren().length) {
result += "\n";
}
i++;
}
return result;
}
private IStatus status;

public MetadataException() {
super();
}

public IStatus getStatus() {
return status;
}

public MetadataException(IStatus status) {
this(childMessages(status), status);
}

public MetadataException(String message, IStatus status) {
super(message);
this.status = status;
}

protected static String childMessages(IStatus status) {
String result = "";
int i = 0;
if (status.getChildren().length > 0) {
for (IStatus child : status.getChildren()) {
result += child.getMessage();
if (i < status.getChildren().length - 1) {
result += "\n";
}
if (i < status.getChildren().length) {
result += "\n";
}
i++;
}
} else {
result += status.getMessage();
}

return result;
}

}
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 THALES GLOBAL SERVICES.
* Copyright (c) 2016, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -10,12 +10,14 @@
*******************************************************************************/
package org.polarsys.capella.common.platform.sirius.ted;

import org.eclipse.osgi.util.NLS;

@Deprecated
/**
* Use a MetadataException instead
*/
public class NoMetadataException extends RuntimeException {

public NoMetadataException(String message) {
super(NLS.bind(Messages.NoMetadataException_Message, message));
super(message);
}

public NoMetadataException() {
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2017 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -24,7 +24,8 @@ public class PlatformSiriusTedActivator extends AbstractActivator {
*/
private static PlatformSiriusTedActivator __instance;

//The identifier of the Capella "virtual" viewpoint
@Deprecated
//Use org.polarsys.capella.core.af.integration.AFIntegrationPlugin.CAPELLA_VIEWPOINT_ID instead
public static final String CAPELLA_VIEWPOINT_ID = "org.polarsys.capella.core.viewpoint";

/**
Expand Down

0 comments on commit 3567d92

Please sign in to comment.