Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Live validation, trasaction and triggers
Live validation, trasaction and triggers [message #417268] Tue, 04 March 2008 12:20 Go to next message
Giovanni is currently offline GiovanniFriend
Messages: 32
Registered: July 2009
Member
I'm trying library example to understand how validation works (this is my
first approch to validation framework).
I'd like to enrich my emf rcp application with live validation, but I
doesn't work as I would.
I need validation avoids setting wrong values to properties of my objects,
but in the example you can put empty name on library (then the message box
gives you the error feedbak).
I suppose that with EMF Trasaction an automatic rollback should happen; is
it true?
Can I find a simple example like tha above one using trasaction+validation
in the editor?
Anyway I use trigger with trasaction so I need to understand when validation
occurs, because I would like to avoid the rollback of the expensive (maybe
undoable) recordingcommands in my triggers.
Thanks

Giovanni
Re: Live validation, trasaction and triggers [message #417276 is a reply to message #417268] Tue, 04 March 2008 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Giovanni,

If you install the EMF Validation Framework examples (which define that
empty-library-name constraint) together with the transaction example
(org.eclipse.emf.workspace.examples.library.editor), then you will see that
violation of this constraint does, indeed, result in transaction roll-back.
Open your *.extlibrary resource in the "EMF Workbench EXTLibrary Model
Editor" and try emptying a library name.

Validation occurs after all trigger commands have been executed. Although
triggers are intended to ensure data integrity pro-actively, and generally
should not introduce problems, a transaction is pessimistic and doesn't
trust its triggers.

Moreover, triggers are normally executed on commit of nested transactions.
This ensures that when the parent transaction resumes, all of the changes
that result from the execution of its nested transactions are already
effective and the transaction can assume that it is in a consistent state.
Validation occurs only when the root transaction commits, and we can be
certain that no more changes will occur that would need to be re-validated.

HTH,

Christian


Giovanni wrote:

> I'm trying library example to understand how validation works (this is my
> first approch to validation framework).
> I'd like to enrich my emf rcp application with live validation, but I
> doesn't work as I would.
> I need validation avoids setting wrong values to properties of my objects,
> but in the example you can put empty name on library (then the message box
> gives you the error feedbak).
> I suppose that with EMF Trasaction an automatic rollback should happen; is
> it true?
> Can I find a simple example like tha above one using trasaction+validation
> in the editor?
> Anyway I use trigger with trasaction so I need to understand when
> validation occurs, because I would like to avoid the rollback of the
> expensive (maybe undoable) recordingcommands in my triggers.
> Thanks
>
> Giovanni
Re: Live validation, trasaction and triggers [message #417374 is a reply to message #417276] Thu, 06 March 2008 21:42 Go to previous messageGo to next message
Giovanni is currently offline GiovanniFriend
Messages: 32
Registered: July 2009
Member
Thanks but at the moment for my project is easier to customize the setters
of some features to avoid setting not valid values; so I don't have to care
about rollling back trigger execution.
Maybe this
https://bugs.eclipse.org:443/bugs/show_bug.cgi?id=211524

+ Validation integration would make more user-friendly these frameworks for
new comer like me.
Ciao

Giovanni


"Christian W. Damus" <cdamus@ca.ibm.com> ha scritto nel messaggio
news:fqjn0e$mg0$1@build.eclipse.org...
> Hi, Giovanni,
>
> If you install the EMF Validation Framework examples (which define that
> empty-library-name constraint) together with the transaction example
> (org.eclipse.emf.workspace.examples.library.editor), then you will see
> that
> violation of this constraint does, indeed, result in transaction
> roll-back.
> Open your *.extlibrary resource in the "EMF Workbench EXTLibrary Model
> Editor" and try emptying a library name.
>
> Validation occurs after all trigger commands have been executed. Although
> triggers are intended to ensure data integrity pro-actively, and generally
> should not introduce problems, a transaction is pessimistic and doesn't
> trust its triggers.
>
> Moreover, triggers are normally executed on commit of nested transactions.
> This ensures that when the parent transaction resumes, all of the changes
> that result from the execution of its nested transactions are already
> effective and the transaction can assume that it is in a consistent state.
> Validation occurs only when the root transaction commits, and we can be
> certain that no more changes will occur that would need to be
> re-validated.
>
> HTH,
>
> Christian
>
>
> Giovanni wrote:
>
>> I'm trying library example to understand how validation works (this is my
>> first approch to validation framework).
>> I'd like to enrich my emf rcp application with live validation, but I
>> doesn't work as I would.
>> I need validation avoids setting wrong values to properties of my
>> objects,
>> but in the example you can put empty name on library (then the message
>> box
>> gives you the error feedbak).
>> I suppose that with EMF Trasaction an automatic rollback should happen;
>> is
>> it true?
>> Can I find a simple example like tha above one using
>> trasaction+validation
>> in the editor?
>> Anyway I use trigger with trasaction so I need to understand when
>> validation occurs, because I would like to avoid the rollback of the
>> expensive (maybe undoable) recordingcommands in my triggers.
>> Thanks
>>
>> Giovanni
>
Re: Live validation, trasaction and triggers [message #417391 is a reply to message #417374] Fri, 07 March 2008 12:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Giovanni,

I agree that the learning curve is a little steep. Integrating more of the
EMF project's components into the code generation would certainly help to
ease the process, by producing working examples with the developer's
models.

This is fertile ground for community contributions. Perhaps, once you no
longer feel like a new-comer, you could help to tackle this integration
problem? :-)

cW


Giovanni wrote:

> Thanks but at the moment for my project is easier to customize the setters
> of some features to avoid setting not valid values; so I don't have to
> care about rollling back trigger execution.
> Maybe this
> https://bugs.eclipse.org:443/bugs/show_bug.cgi?id=211524
>
> + Validation integration would make more user-friendly these frameworks
> for new comer like me.
> Ciao
>
> Giovanni
>
>
> "Christian W. Damus" <cdamus@ca.ibm.com> ha scritto nel messaggio
> news:fqjn0e$mg0$1@build.eclipse.org...
>> Hi, Giovanni,
>>
>> If you install the EMF Validation Framework examples (which define that
>> empty-library-name constraint) together with the transaction example
>> (org.eclipse.emf.workspace.examples.library.editor), then you will see
>> that
>> violation of this constraint does, indeed, result in transaction
>> roll-back.
>> Open your *.extlibrary resource in the "EMF Workbench EXTLibrary Model
>> Editor" and try emptying a library name.
>>
>> Validation occurs after all trigger commands have been executed.
>> Although triggers are intended to ensure data integrity pro-actively, and
>> generally should not introduce problems, a transaction is pessimistic and
>> doesn't trust its triggers.
>>
>> Moreover, triggers are normally executed on commit of nested
>> transactions. This ensures that when the parent transaction resumes, all
>> of the changes that result from the execution of its nested transactions
>> are already effective and the transaction can assume that it is in a
>> consistent state. Validation occurs only when the root transaction
>> commits, and we can be certain that no more changes will occur that would
>> need to be re-validated.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Giovanni wrote:
>>
>>> I'm trying library example to understand how validation works (this is
>>> my first approch to validation framework).
>>> I'd like to enrich my emf rcp application with live validation, but I
>>> doesn't work as I would.
>>> I need validation avoids setting wrong values to properties of my
>>> objects,
>>> but in the example you can put empty name on library (then the message
>>> box
>>> gives you the error feedbak).
>>> I suppose that with EMF Trasaction an automatic rollback should happen;
>>> is
>>> it true?
>>> Can I find a simple example like tha above one using
>>> trasaction+validation
>>> in the editor?
>>> Anyway I use trigger with trasaction so I need to understand when
>>> validation occurs, because I would like to avoid the rollback of the
>>> expensive (maybe undoable) recordingcommands in my triggers.
>>> Thanks
>>>
>>> Giovanni
>>
Re: Live validation, trasaction and triggers [message #417414 is a reply to message #417391] Sun, 09 March 2008 16:31 Go to previous messageGo to next message
Giovanni is currently offline GiovanniFriend
Messages: 32
Registered: July 2009
Member
Other similar questions :-)

I use in my model a ResourceSetListener to check when a feature is set, if
so my application will send to a host a snmp trap. I don't known if I have
understood well, but a rollbak could happen, because Validation Framework
checks the constraint after setting the value of my feature and not before,
so my application will not work as expected because sends trap when a
constraint is violated.
Does it work so?

The following is instead the desidered behavior.
The canExecute method of a command logically should be related with
Validation Framework, but analizing the code it seems having nothing to do
with it.
A command "can execute" if all constraints are satisfied, so if this were
true, I could check first canExecute result, before passing the command to
command stack.
Is there a workaround to realize that?

My last question...

How should I use the sample validator interfaces automatically genereted by
genmodel?

Thanks

Giovanni



"Christian W. Damus" <cdamus@ca.ibm.com> ha scritto nel messaggio
news:fqre7s$bcf$1@build.eclipse.org...
> Hi, Giovanni,
>
> I agree that the learning curve is a little steep. Integrating more of
> the
> EMF project's components into the code generation would certainly help to
> ease the process, by producing working examples with the developer's
> models.
>
> This is fertile ground for community contributions. Perhaps, once you no
> longer feel like a new-comer, you could help to tackle this integration
> problem? :-)
>
> cW
>
>
> Giovanni wrote:
>
>> Thanks but at the moment for my project is easier to customize the
>> setters
>> of some features to avoid setting not valid values; so I don't have to
>> care about rollling back trigger execution.
>> Maybe this
>> https://bugs.eclipse.org:443/bugs/show_bug.cgi?id=211524
>>
>> + Validation integration would make more user-friendly these frameworks
>> for new comer like me.
>> Ciao
>>
>> Giovanni
>>
>>
>> "Christian W. Damus" <cdamus@ca.ibm.com> ha scritto nel messaggio
>> news:fqjn0e$mg0$1@build.eclipse.org...
>>> Hi, Giovanni,
>>>
>>> If you install the EMF Validation Framework examples (which define that
>>> empty-library-name constraint) together with the transaction example
>>> (org.eclipse.emf.workspace.examples.library.editor), then you will see
>>> that
>>> violation of this constraint does, indeed, result in transaction
>>> roll-back.
>>> Open your *.extlibrary resource in the "EMF Workbench EXTLibrary Model
>>> Editor" and try emptying a library name.
>>>
>>> Validation occurs after all trigger commands have been executed.
>>> Although triggers are intended to ensure data integrity pro-actively,
>>> and
>>> generally should not introduce problems, a transaction is pessimistic
>>> and
>>> doesn't trust its triggers.
>>>
>>> Moreover, triggers are normally executed on commit of nested
>>> transactions. This ensures that when the parent transaction resumes, all
>>> of the changes that result from the execution of its nested transactions
>>> are already effective and the transaction can assume that it is in a
>>> consistent state. Validation occurs only when the root transaction
>>> commits, and we can be certain that no more changes will occur that
>>> would
>>> need to be re-validated.
>>>
>>> HTH,
>>>
>>> Christian
>>>
>>>
>>> Giovanni wrote:
>>>
>>>> I'm trying library example to understand how validation works (this is
>>>> my first approch to validation framework).
>>>> I'd like to enrich my emf rcp application with live validation, but I
>>>> doesn't work as I would.
>>>> I need validation avoids setting wrong values to properties of my
>>>> objects,
>>>> but in the example you can put empty name on library (then the message
>>>> box
>>>> gives you the error feedbak).
>>>> I suppose that with EMF Trasaction an automatic rollback should happen;
>>>> is
>>>> it true?
>>>> Can I find a simple example like tha above one using
>>>> trasaction+validation
>>>> in the editor?
>>>> Anyway I use trigger with trasaction so I need to understand when
>>>> validation occurs, because I would like to avoid the rollback of the
>>>> expensive (maybe undoable) recordingcommands in my triggers.
>>>> Thanks
>>>>
>>>> Giovanni
>>>
>
Re: Live validation, trasaction and triggers [message #417421 is a reply to message #417414] Mon, 10 March 2008 13:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Giovanni,

See some replies in-line, below.

HTH,

Christian


Giovanni wrote:

> Other similar questions :-)
>
> I use in my model a ResourceSetListener to check when a feature is set, if
> so my application will send to a host a snmp trap. I don't known if I have
> understood well, but a rollbak could happen, because Validation Framework
> checks the constraint after setting the value of my feature and not
> before, so my application will not work as expected because sends trap
> when a constraint is violated.
> Does it work so?

No. If your SNMP trap is sent from a listener's resourceSetChanged(...)
call-back, then it is assured that the notifications it receives are only
those changes that were successfully committed. In the documentation, this
call-back is referred to as the "post-commit" event. This is, pretty much,
the reason why the post-commit event exists; otherwise, applications would
be left on their own to simply attach Adapters to their models.

The EMF Validation Framework developer guide documentation, included in the
SDK, explains in some detail the purpose of pre-commit and post-commit
listeners, and how these mechanisms work.


> The following is instead the desidered behavior.
> The canExecute method of a command logically should be related with
> Validation Framework, but analizing the code it seems having nothing to do
> with it.
> A command "can execute" if all constraints are satisfied, so if this were
> true, I could check first canExecute result, before passing the command to
> command stack.
> Is there a workaround to realize that?

This would require a validation framework that can predict whether the
changes intended by a Command will result in an invalid state. This is not
what the Validation Framework component provides; it reacts to changes that
have been effected, so that it can inspect the state of the resource set to
determine whether it is invalid. Commands such as the RecordingCommand
make prediction of the outcomes of Commands impractical, at best.


> My last question...
>
> How should I use the sample validator interfaces automatically genereted
> by genmodel?

This is the central construct in a quite different approach to validation,
provided intrinsically by the EMF Core component. It offers certain
advantages to due the nature of generating constraints into a model
implementation, whereas the extrinsic validation framework is geared
towards extensibility and flexibility in the selection of which constraints
are applicable in a particular application context.

The validation framework provides, as a self-extension on the
org.eclipse.emf.validation.constraintParsers point, a "constraint language"
named "EMF." It is similar to the "Java" language, except that it
identifies validation operations generated into a model API, to which it
delegates the constraint logic. Thus, it bridges these two frameworks.

See the org.eclipse.emf.validation.internal.emfadapter.EMFConstraint Parser
class for information about the parameters required by constraints in
the "EMF" language. I think it probably isn't covered by the Developer
Guide documentation.

>
> Thanks
>
> Giovanni

-----8<-----
Re: Live validation, trasaction and triggers [message #417442 is a reply to message #417421] Mon, 10 March 2008 20:07 Go to previous message
Giovanni is currently offline GiovanniFriend
Messages: 32
Registered: July 2009
Member
Thank you very much :-)
A lot of doubts are gone...
Ciao

Giovanni

"Christian W. Damus" <cdamus@ca.ibm.com> ha scritto nel messaggio
news:fr3c5i$vgg$1@build.eclipse.org...
> Hi, Giovanni,
>
> See some replies in-line, below.
>
> HTH,
>
> Christian
>
>
> Giovanni wrote:
>
>> Other similar questions :-)
>>
>> I use in my model a ResourceSetListener to check when a feature is set,
>> if
>> so my application will send to a host a snmp trap. I don't known if I
>> have
>> understood well, but a rollbak could happen, because Validation Framework
>> checks the constraint after setting the value of my feature and not
>> before, so my application will not work as expected because sends trap
>> when a constraint is violated.
>> Does it work so?
>
> No. If your SNMP trap is sent from a listener's resourceSetChanged(...)
> call-back, then it is assured that the notifications it receives are only
> those changes that were successfully committed. In the documentation,
> this
> call-back is referred to as the "post-commit" event. This is, pretty
> much,
> the reason why the post-commit event exists; otherwise, applications would
> be left on their own to simply attach Adapters to their models.
>
> The EMF Validation Framework developer guide documentation, included in
> the
> SDK, explains in some detail the purpose of pre-commit and post-commit
> listeners, and how these mechanisms work.
>
>
>> The following is instead the desidered behavior.
>> The canExecute method of a command logically should be related with
>> Validation Framework, but analizing the code it seems having nothing to
>> do
>> with it.
>> A command "can execute" if all constraints are satisfied, so if this were
>> true, I could check first canExecute result, before passing the command
>> to
>> command stack.
>> Is there a workaround to realize that?
>
> This would require a validation framework that can predict whether the
> changes intended by a Command will result in an invalid state. This is
> not
> what the Validation Framework component provides; it reacts to changes
> that
> have been effected, so that it can inspect the state of the resource set
> to
> determine whether it is invalid. Commands such as the RecordingCommand
> make prediction of the outcomes of Commands impractical, at best.
>
>
>> My last question...
>>
>> How should I use the sample validator interfaces automatically genereted
>> by genmodel?
>
> This is the central construct in a quite different approach to validation,
> provided intrinsically by the EMF Core component. It offers certain
> advantages to due the nature of generating constraints into a model
> implementation, whereas the extrinsic validation framework is geared
> towards extensibility and flexibility in the selection of which
> constraints
> are applicable in a particular application context.
>
> The validation framework provides, as a self-extension on the
> org.eclipse.emf.validation.constraintParsers point, a "constraint
> language"
> named "EMF." It is similar to the "Java" language, except that it
> identifies validation operations generated into a model API, to which it
> delegates the constraint logic. Thus, it bridges these two frameworks.
>
> See the org.eclipse.emf.validation.internal.emfadapter.EMFConstraint Parser
> class for information about the parameters required by constraints in
> the "EMF" language. I think it probably isn't covered by the Developer
> Guide documentation.
>
>>
>> Thanks
>>
>> Giovanni
>
> -----8<-----
Previous Topic:Load with customized XML format
Next Topic:http://www.eclipse.org/emf/2002/Ecore# versus platform:/plugin/org.eclipse.emf.ecore/model/Ecore.eco
Goto Forum:
  


Current Time: Fri Apr 19 23:37:43 GMT 2024

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

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

Back to the top