| 
| problem with OCL.validate(OCLExpression) [message #67378] | Mon, 09 February 2009 11:19  |  | 
| Eclipse User  |  |  |  |  | Hi there, 
 regarding the following code snippet:
 
 ****************************************************
 // create OCL instance (UMLEnvironment)
 // create OCLHelper
 
 ocl.parse(new OCLInput(def)) ;  // parsing attribute -> works
 helper.setContext(...) ;
 OCLExpression<Classifier> expr = helper.createQuery(...) ;   // works
 
 ocl = OCL.newInstance(..)     // create new OCL instance
 ocl.parse(new OCLInput(def)) ;  // parsing of same attribute works
 
 ocl.validate(expr) ;   // validation fails, OCL instance does not know
 // anything about the parsed attribute
 ****************************************************
 
 
 is this really the correct behavior of OCL.validate()? Is the same OCL
 instance(which was used for query creation) needed in order to make this
 working?
 Or am I doing something wrong?
 
 Best regards, Hannes
 |  |  |  | 
| 
| Re: problem with OCL.validate(OCLExpression) [message #67418 is a reply to message #67378] | Mon, 09 February 2009 11:41   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: cdamus.zeligsoft.com 
 Hi, Hannes,
 
 Your deduction is correct.  You need to use the same OCL instance to
 validate the OCL expression because the second OCL instance created a
 distinct instance of the defined attribute.  The expression you are
 validating reference a different attribute, being the one defined in the
 first environment.
 
 Note that, once you have successfully parsed an OCL expression, there is
 usually no need to validate it (parsing does this implicitly).
 Validation is most interesting for expressions that are constructed not
 by parsing, such as by AST transformation from some other language.
 
 Cheers,
 
 Christian
 
 
 Hannes Moesl wrote:
 > Hi there,
 >
 > regarding the following code snippet:
 > ****************************************************
 > // create OCL instance (UMLEnvironment)
 > // create OCLHelper
 >
 > ocl.parse(new OCLInput(def)) ;  // parsing attribute -> works
 > helper.setContext(...) ;
 > OCLExpression<Classifier> expr = helper.createQuery(...) ;   // works
 >
 > ocl = OCL.newInstance(..)     // create new OCL instance
 > ocl.parse(new OCLInput(def)) ;  // parsing of same attribute works
 >
 > ocl.validate(expr) ;   // validation fails, OCL instance does not know
 >                       // anything about the parsed attribute
 > ****************************************************
 >
 >
 > is this really the correct behavior of OCL.validate()? Is the same OCL
 > instance(which was used for query creation) needed in order to make this
 > working?
 > Or am I doing something wrong?
 >
 > Best regards, Hannes
 >
 >
 >
 >
 >
 |  |  |  | 
|  | 
| 
| Re: problem with OCL.validate(OCLExpression) [message #67540 is a reply to message #67440] | Tue, 10 February 2009 10:03   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: cdamus.zeligsoft.com 
 Hi, Hannes,
 
 I see.  I would suggest, then, that the OCL with which the original
 parsing was done be retained for this purpose.  The Environment API
 allows to undefine an additional operation or property definition, if
 and when its body/derivation expression should change.  Just undefine
 the feature in question and define it again.  Then, validating a
 constraint or query that used it, in the same Environment, should catch
 the dependency in the way that you intend.
 
 Alternatively, you can implement a custom visitor (subclass of
 org.eclipse.ocl.utilities.AbstractVisitor) to analyze an OCLExpression's
 usage of defined operations and properties.  This would be largely
 similar to what the ValidationVisitor does, anyway.
 
 HTH,
 
 Christian
 
 Hannes Moesl wrote:
 > Hi Christian,
 >
 > Thanks for your reply.
 > My problem is that I have to efficiently determine which (already
 > created) queries are affected after some OCL constraints are changed and
 > have to be parsed again. In this case I have to deal with about 70
 > queries or more at a time. Creating every single query again takes about
 > 10-12 seconds (including parsing the OCL constraints like operations,
 > attributes, ...), which is actually too much for a background parsing
 > job in an editor.
 >
 > So I thought OCL.validate() will do the job for me, but a new OCL
 > instance is created in every parsing process of the constraints.
 >
 > But what's the best way to determine which OCL constraints are used by a
 > query? OCLExpression.eAllContents()?
 >
 > Best regards, Hannes
 >
 |  |  |  | 
|  | 
Powered by 
FUDForum. Page generated in 0.04110 seconds