Specifying constraints at Model Instance (M0) level. [message #670729] |
Sun, 15 May 2011 08:04  |
Eclipse User |
|
|
|
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 #670824 is a reply to message #670812] |
Sun, 15 May 2011 14:43   |
Eclipse User |
|
|
|
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 15:04   |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Specifying constraints at Model Instance (M0) level. [message #670897 is a reply to message #670865] |
Mon, 16 May 2011 01:50  |
Eclipse User |
|
|
|
Hi Nidhi
The M0 discussion is an irrelevance; you want your users to program in
something.
Java is a GPL; you can do just about anything in it.
OCL is a DSL; much better for modelling; much worse for general purpose
work. You can make it more adequate with custom Java.
"end users (who are ideally business analysts)"
That is where you must start. What is acceptable/sellable to the users?
If they're not comfortable with meta-models then you may want to wrap
it up as SQL. I would not recommend OCL to users who are not keen on
models. If you've got to write a custom DSL, you will find Xbase much
easier to extend than OCL. Xbase perhaps has 90% of the functionality of
OCL; Xbase has very pragmatic support for models. Do you need the extra
10% that provides pedantic OMG compliance?
Regards
Ed Willink
On 16/05/2011 01:54, Nidhi wrote:
> 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
|
|
|
Powered by
FUDForum. Page generated in 0.05068 seconds