| 
| java as language for constraints validation [message #57213] | Thu, 28 September 2006 12:12  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: john.watson.yahoo.com 
 Hi,
 
 where can I get more info how I can use java as language for constraints
 validation in Audit Rule in gmfmap file? (How can I get all object for any
 EClass, how to get the desired attribute, how to validate; any limitations
 if exists, etc)
 
 Thanks in advance!
 |  |  |  | 
| 
| Re: java as language for constraints validation [message #57506 is a reply to message #57213] | Fri, 29 September 2006 08:14  |  | 
| Eclipse User  |  |  |  |  | Hi John, 
 It's on my TODO list to provide such info
 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=159255).
 For now, see comments bellow:
 
 Java should be usually the option, when the expression logic represents
 excessive complexity or requires direct access to complete ecore reflective
 API,
 which is impossible with the rest of supported languages (like OCL).
 While the other language alternatives can be validated at modeling time and
 interpreted at runtime, a concrete java implementation
 is to be provided by the user as a post code-generation step. In other
 words, a java expression body attribute is not to contain the actual java
 source code.
 Instead, the body holds a java identifier, which becomes the basis for
 deriving a name for the corresponding java element in the generated code.
 
 The common convention of EMF code-generation has been adopted and an
 operation skeleton for every java expression is generated.
 This skeleton has appropriate context (eventually environment variables, for
 instance in case of LinkCreationConstraints) as arguments and its default
 implementation only throws an exception reporting 'Missing user
 implementation!'.
 As soon as the user provides a custom implementation, the operation should
 be marked as @generated NOT in order to preserve it across generation
 sessions.
 Which class will be the owner of the skeleton operation is dependent on the
 type of the expression based construct in GMF models.
 
 As an example:
 
 AuditRule {
 Constraint {
 lang : 'java'
 body : 'checkEClass_NonEmptyName'
 }
 DomainElementTarget{
 element: ecore::EClass
 }
 }
 
 results in generation of the following code in the GMF diagram
 ....ValidationProvider class.
 
 /**
 * @generated
 */
 static class JavaAudits {
 /**
 * @generated
 */
 private static Boolean checkEClass_NonEmptyName(EClass self) {
 // TODO: implement this method
 // Ensure that you remove @generated or mark it @generated NOT
 
 throw new EcoreAbstractExpression.NoImplException(
 "No user java implementation provided in 'checkEClass_NonEmptyName'
 operation"); //$NON-NLS-1$
 }
 } //JavaAudits
 
 
 It's worth mentioning, that there are also other options.
 You can implement your own org.eclipse.emf.ecore.EValidator (see
 http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/references/overview/EMF .Validation.html).
 If registered, it gets involved in GMF diagram validation automatically.
 As GMF diagram validation uses EMFT Validation framework, you can also
 create EMFT constraintProvider extension (see
 http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. gmf.doc/tutorials/msl/validationTutorial.html).
 It will be included in GMF diagram validation as well.
 
 Regards,
 /Radek
 
 
 
 "John Watson" <john.watson@yahoo.com> wrote in message
 news:ac37f348421836751a4e7a1959cee894$1@www.eclipse.org...
 > Hi,
 >
 > where can I get more info how I can use java as language for constraints
 > validation in Audit Rule in gmfmap file? (How can I get all object for any
 > EClass, how to get the desired attribute, how to validate; any limitations
 > if exists, etc)
 >
 > Thanks in advance!
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04186 seconds