Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Merging UML models
Merging UML models [message #119142] |
Sat, 19 April 2008 09:07 |
Sam Sabra Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Good day,
I'm trying to modify the standalone example by Cedric Brun (ExampleLauncher.java) to merge two UML models. I've managed to get
it to output the result.emfdiff difference file (while ignoring XMI IDs). When I try to merge, I get a
java.lang.NullPointerException at MergeService.merge(diff.getOwnedElements(), true); (see details below). Any ideas?
Thanks,
Sam
Here's the error:
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
at org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
at org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
at org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
at org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
Here's the essential code:
if (args.length == 2 && new File(args[0]).canRead() && new File(args[1]).canRead()) {
// Creates the resourceSet where we'll load the models
final ResourceSet resourceSet = new ResourceSetImpl();
UMLPackage umlPackage = UMLPackage.eINSTANCE;
resourceSet.getPackageRegistry().put(umlPackage.getNsURI(), umlPackage);
try {
// Loads the two models passed as arguments
final EObject model1 = ModelUtils.load(new File(args[0]), resourceSet);
final EObject model2 = ModelUtils.load(new File(args[1]), resourceSet);
Map<String,Object> options = new HashMap<String,Object>();
options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
// Creates the match then the diff model for those two models
final MatchModel match = MatchService.doMatch(model1, model2, options);
final DiffModel diff = DiffService.doDiff(match, false);
MergeService.merge(diff.getOwnedElements(), true); // line 77: java.lang.NullPointerException
// Prints the results
try {
System.out.println(ModelUtils.serialize(match));
System.out.println(ModelUtils.serialize(diff));
} catch (IOException e) {
e.printStackTrace();
}
// Serializes the result as "result.emfdiff" in the directory this class has been called from.
System.out.println("saving emfdiff as \"result.emfdiff\""); //$NON-NLS-1$
final ModelInputSnapshot snapshot = DiffFactory.eINSTANCE.createModelInputSnapshot();
snapshot.setDate(Calendar.getInstance().getTime());
snapshot.setMatch(match);
snapshot.setDiff(diff);
ModelUtils.save(snapshot, "result.emfdiff"); //$NON-NLS-1$
} catch (IOException e) {
// shouldn't be thrown
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
|
|
|
Re: Merging UML models [message #119338 is a reply to message #119142] |
Mon, 21 April 2008 08:15 |
|
This is a multi-part message in MIME format.
--------------020606000705040607050701
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Sam,
I wonder... Are you using EMF Compare's latest build or the code from
CVS? We fixed some problems within the merging API and some of the
lines from your stack no longer match with code lines so this issue
could already be fixed.
Could you update to the latest version of EMF Compare (we have a new
build ready if you use the built version) and check if the problem still
happens?
If the exception is still thrown, could you provide us the models you
compare (either through bugzilla (preferred) or mail)? This is a
potential problem of the generic differencing engine and we'd need to
confirm it.
Laurent Goubet
Obeo
Sam Sabra a
|
|
|
Re: Merging UML models [message #119414 is a reply to message #119338] |
Mon, 21 April 2008 19:28 |
Sam Sabra Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Laurent,
Thanks for the reply.
I've updated to the latest build and I got the same error with different
line numbers. Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
Regards,
Sam
laurent Goubet wrote:
> Sam,
>
> I wonder... Are you using EMF Compare's latest build or the code from
> CVS? We fixed some problems within the merging API and some of the
> lines from your stack no longer match with code lines so this issue
> could already be fixed.
>
> Could you update to the latest version of EMF Compare (we have a new
> build ready if you use the built version) and check if the problem still
> happens?
>
> If the exception is still thrown, could you provide us the models you
> compare (either through bugzilla (preferred) or mail)? This is a
> potential problem of the generic differencing engine and we'd need to
> confirm it.
>
> Laurent Goubet
> Obeo
>
> Sam Sabra a écrit :
>> Good day,
>>
>> I'm trying to modify the standalone example by Cedric Brun
>> (ExampleLauncher.java) to merge two UML models. I've managed to get it
>> to output the result.emfdiff difference file (while ignoring XMI IDs).
>> When I try to merge, I get a java.lang.NullPointerException at
>> MergeService.merge(diff.getOwnedElements(), true); (see details
>> below). Any ideas?
>>
>> Thanks,
>>
>> Sam
>>
>> Here's the error:
>>
>> Exception in thread "main" java.lang.NullPointerException
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>> at
>> org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>
>> Here's the essential code:
>>
>> if (args.length == 2 && new File(args[0]).canRead() && new
>> File(args[1]).canRead()) {
>> // Creates the resourceSet where we'll load the models
>> final ResourceSet resourceSet = new ResourceSetImpl();
>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>
>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(), umlPackage);
>>
>> try {
>> // Loads the two models passed as arguments
>> final EObject model1 = ModelUtils.load(new
>> File(args[0]), resourceSet);
>> final EObject model2 = ModelUtils.load(new
>> File(args[1]), resourceSet);
>>
>>
>> Map<String,Object> options = new
>> HashMap<String,Object>();
>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>
>> // Creates the match then the diff model for those two
>> models
>> final MatchModel match = MatchService.doMatch(model1,
>> model2, options);
>> final DiffModel diff = DiffService.doDiff(match, false);
>>
>> MergeService.merge(diff.getOwnedElements(), true); //
>> line 77: java.lang.NullPointerException
>>
>>
>> // Prints the results
>> try {
>> System.out.println(ModelUtils.serialize(match));
>> System.out.println(ModelUtils.serialize(diff));
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>> // Serializes the result as "result.emfdiff" in the
>> directory this class has been called from.
>> System.out.println("saving emfdiff as
>> \"result.emfdiff\""); //$NON-NLS-1$
>> final ModelInputSnapshot snapshot =
>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>> snapshot.setDate(Calendar.getInstance().getTime());
>> snapshot.setMatch(match);
>> snapshot.setDiff(diff);
>> ModelUtils.save(snapshot, "result.emfdiff");
>> //$NON-NLS-1$
>> } catch (IOException e) {
>> // shouldn't be thrown
>> e.printStackTrace();
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>> }
>>
>>
>>
>>
>>
>
|
|
|
Re: Merging UML models [message #119478 is a reply to message #119414] |
Tue, 22 April 2008 11:51 |
|
This is a multi-part message in MIME format.
--------------080609070400090401000107
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Sam,
Thanks for the feedback, this was indeed a bug on our side. This has
been fixed on CVS and will be included in the next integration build.
Laurent Goubet
Obeo
Sam Sabra a
|
|
|
Re: Merging UML models [message #119638 is a reply to message #119478] |
Wed, 23 April 2008 02:47 |
Sam Sabra Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Laurent,
Thank you for handling this quickly, excellent response time! Looking
forward to the next integration build.
Best regards,
Sam
laurent Goubet wrote:
> Sam,
>
> Thanks for the feedback, this was indeed a bug on our side. This has
> been fixed on CVS and will be included in the next integration build.
>
> Laurent Goubet
> Obeo
>
> Sam Sabra a écrit :
>> Laurent,
>>
>> Thanks for the reply.
>>
>> I've updated to the latest build and I got the same error with
>> different line numbers. Please see
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>
>> Regards,
>>
>> Sam
>>
>> laurent Goubet wrote:
>>> Sam,
>>>
>>> I wonder... Are you using EMF Compare's latest build or the code from
>>> CVS? We fixed some problems within the merging API and some of the
>>> lines from your stack no longer match with code lines so this issue
>>> could already be fixed.
>>>
>>> Could you update to the latest version of EMF Compare (we have a new
>>> build ready if you use the built version) and check if the problem
>>> still happens?
>>>
>>> If the exception is still thrown, could you provide us the models you
>>> compare (either through bugzilla (preferred) or mail)? This is a
>>> potential problem of the generic differencing engine and we'd need to
>>> confirm it.
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Sam Sabra a écrit :
>>>> Good day,
>>>>
>>>> I'm trying to modify the standalone example by Cedric Brun
>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>> below). Any ideas?
>>>>
>>>> Thanks,
>>>>
>>>> Sam
>>>>
>>>> Here's the error:
>>>>
>>>> Exception in thread "main" java.lang.NullPointerException
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>
>>>>
>>>> Here's the essential code:
>>>>
>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>> File(args[1]).canRead()) {
>>>> // Creates the resourceSet where we'll load the models
>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>
>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>> umlPackage);
>>>>
>>>> try {
>>>> // Loads the two models passed as arguments
>>>> final EObject model1 = ModelUtils.load(new
>>>> File(args[0]), resourceSet);
>>>> final EObject model2 = ModelUtils.load(new
>>>> File(args[1]), resourceSet);
>>>>
>>>>
>>>> Map<String,Object> options = new
>>>> HashMap<String,Object>();
>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>
>>>> // Creates the match then the diff model for those
>>>> two models
>>>> final MatchModel match =
>>>> MatchService.doMatch(model1, model2, options);
>>>> final DiffModel diff = DiffService.doDiff(match,
>>>> false);
>>>>
>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>> // line 77: java.lang.NullPointerException
>>>>
>>>>
>>>> // Prints the results
>>>> try {
>>>> System.out.println(ModelUtils.serialize(match));
>>>> System.out.println(ModelUtils.serialize(diff));
>>>> } catch (IOException e) {
>>>> e.printStackTrace();
>>>> }
>>>>
>>>> // Serializes the result as "result.emfdiff" in the
>>>> directory this class has been called from.
>>>> System.out.println("saving emfdiff as
>>>> \"result.emfdiff\""); //$NON-NLS-1$
>>>> final ModelInputSnapshot snapshot =
>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>> snapshot.setMatch(match);
>>>> snapshot.setDiff(diff);
>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>> //$NON-NLS-1$
>>>> } catch (IOException e) {
>>>> // shouldn't be thrown
>>>> e.printStackTrace();
>>>> } catch (InterruptedException e) {
>>>> e.printStackTrace();
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
|
|
|
Re: Merging UML models [message #119844 is a reply to message #119638] |
Thu, 24 April 2008 09:38 |
Cedric Brun Messages: 431 Registered: July 2009 |
Senior Member |
|
|
Hi Sam,
The new build is available here :
http://www.eclipse.org/modeling/emft/downloads/?project=comp are
regards,
Cédric
Sam Sabra wrote:
> Laurent,
>
> Thank you for handling this quickly, excellent response time! Looking
> forward to the next integration build.
>
> Best regards,
>
> Sam
>
> laurent Goubet wrote:
>> Sam,
>>
>> Thanks for the feedback, this was indeed a bug on our side. This has
>> been fixed on CVS and will be included in the next integration build.
>>
>> Laurent Goubet
>> Obeo
>>
>> Sam Sabra a écrit :
>>> Laurent,
>>>
>>> Thanks for the reply.
>>>
>>> I've updated to the latest build and I got the same error with
>>> different line numbers. Please see
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>
>>> Regards,
>>>
>>> Sam
>>>
>>> laurent Goubet wrote:
>>>> Sam,
>>>>
>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>> CVS? We fixed some problems within the merging API and some of the
>>>> lines from your stack no longer match with code lines so this issue
>>>> could already be fixed.
>>>>
>>>> Could you update to the latest version of EMF Compare (we have a new
>>>> build ready if you use the built version) and check if the problem
>>>> still happens?
>>>>
>>>> If the exception is still thrown, could you provide us the models you
>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>> potential problem of the generic differencing engine and we'd need to
>>>> confirm it.
>>>>
>>>> Laurent Goubet
>>>> Obeo
>>>>
>>>> Sam Sabra a écrit :
>>>>> Good day,
>>>>>
>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>> below). Any ideas?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Sam
>>>>>
>>>>> Here's the error:
>>>>>
>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>>
>>>>>
>>>>> Here's the essential code:
>>>>>
>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>> File(args[1]).canRead()) {
>>>>> // Creates the resourceSet where we'll load the models
>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>
>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>> umlPackage);
>>>>>
>>>>> try {
>>>>> // Loads the two models passed as arguments
>>>>> final EObject model1 = ModelUtils.load(new
>>>>> File(args[0]), resourceSet);
>>>>> final EObject model2 = ModelUtils.load(new
>>>>> File(args[1]), resourceSet);
>>>>>
>>>>>
>>>>> Map<String,Object> options = new
>>>>> HashMap<String,Object>();
>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>>
>>>>> // Creates the match then the diff model for those
>>>>> two models
>>>>> final MatchModel match =
>>>>> MatchService.doMatch(model1, model2, options);
>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>> false);
>>>>>
>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>> // line 77: java.lang.NullPointerException
>>>>>
>>>>>
>>>>> // Prints the results
>>>>> try {
>>>>> System.out.println(ModelUtils.serialize(match));
>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>> } catch (IOException e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>>
>>>>> // Serializes the result as "result.emfdiff" in the
>>>>> directory this class has been called from.
>>>>> System.out.println("saving emfdiff as
>>>>> \"result.emfdiff\""); //$NON-NLS-1$
>>>>> final ModelInputSnapshot snapshot =
>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>> snapshot.setMatch(match);
>>>>> snapshot.setDiff(diff);
>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>> //$NON-NLS-1$
>>>>> } catch (IOException e) {
>>>>> // shouldn't be thrown
>>>>> e.printStackTrace();
>>>>> } catch (InterruptedException e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
http://cedric.brun.io news and articles on eclipse and eclipse modeling.
|
|
|
Re: Merging UML models [message #122682 is a reply to message #119844] |
Mon, 19 May 2008 16:38 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Sam, Cedric,
I was having the same problem, and got the latest from the EMFT site. I
now have a new error, a ConcurrentModificationException which is a bit of
a mystery as there is nothing concurrent in what I am doing? The error is
below, I am working with EMF Compare 0.8.0v20080506. Any ideas?
Mark
java.util.ConcurrentModificationException
at
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
at
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
at
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
at
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
at test.Test.main(Test.java:39)
Cédric Brun wrote:
> Hi Sam,
> The new build is available here :
> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
> regards,
> Cédric
> Sam Sabra wrote:
>> Laurent,
>>
>> Thank you for handling this quickly, excellent response time! Looking
>> forward to the next integration build.
>>
>> Best regards,
>>
>> Sam
>>
>> laurent Goubet wrote:
>>> Sam,
>>>
>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>> been fixed on CVS and will be included in the next integration build.
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Sam Sabra a écrit :
>>>> Laurent,
>>>>
>>>> Thanks for the reply.
>>>>
>>>> I've updated to the latest build and I got the same error with
>>>> different line numbers. Please see
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>
>>>> Regards,
>>>>
>>>> Sam
>>>>
>>>> laurent Goubet wrote:
>>>>> Sam,
>>>>>
>>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>> lines from your stack no longer match with code lines so this issue
>>>>> could already be fixed.
>>>>>
>>>>> Could you update to the latest version of EMF Compare (we have a new
>>>>> build ready if you use the built version) and check if the problem
>>>>> still happens?
>>>>>
>>>>> If the exception is still thrown, could you provide us the models you
>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>> potential problem of the generic differencing engine and we'd need to
>>>>> confirm it.
>>>>>
>>>>> Laurent Goubet
>>>>> Obeo
>>>>>
>>>>> Sam Sabra a écrit :
>>>>>> Good day,
>>>>>>
>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>> below). Any ideas?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> Here's the error:
>>>>>>
>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>>>
>>>>>>
>>>>>> Here's the essential code:
>>>>>>
>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>> File(args[1]).canRead()) {
>>>>>> // Creates the resourceSet where we'll load the models
>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>
>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>> umlPackage);
>>>>>>
>>>>>> try {
>>>>>> // Loads the two models passed as arguments
>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>> File(args[0]), resourceSet);
>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>> File(args[1]), resourceSet);
>>>>>>
>>>>>>
>>>>>> Map<String,Object> options = new
>>>>>> HashMap<String,Object>();
>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>>>
>>>>>> // Creates the match then the diff model for those
>>>>>> two models
>>>>>> final MatchModel match =
>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>> false);
>>>>>>
>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>> // line 77: java.lang.NullPointerException
>>>>>>
>>>>>>
>>>>>> // Prints the results
>>>>>> try {
>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>> } catch (IOException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>>
>>>>>> // Serializes the result as "result.emfdiff" in the
>>>>>> directory this class has been called from.
>>>>>> System.out.println("saving emfdiff as
>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>> final ModelInputSnapshot snapshot =
>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>> snapshot.setMatch(match);
>>>>>> snapshot.setDiff(diff);
>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>> //$NON-NLS-1$
>>>>>> } catch (IOException e) {
>>>>>> // shouldn't be thrown
>>>>>> e.printStackTrace();
>>>>>> } catch (InterruptedException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
|
|
|
Re: Merging UML models [message #122692 is a reply to message #122682] |
Tue, 20 May 2008 07:08 |
|
This is a multi-part message in MIME format.
--------------060403030008040902080707
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
Here is the javadoc for MergeService#merge(List, boolean) which you are
calling in your code :
/**
* Merges a list of DiffElements in the direction specified by
<code>leftToRight</code>.
* <p>
* Will notify the list of its merge listeners before, and after the
operation.
* </p>
*
* @param elements
* {@link DiffElement}s containing the information to merge.
* @param leftToRight
* <code>True</code> if the changes must be applied from the
left to the right model,
* <code>False</code> when they have to be applied the other
way around.
* @throws ConcurrentModificationException
* Could be thrown if the list you give is directly a
reference from the meta model such as
* {@link DiffModel#getOwnedElements()} or {@link
DiffElement#getSubDiffElements()}. Copy the
* list before merging it.
*/
So yes, a ConcurrentModificationException *can* be thrown as the model
will be modified when using merge operations. Simply create a new List
containing all the elements to be merged to avoid these exceptions.
Laurent Goubet
Obeo
Mark Melia a
|
|
|
Re: Merging UML models [message #122697 is a reply to message #122692] |
Tue, 20 May 2008 11:09 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
Ok - I think I am nearly there - and thanks again for all your help. I
have the code running ok (well appears to be), but the models do not
change - there is no merge of one model into another (am I missing
something)?
I have pasted the code below and I think it should work as when i iterate
the diffElements I get:
org.eclipse.emf.compare.diff.metamodel.impl.DiffGroupImpl@12b3d53
(conflicting: false, kind: Addition)
Any ideas - thanks :)?
Mark
ps If you want to see the models I can paste the XMI in.
public static void main(String[] args) {
try {
EPackage model = (EPackage)ModelUtils.load(new
File("/home/mmelia/workspace3/AATest/model/A.ecore"), new
ResourceSetImpl());
EPackage.Registry.INSTANCE.put("http://dcu.ie/#A", model);
Resource model1 = ModelUtils.load(new
File("/home/mmelia/workspace3/AATest/model/B.ecore"), new
ResourceSetImpl()).eResource();
Resource model2 =
ModelUtils.load(URI.createFileURI("/home/mmelia/workspace3/AATest/model/C.ecore "),new
ResourceSetImpl()).eResource();
final MatchModel match = MatchService.doResourceMatch(model1, model2,
null);
// Detects differences
final DiffModel diff = DiffService.doDiff(match);
// Merges all differences from model1 to model2
EList<DiffElement> el = new BasicEList
<DiffElement>(diff.getOwnedElements());
MergeService.merge(el, true);
Iterator itr = el.iterator();
while(itr.hasNext()){
Object diffElement = itr.next();
DiffElement d = (org.eclipse.emf.compare.diff.metamodel.DiffElement)
diffElement;
System.out.println("here "+ d);
while(d.eContents().iterator().hasNext()){
EObject o = (EObject)d.eContents().iterator().next();
System.out.println(o);
}
}
} catch (Exception exception) {
exception.printStackTrace();
laurent Goubet wrote:
> Mark,
> Here is the javadoc for MergeService#merge(List, boolean) which you are
> calling in your code :
> /**
> * Merges a list of DiffElements in the direction specified by
> <code>leftToRight</code>.
> * <p>
> * Will notify the list of its merge listeners before, and after the
> operation.
> * </p>
> *
> * @param elements
> * {@link DiffElement}s containing the information to merge.
> * @param leftToRight
> * <code>True</code> if the changes must be applied from the
> left to the right model,
> * <code>False</code> when they have to be applied the other
> way around.
> * @throws ConcurrentModificationException
> * Could be thrown if the list you give is directly a
> reference from the meta model such as
> * {@link DiffModel#getOwnedElements()} or {@link
> DiffElement#getSubDiffElements()}. Copy the
> * list before merging it.
> */
> So yes, a ConcurrentModificationException *can* be thrown as the model
> will be modified when using merge operations. Simply create a new List
> containing all the elements to be merged to avoid these exceptions.
> Laurent Goubet
> Obeo
> Mark Melia a écrit :
>> Hi Sam, Cedric,
>>
>> I was having the same problem, and got the latest from the EMFT site. I
>> now have a new error, a ConcurrentModificationException which is a bit
>> of a mystery as there is nothing concurrent in what I am doing? The
>> error is below, I am working with EMF Compare 0.8.0v20080506. Any ideas?
>>
>> Mark
>>
>> java.util.ConcurrentModificationException
>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
>>
>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
>>
>> at
>> org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
>> at
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
>>
>> at test.Test.main(Test.java:39)
>>
>> Cédric Brun wrote:
>>
>>> Hi Sam,
>>
>>> The new build is available here :
>>
>>> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
>>
>>> regards,
>>
>>> Cédric
>>
>>> Sam Sabra wrote:
>>
>>>> Laurent,
>>>>
>>>> Thank you for handling this quickly, excellent response time! Looking
>>>> forward to the next integration build.
>>>>
>>>> Best regards,
>>>>
>>>> Sam
>>>>
>>>> laurent Goubet wrote:
>>>>> Sam,
>>>>>
>>>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>>>> been fixed on CVS and will be included in the next integration build.
>>>>>
>>>>> Laurent Goubet
>>>>> Obeo
>>>>>
>>>>> Sam Sabra a écrit :
>>>>>> Laurent,
>>>>>>
>>>>>> Thanks for the reply.
>>>>>>
>>>>>> I've updated to the latest build and I got the same error with
>>>>>> different line numbers. Please see
>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> laurent Goubet wrote:
>>>>>>> Sam,
>>>>>>>
>>>>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>>>> lines from your stack no longer match with code lines so this issue
>>>>>>> could already be fixed.
>>>>>>>
>>>>>>> Could you update to the latest version of EMF Compare (we have a new
>>>>>>> build ready if you use the built version) and check if the problem
>>>>>>> still happens?
>>>>>>>
>>>>>>> If the exception is still thrown, could you provide us the models you
>>>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>>>> potential problem of the generic differencing engine and we'd need to
>>>>>>> confirm it.
>>>>>>>
>>>>>>> Laurent Goubet
>>>>>>> Obeo
>>>>>>>
>>>>>>> Sam Sabra a écrit :
>>>>>>>> Good day,
>>>>>>>>
>>>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>>>> below). Any ideas?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Sam
>>>>>>>>
>>>>>>>> Here's the error:
>>>>>>>>
>>>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Here's the essential code:
>>>>>>>>
>>>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>>>> File(args[1]).canRead()) {
>>>>>>>> // Creates the resourceSet where we'll load the models
>>>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>>>
>>>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>>>> umlPackage);
>>>>>>>>
>>>>>>>> try {
>>>>>>>> // Loads the two models passed as arguments
>>>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>>>> File(args[0]), resourceSet);
>>>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>>>> File(args[1]), resourceSet);
>>>>>>>>
>>>>>>>>
>>>>>>>> Map<String,Object> options = new
>>>>>>>> HashMap<String,Object>();
>>>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>>>>>> true);
>>>>>>>>
>>>>>>>> // Creates the match then the diff model for those
>>>>>>>> two models
>>>>>>>> final MatchModel match =
>>>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>>>> false);
>>>>>>>>
>>>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>>>> // line 77: java.lang.NullPointerException
>>>>>>>>
>>>>>>>>
>>>>>>>> // Prints the results
>>>>>>>> try {
>>>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>>>> } catch (IOException e) {
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>>
>>>>>>>> // Serializes the result as "result.emfdiff" in the
>>>>>>>> directory this class has been called from.
>>>>>>>> System.out.println("saving emfdiff as
>>>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>>>> final ModelInputSnapshot snapshot =
>>>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>>>> snapshot.setMatch(match);
>>>>>>>> snapshot.setDiff(diff);
>>>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>>>> //$NON-NLS-1$
>>>>>>>> } catch (IOException e) {
>>>>>>>> // shouldn't be thrown
>>>>>>>> e.printStackTrace();
>>>>>>>> } catch (InterruptedException e) {
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>
>>
|
|
|
Re: Merging UML models [message #122704 is a reply to message #122697] |
Tue, 20 May 2008 11:24 |
|
This is a multi-part message in MIME format.
--------------010308070404050207040107
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
You will need to save the merged model. Simply put the following line
before the end of your try/catch :
model2.save(Collections.emptyMap());
Laurent Goubet
Obeo
Mark Melia a
|
|
|
Re: Merging UML models [message #122710 is a reply to message #122704] |
Tue, 20 May 2008 12:31 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
Thanks for that, it now saves a new model, but the model seems to just be
model1 copied to model2. I am wondering if I am using the right classes,
as I see there are two MergeService classes for EMF compare. I have copied
my import statements - are all these the correct classes to be using?
Apologies for not getting this - and thanks for your patience.
Mark
import org.eclipse.emf.compare.diff.merge.service.MergeService;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.DiffModel;
import org.eclipse.emf.compare.diff.service.DiffService;
import org.eclipse.emf.compare.match.metamodel.MatchModel;
import org.eclipse.emf.compare.match.service.MatchService;
import org.eclipse.emf.compare.util.ModelUtils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI
laurent Goubet wrote:
> Mark,
> You will need to save the merged model. Simply put the following line
> before the end of your try/catch :
> model2.save(Collections.emptyMap());
> Laurent Goubet
> Obeo
> Mark Melia a écrit :
>> Hi Laurent,
>>
>> Ok - I think I am nearly there - and thanks again for all your help. I
>> have the code running ok (well appears to be), but the models do not
>> change - there is no merge of one model into another (am I missing
>> something)?
>>
>> I have pasted the code below and I think it should work as when i
>> iterate the diffElements I get:
>> org.eclipse.emf.compare.diff.metamodel.impl.DiffGroupImpl@12b3d53
>> (conflicting: false, kind: Addition)
>>
>> Any ideas - thanks :)?
>>
>> Mark
>>
>> ps If you want to see the models I can paste the XMI in.
>>
>> public static void main(String[] args) {
>> try {
>> EPackage model = (EPackage)ModelUtils.load(new
>> File("/home/mmelia/workspace3/AATest/model/A.ecore"), new
>> ResourceSetImpl());
>> EPackage.Registry.INSTANCE.put("http://dcu.ie/#A", model);
>> Resource model1 = ModelUtils.load(new
>> File("/home/mmelia/workspace3/AATest/model/B.ecore"), new
>> ResourceSetImpl()).eResource(); Resource model2 =
>>
ModelUtils.load(URI.createFileURI("/home/mmelia/workspace3/AATest/model/C.ecore "),new
>> ResourceSetImpl()).eResource();
>>
>> final MatchModel match =
>> MatchService.doResourceMatch(model1, model2, null);
>> // Detects differences
>> final DiffModel diff = DiffService.doDiff(match);
>> // Merges all differences from model1 to model2
>> EList<DiffElement> el = new BasicEList
>> <DiffElement>(diff.getOwnedElements());
>> MergeService.merge(el, true);
>> Iterator itr = el.iterator();
>> while(itr.hasNext()){
>>
>> Object diffElement = itr.next();
>> DiffElement d =
>> (org.eclipse.emf.compare.diff.metamodel.DiffElement) diffElement;
>> System.out.println("here "+ d);
>> while(d.eContents().iterator().hasNext()){
>> EObject o = (EObject)d.eContents().iterator().next();
>> System.out.println(o);
>> }
>> }
>>
>> } catch (Exception exception) {
>> exception.printStackTrace();
>>
>>
>> laurent Goubet wrote:
>>
>>> Mark,
>>
>>> Here is the javadoc for MergeService#merge(List, boolean) which you
>>> are calling in your code :
>>
>>> /**
>>> * Merges a list of DiffElements in the direction specified by
>>> <code>leftToRight</code>.
>>> * <p>
>>> * Will notify the list of its merge listeners before, and after the
>>> operation.
>>> * </p>
>>> *
>>> * @param elements
>>> * {@link DiffElement}s containing the information to merge.
>>> * @param leftToRight
>>> * <code>True</code> if the changes must be applied from
>>> the left to the right model,
>>> * <code>False</code> when they have to be applied the
>>> other way around.
>>> * @throws ConcurrentModificationException
>>> * Could be thrown if the list you give is directly a
>>> reference from the meta model such as
>>> * {@link DiffModel#getOwnedElements()} or {@link
>>> DiffElement#getSubDiffElements()}. Copy the
>>> * list before merging it.
>>> */
>>
>>> So yes, a ConcurrentModificationException *can* be thrown as the model
>>> will be modified when using merge operations. Simply create a new List
>>> containing all the elements to be merged to avoid these exceptions.
>>
>>> Laurent Goubet
>>> Obeo
>>
>>> Mark Melia a écrit :
>>>> Hi Sam, Cedric,
>>>>
>>>> I was having the same problem, and got the latest from the EMFT site.
>>>> I now have a new error, a ConcurrentModificationException which is a
>>>> bit of a mystery as there is nothing concurrent in what I am doing?
>>>> The error is below, I am working with EMF Compare 0.8.0v20080506. Any
>>>> ideas?
>>>>
>>>> Mark
>>>>
>>>> java.util.ConcurrentModificationException
>>>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
>>
>>>>
>>>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
>>
>>>>
>>>> at
>>>>
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
>>>>
>>>> at
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
>>
>>>>
>>>> at test.Test.main(Test.java:39)
>>>>
>>>> Cédric Brun wrote:
>>>>
>>>>> Hi Sam,
>>>>
>>>>> The new build is available here :
>>>>
>>>>> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
>>>>
>>>>> regards,
>>>>
>>>>> Cédric
>>>>
>>>>> Sam Sabra wrote:
>>>>
>>>>>> Laurent,
>>>>>>
>>>>>> Thank you for handling this quickly, excellent response time! Looking
>>>>>> forward to the next integration build.
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> laurent Goubet wrote:
>>>>>>> Sam,
>>>>>>>
>>>>>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>>>>>> been fixed on CVS and will be included in the next integration build.
>>>>>>>
>>>>>>> Laurent Goubet
>>>>>>> Obeo
>>>>>>>
>>>>>>> Sam Sabra a écrit :
>>>>>>>> Laurent,
>>>>>>>>
>>>>>>>> Thanks for the reply.
>>>>>>>>
>>>>>>>> I've updated to the latest build and I got the same error with
>>>>>>>> different line numbers. Please see
>>>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> Sam
>>>>>>>>
>>>>>>>> laurent Goubet wrote:
>>>>>>>>> Sam,
>>>>>>>>>
>>>>>>>>> I wonder... Are you using EMF Compare's latest build or the code
>>>>>>>>> from
>>>>>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>>>>>> lines from your stack no longer match with code lines so this issue
>>>>>>>>> could already be fixed.
>>>>>>>>>
>>>>>>>>> Could you update to the latest version of EMF Compare (we have a
>>>>>>>>> new
>>>>>>>>> build ready if you use the built version) and check if the problem
>>>>>>>>> still happens?
>>>>>>>>>
>>>>>>>>> If the exception is still thrown, could you provide us the
>>>>>>>>> models you
>>>>>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>>>>>> potential problem of the generic differencing engine and we'd
>>>>>>>>> need to
>>>>>>>>> confirm it.
>>>>>>>>>
>>>>>>>>> Laurent Goubet
>>>>>>>>> Obeo
>>>>>>>>>
>>>>>>>>> Sam Sabra a écrit :
>>>>>>>>>> Good day,
>>>>>>>>>>
>>>>>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to
>>>>>>>>>> get
>>>>>>>>>> it to output the result.emfdiff difference file (while ignoring
>>>>>>>>>> XMI
>>>>>>>>>> IDs). When I try to merge, I get a
>>>>>>>>>> java.lang.NullPointerException at
>>>>>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>>>>>> below). Any ideas?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>>
>>>>>>>>>> Sam
>>>>>>>>>>
>>>>>>>>>> Here's the error:
>>>>>>>>>>
>>>>>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Here's the essential code:
>>>>>>>>>>
>>>>>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>>>>>> File(args[1]).canRead()) {
>>>>>>>>>> // Creates the resourceSet where we'll load the models
>>>>>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>>>>>
>>>>>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>>>>>> umlPackage);
>>>>>>>>>>
>>>>>>>>>> try {
>>>>>>>>>> // Loads the two models passed as arguments
>>>>>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>>>>>> File(args[0]), resourceSet);
>>>>>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>>>>>> File(args[1]), resourceSet);
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Map<String,Object> options = new
>>>>>>>>>> HashMap<String,Object>();
>>>>>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>>>>>>>> true);
>>>>>>>>>>
>>>>>>>>>> // Creates the match then the diff model for those
>>>>>>>>>> two models
>>>>>>>>>> final MatchModel match =
>>>>>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>>>>>> false);
>>>>>>>>>>
>>>>>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>>>>>> // line 77: java.lang.NullPointerException
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> // Prints the results
>>>>>>>>>> try {
>>>>>>>>>>
>>>>>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>>>>>>
>>>>>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>>>>>> } catch (IOException e) {
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> // Serializes the result as "result.emfdiff" in
>>>>>>>>>> the
>>>>>>>>>> directory this class has been called from.
>>>>>>>>>> System.out.println("saving emfdiff as
>>>>>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>>>>>> final ModelInputSnapshot snapshot =
>>>>>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>>>>>>
>>>>>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>>>>>> snapshot.setMatch(match);
>>>>>>>>>> snapshot.setDiff(diff);
>>>>>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>>>>>> //$NON-NLS-1$
>>>>>>>>>> } catch (IOException e) {
>>>>>>>>>> // shouldn't be thrown
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> } catch (InterruptedException e) {
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Merging UML models [message #122715 is a reply to message #122710] |
Tue, 20 May 2008 12:42 |
|
This is a multi-part message in MIME format.
--------------070007000108040507010903
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
Obviously, if you copy *all* changes from model1 to model2 ... you will
get a copy of model1 as output. You have to filter out the differences
you want merged. If you simply wish to copy additions, only merge
AddModelElements, for deletions, RemoveModelElements... you will have to
take a look at the list of DiffElement you're merging to obtain the
expected result.
Cheers
Laurent Gobet
Obeo
Mark Melia a
|
|
|
Re: Merging UML models [message #617860 is a reply to message #119142] |
Mon, 21 April 2008 08:15 |
|
This is a multi-part message in MIME format.
--------------020606000705040607050701
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Sam,
I wonder... Are you using EMF Compare's latest build or the code from
CVS? We fixed some problems within the merging API and some of the
lines from your stack no longer match with code lines so this issue
could already be fixed.
Could you update to the latest version of EMF Compare (we have a new
build ready if you use the built version) and check if the problem still
happens?
If the exception is still thrown, could you provide us the models you
compare (either through bugzilla (preferred) or mail)? This is a
potential problem of the generic differencing engine and we'd need to
confirm it.
Laurent Goubet
Obeo
Sam Sabra a
|
|
|
Re: Merging UML models [message #617866 is a reply to message #119338] |
Mon, 21 April 2008 19:28 |
Sam Sabra Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Laurent,
Thanks for the reply.
I've updated to the latest build and I got the same error with different
line numbers. Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
Regards,
Sam
laurent Goubet wrote:
> Sam,
>
> I wonder... Are you using EMF Compare's latest build or the code from
> CVS? We fixed some problems within the merging API and some of the
> lines from your stack no longer match with code lines so this issue
> could already be fixed.
>
> Could you update to the latest version of EMF Compare (we have a new
> build ready if you use the built version) and check if the problem still
> happens?
>
> If the exception is still thrown, could you provide us the models you
> compare (either through bugzilla (preferred) or mail)? This is a
> potential problem of the generic differencing engine and we'd need to
> confirm it.
>
> Laurent Goubet
> Obeo
>
> Sam Sabra a écrit :
>> Good day,
>>
>> I'm trying to modify the standalone example by Cedric Brun
>> (ExampleLauncher.java) to merge two UML models. I've managed to get it
>> to output the result.emfdiff difference file (while ignoring XMI IDs).
>> When I try to merge, I get a java.lang.NullPointerException at
>> MergeService.merge(diff.getOwnedElements(), true); (see details
>> below). Any ideas?
>>
>> Thanks,
>>
>> Sam
>>
>> Here's the error:
>>
>> Exception in thread "main" java.lang.NullPointerException
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>> at
>> org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>> at
>> org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>
>> Here's the essential code:
>>
>> if (args.length == 2 && new File(args[0]).canRead() && new
>> File(args[1]).canRead()) {
>> // Creates the resourceSet where we'll load the models
>> final ResourceSet resourceSet = new ResourceSetImpl();
>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>
>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(), umlPackage);
>>
>> try {
>> // Loads the two models passed as arguments
>> final EObject model1 = ModelUtils.load(new
>> File(args[0]), resourceSet);
>> final EObject model2 = ModelUtils.load(new
>> File(args[1]), resourceSet);
>>
>>
>> Map<String,Object> options = new
>> HashMap<String,Object>();
>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>
>> // Creates the match then the diff model for those two
>> models
>> final MatchModel match = MatchService.doMatch(model1,
>> model2, options);
>> final DiffModel diff = DiffService.doDiff(match, false);
>>
>> MergeService.merge(diff.getOwnedElements(), true); //
>> line 77: java.lang.NullPointerException
>>
>>
>> // Prints the results
>> try {
>> System.out.println(ModelUtils.serialize(match));
>> System.out.println(ModelUtils.serialize(diff));
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>> // Serializes the result as "result.emfdiff" in the
>> directory this class has been called from.
>> System.out.println("saving emfdiff as
>> \"result.emfdiff\""); //$NON-NLS-1$
>> final ModelInputSnapshot snapshot =
>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>> snapshot.setDate(Calendar.getInstance().getTime());
>> snapshot.setMatch(match);
>> snapshot.setDiff(diff);
>> ModelUtils.save(snapshot, "result.emfdiff");
>> //$NON-NLS-1$
>> } catch (IOException e) {
>> // shouldn't be thrown
>> e.printStackTrace();
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>> }
>>
>>
>>
>>
>>
>
|
|
|
Re: Merging UML models [message #617871 is a reply to message #119414] |
Tue, 22 April 2008 11:51 |
|
This is a multi-part message in MIME format.
--------------080609070400090401000107
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Sam,
Thanks for the feedback, this was indeed a bug on our side. This has
been fixed on CVS and will be included in the next integration build.
Laurent Goubet
Obeo
Sam Sabra a
|
|
|
Re: Merging UML models [message #617883 is a reply to message #119478] |
Wed, 23 April 2008 02:47 |
Sam Sabra Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Laurent,
Thank you for handling this quickly, excellent response time! Looking
forward to the next integration build.
Best regards,
Sam
laurent Goubet wrote:
> Sam,
>
> Thanks for the feedback, this was indeed a bug on our side. This has
> been fixed on CVS and will be included in the next integration build.
>
> Laurent Goubet
> Obeo
>
> Sam Sabra a écrit :
>> Laurent,
>>
>> Thanks for the reply.
>>
>> I've updated to the latest build and I got the same error with
>> different line numbers. Please see
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>
>> Regards,
>>
>> Sam
>>
>> laurent Goubet wrote:
>>> Sam,
>>>
>>> I wonder... Are you using EMF Compare's latest build or the code from
>>> CVS? We fixed some problems within the merging API and some of the
>>> lines from your stack no longer match with code lines so this issue
>>> could already be fixed.
>>>
>>> Could you update to the latest version of EMF Compare (we have a new
>>> build ready if you use the built version) and check if the problem
>>> still happens?
>>>
>>> If the exception is still thrown, could you provide us the models you
>>> compare (either through bugzilla (preferred) or mail)? This is a
>>> potential problem of the generic differencing engine and we'd need to
>>> confirm it.
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Sam Sabra a écrit :
>>>> Good day,
>>>>
>>>> I'm trying to modify the standalone example by Cedric Brun
>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>> below). Any ideas?
>>>>
>>>> Thanks,
>>>>
>>>> Sam
>>>>
>>>> Here's the error:
>>>>
>>>> Exception in thread "main" java.lang.NullPointerException
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>
>>>> at
>>>> org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>
>>>>
>>>> Here's the essential code:
>>>>
>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>> File(args[1]).canRead()) {
>>>> // Creates the resourceSet where we'll load the models
>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>
>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>> umlPackage);
>>>>
>>>> try {
>>>> // Loads the two models passed as arguments
>>>> final EObject model1 = ModelUtils.load(new
>>>> File(args[0]), resourceSet);
>>>> final EObject model2 = ModelUtils.load(new
>>>> File(args[1]), resourceSet);
>>>>
>>>>
>>>> Map<String,Object> options = new
>>>> HashMap<String,Object>();
>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>
>>>> // Creates the match then the diff model for those
>>>> two models
>>>> final MatchModel match =
>>>> MatchService.doMatch(model1, model2, options);
>>>> final DiffModel diff = DiffService.doDiff(match,
>>>> false);
>>>>
>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>> // line 77: java.lang.NullPointerException
>>>>
>>>>
>>>> // Prints the results
>>>> try {
>>>> System.out.println(ModelUtils.serialize(match));
>>>> System.out.println(ModelUtils.serialize(diff));
>>>> } catch (IOException e) {
>>>> e.printStackTrace();
>>>> }
>>>>
>>>> // Serializes the result as "result.emfdiff" in the
>>>> directory this class has been called from.
>>>> System.out.println("saving emfdiff as
>>>> \"result.emfdiff\""); //$NON-NLS-1$
>>>> final ModelInputSnapshot snapshot =
>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>> snapshot.setMatch(match);
>>>> snapshot.setDiff(diff);
>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>> //$NON-NLS-1$
>>>> } catch (IOException e) {
>>>> // shouldn't be thrown
>>>> e.printStackTrace();
>>>> } catch (InterruptedException e) {
>>>> e.printStackTrace();
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
|
|
|
Re: Merging UML models [message #617899 is a reply to message #119638] |
Thu, 24 April 2008 09:38 |
Cedric Brun Messages: 431 Registered: July 2009 |
Senior Member |
|
|
Hi Sam,
The new build is available here :
http://www.eclipse.org/modeling/emft/downloads/?project=comp are
regards,
Cédric
Sam Sabra wrote:
> Laurent,
>
> Thank you for handling this quickly, excellent response time! Looking
> forward to the next integration build.
>
> Best regards,
>
> Sam
>
> laurent Goubet wrote:
>> Sam,
>>
>> Thanks for the feedback, this was indeed a bug on our side. This has
>> been fixed on CVS and will be included in the next integration build.
>>
>> Laurent Goubet
>> Obeo
>>
>> Sam Sabra a écrit :
>>> Laurent,
>>>
>>> Thanks for the reply.
>>>
>>> I've updated to the latest build and I got the same error with
>>> different line numbers. Please see
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>
>>> Regards,
>>>
>>> Sam
>>>
>>> laurent Goubet wrote:
>>>> Sam,
>>>>
>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>> CVS? We fixed some problems within the merging API and some of the
>>>> lines from your stack no longer match with code lines so this issue
>>>> could already be fixed.
>>>>
>>>> Could you update to the latest version of EMF Compare (we have a new
>>>> build ready if you use the built version) and check if the problem
>>>> still happens?
>>>>
>>>> If the exception is still thrown, could you provide us the models you
>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>> potential problem of the generic differencing engine and we'd need to
>>>> confirm it.
>>>>
>>>> Laurent Goubet
>>>> Obeo
>>>>
>>>> Sam Sabra a écrit :
>>>>> Good day,
>>>>>
>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>> below). Any ideas?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Sam
>>>>>
>>>>> Here's the error:
>>>>>
>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>>
>>>>>
>>>>> Here's the essential code:
>>>>>
>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>> File(args[1]).canRead()) {
>>>>> // Creates the resourceSet where we'll load the models
>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>
>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>> umlPackage);
>>>>>
>>>>> try {
>>>>> // Loads the two models passed as arguments
>>>>> final EObject model1 = ModelUtils.load(new
>>>>> File(args[0]), resourceSet);
>>>>> final EObject model2 = ModelUtils.load(new
>>>>> File(args[1]), resourceSet);
>>>>>
>>>>>
>>>>> Map<String,Object> options = new
>>>>> HashMap<String,Object>();
>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>>
>>>>> // Creates the match then the diff model for those
>>>>> two models
>>>>> final MatchModel match =
>>>>> MatchService.doMatch(model1, model2, options);
>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>> false);
>>>>>
>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>> // line 77: java.lang.NullPointerException
>>>>>
>>>>>
>>>>> // Prints the results
>>>>> try {
>>>>> System.out.println(ModelUtils.serialize(match));
>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>> } catch (IOException e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>>
>>>>> // Serializes the result as "result.emfdiff" in the
>>>>> directory this class has been called from.
>>>>> System.out.println("saving emfdiff as
>>>>> \"result.emfdiff\""); //$NON-NLS-1$
>>>>> final ModelInputSnapshot snapshot =
>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>> snapshot.setMatch(match);
>>>>> snapshot.setDiff(diff);
>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>> //$NON-NLS-1$
>>>>> } catch (IOException e) {
>>>>> // shouldn't be thrown
>>>>> e.printStackTrace();
>>>>> } catch (InterruptedException e) {
>>>>> e.printStackTrace();
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
http://cedric.brun.io news and articles on eclipse and eclipse modeling.
|
|
|
Re: Merging UML models [message #618070 is a reply to message #119844] |
Mon, 19 May 2008 16:38 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Sam, Cedric,
I was having the same problem, and got the latest from the EMFT site. I
now have a new error, a ConcurrentModificationException which is a bit of
a mystery as there is nothing concurrent in what I am doing? The error is
below, I am working with EMF Compare 0.8.0v20080506. Any ideas?
Mark
java.util.ConcurrentModificationException
at
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
at
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
at
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
at
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
at test.Test.main(Test.java:39)
Cédric Brun wrote:
> Hi Sam,
> The new build is available here :
> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
> regards,
> Cédric
> Sam Sabra wrote:
>> Laurent,
>>
>> Thank you for handling this quickly, excellent response time! Looking
>> forward to the next integration build.
>>
>> Best regards,
>>
>> Sam
>>
>> laurent Goubet wrote:
>>> Sam,
>>>
>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>> been fixed on CVS and will be included in the next integration build.
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Sam Sabra a écrit :
>>>> Laurent,
>>>>
>>>> Thanks for the reply.
>>>>
>>>> I've updated to the latest build and I got the same error with
>>>> different line numbers. Please see
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>
>>>> Regards,
>>>>
>>>> Sam
>>>>
>>>> laurent Goubet wrote:
>>>>> Sam,
>>>>>
>>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>> lines from your stack no longer match with code lines so this issue
>>>>> could already be fixed.
>>>>>
>>>>> Could you update to the latest version of EMF Compare (we have a new
>>>>> build ready if you use the built version) and check if the problem
>>>>> still happens?
>>>>>
>>>>> If the exception is still thrown, could you provide us the models you
>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>> potential problem of the generic differencing engine and we'd need to
>>>>> confirm it.
>>>>>
>>>>> Laurent Goubet
>>>>> Obeo
>>>>>
>>>>> Sam Sabra a écrit :
>>>>>> Good day,
>>>>>>
>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>> below). Any ideas?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> Here's the error:
>>>>>>
>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>>>>>
>>>>>> at
>>>>>>
>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>>>>>
>>>>>>
>>>>>> Here's the essential code:
>>>>>>
>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>> File(args[1]).canRead()) {
>>>>>> // Creates the resourceSet where we'll load the models
>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>
>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>> umlPackage);
>>>>>>
>>>>>> try {
>>>>>> // Loads the two models passed as arguments
>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>> File(args[0]), resourceSet);
>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>> File(args[1]), resourceSet);
>>>>>>
>>>>>>
>>>>>> Map<String,Object> options = new
>>>>>> HashMap<String,Object>();
>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, true);
>>>>>>
>>>>>> // Creates the match then the diff model for those
>>>>>> two models
>>>>>> final MatchModel match =
>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>> false);
>>>>>>
>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>> // line 77: java.lang.NullPointerException
>>>>>>
>>>>>>
>>>>>> // Prints the results
>>>>>> try {
>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>> } catch (IOException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>>
>>>>>> // Serializes the result as "result.emfdiff" in the
>>>>>> directory this class has been called from.
>>>>>> System.out.println("saving emfdiff as
>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>> final ModelInputSnapshot snapshot =
>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>> snapshot.setMatch(match);
>>>>>> snapshot.setDiff(diff);
>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>> //$NON-NLS-1$
>>>>>> } catch (IOException e) {
>>>>>> // shouldn't be thrown
>>>>>> e.printStackTrace();
>>>>>> } catch (InterruptedException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
|
|
|
Re: Merging UML models [message #618072 is a reply to message #122682] |
Tue, 20 May 2008 07:08 |
|
This is a multi-part message in MIME format.
--------------060403030008040902080707
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
Here is the javadoc for MergeService#merge(List, boolean) which you are
calling in your code :
/**
* Merges a list of DiffElements in the direction specified by
<code>leftToRight</code>.
* <p>
* Will notify the list of its merge listeners before, and after the
operation.
* </p>
*
* @param elements
* {@link DiffElement}s containing the information to merge.
* @param leftToRight
* <code>True</code> if the changes must be applied from the
left to the right model,
* <code>False</code> when they have to be applied the other
way around.
* @throws ConcurrentModificationException
* Could be thrown if the list you give is directly a
reference from the meta model such as
* {@link DiffModel#getOwnedElements()} or {@link
DiffElement#getSubDiffElements()}. Copy the
* list before merging it.
*/
So yes, a ConcurrentModificationException *can* be thrown as the model
will be modified when using merge operations. Simply create a new List
containing all the elements to be merged to avoid these exceptions.
Laurent Goubet
Obeo
Mark Melia a
|
|
|
Re: Merging UML models [message #618073 is a reply to message #122692] |
Tue, 20 May 2008 11:09 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
Ok - I think I am nearly there - and thanks again for all your help. I
have the code running ok (well appears to be), but the models do not
change - there is no merge of one model into another (am I missing
something)?
I have pasted the code below and I think it should work as when i iterate
the diffElements I get:
org.eclipse.emf.compare.diff.metamodel.impl.DiffGroupImpl@12b3d53
(conflicting: false, kind: Addition)
Any ideas - thanks :)?
Mark
ps If you want to see the models I can paste the XMI in.
public static void main(String[] args) {
try {
EPackage model = (EPackage)ModelUtils.load(new
File("/home/mmelia/workspace3/AATest/model/A.ecore"), new
ResourceSetImpl());
EPackage.Registry.INSTANCE.put("http://dcu.ie/#A", model);
Resource model1 = ModelUtils.load(new
File("/home/mmelia/workspace3/AATest/model/B.ecore"), new
ResourceSetImpl()).eResource();
Resource model2 =
ModelUtils.load(URI.createFileURI("/home/mmelia/workspace3/AATest/model/C.ecore "),new
ResourceSetImpl()).eResource();
final MatchModel match = MatchService.doResourceMatch(model1, model2,
null);
// Detects differences
final DiffModel diff = DiffService.doDiff(match);
// Merges all differences from model1 to model2
EList<DiffElement> el = new BasicEList
<DiffElement>(diff.getOwnedElements());
MergeService.merge(el, true);
Iterator itr = el.iterator();
while(itr.hasNext()){
Object diffElement = itr.next();
DiffElement d = (org.eclipse.emf.compare.diff.metamodel.DiffElement)
diffElement;
System.out.println("here "+ d);
while(d.eContents().iterator().hasNext()){
EObject o = (EObject)d.eContents().iterator().next();
System.out.println(o);
}
}
} catch (Exception exception) {
exception.printStackTrace();
laurent Goubet wrote:
> Mark,
> Here is the javadoc for MergeService#merge(List, boolean) which you are
> calling in your code :
> /**
> * Merges a list of DiffElements in the direction specified by
> <code>leftToRight</code>.
> * <p>
> * Will notify the list of its merge listeners before, and after the
> operation.
> * </p>
> *
> * @param elements
> * {@link DiffElement}s containing the information to merge.
> * @param leftToRight
> * <code>True</code> if the changes must be applied from the
> left to the right model,
> * <code>False</code> when they have to be applied the other
> way around.
> * @throws ConcurrentModificationException
> * Could be thrown if the list you give is directly a
> reference from the meta model such as
> * {@link DiffModel#getOwnedElements()} or {@link
> DiffElement#getSubDiffElements()}. Copy the
> * list before merging it.
> */
> So yes, a ConcurrentModificationException *can* be thrown as the model
> will be modified when using merge operations. Simply create a new List
> containing all the elements to be merged to avoid these exceptions.
> Laurent Goubet
> Obeo
> Mark Melia a écrit :
>> Hi Sam, Cedric,
>>
>> I was having the same problem, and got the latest from the EMFT site. I
>> now have a new error, a ConcurrentModificationException which is a bit
>> of a mystery as there is nothing concurrent in what I am doing? The
>> error is below, I am working with EMF Compare 0.8.0v20080506. Any ideas?
>>
>> Mark
>>
>> java.util.ConcurrentModificationException
>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
>>
>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
>>
>> at
>> org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
>> at
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
>>
>> at test.Test.main(Test.java:39)
>>
>> Cédric Brun wrote:
>>
>>> Hi Sam,
>>
>>> The new build is available here :
>>
>>> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
>>
>>> regards,
>>
>>> Cédric
>>
>>> Sam Sabra wrote:
>>
>>>> Laurent,
>>>>
>>>> Thank you for handling this quickly, excellent response time! Looking
>>>> forward to the next integration build.
>>>>
>>>> Best regards,
>>>>
>>>> Sam
>>>>
>>>> laurent Goubet wrote:
>>>>> Sam,
>>>>>
>>>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>>>> been fixed on CVS and will be included in the next integration build.
>>>>>
>>>>> Laurent Goubet
>>>>> Obeo
>>>>>
>>>>> Sam Sabra a écrit :
>>>>>> Laurent,
>>>>>>
>>>>>> Thanks for the reply.
>>>>>>
>>>>>> I've updated to the latest build and I got the same error with
>>>>>> different line numbers. Please see
>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> laurent Goubet wrote:
>>>>>>> Sam,
>>>>>>>
>>>>>>> I wonder... Are you using EMF Compare's latest build or the code from
>>>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>>>> lines from your stack no longer match with code lines so this issue
>>>>>>> could already be fixed.
>>>>>>>
>>>>>>> Could you update to the latest version of EMF Compare (we have a new
>>>>>>> build ready if you use the built version) and check if the problem
>>>>>>> still happens?
>>>>>>>
>>>>>>> If the exception is still thrown, could you provide us the models you
>>>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>>>> potential problem of the generic differencing engine and we'd need to
>>>>>>> confirm it.
>>>>>>>
>>>>>>> Laurent Goubet
>>>>>>> Obeo
>>>>>>>
>>>>>>> Sam Sabra a écrit :
>>>>>>>> Good day,
>>>>>>>>
>>>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to get
>>>>>>>> it to output the result.emfdiff difference file (while ignoring XMI
>>>>>>>> IDs). When I try to merge, I get a java.lang.NullPointerException at
>>>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>>>> below). Any ideas?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Sam
>>>>>>>>
>>>>>>>> Here's the error:
>>>>>>>>
>>>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>
>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Here's the essential code:
>>>>>>>>
>>>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>>>> File(args[1]).canRead()) {
>>>>>>>> // Creates the resourceSet where we'll load the models
>>>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>>>
>>>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>>>> umlPackage);
>>>>>>>>
>>>>>>>> try {
>>>>>>>> // Loads the two models passed as arguments
>>>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>>>> File(args[0]), resourceSet);
>>>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>>>> File(args[1]), resourceSet);
>>>>>>>>
>>>>>>>>
>>>>>>>> Map<String,Object> options = new
>>>>>>>> HashMap<String,Object>();
>>>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>>>>>> true);
>>>>>>>>
>>>>>>>> // Creates the match then the diff model for those
>>>>>>>> two models
>>>>>>>> final MatchModel match =
>>>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>>>> false);
>>>>>>>>
>>>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>>>> // line 77: java.lang.NullPointerException
>>>>>>>>
>>>>>>>>
>>>>>>>> // Prints the results
>>>>>>>> try {
>>>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>>>> } catch (IOException e) {
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>>
>>>>>>>> // Serializes the result as "result.emfdiff" in the
>>>>>>>> directory this class has been called from.
>>>>>>>> System.out.println("saving emfdiff as
>>>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>>>> final ModelInputSnapshot snapshot =
>>>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>>>> snapshot.setMatch(match);
>>>>>>>> snapshot.setDiff(diff);
>>>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>>>> //$NON-NLS-1$
>>>>>>>> } catch (IOException e) {
>>>>>>>> // shouldn't be thrown
>>>>>>>> e.printStackTrace();
>>>>>>>> } catch (InterruptedException e) {
>>>>>>>> e.printStackTrace();
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>
>>
|
|
|
Re: Merging UML models [message #618074 is a reply to message #122697] |
Tue, 20 May 2008 11:24 |
|
This is a multi-part message in MIME format.
--------------010308070404050207040107
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
You will need to save the merged model. Simply put the following line
before the end of your try/catch :
model2.save(Collections.emptyMap());
Laurent Goubet
Obeo
Mark Melia a
|
|
|
Re: Merging UML models [message #618075 is a reply to message #122704] |
Tue, 20 May 2008 12:31 |
Mark Melia Messages: 142 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
Thanks for that, it now saves a new model, but the model seems to just be
model1 copied to model2. I am wondering if I am using the right classes,
as I see there are two MergeService classes for EMF compare. I have copied
my import statements - are all these the correct classes to be using?
Apologies for not getting this - and thanks for your patience.
Mark
import org.eclipse.emf.compare.diff.merge.service.MergeService;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.DiffModel;
import org.eclipse.emf.compare.diff.service.DiffService;
import org.eclipse.emf.compare.match.metamodel.MatchModel;
import org.eclipse.emf.compare.match.service.MatchService;
import org.eclipse.emf.compare.util.ModelUtils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI
laurent Goubet wrote:
> Mark,
> You will need to save the merged model. Simply put the following line
> before the end of your try/catch :
> model2.save(Collections.emptyMap());
> Laurent Goubet
> Obeo
> Mark Melia a écrit :
>> Hi Laurent,
>>
>> Ok - I think I am nearly there - and thanks again for all your help. I
>> have the code running ok (well appears to be), but the models do not
>> change - there is no merge of one model into another (am I missing
>> something)?
>>
>> I have pasted the code below and I think it should work as when i
>> iterate the diffElements I get:
>> org.eclipse.emf.compare.diff.metamodel.impl.DiffGroupImpl@12b3d53
>> (conflicting: false, kind: Addition)
>>
>> Any ideas - thanks :)?
>>
>> Mark
>>
>> ps If you want to see the models I can paste the XMI in.
>>
>> public static void main(String[] args) {
>> try {
>> EPackage model = (EPackage)ModelUtils.load(new
>> File("/home/mmelia/workspace3/AATest/model/A.ecore"), new
>> ResourceSetImpl());
>> EPackage.Registry.INSTANCE.put("http://dcu.ie/#A", model);
>> Resource model1 = ModelUtils.load(new
>> File("/home/mmelia/workspace3/AATest/model/B.ecore"), new
>> ResourceSetImpl()).eResource(); Resource model2 =
>>
ModelUtils.load(URI.createFileURI("/home/mmelia/workspace3/AATest/model/C.ecore "),new
>> ResourceSetImpl()).eResource();
>>
>> final MatchModel match =
>> MatchService.doResourceMatch(model1, model2, null);
>> // Detects differences
>> final DiffModel diff = DiffService.doDiff(match);
>> // Merges all differences from model1 to model2
>> EList<DiffElement> el = new BasicEList
>> <DiffElement>(diff.getOwnedElements());
>> MergeService.merge(el, true);
>> Iterator itr = el.iterator();
>> while(itr.hasNext()){
>>
>> Object diffElement = itr.next();
>> DiffElement d =
>> (org.eclipse.emf.compare.diff.metamodel.DiffElement) diffElement;
>> System.out.println("here "+ d);
>> while(d.eContents().iterator().hasNext()){
>> EObject o = (EObject)d.eContents().iterator().next();
>> System.out.println(o);
>> }
>> }
>>
>> } catch (Exception exception) {
>> exception.printStackTrace();
>>
>>
>> laurent Goubet wrote:
>>
>>> Mark,
>>
>>> Here is the javadoc for MergeService#merge(List, boolean) which you
>>> are calling in your code :
>>
>>> /**
>>> * Merges a list of DiffElements in the direction specified by
>>> <code>leftToRight</code>.
>>> * <p>
>>> * Will notify the list of its merge listeners before, and after the
>>> operation.
>>> * </p>
>>> *
>>> * @param elements
>>> * {@link DiffElement}s containing the information to merge.
>>> * @param leftToRight
>>> * <code>True</code> if the changes must be applied from
>>> the left to the right model,
>>> * <code>False</code> when they have to be applied the
>>> other way around.
>>> * @throws ConcurrentModificationException
>>> * Could be thrown if the list you give is directly a
>>> reference from the meta model such as
>>> * {@link DiffModel#getOwnedElements()} or {@link
>>> DiffElement#getSubDiffElements()}. Copy the
>>> * list before merging it.
>>> */
>>
>>> So yes, a ConcurrentModificationException *can* be thrown as the model
>>> will be modified when using merge operations. Simply create a new List
>>> containing all the elements to be merged to avoid these exceptions.
>>
>>> Laurent Goubet
>>> Obeo
>>
>>> Mark Melia a écrit :
>>>> Hi Sam, Cedric,
>>>>
>>>> I was having the same problem, and got the latest from the EMFT site.
>>>> I now have a new error, a ConcurrentModificationException which is a
>>>> bit of a mystery as there is nothing concurrent in what I am doing?
>>>> The error is below, I am working with EMF Compare 0.8.0v20080506. Any
>>>> ideas?
>>>>
>>>> Mark
>>>>
>>>> java.util.ConcurrentModificationException
>>>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.java:1378)
>>
>>>>
>>>> at
>>
org.eclipse.emf.common.util.BasicEList$EIterator.doNext(Basi cEList.java:1332)
>>
>>>>
>>>> at
>>>>
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1312)
>>>>
>>>> at
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
>>
>>>>
>>>> at test.Test.main(Test.java:39)
>>>>
>>>> Cédric Brun wrote:
>>>>
>>>>> Hi Sam,
>>>>
>>>>> The new build is available here :
>>>>
>>>>> http://www.eclipse.org/modeling/emft/downloads/?project=comp are
>>>>
>>>>> regards,
>>>>
>>>>> Cédric
>>>>
>>>>> Sam Sabra wrote:
>>>>
>>>>>> Laurent,
>>>>>>
>>>>>> Thank you for handling this quickly, excellent response time! Looking
>>>>>> forward to the next integration build.
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Sam
>>>>>>
>>>>>> laurent Goubet wrote:
>>>>>>> Sam,
>>>>>>>
>>>>>>> Thanks for the feedback, this was indeed a bug on our side. This has
>>>>>>> been fixed on CVS and will be included in the next integration build.
>>>>>>>
>>>>>>> Laurent Goubet
>>>>>>> Obeo
>>>>>>>
>>>>>>> Sam Sabra a écrit :
>>>>>>>> Laurent,
>>>>>>>>
>>>>>>>> Thanks for the reply.
>>>>>>>>
>>>>>>>> I've updated to the latest build and I got the same error with
>>>>>>>> different line numbers. Please see
>>>>>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=228087
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> Sam
>>>>>>>>
>>>>>>>> laurent Goubet wrote:
>>>>>>>>> Sam,
>>>>>>>>>
>>>>>>>>> I wonder... Are you using EMF Compare's latest build or the code
>>>>>>>>> from
>>>>>>>>> CVS? We fixed some problems within the merging API and some of the
>>>>>>>>> lines from your stack no longer match with code lines so this issue
>>>>>>>>> could already be fixed.
>>>>>>>>>
>>>>>>>>> Could you update to the latest version of EMF Compare (we have a
>>>>>>>>> new
>>>>>>>>> build ready if you use the built version) and check if the problem
>>>>>>>>> still happens?
>>>>>>>>>
>>>>>>>>> If the exception is still thrown, could you provide us the
>>>>>>>>> models you
>>>>>>>>> compare (either through bugzilla (preferred) or mail)? This is a
>>>>>>>>> potential problem of the generic differencing engine and we'd
>>>>>>>>> need to
>>>>>>>>> confirm it.
>>>>>>>>>
>>>>>>>>> Laurent Goubet
>>>>>>>>> Obeo
>>>>>>>>>
>>>>>>>>> Sam Sabra a écrit :
>>>>>>>>>> Good day,
>>>>>>>>>>
>>>>>>>>>> I'm trying to modify the standalone example by Cedric Brun
>>>>>>>>>> (ExampleLauncher.java) to merge two UML models. I've managed to
>>>>>>>>>> get
>>>>>>>>>> it to output the result.emfdiff difference file (while ignoring
>>>>>>>>>> XMI
>>>>>>>>>> IDs). When I try to merge, I get a
>>>>>>>>>> java.lang.NullPointerException at
>>>>>>>>>> MergeService.merge(diff.getOwnedElements(), true); (see details
>>>>>>>>>> below). Any ideas?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>>
>>>>>>>>>> Sam
>>>>>>>>>>
>>>>>>>>>> Here's the error:
>>>>>>>>>>
>>>>>>>>>> Exception in thread "main" java.lang.NullPointerException
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.getB estMerger(MergeFactory.java:109)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeFactory.crea teMerger(MergeFactory.java:79)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.doMe rge(MergeService.java:143)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:109)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>> at
>>>>>>>>>>
>>>>>
>>>>
>>
org.eclipse.emf.compare.examples.standalone.ExampleLauncher. main(ExampleLauncher.java:77)
>>
>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Here's the essential code:
>>>>>>>>>>
>>>>>>>>>> if (args.length == 2 && new File(args[0]).canRead() && new
>>>>>>>>>> File(args[1]).canRead()) {
>>>>>>>>>> // Creates the resourceSet where we'll load the models
>>>>>>>>>> final ResourceSet resourceSet = new ResourceSetImpl();
>>>>>>>>>> UMLPackage umlPackage = UMLPackage.eINSTANCE;
>>>>>>>>>>
>>>>>>>>>> resourceSet.getPackageRegistry().put(umlPackage.getNsURI(),
>>>>>>>>>> umlPackage);
>>>>>>>>>>
>>>>>>>>>> try {
>>>>>>>>>> // Loads the two models passed as arguments
>>>>>>>>>> final EObject model1 = ModelUtils.load(new
>>>>>>>>>> File(args[0]), resourceSet);
>>>>>>>>>> final EObject model2 = ModelUtils.load(new
>>>>>>>>>> File(args[1]), resourceSet);
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Map<String,Object> options = new
>>>>>>>>>> HashMap<String,Object>();
>>>>>>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>>>>>>>> true);
>>>>>>>>>>
>>>>>>>>>> // Creates the match then the diff model for those
>>>>>>>>>> two models
>>>>>>>>>> final MatchModel match =
>>>>>>>>>> MatchService.doMatch(model1, model2, options);
>>>>>>>>>> final DiffModel diff = DiffService.doDiff(match,
>>>>>>>>>> false);
>>>>>>>>>>
>>>>>>>>>> MergeService.merge(diff.getOwnedElements(), true);
>>>>>>>>>> // line 77: java.lang.NullPointerException
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> // Prints the results
>>>>>>>>>> try {
>>>>>>>>>>
>>>>>>>>>> System.out.println(ModelUtils.serialize(match));
>>>>>>>>>>
>>>>>>>>>> System.out.println(ModelUtils.serialize(diff));
>>>>>>>>>> } catch (IOException e) {
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> // Serializes the result as "result.emfdiff" in
>>>>>>>>>> the
>>>>>>>>>> directory this class has been called from.
>>>>>>>>>> System.out.println("saving emfdiff as
>>>>>>>>>> "result.emfdiff""); //$NON-NLS-1$
>>>>>>>>>> final ModelInputSnapshot snapshot =
>>>>>>>>>> DiffFactory.eINSTANCE.createModelInputSnapshot();
>>>>>>>>>>
>>>>>>>>>> snapshot.setDate(Calendar.getInstance().getTime());
>>>>>>>>>> snapshot.setMatch(match);
>>>>>>>>>> snapshot.setDiff(diff);
>>>>>>>>>> ModelUtils.save(snapshot, "result.emfdiff");
>>>>>>>>>> //$NON-NLS-1$
>>>>>>>>>> } catch (IOException e) {
>>>>>>>>>> // shouldn't be thrown
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> } catch (InterruptedException e) {
>>>>>>>>>> e.printStackTrace();
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>
>>>>
>>
>>
|
|
|
Re: Merging UML models [message #618076 is a reply to message #122710] |
Tue, 20 May 2008 12:42 |
|
This is a multi-part message in MIME format.
--------------070007000108040507010903
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Mark,
Obviously, if you copy *all* changes from model1 to model2 ... you will
get a copy of model1 as output. You have to filter out the differences
you want merged. If you simply wish to copy additions, only merge
AddModelElements, for deletions, RemoveModelElements... you will have to
take a look at the list of DiffElement you're merging to obtain the
expected result.
Cheers
Laurent Gobet
Obeo
Mark Melia a
|
|
|
Goto Forum:
Current Time: Sat Nov 23 23:13:08 GMT 2024
Powered by FUDForum. Page generated in 0.06357 seconds
|