Skip to content

Commit

Permalink
fixes import
Browse files Browse the repository at this point in the history
Fixes issues with import
  • Loading branch information
etiennebrosse committed Jun 15, 2022
1 parent 60474cb commit e95ebc8
Show file tree
Hide file tree
Showing 20 changed files with 316 additions and 117 deletions.
75 changes: 75 additions & 0 deletions src/main/conf/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,81 @@
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/com.google.guava-21.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.core-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe2.runtime-2.9.1-SNAPSHOT.jar"/>
<PathEntry path="lib/org.eclipse.emf.mwe.utils-1.3.21-SNAPSHOT.jar"/>
<PathEntry path="lib/CamelDSLExporter-3.0.0-SNAPSHOT.jar"/>
<PathEntry path="lib/gson-2.7.jar"/>
<PathEntry path="lib/inject-3.0.0.jar"/>
<PathEntry path="lib/registry-3.7.0.jar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import java.util.Map;
import com.modeliosoft.modelio.javadesigner.annotations.objid;
import fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.CamelElement;
import fr.softeam.cameldesigner.exchange.exporter.GenerateProcess;
import org.eclipse.emf.cdo.CDOObject;
import org.modelio.metamodel.uml.statik.Package;
import camel.core.CamelModel;
import fr.softeam.cameldesigner.exchange.walker.CamelWalker;
import fr.softeam.cameldesigner.exchange.walker.IWalker;
import fr.softeam.cameldesigner.exchange.walker.UmlWalker;
import fr.softeam.cameldesigner.impl.CamelDesignerModule;

@objid ("acd66265-f660-48ff-a105-5a526a8cf126")
Expand All @@ -28,49 +29,52 @@ public AbstractImporterService(Map<String, Boolean> options, String fileExtensio
this._fileExtension = fileExtension;
}

@objid ("ca80b229-66ad-4f42-b548-ae2feea0296c")
public void importFromFile(fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel root, String filePath) {
ImportMap impMap = ImportMap.getInstance();
impMap.clear();

// CamelModel camelModel = createCamelModelRoot(camelUMLModel, impMap);
@objid ("c193b036-5cad-4b90-b6af-ec22d0ecb154")
protected abstract CamelModel importCamel(String filePath);

GenerateProcess generateProcess = new GenerateProcess(null);
try {
IWalker<CamelElement> umlWalker = new UmlWalker(generateProcess);
umlWalker.walk(root);
}catch(Exception e) {
CamelDesignerModule.logService.error(e);
}

this.importCamel(root, filePath);
}
private fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel createCamelModelRoot(CamelModel rootProxy, Package root) {

@objid ("c193b036-5cad-4b90-b6af-ec22d0ecb154")
protected abstract void importCamel(fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel root, String filePath);
//Creates root Camel Model
fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel camelModel = fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel.create();
camelModel.setName(rootProxy.getName());

root.getOwnedElement().add(camelModel.getElement());

// private CamelModel createCamelModelRoot(CamelModel rootProxy, ImportMap genMap) {
// //Creates root Camel Model
// fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel camelModel = CoreFactory.eINSTANCE.createCamelModel();
// camelModel.setName(rootProxy.getElement().getName());
//
// //Creates Application
//Creates Application
// Application application = CoreFactory.eINSTANCE.createApplication();
// application.setName(rootProxy.getApplicationName());
// application.setVersion(rootProxy.getApplicationVersion());
// camelModel.setApplication(application);
//
// //Adds Library
//// Package root = CamelDesignerModule.getInstance().getModuleContext().getModelingSession().findElementById(Package.class, this._rootID);
//// for (ModelTree ownedElt : root.getOwnedElement()) {
//// if (ownedElt.isStereotyped(CamelDesignerPeerModule.MODULE_NAME, fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel.STEREOTYPE_NAME)) {
//// genMap.put(ownedElt, camelModel);
//// }
//// }
//

//Adds Library
// Package root = CamelDesignerModule.getInstance().getModuleContext().getModelingSession().findElementById(Package.class, this._rootID);
// for (ModelTree ownedElt : root.getOwnedElement()) {
// if (ownedElt.isStereotyped(CamelDesignerPeerModule.MODULE_NAME, fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel.STEREOTYPE_NAME)) {
// genMap.put(ownedElt, camelModel);
// }
// }

// genMap.put(camelModel ) ;
// return camelModel;
// }
return camelModel;
}

public void importFromFile(Package selectedElt, String absolutePath) {
ImportMap impMap = ImportMap.getInstance();
impMap.clear();

CamelModel camelModel = this.importCamel(absolutePath);

fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel impCamelModel = createCamelModelRoot(camelModel, selectedElt);
impMap.put(camelModel, impCamelModel);

ImportProcess importProcess = new ImportProcess(null);
try {
IWalker<CDOObject> camelWalker = new CamelWalker(importProcess);
camelWalker.walk(camelModel);
}catch(Exception e) {
CamelDesignerModule.logService.error(e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package fr.softeam.cameldesigner.exchange.importer;

import java.util.HashMap;
import com.google.inject.Injector;
import com.modeliosoft.modelio.javadesigner.annotations.objid;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import camel.core.CamelModel;
import camel.core.CorePackage;
import fr.softeam.cameldesigner.conversion.CamelDslManager;

@objid ("9b36fd5d-a0af-44b9-adad-7533e3d21178")
public class CamelImporterService extends AbstractImporterService {
Expand All @@ -17,7 +24,14 @@ public CamelImporterService() {

@objid ("59f2b81a-edef-4e53-9a6d-261ba285ac80")
@Override
protected void importCamel(fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel camelModel, String filePath) {
protected CamelModel importCamel(String filePath) {
Injector injector = CamelDslManager.getInstance().getInjector();

XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.getPackageRegistry().put(CorePackage.eNS_URI, CorePackage.eINSTANCE);
resourceSet.addLoadOption(this.loadOption, Boolean.TRUE);
Resource resource = resourceSet.getResource(URI.createFileURI(filePath), true);
return(CamelModel) resource.getContents().get(0);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package fr.softeam.cameldesigner.exchange.importer;

import org.eclipse.emf.cdo.CDOObject;
import camel.core.CamelModel;
import camel.core.Feature;
import camel.core.Model;
import camel.core.NamedElement;
import camel.mms.MetaDataModel;
import camel.mms.MmsConcept;
import camel.mms.MmsObject;
import fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.CamelElement;
import fr.softeam.cameldesigner.exchange.importer.core.CamelElementImporter;
import fr.softeam.cameldesigner.exchange.importer.core.CamelModelImporter;
import fr.softeam.cameldesigner.exchange.importer.core.FeatureImporter;
import fr.softeam.cameldesigner.exchange.importer.core.NamedElementImporter;
import fr.softeam.cameldesigner.exchange.importer.core.SubModelImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MetaDataModelImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsConceptImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsObjectImporter;

public interface ICamelImporterVisitor {


Object visitFeature(FeatureImporter<? extends Feature, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature> feature);

Object visitCamelElement(CamelElementImporter<? extends CDOObject, ? extends CDOObject, ? extends CamelElement, ? extends CamelElement> camelElt);

Object visitCamelModel(CamelModelImporter<? extends CamelModel, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature> camelModel);

Object visitMetaDataModel(MetaDataModelImporter<? extends MetaDataModel, ? extends CamelModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel, ? extends fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel> metaDataModel);

Object visitMmsConcept(MmsConceptImporter<? extends MmsConcept, ? extends MetaDataModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.class_.MmsConcept, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel> mmsConcept);

Object visitMmsObject(MmsObjectImporter<? extends MmsObject, ? extends MetaDataModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.infrastructure.modelelement.MmsObject, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel> model);

Object visitModel(SubModelImporter<? extends Model, ? extends Feature, ? extends CamelElement, ? extends CamelElement> model);

Object visitNamedElement(NamedElementImporter<? extends NamedElement, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.NamedElement, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.NamedElement> namedElement);



}
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,25 @@
import camel.mms.MetaDataModel;
import camel.mms.MmsConcept;
import camel.mms.MmsObject;
import fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.CamelElement;
import fr.softeam.cameldesigner.exchange.importer.core.CamelElementImporter;
import fr.softeam.cameldesigner.exchange.importer.core.CamelModelImporter;
import fr.softeam.cameldesigner.exchange.importer.core.FeatureImporter;
import fr.softeam.cameldesigner.exchange.importer.core.NamedElementImporter;
import fr.softeam.cameldesigner.exchange.importer.core.SubModelImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MetaDataModelImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsConceptImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsObjectImporter;

public interface ICamelVisitor {


Object visitFeature(FeatureImporter<? extends Feature, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature> feature);
Object visitFeature(Feature feature);

Object visitCamelElement(CamelElementImporter<? extends CDOObject, ? extends CDOObject, ? extends CamelElement, ? extends CamelElement> camelElt);
Object visitCDOObject(CDOObject object);

Object visitCamelModel(CamelModelImporter<? extends CamelModel, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature> camelModel);
Object visitCamelModel(CamelModel camelModel);

Object visitMetaDataModel(MetaDataModelImporter<? extends MetaDataModel, ? extends CamelModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel, ? extends fr.softeam.cameldesigner.api.camelcore.standard.package_.CamelModel> metaDataModel);
Object visitMetaDataModel(MetaDataModel metaDataModel);

Object visitMmsConcept(MmsConceptImporter<? extends MmsConcept, ? extends MetaDataModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.class_.MmsConcept, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel> mmsConcept);
Object visitMmsConcept(MmsConcept mmsConcept);

Object visitMmsObject(MmsObjectImporter<? extends MmsObject, ? extends MetaDataModel, ? extends fr.softeam.cameldesigner.api.metadatamodel.infrastructure.modelelement.MmsObject, ? extends fr.softeam.cameldesigner.api.metadatamodel.standard.package_.MetaDataModel> model);
Object visitMmsObject(MmsObject mmsObject);

Object visitModel(SubModelImporter<? extends Model, ? extends Feature, ? extends CamelElement, ? extends CamelElement> model);
Object visitModel(Model model);

Object visitNamedElement(NamedElementImporter<? extends NamedElement, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.NamedElement, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.NamedElement> namedElement);
Object visitNamedElement(NamedElement namedElement);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsConceptImporter;
import fr.softeam.cameldesigner.exchange.importer.metadata.MmsObjectImporter;

public interface IDefaultCamelVisitor extends ICamelVisitor{
public interface IDefaultCamelVisitor extends ICamelImporterVisitor{

@Override
default Object visitFeature(FeatureImporter<? extends Feature, ? extends Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature, ? extends fr.softeam.cameldesigner.api.camelcore.infrastructure.modelelement.Feature> feature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public CamelElement process(CDOObject element, CDOObject context) {
ImportMap importMap = ImportMap.getInstance();

try {
CamelElementImporter importer = ImporterFactory.getImporter(element);
CamelElementImporter<CDOObject, CDOObject, CamelElement, CamelElement> importer = ImporterFactory.getImporter(element);
importer.setProcess(this);

if(importMap.containsKey(element)) {
processedElement = importMap.get(element);
} else {

CamelElement owner = importer.createCamelElt(context);
CamelElement owner = getElement(context);
processedElement = importer.createCamelElt(context);
importer.attach(processedElement, owner);
if(processedElement != null) {
importMap.put(element, processedElement);
Expand Down
Loading

0 comments on commit e95ebc8

Please sign in to comment.