Home » Modeling » EMF Diff/Merge » How do I force the merge of all attributes in a UML file?
| |
Re: How do I force the merge of all attributes in a UML file? [message #1728057 is a reply to message #1728045] |
Wed, 30 March 2016 16:20 |
Wesley Klewerton Messages: 11 Registered: March 2016 |
Junior Member |
|
|
My environment is:
Eclipse Modeling Tools, Version: Kepler Service Release 2, Build id: 20140224-0627
EMF-DiffMerge-0.5.0.v20150608-0931
mdt-uml2-Update-5.1.2
Here is the code I am using:
IEditableModelScope referenceScope = new FragmentedModelScope(reference, false);
IEditableModelScope targetScope = new FragmentedModelScope(target, false);
IComparison comparison = new EComparisonImpl(targetScope, referenceScope);
comparison.compute(null, null, null, null);
Collection<IDifference> diffsReference = comparison.getDifferences(Role.REFERENCE);
Collection<IDifference> diffs = comparison.merge(diffsReference, Role.TARGET, true, null);
Attached you will find an image with the differences between the two UML files.
|
|
| | | |
Re: How do I force the merge of all attributes in a UML file? [message #1728596 is a reply to message #1728572] |
Tue, 05 April 2016 17:27 |
Wesley Klewerton Messages: 11 Registered: March 2016 |
Junior Member |
|
|
To test if it is working I got the EObject from differences I have. I've used the following code:
comparison.compute(null, null, null, null);
Collection<IDifference> diffsReference = comparison.getDifferences(Role.REFERENCE);
for (IDifference d : diffsReference) {
System.out.print("Current: ");
System.out.println( ((AnyTypeImpl) ((EElementPresenceImpl)d).getElement()).toString() );
EObject myCopy = EcoreUtil.copy( ((EElementPresenceImpl)d).getElement() );
System.out.print("copy: ");
System.out.println( myCopy.toString() );
}
An excerpt of the output:
Current: org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@44d52de2 (mixed: [ecore.xml.type:text=
, ownedParameter=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@95e33cc (mixed: [], anyAttribute: [name=amount, type=__EEsJH-OEeO41f7pJZDqVw]), ecore.xml.type:text=
], anyAttribute: [name=withdrawWithoutLimit])
copy: org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@61fe30 (mixed: [ecore.xml.type:text=
, ownedParameter=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@c9d0d6 (mixed: [], anyAttribute: [name=amount, type=__EEsJH-OEeO41f7pJZDqVw]), ecore.xml.type:text=
], anyAttribute: [name=withdrawWithoutLimit])
It copies all the properties.
|
|
| | | | | |
Re: How do I force the merge of all attributes in a UML file? [message #1731563 is a reply to message #1729570] |
Fri, 06 May 2016 19:27 |
Wesley Klewerton Messages: 11 Registered: March 2016 |
Junior Member |
|
|
I have tryed to load the model using the instructions you recomend, but it is still not working.
Whe I use the following piece of code (UMLResource) it returns an exception: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://www.eclipse.org/uml2/4.0.0/UML' not found. (file:///home/wesley/workspaceMars/br.ufpr.inf.gres.ModelMerge/model/Bank_1.uml, 2, 179)
try {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI("jar:file:/home/wesley/eclipseMars/plugins/org.eclipse.uml2.uml.resources_5.1.0.v20160201-0816.jar!/");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
UMLResource resource = new UMLResourceImpl(uriModel);
resource.load(uriMap);
return resource;
} catch (Exception e) {
e.printStackTrace();
return null;
}
When I use the Resouce class it return elements of org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl.
try {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI("jar:file:/home/wesley/eclipseMars/plugins/org.eclipse.uml2.uml.resources_5.1.0.v20160201-0816.jar!/");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
Resource resource = resourceSet.getResource(uriModel, true);
resource.load(uriMap);
return resource;
} catch (Exception e) {
e.printStackTrace();
return null;
}
The above code returns:
org.eclipse.uml2.uml.internal.resource.UMLResourceImpl@305ffe9e uri='model/Bank_1.uml'
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@15043a2f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@4a83a74a (name: Model) (instanceClassName: null) (abstract: false, interface: false)) (mixed: [ecore.xml.type:text=...
|
|
| | |
Goto Forum:
Current Time: Wed Sep 25 21:08:02 GMT 2024
Powered by FUDForum. Page generated in 0.05375 seconds
|