Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » EMF Compare Example(working with same instances of Ecore models)
|
Re: EMF Compare Example [message #493608 is a reply to message #493580] |
Tue, 27 October 2009 08:37 |
|
This is a multi-part message in MIME format.
--------------070504010300050905030705
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi saad,
comments inlined below.
Laurent
saad bin abid a écrit :
> Hello Fellow Emf compare users,
>
> I am very new to EMF compare and have just started with it. I have
> downloaded all plug-ins and started working with initial examples. which
> worked fine for me. But now.I am having trouble in comparing and
> understanding Emf merge model.
>
> 1. I am comparing two models, instances of same meta model. after
> executing EMF compare i get *.emfdiff file i am having same left and
> right elements and references to them even though i am loading both from
> difference directories resources (But in the same resource). same names
> and elements but different "hrefs" for left and right model. I am
> confused why is it so?
Don't really understand your question here. Different hrefs means the
two elements are not "the same". You're probably looking at a
MatchElement which "left" reference points to the left model and "right"
reference to the right model. These elements allow us to match similar
elements from both models, and looking at the MatchElement in "visual"
mode (in the sample ecore editor) will probably give two elements
looking really similar if you haven't changed the name of one of the two
in one of the two models.
>
> 2. When i try to traverse for unmatched elements (after change by adding
> new elements to left model) i cannot traverse it properly? (any example
> available)
Sorry, don't understand your question. What does "I cannot traverse it
properly" mean? You get an exception? How do you "traverse" your
elements : in the sample ecore editor, through code, ...? Examples of a
comparison from start to finish, merge included, can be found in the
org.eclipse.emf.compare.example.standalone example.
>
> 3. I would to solve the following scenario with emf compare
> model a
> model b
> in the beginning both are having similar elements in them .
> i am changing model "a" and than comparing it with model "b". now i want
> to synchronize "b" w.r.t "a" automatically. Is there anyway in EMF
> compare untility?
Comparing a and b is done through
DiffService.doDiff(a, b);
MatchService.doMatch(diff);
The same kind of facility is accessible for the merge through
"MergeService.merge(differences, direction)"
>
> thank you very much for consideration
> regards
> saad
>
--------------070504010300050905030705
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------070504010300050905030705--
|
|
|
Re: EMF Compare Example [message #493633 is a reply to message #493608] |
Tue, 27 October 2009 12:09 |
saadbin abid Messages: 61 Registered: October 2009 Location: Ireland |
Member |
|
|
Thank you very much for quick feedback Laurent,
I understood answer to my 1 question.I suppose that i couldnt make you understand what my issue is?
let me try it once again
I would like to traverse unmatched elements from match model using code, after that i am again coding to merge the changes (change names) from one left model element to right one.
i tried to used the following EMF services to compare,merge the changes (renaming an element, adding new element in a) from left model (a) to right model (b)
following steps are taken
1.// ResourceSet resourceSet_right_b= new ResourceSetImp l();
//ResourceSet resourceSet_left_a= new ResourceSetImpl();
2. // registering appropriate packages and loading
Resource resource_left =resourceSet_left.getResource(some_uri, true);
// two way match
3. MatchModel match1=MatchService.doResourceMatch(resource_left, resource_right, Collections.<String,Object> emptyMap());
4. final DiffModel diff= DiffService.doDiff(match1,false);
5.final List<DiffElement> differences=new ArrayList<DiffElement>(diff.getOwnedElements());
// merging differences
MergeService.merge(differences, true);
6. storing them in snapshot and saving them as result.emfdiff
now my question is
if the code idea is right will i be able to see changes done (name change, new element added) in left model (a) into right model (b)?
if yes i am not able to see anything changed in model b. Why so?
help will be much appriciated
regards
saad
|
|
|
Re: EMF Compare Example [message #493646 is a reply to message #493633] |
Tue, 27 October 2009 12:54 |
|
This is a multi-part message in MIME format.
--------------020403060801040809040009
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi Saad,
The code itself is right, the only reason I see that you wouldn't see
changes merged would be if there is no differences between your models.
If you use XMI IDs or functional IDs, set both
MatchOption.OPTION_IGNORE_XMI_ID and MatchOption.OPTION_IGNORE_ID to
true when comparing (in the Map you pass the MatchService).
Laurent Goubet
Obeo
saad bin abid a écrit :
> Thank you very much for quick feedback Laurent,
>
> I understood answer to my 1 question.I suppose that i couldnt make you
> understand what my issue is?
>
> let me try it once again
> I would like to traverse unmatched elements from match model using code,
> after that i am again coding to merge the changes (change names) from
> one left model element to right one.
> i tried to used the following EMF services to compare,merge the changes
> (renaming an element, adding new element in a) from left model (a) to
> right model (b)
>
> following steps are taken
>
> 1.// ResourceSet resourceSet_right_b= new ResourceSetImp l();
> //ResourceSet resourceSet_left_a= new ResourceSetImpl();
>
> 2. // registering appropriate packages and loading
>
> Resource resource_left =resourceSet_left.getResource(some_uri, true);
>
> // two way match
> 3. MatchModel match1=MatchService.doResourceMatch(resource_left,
> resource_right, Collections.<String,Object> emptyMap());
>
> 4. final DiffModel diff= DiffService.doDiff(match1,false);
>
> 5.final List<DiffElement> differences=new
> ArrayList<DiffElement>(diff.getOwnedElements());
>
> // merging differences
> MergeService.merge(differences, true);
> 6. storing them in snapshot and saving them as result.emfdiff
>
> now my question is
> if the code idea is right will i be able to see changes done (name
> change, new element added) in left model (a) into right model (b)?
>
> if yes i am not able to see anything changed in model b. Why so?
>
>
> help will be much appriciated
> regards
> saad
--------------020403060801040809040009
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------020403060801040809040009--
|
|
|
Re: EMF Compare Example [message #493664 is a reply to message #493646] |
Tue, 27 October 2009 14:11 |
saadbin abid Messages: 61 Registered: October 2009 Location: Ireland |
Member |
|
|
Hello Laurent,
thank you very much for quick reply again. You are right there are no differences shown in diff model as i am just changing the name of elements and adding new ones. well I am working with two different instances of same ecore model. both models having same URI. I am adding instances in one model and want to automatically get in the other one (for synchronization purpose).
example of scenario i am trying to solve is
abc.ecore
a.instanceofe (left)
b.instanceofe (right)
initially
a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3)}
b={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3)}
where e is element with attributes like name and qualified name.
now in next step i add element in left model (a)
a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3),e4=(name=test4,qualifiedname=a.e4)}
1. i dont get any differences in diff model. will i have to? i just get unmatched element tuple in match model.
2. I want to get e4 from model a and want to transfer it to model b on the right place. do i have to manually right code for that? or can EMF merge help me in this situation?
thank you very much for your support and help
best regards
saad
|
|
|
Re: EMF Compare Example [message #493675 is a reply to message #493664] |
Tue, 27 October 2009 14:31 |
|
This is a multi-part message in MIME format.
--------------090703020009060405020609
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Saad,
EMF Compare should be able to do what you describe here, but you need to
compare the two models (calls to MatchService and DiffService) _after_
you add e4 in a. The MatchModel (MatchService.doMatch()) should indeed
return you 3 matchElements and 1 UnmatchedElement. Your DiffModel (call
to DiffService.doDiff()) should then contain one DiffElement of type
AddModelElement.
Merging its containing DiffGroup (call to
MergeService.merge(diff.getOwnedElements())) will copy this change in
the right direction. That is : if a is your left model and b the right,
and you added e4 in a; asking EMF Compare to merge from leftToRight will
add a copy of e4 in b, while asking it to merge from rightToLeft will
remove e4 from a.
I don't know if this explanation of the process helps in any way ... but
I have trouble understanding which part of this doesn't work in your case.
Laurent Goubet
Obeo
saad bin abid a écrit :
> Hello Laurent,
>
> thank you very much for quick reply again. You are right there are no
> differences shown in diff model as i am just changing the name of
> elements and adding new ones. well I am working with two different
> instances of same ecore model. both models having same URI. I am adding
> instances in one model and want to automatically get in the other one
> (for synchronization purpose).
>
> example of scenario i am trying to solve is
>
> abc.ecore
> a.instanceofe (left)
> b.instanceofe (right)
>
> initially
> a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3, qualifiedname=a.e3)}
> b={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3, qualifiedname=a.e3)}
>
> where e is element with attributes like name and qualified name.
> now in next step i add element in left model (a)
> a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3,
> qualifiedname=a.e3),e4=(name=test4,qualifiedname=a.e4)}
>
>
> 1. i dont get any differences in diff model. will i have to? i just get
> unmatched element tuple in match model.
>
> 2. I want to get e4 from model a and want to transfer it to model b on
> the right place. do i have to manually right code for that? or can EMF
> merge help me in this situation?
>
> thank you very much for your support and help
> best regards
> saad
>
>
>
--------------090703020009060405020609
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------090703020009060405020609--
|
|
| | |
Re: EMF Compare Example [message #494110 is a reply to message #494055] |
Thu, 29 October 2009 09:11 |
|
This is a multi-part message in MIME format.
--------------060105090109060305080409
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi saad,
Saving the merged file elsewhere is not possible in this order. What you
can do is copy a.xml to c.xml (so that "a.xml" is now a backup), compare
"c.xml" with "b.xml" (instead of comparing a.xml and b.xml) and merge
all changes to c.xml. That would do the trick for you would it not?
Laurent Goubet
Obeo
saad bin abid a écrit :
> Hello Laurent,
> I just figure out the problem. As i was using both merging and
> differencing at the same time so that was the reason i wasn't able to
> see the changes i was making and also 3 way compare better suited to
> solve my problem. anyhow thanks for your quick replies.
>
> my next question is that is it possible to save merge as new file some
> where else on disk or serialize that as snap shot?
>
> I want to merge file a.xml with file b.xml and save it as file c.xml on
> disk regards
> saad
--------------060105090109060305080409
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------060105090109060305080409--
|
|
|
Re: EMF Compare Example [message #621521 is a reply to message #493608] |
Tue, 27 October 2009 12:09 |
saadbin abid Messages: 61 Registered: October 2009 Location: Ireland |
Member |
|
|
Thank you very much for quick feedback Laurent,
I understood answer to my 1 question.I suppose that i couldnt make you understand what my issue is?
let me try it once again
I would like to traverse unmatched elements from match model using code, after that i am again coding to merge the changes (change names) from one left model element to right one.
i tried to used the following EMF services to compare,merge the changes (renaming an element, adding new element in a) from left model (a) to right model (b)
following steps are taken
1.// ResourceSet resourceSet_right_b= new ResourceSetImp l();
//ResourceSet resourceSet_left_a= new ResourceSetImpl();
2. // registering appropriate packages and loading
Resource resource_left =resourceSet_left.getResource(some_uri, true);
// two way match
3. MatchModel match1=MatchService.doResourceMatch(resource_left, resource_right, Collections.<String,Object> emptyMap());
4. final DiffModel diff= DiffService.doDiff(match1,false);
5.final List<DiffElement> differences=new ArrayList<DiffElement>(diff.getOwnedElements());
// merging differences
MergeService.merge(differences, true);
6. storing them in snapshot and saving them as result.emfdiff
now my question is
if the code idea is right will i be able to see changes done (name change, new element added) in left model (a) into right model (b)?
if yes i am not able to see anything changed in model b. Why so?
help will be much appriciated
regards
saad
|
|
|
Re: EMF Compare Example [message #621522 is a reply to message #621521] |
Tue, 27 October 2009 12:54 |
|
This is a multi-part message in MIME format.
--------------020403060801040809040009
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi Saad,
The code itself is right, the only reason I see that you wouldn't see
changes merged would be if there is no differences between your models.
If you use XMI IDs or functional IDs, set both
MatchOption.OPTION_IGNORE_XMI_ID and MatchOption.OPTION_IGNORE_ID to
true when comparing (in the Map you pass the MatchService).
Laurent Goubet
Obeo
saad bin abid a écrit :
> Thank you very much for quick feedback Laurent,
>
> I understood answer to my 1 question.I suppose that i couldnt make you
> understand what my issue is?
>
> let me try it once again
> I would like to traverse unmatched elements from match model using code,
> after that i am again coding to merge the changes (change names) from
> one left model element to right one.
> i tried to used the following EMF services to compare,merge the changes
> (renaming an element, adding new element in a) from left model (a) to
> right model (b)
>
> following steps are taken
>
> 1.// ResourceSet resourceSet_right_b= new ResourceSetImp l();
> //ResourceSet resourceSet_left_a= new ResourceSetImpl();
>
> 2. // registering appropriate packages and loading
>
> Resource resource_left =resourceSet_left.getResource(some_uri, true);
>
> // two way match
> 3. MatchModel match1=MatchService.doResourceMatch(resource_left,
> resource_right, Collections.<String,Object> emptyMap());
>
> 4. final DiffModel diff= DiffService.doDiff(match1,false);
>
> 5.final List<DiffElement> differences=new
> ArrayList<DiffElement>(diff.getOwnedElements());
>
> // merging differences
> MergeService.merge(differences, true);
> 6. storing them in snapshot and saving them as result.emfdiff
>
> now my question is
> if the code idea is right will i be able to see changes done (name
> change, new element added) in left model (a) into right model (b)?
>
> if yes i am not able to see anything changed in model b. Why so?
>
>
> help will be much appriciated
> regards
> saad
--------------020403060801040809040009
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------020403060801040809040009--
|
|
|
Re: EMF Compare Example [message #621523 is a reply to message #493646] |
Tue, 27 October 2009 14:11 |
saadbin abid Messages: 61 Registered: October 2009 Location: Ireland |
Member |
|
|
Hello Laurent,
thank you very much for quick reply again. You are right there are no differences shown in diff model as i am just changing the name of elements and adding new ones. well I am working with two different instances of same ecore model. both models having same URI. I am adding instances in one model and want to automatically get in the other one (for synchronization purpose).
example of scenario i am trying to solve is
abc.ecore
a.instanceofe (left)
b.instanceofe (right)
initially
a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3)}
b={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3)}
where e is element with attributes like name and qualified name.
now in next step i add element in left model (a)
a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname= a.e2),e3=(name=test3, qualifiedname=a.e3),e4=(name=test4,qualifiedname=a.e4)}
1. i dont get any differences in diff model. will i have to? i just get unmatched element tuple in match model.
2. I want to get e4 from model a and want to transfer it to model b on the right place. do i have to manually right code for that? or can EMF merge help me in this situation?
thank you very much for your support and help
best regards
saad
|
|
|
Re: EMF Compare Example [message #621524 is a reply to message #493664] |
Tue, 27 October 2009 14:31 |
|
This is a multi-part message in MIME format.
--------------090703020009060405020609
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Saad,
EMF Compare should be able to do what you describe here, but you need to
compare the two models (calls to MatchService and DiffService) _after_
you add e4 in a. The MatchModel (MatchService.doMatch()) should indeed
return you 3 matchElements and 1 UnmatchedElement. Your DiffModel (call
to DiffService.doDiff()) should then contain one DiffElement of type
AddModelElement.
Merging its containing DiffGroup (call to
MergeService.merge(diff.getOwnedElements())) will copy this change in
the right direction. That is : if a is your left model and b the right,
and you added e4 in a; asking EMF Compare to merge from leftToRight will
add a copy of e4 in b, while asking it to merge from rightToLeft will
remove e4 from a.
I don't know if this explanation of the process helps in any way ... but
I have trouble understanding which part of this doesn't work in your case.
Laurent Goubet
Obeo
saad bin abid a écrit :
> Hello Laurent,
>
> thank you very much for quick reply again. You are right there are no
> differences shown in diff model as i am just changing the name of
> elements and adding new ones. well I am working with two different
> instances of same ecore model. both models having same URI. I am adding
> instances in one model and want to automatically get in the other one
> (for synchronization purpose).
>
> example of scenario i am trying to solve is
>
> abc.ecore
> a.instanceofe (left)
> b.instanceofe (right)
>
> initially
> a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3, qualifiedname=a.e3)}
> b={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3, qualifiedname=a.e3)}
>
> where e is element with attributes like name and qualified name.
> now in next step i add element in left model (a)
> a={e1 (name=test1,qualifiedname=a.e1),e2(name=test2,qualifiedname=
> a.e2),e3=(name=test3,
> qualifiedname=a.e3),e4=(name=test4,qualifiedname=a.e4)}
>
>
> 1. i dont get any differences in diff model. will i have to? i just get
> unmatched element tuple in match model.
>
> 2. I want to get e4 from model a and want to transfer it to model b on
> the right place. do i have to manually right code for that? or can EMF
> merge help me in this situation?
>
> thank you very much for your support and help
> best regards
> saad
>
>
>
--------------090703020009060405020609
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyLyI+T2JlbzwvYT4NCmVtYWls O2ludGVybmV0
OmxhdXJlbnQuZ291YmV0QG9iZW8uZnINCnVybDpodHRwOi8vd3d3Lm9iZW8u ZnINCnZlcnNp
b246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------090703020009060405020609--
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 03:54:59 GMT 2024
Powered by FUDForum. Page generated in 0.03879 seconds
|