Skip to content

Commit

Permalink
#1 MMS4 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
j-barata committed Feb 17, 2020
1 parent be1e509 commit 64d5060
Show file tree
Hide file tree
Showing 38 changed files with 1,044 additions and 507 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ public interface FilesystemPackage extends EPackage {
* <!-- end-user-doc -->
* @generated
*/
String eNAME = "filesystem";
String eNAME = "filesystem"; //$NON-NLS-1$

/**
* The package namespace URI.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_URI = "http://www.thalesgroup.com/mde/openmbee/connector";
String eNS_URI = "http://www.thalesgroup.com/mde/openmbee/connector"; //$NON-NLS-1$

/**
* The package namespace name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
String eNS_PREFIX = "com.thalesgroup.mde.openmbee.connector.fsmodel";
String eNS_PREFIX = "com.thalesgroup.mde.openmbee.connector.fsmodel"; //$NON-NLS-1$

/**
* The singleton instance of the package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ public String toString() {
if (eIsProxy()) return super.toString();

StringBuilder result = new StringBuilder(super.toString());
result.append(" (name: ");
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", path: ");
result.append(", path: "); //$NON-NLS-1$
result.append(path);
result.append(", content: ");
result.append(", content: "); //$NON-NLS-1$
result.append(content);
result.append(')');
return result.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public EObject create(EClass eClass) {
case FilesystemPackage.FILE: return createFile();
case FilesystemPackage.FOLDER: return createFolder();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ public void initializePackageContents() {
folderEClass.getESuperTypes().add(this.getFileSystemElement());

// Initialize classes, features, and operations; add parameters
initEClass(fileSystemElementEClass, FileSystemElement.class, "FileSystemElement", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getFileSystemElement_Name(), ecorePackage.getEString(), "name", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getFileSystemElement_Path(), ecorePackage.getEString(), "path", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getFileSystemElement_Owner(), this.getFolder(), null, "owner", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(fileSystemElementEClass, FileSystemElement.class, "FileSystemElement", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
initEAttribute(getFileSystemElement_Name(), ecorePackage.getEString(), "name", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
initEAttribute(getFileSystemElement_Path(), ecorePackage.getEString(), "path", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
initEReference(getFileSystemElement_Owner(), this.getFolder(), null, "owner", null, 0, 1, FileSystemElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$

initEClass(fileEClass, File.class, "File", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getFile_Content(), ecorePackage.getEString(), "content", null, 0, 1, File.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(fileEClass, File.class, "File", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
initEAttribute(getFile_Content(), ecorePackage.getEString(), "content", null, 0, 1, File.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$

initEClass(folderEClass, Folder.class, "Folder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEClass(folderEClass, Folder.class, "Folder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$

// Create resource
createResource(eNS_URI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ public String toString() {
if (eIsProxy()) return super.toString();

StringBuilder result = new StringBuilder(super.toString());
result.append(" (name: ");
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", path: ");
result.append(", path: "); //$NON-NLS-1$
result.append(path);
result.append(')');
return result.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2020 Thales Global Services S.A.S.&#xA;&#xA;This program and the accompanying materials&#xA;are made available under the terms of the Eclipse Public License 2.0&#xA;which accompanies this distribution, and is available at&#xA;https://www.eclipse.org/legal/epl-2.0/&#xA;&#xA;SPDX-License-Identifier: EPL-2.0&#xA;&#xA;Contributors:&#xA; Thales - Initial API and implementation"
modelDirectory="/com.thalesgroup.mde.openmbee.connector.fsmodel/emf-gen" modelPluginID="com.thalesgroup.mde.openmbee.connector.fsmodel"
modelName="FileSystem" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
modelName="FileSystem" nonNLSMarkers="true" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false"
operationReflection="true" importOrganizing="true">
<foreignModel>filesystem.ecore</foreignModel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Automatic-Module-Name: com.thalesgroup.mde.openmbee.connector.mms.doc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static MmsServerManagementUiPlugin getInstance() {

public MMSServerDescriptor[] getStoredMMSServerDescriptors() {
try(StringReader stringReader = new StringReader(getStoredServerDataString())) {
return MMSJsonHelper.getPreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
return MMSJsonHelper.getMMS3PreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
} catch (Exception e) {
logHelper.error(e);
}
Expand All @@ -65,14 +65,14 @@ public MMSServerDescriptor[] getStoredMMSServerDescriptors() {

public void addStoredMMSServerDescriptor(MMSServerDescriptor serverDescriptor) {
try(StringReader stringReader = new StringReader(getStoredServerDataString())) {
MMSServerDescriptor[] fromJson = MMSJsonHelper.getPreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
MMSServerDescriptor[] fromJson = MMSJsonHelper.getMMS3PreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
Set<MMSServerDescriptor> existingOnes = new HashSet<>();
if(fromJson != null && fromJson.length > 0) {
existingOnes.addAll(Arrays.asList(fromJson));
}
if(!existingOnes.contains(serverDescriptor)) {
if(existingOnes.add(serverDescriptor)) {
SecurePreferencesFactory.getDefault().node(PLUGIN_ID).put(PREFERENCES_MMS_SERVERDATA, MMSJsonHelper.getPreparedGsonBuilder().create().toJson(existingOnes), true);
SecurePreferencesFactory.getDefault().node(PLUGIN_ID).put(PREFERENCES_MMS_SERVERDATA, MMSJsonHelper.getMMS3PreparedGsonBuilder().create().toJson(existingOnes), true);
}
}
} catch (StorageException e) {
Expand All @@ -82,14 +82,14 @@ public void addStoredMMSServerDescriptor(MMSServerDescriptor serverDescriptor) {

public void removeStoredMMSServerDescriptor(MMSServerDescriptor serverDescriptor) {
try(StringReader stringReader = new StringReader(getStoredServerDataString())) {
MMSServerDescriptor[] fromJson = MMSJsonHelper.getPreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
MMSServerDescriptor[] fromJson = MMSJsonHelper.getMMS3PreparedGsonBuilder().create().fromJson(stringReader, MMSServerDescriptor[].class);
Set<MMSServerDescriptor> existingOnes = new HashSet<>();
if(fromJson != null && fromJson.length > 0) {
existingOnes.addAll(Arrays.asList(fromJson));
}
Optional<MMSServerDescriptor> removable = existingOnes.stream().filter(s -> serverDescriptor.id.contentEquals(s.id)).findFirst();
if(removable.isPresent() && existingOnes.remove(removable.get())) {
SecurePreferencesFactory.getDefault().node(PLUGIN_ID).put(PREFERENCES_MMS_SERVERDATA, MMSJsonHelper.getPreparedGsonBuilder().create().toJson(existingOnes), true);
SecurePreferencesFactory.getDefault().node(PLUGIN_ID).put(PREFERENCES_MMS_SERVERDATA, MMSJsonHelper.getMMS3PreparedGsonBuilder().create().toJson(existingOnes), true);
}
} catch (StorageException e) {
logHelper.error(e);
Expand All @@ -99,10 +99,10 @@ public void removeStoredMMSServerDescriptor(MMSServerDescriptor serverDescriptor
private String getStoredServerDataString() {
String storedServerDataString = null;
try {
storedServerDataString = SecurePreferencesFactory.getDefault().node(PLUGIN_ID).get(PREFERENCES_MMS_SERVERDATA, "[]");
storedServerDataString = SecurePreferencesFactory.getDefault().node(PLUGIN_ID).get(PREFERENCES_MMS_SERVERDATA, "[]"); //$NON-NLS-1$
} catch (StorageException e1) {}
if(storedServerDataString == null) {
storedServerDataString = "[]";
storedServerDataString = "[]"; //$NON-NLS-1$
}
return storedServerDataString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MMSTreeParent(MMSIdentifiableDescriptor mmsObject) {
super(mmsObject);
if(mmsObject instanceof MMSServerDescriptor) {
MMSServerDescriptor server = (MMSServerDescriptor)mmsObject;
helper = new MMSServerHelper(server.url, server.autData);
helper = new MMSServerHelper(server.url, server.apiVersion, server.autData);
}
}

Expand Down Expand Up @@ -85,9 +85,9 @@ public MMSTreeObject[] getChildren() {
} else if(mmsObject instanceof MMSOrganizationDescriptor) {
setChildren(wrapAll(helper.getProjects(mmsObject.id)));
} else if(mmsObject instanceof MMSProjectDescriptor) {
setChildren(wrapAll(helper.getBranches(((MMSProjectDescriptor) mmsObject).org, mmsObject.id)));
setChildren(wrapAll(helper.getBranches(((MMSProjectDescriptor) mmsObject).orgId, mmsObject.id)));
} else if(mmsObject instanceof MMSRefDescriptor) {
setChildren(wrapAll(helper.getCommits(((MMSProjectDescriptor) parent.mmsObject).org, parent.mmsObject.id, mmsObject.id)));
setChildren(wrapAll(helper.getCommits(((MMSProjectDescriptor) parent.mmsObject).orgId, parent.mmsObject.id, mmsObject.id)));
}
}
if(children == null || children.size() == 0) hasChildren = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import com.thalesgroup.mde.openmbee.connector.mms.management.ui.data.MMSTreeParent;

public class MMSTreeObjectViewLabelProvider extends LabelProvider {
private static final String LBL_SERVER_DESCRIPTOR1 = "[%s] %s"; //$NON-NLS-1$
private static final String LBL_SERVER_DESCRIPTOR2 = "[%s] %s [%s]"; //$NON-NLS-1$

private static final String LBL_NAMED_DESCRIPTOR = "%s [%s]"; //$NON-NLS-1$
private static final String LBL_COMMIT_DESCRIPTOR = "%s [%s - %s]"; //$NON-NLS-1$
private IWorkbench workbench;
Expand All @@ -46,8 +49,8 @@ public String getText(Object obj) {
} else if(mmsObject instanceof MMSServerDescriptor) {
MMSServerDescriptor mmsServer = (MMSServerDescriptor)mmsObject;
return mmsServer.url.contentEquals(mmsServer.name) ?
mmsServer.name :
String.format(LBL_NAMED_DESCRIPTOR, mmsServer.name, mmsServer.url);
String.format(LBL_SERVER_DESCRIPTOR1, mmsServer.apiVersion, mmsServer.name) :
String.format(LBL_SERVER_DESCRIPTOR2, mmsServer.apiVersion, mmsServer.name, mmsServer.url);
} else {
return String.format(LBL_NAMED_DESCRIPTOR, ((MMSNamedDescriptor)mmsObject).name, mmsObject.id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,33 @@ public void widgetSelected(SelectionEvent e) {
boolean valid = false;
MMSNamedDescriptor nd = null;
switch(childType) {
case Organization:
valid = serverHelper.getOrgs().stream()
.noneMatch(o -> o.id.contentEquals(id.getText()));
if(valid) {
nd = new MMSOrganizationDescriptor();
case Organization: {
valid = serverHelper.getOrgs().stream().noneMatch(o -> o.id.contentEquals(id.getText()));
if (valid) {
nd = new MMSOrganizationDescriptor();
}
break;
}
break;
case Project:
valid = serverHelper.getProjects().stream()
.noneMatch(p -> p.id.contentEquals(id.getText()));
if(valid) {
nd = new MMSProjectDescriptor();
case Project: {
MMSIdentifiableDescriptor parent = MmsChildCreationWizard.this.parent;
valid = serverHelper.getProjects(parent.id).stream().noneMatch(p -> p.id.contentEquals(id.getText()));
if (valid) {
nd = new MMSProjectDescriptor();
}
break;
}
break;
case Ref:
MMSIdentifiableDescriptor parent = MmsChildCreationWizard.this.parent;
valid = serverHelper.getBranches((parent instanceof MMSProjectDescriptor) ? ((MMSProjectDescriptor) parent).org : null, parent.id).stream()
.noneMatch(b -> b.id.contentEquals(id.getText()));
if(valid) {
nd = new MMSRefDescriptor();
case Ref: {
MMSIdentifiableDescriptor parent = MmsChildCreationWizard.this.parent;
valid = serverHelper.getBranches((parent instanceof MMSProjectDescriptor) ? ((MMSProjectDescriptor) parent).orgId : null, parent.id).stream()
.noneMatch(b -> b.id.contentEquals(id.getText()));
if (valid) {
nd = new MMSRefDescriptor();
}
break;
}
break;
}
if(valid) {

if (valid) {
nd.id = id.getText();
nd.name = name.getText().matches(VALIDATION_PATTERN_NAME) ? id.getText() : name.getText();
preparedChild.set(nd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class MmsServerConnectionPage extends WizardPage {
private Text serverName;
private String defaultName = null;
private String defaultUrl = null;
private String defaultAPIVersion = null;
private String defaultUser = null;
private String defaultPassword = null;

Expand Down Expand Up @@ -67,6 +68,9 @@ public void createControl(Composite parent) {
if(defaultUrl != null) {
connection.setUrl(defaultUrl);
}
if(defaultAPIVersion != null) {
connection.setAPIVersion(defaultAPIVersion);
}
if(defaultUser != null) {
connection.setUser(defaultUser);
}
Expand All @@ -88,6 +92,10 @@ public MMSServerDescriptor getConnectionData() {
public String getUrl() {
return connection.getUrl();
}

public String getAPIVersion() {
return connection.getAPIVersion();
}

public String getUser() {
return connection.getUser();
Expand All @@ -100,6 +108,10 @@ public String getPassword() {
public void setDefaultUrl(String url) {
defaultUrl = url;
}

public void setDefaultAPIVersion(String apiVersion) {
defaultAPIVersion = apiVersion;
}

public void setDefaultUser(String user) {
defaultUser = user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ public void addPages() {
} catch (IllegalArgumentException e) {}
connectionPage.setDefaultName(server.name);
connectionPage.setDefaultUrl(server.url);
connectionPage.setDefaultAPIVersion(server.apiVersion);
}

@Override
public boolean performFinish() {
MMSServerDescriptor connectionData = connectionPage.getConnectionData();
boolean success = connectionData != null;
if(success) {
connectionDataModified = !server.url.contentEquals(connectionData.url) ||
connectionDataModified = !server.url.contentEquals(connectionData.url) ||
server.apiVersion == null ||
!server.apiVersion.contentEquals(connectionData.apiVersion) ||
!server.autData.contentEquals(connectionData.autData);
success = connectionDataModified || !server.name.contentEquals(connectionData.name);
if(success) {
Expand All @@ -56,6 +59,7 @@ public boolean performFinish() {
plugin.removeStoredMMSServerDescriptor(server);
server.id = connectionData.id;
server.url = connectionData.url;
server.apiVersion = connectionData.apiVersion;
server.autData = connectionData.autData;
server.name = connectionData.name;
plugin.addStoredMMSServerDescriptor(server);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public MmsRepositoriesView() {

protected void retrieveViewerData() {
MMSRepositoryViewRoot mmsRoot = new MMSRepositoryViewRoot();
mmsRoot.id = "root";
mmsRoot.id = "root"; //$NON-NLS-1$
viewerDataRoot = new MMSTreeParent(mmsRoot);
MMSServerDescriptor[] storedMMSServerDescriptors = MmsServerManagementUiPlugin.getInstance().getStoredMMSServerDescriptors();
if(storedMMSServerDescriptors != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void run() {
dialog.run(true, true, new ImportRunnable(
new AtomicReference<ExecutionResult>(),
new MmsProjectImportData(
new MmsConnectionData(server.url, server.autData, org.id),
new MmsConnectionData(server.url, server.apiVersion, server.autData, org.id),
project.id, ref.id,
commit == null ? null : commit.id),
project.clientSideName, m -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private ExecutionResult executeExport(IProject selectedProject, MmsProjectCommit

if(connectionData != null && selectedProject != null) {
try {
MMSServerHelper serverHelper = new MMSServerHelper(connectionData.serverUrl, connectionData.autData);
MMSServerHelper serverHelper = new MMSServerHelper(connectionData.serverUrl, connectionData.apiVersion, connectionData.autData);
SiriusProjectConnector projectConnector = new SiriusProjectConnector();
monitor.beginTask("Export to MMS", 2+projectConnector.getNumberOfSubTaskOfToMms()); //$NON-NLS-1$

Expand All @@ -196,11 +196,10 @@ private ExecutionResult executeExport(IProject selectedProject, MmsProjectCommit
connectionData.projectId,
connectionData.projectServerName,
selectedProject.getName());
organizationId = project.org;
organizationId = project.orgId;
projectId = project.id;
projectFeaturePrefix = project.featurePrefix;
MMSRefDescriptor ref = serverHelper.getOrCreateBranch(project.org, project.id,
MMSServerHelper.MMS_REF__DEFAULT);
MMSRefDescriptor ref = serverHelper.getOrCreateBranch(project.orgId, project.id, MMSServerHelper.MMS_REF__DEFAULT);
refId = ref.id;
} else {
// otherwise use the caught data
Expand All @@ -211,7 +210,7 @@ private ExecutionResult executeExport(IProject selectedProject, MmsProjectCommit
}
monitor.worked(1);

// collect convertable resources
// collect convertible resources
if(monitor.isCanceled()) {
throw new InterruptedException(SiriusProjectConnector.MESSAGE_CANCELLATION_EXPORT);
}
Expand All @@ -224,7 +223,8 @@ private ExecutionResult executeExport(IProject selectedProject, MmsProjectCommit
throw new InterruptedException(SiriusProjectConnector.MESSAGE_CANCELLATION_EXPORT);
}
if(siriusModelFiles.size()>1) {
success = projectConnector.toMms(connectionData.serverUrl,
success = projectConnector.toMms(connectionData.serverUrl,
connectionData.apiVersion,
connectionData.autData,
organizationId,
projectId,
Expand Down
Loading

0 comments on commit 64d5060

Please sign in to comment.