Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Specifying constraints at Model Instance (M0) level.
Specifying constraints at Model Instance (M0) level. [message #670729] |
Sun, 15 May 2011 12:04 |
|
Hi,
I wanted to know if there is a mechanism to define constraints at the M0 or model instance level based on the created instances.
To give an overview my domain model in ECore looks something like this:
Service
- Parameter (0..n)
On instantiating this model I get something like this:
Pizza Delivery Service
- Customer Profile
- Geographic Location
I need to specify constraints such as:
if(Customer Profile == "Gold"), do this else do that...
As far as I understand about OCL, I can define constraints maximum at the domain model level (M1) and use it to validate the model instance (M0).
It would be really helpful to know if there is a mechanism for my above use case and if my understanding that I cannot use OCL for the same is correct.
Best Regards,
Nidhi
|
|
| |
Re: Specifying constraints at Model Instance (M0) level. [message #670783 is a reply to message #670769] |
Sun, 15 May 2011 14:45 |
|
Hi Ed,
I am really sorry for the inconvenience, but this is NOT AT ALL intentional.
This seems to be a bug. I tried posting the question and every time I was taken to a blank page without my post but with "Quick Reply". Also when I tried clicking on the "Tree View" it simply said the link that led to the page was invalid and a notification was send to the Webmaster. The question was simply not getting posted.
As you can see many of the questions don't even have a subject, I am not sure if it is possible to create new posts without a subject.
I have reported this post to the moderators to help me delete all duplicate posts.
Hope I wont face any problem while trying to post this reply.
Best Regards,
Nidhi
[Updated on: Sun, 15 May 2011 15:00] Report message to a moderator
|
|
| |
Re: Specifying constraints at Model Instance (M0) level. [message #670824 is a reply to message #670812] |
Sun, 15 May 2011 18:43 |
|
Hi Ed,
Thanks for the quick response. My mistake, you are right these are rules not constraints.
I wanted to focus only on the expression: CustomerProfile == "Gold"
The use case is to just allow creation of these expressions, nothing to do with the action post the expression is evaluated.
This might be repetetive, but I'll try to rewrite the use case more clearly:
1. My domain Ecore model contains the following entities:
Stakeholder
- parameters : Parameter
2. On instantiating this model, I create the following entities:
Customer
- CustomerProfile
3. Now I need to define a expression on the instantiated Parameter entity such as the one above:
CustomerProfile == "Gold"
This expression would later be evaluated as a business rule and help identify the path in a business
process workflow to be taken. But for the time being I just need a mechanism to define the expression.
I tried using XText but it doesn't seem very apt and probably OCL is also the wrong place I am looking for.
I needed some pointers on what is a good mechanism to achieve this.
Or am I just thinking complicated and rather shall just create entity corresponding to an "Expression" in my
domain metamodel. The only thing is I would need to exhaustively consider all the artifacts of an expression
such as all types of Comparison Operators, ANDing and ORing various expressions, etc.
Ed, this might not be the right place to post the question but I really need some pointers to post it in the
right forum.
Thanks,
Best Regards,
Nidhi
|
|
|
Re: Specifying constraints at Model Instance (M0) level. [message #670833 is a reply to message #670824] |
Sun, 15 May 2011 19:04 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Nidhi,
It seems to me you could easily use OCL to write such expressions (that
are evaluated against instances). Or course you could write them in
Java using the generated Java API for the model. Or you could look into
the XBase language provided by Xtext and use some derivative of that to
define your own expression language.
Nidhi wrote:
> Hi Ed,
>
> Thanks for the quick response. My mistake, you are right
> these are rules not constraints.
>
> I wanted to focus only on the expression: CustomerProfile ==
> "Gold"
>
> The use case is to just allow creation of these expressions,
> nothing to do with the action post the expression is
> evaluated.
>
> This might be repetetive, but I'll try to rewrite the use
> case more clearly:
>
> 1. My domain Ecore model contains the following entities:
> Stakeholder
> - parameters : Parameter
>
> 2. On instantiating this model, I create the following
> entities:
> Customer
> - CustomerProfile
>
> 3. Now I need to define a expression on the instantiated
> Parameter entity such as the one above:
> CustomerProfile == "Gold"
>
> This expression would later be evaluated as a business
> rule and help identify the path in a business
> process workflow to be taken. But for the time being I
> just need a mechanism to define the expression.
>
> I tried using XText but it doesn't seem very apt and
> probably OCL is also the wrong place I am looking for.
> I needed some pointers on what is a good mechanism to
> achieve this.
>
> Or am I just thinking complicated and rather shall just
> create entity corresponding to an "Expression" in my domain metamodel.
> The only thing is I would need to
> exhaustively consider all the artifacts of an expression
> such as all types of Comparison Operators, ANDing and ORing
> various expressions, etc.
>
> Ed, this might not be the right place to post the question
> but I really need some pointers to post it in the
> right forum.
>
> Thanks,
> Best Regards,
> Nidhi
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Specifying constraints at Model Instance (M0) level. [message #670865 is a reply to message #670833] |
Mon, 16 May 2011 00:54 |
|
Hi Ed,
So I was not very wrong in thinking of using OCL. But as far as I understand after reading on OCL is that it can help me
define constraints on the model (M1 level) and help evaluating these on the model instance (M0 level).
From the previous example, my model contains Stakeholder and Parameter and model instance contains Customer (corresponding to
Stakeholder) and CustomerProfile (corresponding to Parameter).
However, I need to enable end users of my tool to declaratively create expressions using the model instance CustomerProfile
and not model entity Parameter. So the end user first declaratively creates a model instance CustomerProfile and then declaratively defines the expression using it.(CustomerProfile == "Gold").
This leads to the first question I had asked, would it be possible to define constraints at M0 level using OCL. The reason of not using
JAVA API is because my tool should allow the end users (who are ideally business analysts) to declaratively create these expressions, hence
it would be good to have these expressions written in more intuitive format.
I shall have a look at XBase too in the mean while.
Best Regards,
Nidhi
|
|
| |
Goto Forum:
Current Time: Wed Apr 24 17:30:02 GMT 2024
Powered by FUDForum. Page generated in 0.04041 seconds
|