Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » How to implement constraint for group of objects?
How to implement constraint for group of objects? [message #48256] Fri, 01 September 2006 12:39 Go to next message
Eclipse UserFriend
I have a constraint on model objects and relations between them. Check
process needs to traverse over all model elements and is quite expensive.
I want to implement AbstractModelConstraint which will perform such
validation which will be executed only once during validation
session(another way is to execute such constraint on every model element).
If I run validation on root element then it will occure only once during
validation session but I can create resulting failure status only for
current element(root of my model actually), not for each model element
violating the constraint. Any ideas how to implement such validation?
Re: How to implement constraint for group of objects? [message #48286 is a reply to message #48256] Fri, 01 September 2006 14:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050001080805010302090803
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Yury,

I assume you've ready The EMF Validation Framework Overview
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?
I'd expect you just to have a named constraint on some type of object,
and as that object is visited, your specialized method would check the
constraint and create a diagnostic if it's violated. This should allow
you to create a diagnostic per instance that violates the constraint.

Yury wrote:
> I have a constraint on model objects and relations between them. Check
> process needs to traverse over all model elements and is quite
> expensive. I want to implement AbstractModelConstraint which will
> perform such validation which will be executed only once during
> validation session(another way is to execute such constraint on every
> model element). If I run validation on root element then it will
> occure only once during validation session but I can create resulting
> failure status only for current element(root of my model actually),
> not for each model element violating the constraint. Any ideas how to
> implement such validation?
>


--------------050001080805010302090803
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Yury,<br>
<br>
I assume you've ready <a
href=" http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html">The
EMF Validation Framework Overview</a>?
Re: How to implement constraint for group of objects? [message #48404 is a reply to message #48286] Mon, 04 September 2006 11:25 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

I've read validation The EMF Validation Framework Overview and have
already implemeted some constraints. Following your suggestion I will need
to run call method on every object which can violate the constraint. But
every time I call that method it will have to traverse all objects in the
model. It may result in great performance hit. I think that I can cache
result in a constraint while processing model root(assuming it is
processed berfore other elements) and afterwards reuse that calculated
result while validating model elements. But I do not want to keep that
cache between validation sessions. Can I get know when validation session
is finished?

> I assume you've ready The EMF Validation Framework Overview
>
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?

> I'd expect you just to have a named constraint on some type of object,
> and as that object is visited, your specialized method would check the
> constraint and create a diagnostic if it's violated. This should allow
> you to create a diagnostic per instance that violates the constraint.
Re: How to implement constraint for group of objects? [message #48424 is a reply to message #48404] Mon, 04 September 2006 11:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Yury,

You can use the context Map to cache information/state during
validation. A new such map is created for each session.


Yury wrote:
> Ed,
>
> I've read validation The EMF Validation Framework Overview and have
> already implemeted some constraints. Following your suggestion I will
> need to run call method on every object which can violate the
> constraint. But every time I call that method it will have to traverse
> all objects in the model. It may result in great performance hit. I
> think that I can cache result in a constraint while processing model
> root(assuming it is processed berfore other elements) and afterwards
> reuse that calculated result while validating model elements. But I do
> not want to keep that cache between validation sessions. Can I get
> know when validation session is finished?
>
>> I assume you've ready The EMF Validation Framework Overview
> < http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?
>
>> I'd expect you just to have a named constraint on some type of
>> object, and as that object is visited, your specialized method would
>> check the constraint and create a diagnostic if it's violated. This
>> should allow you to create a diagnostic per instance that violates
>> the constraint.
>
>
Re: How to implement constraint for group of objects? [message #48634 is a reply to message #48424] Tue, 05 September 2006 07:21 Go to previous messageGo to next message
Eclipse UserFriend
I can see only map in IValidator (it has put/getClientData methods) but
AbstractModelConstraint does not have access to IValidator. What map do
you mean?


Ed Merks wrote:

> Yury,

> You can use the context Map to cache information/state during
> validation. A new such map is created for each session.
Re: How to implement constraint for group of objects? [message #48692 is a reply to message #48634] Tue, 05 September 2006 08:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050505030702030006080608
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Yury,

A named constraint "A" on an EClass Library would generate something
like this in the generated validator:

public boolean validateLibrary_A(Library library, DiagnosticChain
diagnostics, Map context)

So I'm answering EMF basic validation questions but you are asking more
general EMFT validation framework questions. I imagine this get and put
for client data can be used to accomplish the same goal...


Yury wrote:
> I can see only map in IValidator (it has put/getClientData methods)
> but AbstractModelConstraint does not have access to IValidator. What
> map do you mean?
>
>
> Ed Merks wrote:
>
>> Yury,
>
>> You can use the context Map to cache information/state during
>> validation. A new such map is created for each session.
>
>


--------------050505030702030006080608
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Yury,<br>
<br>
A named constraint "A" on an EClass Library would generate something
like this in the generated validator:<br>
<blockquote>
Re: How to implement constraint for group of objects? [message #48720 is a reply to message #48692] Tue, 05 September 2006 09:31 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

I guess you are talking about EValidator but my question was about
AbstractModelConstraint from EMF.Validation framework which is independent
of EValidator. AbstractModelConstraint is not passed a context map and
that is the main problem. Theoretically I can implement EValidator for my
model package but this approach is less flexible than use of
EMF.Validation because in case of EValidator I will need to implement all
constraints in single class.

It seems for me that AbstractModelConstraint is designed to validate
separate element without any knowledge about context where it is placed,
is it true?
Re: How to implement constraint for group of objects? [message #49052 is a reply to message #48720] Thu, 07 September 2006 11:33 Go to previous message
Eclipse UserFriend
Hi Yury,

The get/putCurrentConstraintData should allow you to pass information
for later retrieval in the same validation session. This should allow
you to structure your constraint so that it will not report the same
failure on all of the objects that constitute the failure in the same
validation session.

To answer your most recent question, yes, the AbstractModelConstraint is
designed to validate many distinct objects. The same constraint may be
called to validate numerous objects that are instances of the EClass
referenced in the declaration of the constraint in the plugin.xml.

I hope this helps,
Chris McGee

Yury wrote:
> Ed,
>
> I guess you are talking about EValidator but my question was about
> AbstractModelConstraint from EMF.Validation framework which is
> independent of EValidator. AbstractModelConstraint is not passed a
> context map and that is the main problem. Theoretically I can implement
> EValidator for my model package but this approach is less flexible than
> use of EMF.Validation because in case of EValidator I will need to
> implement all constraints in single class.
> It seems for me that AbstractModelConstraint is designed to validate
> separate element without any knowledge about context where it is placed,
> is it true?
>
Re: How to implement constraint for group of objects? [message #587070 is a reply to message #48256] Fri, 01 September 2006 14:26 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------050001080805010302090803
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Yury,

I assume you've ready The EMF Validation Framework Overview
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?
I'd expect you just to have a named constraint on some type of object,
and as that object is visited, your specialized method would check the
constraint and create a diagnostic if it's violated. This should allow
you to create a diagnostic per instance that violates the constraint.

Yury wrote:
> I have a constraint on model objects and relations between them. Check
> process needs to traverse over all model elements and is quite
> expensive. I want to implement AbstractModelConstraint which will
> perform such validation which will be executed only once during
> validation session(another way is to execute such constraint on every
> model element). If I run validation on root element then it will
> occure only once during validation session but I can create resulting
> failure status only for current element(root of my model actually),
> not for each model element violating the constraint. Any ideas how to
> implement such validation?
>


--------------050001080805010302090803
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Yury,<br>
<br>
I assume you've ready <a
href=" http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html">The
EMF Validation Framework Overview</a>?
Re: How to implement constraint for group of objects? [message #587121 is a reply to message #48286] Mon, 04 September 2006 11:25 Go to previous message
Eclipse UserFriend
Ed,

I've read validation The EMF Validation Framework Overview and have
already implemeted some constraints. Following your suggestion I will need
to run call method on every object which can violate the constraint. But
every time I call that method it will have to traverse all objects in the
model. It may result in great performance hit. I think that I can cache
result in a constraint while processing model root(assuming it is
processed berfore other elements) and afterwards reuse that calculated
result while validating model elements. But I do not want to keep that
cache between validation sessions. Can I get know when validation session
is finished?

> I assume you've ready The EMF Validation Framework Overview
>
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?

> I'd expect you just to have a named constraint on some type of object,
> and as that object is visited, your specialized method would check the
> constraint and create a diagnostic if it's violated. This should allow
> you to create a diagnostic per instance that violates the constraint.
Re: How to implement constraint for group of objects? [message #587129 is a reply to message #48404] Mon, 04 September 2006 11:40 Go to previous message
Eclipse UserFriend
Yury,

You can use the context Map to cache information/state during
validation. A new such map is created for each session.


Yury wrote:
> Ed,
>
> I've read validation The EMF Validation Framework Overview and have
> already implemeted some constraints. Following your suggestion I will
> need to run call method on every object which can violate the
> constraint. But every time I call that method it will have to traverse
> all objects in the model. It may result in great performance hit. I
> think that I can cache result in a constraint while processing model
> root(assuming it is processed berfore other elements) and afterwards
> reuse that calculated result while validating model elements. But I do
> not want to keep that cache between validation sessions. Can I get
> know when validation session is finished?
>
>> I assume you've ready The EMF Validation Framework Overview
> < http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html>?
>
>> I'd expect you just to have a named constraint on some type of
>> object, and as that object is visited, your specialized method would
>> check the constraint and create a diagnostic if it's violated. This
>> should allow you to create a diagnostic per instance that violates
>> the constraint.
>
>
Re: How to implement constraint for group of objects? [message #590220 is a reply to message #48424] Tue, 05 September 2006 07:21 Go to previous message
Eclipse UserFriend
I can see only map in IValidator (it has put/getClientData methods) but
AbstractModelConstraint does not have access to IValidator. What map do
you mean?


Ed Merks wrote:

> Yury,

> You can use the context Map to cache information/state during
> validation. A new such map is created for each session.
Re: How to implement constraint for group of objects? [message #590241 is a reply to message #48634] Tue, 05 September 2006 08:07 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------050505030702030006080608
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Yury,

A named constraint "A" on an EClass Library would generate something
like this in the generated validator:

public boolean validateLibrary_A(Library library, DiagnosticChain
diagnostics, Map context)

So I'm answering EMF basic validation questions but you are asking more
general EMFT validation framework questions. I imagine this get and put
for client data can be used to accomplish the same goal...


Yury wrote:
> I can see only map in IValidator (it has put/getClientData methods)
> but AbstractModelConstraint does not have access to IValidator. What
> map do you mean?
>
>
> Ed Merks wrote:
>
>> Yury,
>
>> You can use the context Map to cache information/state during
>> validation. A new such map is created for each session.
>
>


--------------050505030702030006080608
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Yury,<br>
<br>
A named constraint "A" on an EClass Library would generate something
like this in the generated validator:<br>
<blockquote>
Re: How to implement constraint for group of objects? [message #590251 is a reply to message #48692] Tue, 05 September 2006 09:31 Go to previous message
Eclipse UserFriend
Ed,

I guess you are talking about EValidator but my question was about
AbstractModelConstraint from EMF.Validation framework which is independent
of EValidator. AbstractModelConstraint is not passed a context map and
that is the main problem. Theoretically I can implement EValidator for my
model package but this approach is less flexible than use of
EMF.Validation because in case of EValidator I will need to implement all
constraints in single class.

It seems for me that AbstractModelConstraint is designed to validate
separate element without any knowledge about context where it is placed,
is it true?
Re: How to implement constraint for group of objects? [message #590399 is a reply to message #48720] Thu, 07 September 2006 11:33 Go to previous message
Eclipse UserFriend
Hi Yury,

The get/putCurrentConstraintData should allow you to pass information
for later retrieval in the same validation session. This should allow
you to structure your constraint so that it will not report the same
failure on all of the objects that constitute the failure in the same
validation session.

To answer your most recent question, yes, the AbstractModelConstraint is
designed to validate many distinct objects. The same constraint may be
called to validate numerous objects that are instances of the EClass
referenced in the declaration of the constraint in the plugin.xml.

I hope this helps,
Chris McGee

Yury wrote:
> Ed,
>
> I guess you are talking about EValidator but my question was about
> AbstractModelConstraint from EMF.Validation framework which is
> independent of EValidator. AbstractModelConstraint is not passed a
> context map and that is the main problem. Theoretically I can implement
> EValidator for my model package but this approach is less flexible than
> use of EMF.Validation because in case of EValidator I will need to
> implement all constraints in single class.
> It seems for me that AbstractModelConstraint is designed to validate
> separate element without any knowledge about context where it is placed,
> is it true?
>
Previous Topic:xml to ecore
Next Topic:Re: Ecore to DBSchema...Is sympedia's CDO same as the one in EMFT now
Goto Forum:
  


Current Time: Thu Apr 24 00:17:43 EDT 2025

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

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

Back to the top