Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF + CDO] Strategy for restricting duplicate EAttributes values
[EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1451904] Fri, 24 October 2014 13:22 Go to next message
Phil Wim is currently offline Phil WimFriend
Messages: 88
Registered: October 2013
Member
I'm looking for a way to implement unique attribute values.

I want to restrict adding eobjects with same values in same EAttributes. As a unique index in mysql.

I'm running a emf cdo environment.

I appreciate any help!
Philippe

Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1453661 is a reply to message #1451904] Mon, 27 October 2014 09:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 28968
Registered: July 2009
Senior Member
Phil,

Comments below.

On 24/10/2014 3:22 PM, Phil Wim wrote:
> I'm looking for a way to implement unique attribute values.
> I want to restrict adding eobjects with same values in same EAttributes.
Where do you want such a restriction to be applied? Certainly on any
EReference you can specify eKeys, i.e., one or more of the EAttributes
of the EReference's eReferenceType whose values must be unique within
that reference. The EObjectValidator will check this constraint and
produce diagnostics for violations. It's also useful to affect the
serialization when applied to a containment EReference, i.e., instead of
serializing references as @<feature-name>.<index> it will serialize as
@<feature-name>[key1='value1',key2='value2'] so that references will be
stable with respect to reordering.
> As a unique index in mysql.
There's also the ability on an EAttribute to set iD to true. The value
of that attribute must be unique within the containing resource (and the
EObjectValidator will validate this constraint).
>
> I'm running a emf cdo environment.
>
> I appreciate any help!
> Philippe
>
>
Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1453886 is a reply to message #1453661] Mon, 27 October 2014 17:03 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 88
Registered: October 2013
Member
Hey Ed,

EKeys is what i was looking for. Is there a way to trigger this validation rule also in creation of EObject which is added to the EReference? Or do i have to implement this as a custom validation rule?

Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1454048 is a reply to message #1453886] Mon, 27 October 2014 22:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 28968
Registered: July 2009
Senior Member
Phil,

Comments below.

On 27/10/2014 6:03 PM, Phil Wim wrote:
> Hey Ed,
>
> EKeys is what i was looking for. Is there a way to trigger this
> validation rule also in creation of EObject which is added to the
> EReference?
On a GenModel you can set the Decoration property to "Live". In this
case, each time the model changes (after a command) and when opening the
editor, the validator will automatically check all the constraints, and
the tree will be decorated with error markers (with hover help) to
indicate any objects with problems or that contain children with problems.
> Or do i have to implement this as a custom validation rule?
It's validated by EObjectValidator, so all models will check this
without hand written constraints.
>
>
Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1454382 is a reply to message #1454048] Tue, 28 October 2014 10:10 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 88
Registered: October 2013
Member
Ed,

awesome feature! Is it also available for RAP?
Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1454395 is a reply to message #1454382] Tue, 28 October 2014 10:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 28968
Registered: July 2009
Senior Member
Phil,

I think so, but I've never tried.

On 28/10/2014 11:10 AM, Phil Wim wrote:
> Ed,
>
> awesome feature! Is it also available for RAP?
Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1454417 is a reply to message #1454395] Tue, 28 October 2014 11:12 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 88
Registered: October 2013
Member
I see " Decoration property" belongs to the Editor. So i was checking the Editor code which i cant resolve with my RAP Target Platform.

Is the following code (snip of editor code) the right way to activate this feature?

				
treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
				treeViewer.setLabelProvider(new DecoratingColumLabelProvider(new AdapterFactoryLabelProvider(adapterFactory), new DiagnosticDecorator(editingDomain, treeViewer)));

				new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
				new ColumnViewerInformationControlToolTipSupport(treeViewer, new DiagnosticDecorator.EditingDomainLocationListener(editingDomain, treeViewer));


I'm not able to resolve (with RAP Target) the the Dependencies for the bundles "org.eclipse.emf.common.ui" and "org.eclipse.emf.edit.ui" where the classes ColumnViewerInformationControlToolTipSupport, DiagnosticDecorator, DecoratingColumLabelProvider are located.


Re: [EMF + CDO] Strategy for restricting duplicate EAttributes values [message #1454672 is a reply to message #1454417] Tue, 28 October 2014 16:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 28968
Registered: July 2009
Senior Member
Phil,

I see. Yes, sorry, I've never ported those to the RAP versions of the
UI bundles. I suppose they ought to work there, but I haven't tried.
Perhaps you want to try copying them over. You could set up an IDE with
EMF's RAP source using Oomph:
https://wiki.eclipse.org/Eclipse_Oomph_Installer, and see if those
classes compile there.

On 28/10/2014 12:12 PM, Phil Wim wrote:
> I see " Decoration property" belongs to the Editor. So i was checking
> the Editor code which i cant resolve with my RAP Target Platform.
> Is the following code (snip of editor code) the right way to activate
> this feature?
>
>
> treeViewer.setContentProvider(new
> AdapterFactoryContentProvider(adapterFactory));
> treeViewer.setLabelProvider(new
> DecoratingColumLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory), new
> DiagnosticDecorator(editingDomain, treeViewer)));
>
> new AdapterFactoryTreeEditor(treeViewer.getTree(),
> adapterFactory);
> new
> ColumnViewerInformationControlToolTipSupport(treeViewer, new
> DiagnosticDecorator.EditingDomainLocationListener(editingDomain,
> treeViewer));
>
> I'm not able to resolve (with RAP Target) the the Dependencies for the
> bundles "org.eclipse.emf.common.ui" and "org.eclipse.emf.edit.ui"
> where the classes ColumnViewerInformationControlToolTipSupport,
> DiagnosticDecorator, DecoratingColumLabelProvider are located.
>
>
Previous Topic:PSF Files, SVN changelist and multiple projects from multiple directories
Next Topic:How to change Code generation Template
Goto Forum:
  


Current Time: Tue Nov 21 04:33:21 GMT 2017

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

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