Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be called(How to use the extended classes of the CDOResourceImpl on the Papyrus Model Repositories)
the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be called [message #1446302] Thu, 16 October 2014 16:50 Go to next message
Nguyen Viet Hoa is currently offline Nguyen Viet HoaFriend
Messages: 5
Registered: August 2013
Junior Member
Hi everyone,

Firstly, i would like to explain my problem:

1. Problem: i created a plugin the permits to import papyrus models into the papyrus cdo model repository. For the purpose of overriding the attach/detach methods, i created a class that extends the CDOResourceImpl class. The problem is that, the attach/detach methods of my created class were not called when i add/delete elements of the models (because the created resources on the repository are instanceof the classic CDOReousrceImpl but not instancesof my created class).

2. What i did:

I created a PapyrusCDOResourceImpl class that extends the CDOResourceImpl class, and a resouce factory class :
class PapyrusCDOResourceFactoryImpl extends CDOResourceFactoryImpl

and then i tried to both register the resource factory class to the registry by using the ecore.protocole_parser extension point, and also register the registry programmatically like this:

Registry cdoReg = cdoTransaction_p.getResourceSet()
.getResourceFactoryRegistry();
Map<String, Object> protocolToFactoryMap = registry_p
.getProtocolToFactoryMap();
protocolToFactoryMap.remove(CDOProtocolConstants.PROTOCOL_NAME);
protocolToFactoryMap.put(CDOProtocolConstants.PROTOCOL_NAME,
new PapyrusCDOResourceFactoryImpl());

Thanks in advance for your help,

Kind Regards,

Hoa
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1446355 is a reply to message #1446302] Thu, 16 October 2014 18:30 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hoa,

Have you had a look at what the org.eclipse.papyrus.cdo.core.importer
package offers for importing resources from the workspace into a CDO
repository? Why do you need to change the behaviour of the attached()
and detached() methods? What specific problem is that trying to solve?
Perhaps there is already a solution available, or a better path to a
solution.

Cheers,

Christian

On 2014-10-16 16:50:10 +0000, Nguyen Viet Hoa said:

> Hi everyone,
> Firstly, i would like to explain my problem:
>
> 1. Problem: i created a plugin the permits to import papyrus models
> into the papyrus cdo model repository. For the purpose of overriding
> the attach/detach methods, i created a class that extends the
> CDOResourceImpl class. The problem is that, the attach/detach methods
> of my created class were not called when i add/delete elements of the
> models (because the created resources on the repository are instanceof
> the classic CDOReousrceImpl but not instancesof my created class).
>
> 2. What i did:
>
> I created a PapyrusCDOResourceImpl class that extends the
> CDOResourceImpl class, and a resouce factory class :
> class PapyrusCDOResourceFactoryImpl extends CDOResourceFactoryImpl
>
> and then i tried to both register the resource factory class to the
> registry by using the ecore.protocole_parser extension point, and also
> register the registry programmatically like this:
> Registry cdoReg = cdoTransaction_p.getResourceSet()
> .getResourceFactoryRegistry();
> Map<String, Object> protocolToFactoryMap = registry_p
> .getProtocolToFactoryMap();
> protocolToFactoryMap.remove(CDOProtocolConstants.PROTOCOL_NAME);
> protocolToFactoryMap.put(CDOProtocolConstants.PROTOCOL_NAME,
> new PapyrusCDOResourceFactoryImpl());
>
> Thanks in advance for your help,
>
> Kind Regards,
>
> Hoa
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1446720 is a reply to message #1446355] Fri, 17 October 2014 07:51 Go to previous messageGo to next message
Nguyen Viet Hoa is currently offline Nguyen Viet HoaFriend
Messages: 5
Registered: August 2013
Junior Member
Hi Christian,

Thank you so much for your quick response. I'll look at the the org.eclipse.papyrus.cdo.core.importer package.

The reason for changing behavior of the attach/detach methods is that, i have another resource that contains the "cdo id" of the imported papyrus elements and this resource refers directly to the papyrus elements. I have to override the attach/detach methods to update this resource as soon as the PapyrusCDOResource change.

Cheers,

Hoa
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1446885 is a reply to message #1446720] Fri, 17 October 2014 13:02 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Hoa,

I see. I'm not sure that will work as you expect. CDO objects don't
have IDs assigned until they are committed. While they are in the
"transient" state they have non-unique local IDs that bear no
resemblance to what their IDs would be once they are persisted in the
server.

You will have better luck with a CDOCommitListener to detect what new
objects have been added in the transaction and get their IDs at that
time. Then you won't have to worry about resource implementations.

HTH,

Christian


On 2014-10-17 07:51:33 +0000, Nguyen Viet Hoa said:

> Hi Christian,
> Thank you so much for your quick response. I'll look at the the
> org.eclipse.papyrus.cdo.core.importer package.
> The reason for changing behavior of the attach/detach methods is that,
> i have another resource that contains the "cdo id" of the imported
> papyrus elements and this resource refers directly to the papyrus
> elements. I have to override the attach/detach methods to update this
> resource as soon as the PapyrusCDOResource change.
> Cheers,
>
> Hoa
Re: the overrided attach/detach methods of the extended class of the CDOResourceImpl class not be ca [message #1447175 is a reply to message #1446885] Fri, 17 October 2014 22:40 Go to previous message
Nguyen Viet Hoa is currently offline Nguyen Viet HoaFriend
Messages: 5
Registered: August 2013
Junior Member
Hi Christian,

Thank you Christan, your answers help me so much. I think i found the solution to resolve my problem.

Cheers,

Hoa
Previous Topic:Papyrus not available under "Install Modeling Components"
Next Topic:[appearance] showing default value in case of an instanceValue
Goto Forum:
  


Current Time: Thu Mar 28 11:18:39 GMT 2024

Powered by FUDForum. Page generated in 0.03417 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top