<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3785194791828387872</id><updated>2011-04-21T20:03:55.808+02:00</updated><category term='Acceleo'/><title type='text'>Life is a Model - by Cedric Notot</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cedricnco.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3785194791828387872/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cedricnco.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Cerdicus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3785194791828387872.post-8809617965625236738</id><published>2007-12-11T08:30:00.000+01:00</published><updated>2007-12-21T10:31:34.805+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Acceleo'/><title type='text'>Validation of Models with Acceleo (Part 2)</title><content type='html'>The second one (Part 2) consists in creating&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt; Acceleo services&lt;/span&gt;&lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This solution provides additionnal functionalities in relation to the first one. Indeed, as the rules are written in Java language, you can decide that a specific rule won't overload a generic one for example...&lt;br /&gt;&lt;br /&gt;I've created a "ValidatorServices" class which implements a mechanism to validate a model and get the report from templates, thanks to the services that it provides. The end-user has just to extend this one and to implement the "checkRules" abstract protected method in order to define his own rules.&lt;br /&gt;He can use "validate", "isErrorChecking" or "isWarningChecking" services to validate his model.&lt;br /&gt;&lt;br /&gt;But the main new feature consists in giving the possibility to use the result of the validation report and to act on the generation or not. Let's interest by this feature:&lt;br /&gt;&lt;br /&gt;The "isErrorChecking" and "isWarningChecking" are able to notify if an error/warning at least has been detected. So, "isErrorChecking" may be used for example to forbid the generation if it returns true.&lt;br /&gt;&lt;br /&gt;The "ValidatorServices" class manages a "singleton" behaviour in order to have only one validation launch per generation and to optimize the process.&lt;br /&gt;Moreover, it manages a workaround about Acceleo architecture limitation on the instanciating of custom services between templates...&lt;br /&gt;&lt;br /&gt;Indeed, the services don't share the same context between each template. So, let's take an example with two templates where each of them generates a file. We knows that the generation depends on the "file" parameter. Consequently, it's in this place that you have to use "isExistingError" if you want to control the generation. Not to have as many validation launches as templates which generate files, it is required to keep report in memory. To do that, the "ValidatorServices" retrieve data from a temporary file, in the temporary directory of the OS (Java environment variable). You can use a custom action to delete this file (clean data context) at the end of the generation process.&lt;br /&gt;IsXXXChecking use temporary file only if it is called in different templates which generate files.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://c.notot.online.fr/blog1/secondSolution.htm"&gt;See the demo&lt;/a&gt;:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://c.notot.online.fr/blog1/secondSolution.htm"&gt;&lt;img style="cursor: pointer; width: 400px;" src="http://c.notot.online.fr/blog1/services2.bmp" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;The main benefit&lt;/span&gt; of this way is &lt;span style="color: rgb(51, 102, 255); font-style: italic;"&gt;to be able to cancel the generation if the validation process has thrown errors or warnings...&lt;/span&gt; according to your rules.&lt;br /&gt;Then, it provides &lt;span style="font-style: italic;"&gt;a &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 102, 255);"&gt;flexibility&lt;/span&gt; for the use of the validation mechanism (priority of rules, control generation...) thanks to the Java language. So, applying a rule on a "super" meta-class and an other one on a "child" meta-class, you can decide to display the both respective messages if these rules are not checked (and not only the "child" one).&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;The concern&lt;/span&gt; is the &lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;technical heaviness&lt;/span&gt; of the solution which might be managed, in a more transparent way, by the acceleo core.&lt;br /&gt;Then, &lt;span style="color: rgb(255, 0, 0); font-style: italic;"&gt;the use of Java language&lt;/span&gt; involves a loss of the Acceleo features (debugging, traceability...).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3785194791828387872-8809617965625236738?l=cedricnco.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cedricnco.blogspot.com/feeds/8809617965625236738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3785194791828387872&amp;postID=8809617965625236738' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3785194791828387872/posts/default/8809617965625236738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3785194791828387872/posts/default/8809617965625236738'/><link rel='alternate' type='text/html' href='http://cedricnco.blogspot.com/2007/11/validation-of-models-with-acceleo-part.html' title='Validation of Models with Acceleo (Part 2)'/><author><name>Cerdicus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3785194791828387872.post-4079962463742618570</id><published>2007-12-10T08:55:00.000+01:00</published><updated>2007-12-18T22:48:39.942+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Acceleo'/><title type='text'>Validation of Models with Acceleo (Part 1)</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;With Acceleo, you can define your own functional validation rules on a model and log messages according to them, during code generation.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I suggest different ways to define the validation rules.&lt;br /&gt;&lt;br /&gt;The first one (Part 1) consists in creating &lt;span style="color: rgb(51, 204, 0); font-weight: bold;"&gt;a simple Acceleo template&lt;/span&gt; where each script defines a set of rules to check on a particular meta-class of the meta-model.&lt;br /&gt;&lt;br /&gt;I've created basic java services to log messages with different severities. These messages take as parameter the condition to check (a boolean) and the text to display if this one is false.&lt;br /&gt;&lt;br /&gt;We knows that a script may be called if the « file » parameter is setted or if an other script calls it. We also knows that this parameter is used to decide to generate or not the code and to specify where it has to be generated.&lt;br /&gt;In our specific case, we want to activate rules sets without generating code. So, each script owns a « file » parameter which is a call script returning nothing and which gets the particularity to call back the right script to run the rules to apply.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://c.notot.online.fr/blog1/firstSolution.htm"&gt;see a demo&lt;/a&gt; with an example of a template in order to validate a State Machine UML2 model:&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://c.notot.online.fr/blog1/firstSolution.htm"&gt;&lt;img style="cursor: pointer; width: 400px;" src="http://c.notot.online.fr/blog1/template2.bmp" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;The benefit&lt;/span&gt; of this way is really &lt;span style="color: rgb(51, 102, 255); font-style: italic;"&gt;the easiness to define the rules thanks to Acceleo Language&lt;/span&gt;.&lt;br /&gt;The generic rules (in this example, on the « Named Elements ») apply only on the objects not concerned by a specific rule (inheriting concept).&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;The only concern&lt;/span&gt; is about using the result of the validation to decide to generate or not, for example. Here, it's not simple to do that because, &lt;span style="color: rgb(255, 0, 0); font-style: italic;"&gt;in a chain, every templates which are called are not able to directly communicate between them&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-style: italic;"&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3785194791828387872-4079962463742618570?l=cedricnco.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cedricnco.blogspot.com/feeds/4079962463742618570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3785194791828387872&amp;postID=4079962463742618570' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3785194791828387872/posts/default/4079962463742618570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3785194791828387872/posts/default/4079962463742618570'/><link rel='alternate' type='text/html' href='http://cedricnco.blogspot.com/2007/11/functional-validation-of-models-with.html' title='Validation of Models with Acceleo (Part 1)'/><author><name>Cerdicus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
