Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Instance level permissions
Instance level permissions [message #1863941] Thu, 07 March 2024 12:01 Go to next message
Klarise Hund is currently offline Klarise HundFriend
Messages: 24
Registered: October 2022
Junior Member
Hi,

I know that in order to allow disallow certain permissions on EObject instances you can play around with ItemProviders. This approach, however, applies the changes made to the ItemProvider, to all instances of the EObject of that ItemProvider. Do you have any information on how a similar thing can be done only for specific instances? For instances, not for all elements of type "Person", but only for those with the attribute "age" under 25. When I talk about permissions on EObjects I am referring to a variety of EObjects not just EClasses (e.g., References, Attributes).

Thanks!
Re: Instance level permissions [message #1863944 is a reply to message #1863941] Thu, 07 March 2024 13:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Any logic that you write you can make conditional on whatever you wish. So you could return different list of itemPropertyDescriptors depending on something about the input object.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Instance level permissions [message #1863948 is a reply to message #1863944] Thu, 07 March 2024 16:07 Go to previous messageGo to next message
Klarise Hund is currently offline Klarise HundFriend
Messages: 24
Registered: October 2022
Junior Member
Maybe I am misunderstanding your answer.

Consider I have an object of type "Person" in my metamodel, and I have three instances of Person in my model (E.g., Person Ben/ age: 27, Person Adam/ age:23, Person Sara/age:52).

In the model I want to limit users that for people under 25 (i.e., Adam), the user cannot see them.

For people above 25 (i.e., Ben and Sara), the user can see them but cannot delete them and cannot create them. And also cannot change the value of their attributes.

How can the itemPropertyDescriptors help with all that? And wouldn't a change in the itemPropertyDescriptor apply to all three?
Re: Instance level permissions [message #1863957 is a reply to message #1863948] Fri, 08 March 2024 06:44 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Of course you realize that "certain permissions" is not very clear. Somewhere in your logic you are collecting the Person objects to present them to the user; you can filter things there. Deleting implies removing them from a container object, but you've not described that part of your model. The container's item provider will be called for createRemoveCommand; you can override that method to return an UnexecutableCommand.INSTANCE for some Persons. Some things seem trickier. When a person is created, the age is not yet determined so how can you prevent creation of a Person of indeterminate age? My original answer was focused on the "permissions" for modifying of the attributes, presumably by the properties view, which is done via the property descriptors which you can specialize to make them read only or filter them be not visible.

In general my advice would be to use the debugger to see the call stack when the thing you want to restrict happens so that you see where along that chain you can specialize the code to behave differently.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Other/Custom names for objects in EMF-Plugin
Next Topic:Why Enumerators save the Literal into the file
Goto Forum:
  


Current Time: Thu May 02 00:15:15 GMT 2024

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

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

Back to the top