<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My own tech words... &#187; Grails</title>
	<atom:link href="http://blog.lucastex.com/category/tech/grails/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lucastex.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Apr 2010 12:01:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Grails 1.2 Milestone 2 is out!</title>
		<link>http://blog.lucastex.com/2009/08/11/grails-1-2-milestone-2-is-out/</link>
		<comments>http://blog.lucastex.com/2009/08/11/grails-1-2-milestone-2-is-out/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 11:21:14 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=439</guid>
		<description><![CDATA[Yeah!! Graeme just announced rigth now that grails 1.2-M2 is out!
I&#8217;ve already talked about some changes and improvements in my twitter, but now is officially!
Check the release notes here: http://www.grails.org/1.2-M2+Release+Notes, the changelog, and download it to upgrade your applications!  
Docs, as usual available here: http://grails.org/doc/latest
Later, I&#8217;ll write a post about the new features, probably [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah!! Graeme <a href="http://twitter.com/graemerocher/status/3243636664">just announced</a> rigth now that grails 1.2-M2 is out!<br />
I&#8217;ve already talked about some changes and improvements in <a href="http://twitter.com/lucastex">my twitter</a>, but now is officially!</p>
<p>Check the release notes here: <a href="http://www.grails.org/1.2-M2+Release+Notes">http://www.grails.org/1.2-M2+Release+Notes</a>, the <a href="http://jira.codehaus.org/browse/GRAILS?report=com.atlassian.jira.plugin.system.project:changelog-panel">changelog</a>, and <a href="http://grails.org/Download">download it</a> to <a href="http://grails.org/doc/latest/ref/Command%20Line/upgrade.html">upgrade your applications</a>!  </p>
<p>Docs, as usual available here: <a href="http://grails.org/doc/latest">http://grails.org/doc/latest</a></p>
<p>Later, I&#8217;ll write a post about the new features, probably one by one, come back!</p>
<p><a href="http://twitter.com/lucastex">Following me on twitter?</a></p>
<p>[]s,</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/08/11/grails-1-2-milestone-2-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A simple grails custom validator</title>
		<link>http://blog.lucastex.com/2009/08/10/a-simple-grails-custom-validator/</link>
		<comments>http://blog.lucastex.com/2009/08/10/a-simple-grails-custom-validator/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 23:52:42 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[constraints]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=436</guid>
		<description><![CDATA[While writing a simple CRUD with #grails, client asked me to validate pogo&#8217;s birth date (had to be in the last year). In this cases, we can&#8217;t just use regular validators, cause their are static. So we can solve this using our own custom validators, so simple and useful.
static constraints = {
	//...
	borned(validator: {
		return (it &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>While writing a simple CRUD with #grails, client asked me to validate pogo&#8217;s birth date (had to be in the last year). In this cases, we can&#8217;t just use regular validators, cause their are static. So we can solve this using our own custom validators, so simple and useful.</p>
<pre class="brush: groovy;">static constraints = {
	//...
	borned(validator: {
		return (it &gt; new Date()-365)
	})
	//...
}</pre>
<p>That&#8217;s it, this way every time a new instance is validated (during save or manually), a new date will be created and compared to it. (no I don&#8217;t care about leap years).</p>
<p>Already <a href="http://twitter.com/lucastex">following me on twitter</a>?</p>
<p>[]s,</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/08/10/a-simple-grails-custom-validator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yuuuuh!!!! We got Grails 1.1.1!</title>
		<link>http://blog.lucastex.com/2009/05/14/yuuuuh-we-got-grails-111/</link>
		<comments>http://blog.lucastex.com/2009/05/14/yuuuuh-we-got-grails-111/#comments</comments>
		<pubDate>Thu, 14 May 2009 15:26:31 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[1.1.1]]></category>
		<category><![CDATA[mail thread]]></category>
		<category><![CDATA[mailing list]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=408</guid>
		<description><![CDATA[As I said earlier, we got Grails 1.1.1 today!!
Take a look in the links below:

Release Notes
JIRA tasks for this version (changelog)
Download
Documentation
Official announce
My happy announce


But watch out! People in the grails mailing list noticed some broken stuff in the build when trying to upgrade. A little workaround is availabe in this mail thread, just keep looking [...]]]></description>
			<content:encoded><![CDATA[<p>As I said earlier, we got Grails 1.1.1 today!!</p>
<p>Take a look in the links below:</p>
<blockquote><ul>
<li><a href="http://grails.org/1.1.1+Release+Notes">Release Notes</a></li>
<li><a href="http://jira.codehaus.org/browse/GRAILS?report=com.atlassian.jira.plugin.system.project:changelog-panel">JIRA tasks for this version (changelog)</a></li>
<li><a href="http://grails.org/Download">Download</a></li>
<li><a href="http://grails.org/doc/1.1.x/">Documentation</a></li>
<li><a href="http://grails.org/blog/graemerocher/Grails+1.1.1+Released">Official announce</a></li>
<li><a href="http://twitter.com/lucastex/status/1794936148">My happy announce</a></li>
</ul>
</blockquote>
<p>But watch out! People in the grails mailing list noticed some broken stuff in the build when trying to upgrade. A little workaround is availabe in <a href="http://www.nabble.com/Exception-while-trying-to-upgrade-webapp-from-Grails-1.1-to-1.1.1-to23541298.html">this mail thread</a>, just keep looking <a href="http://www.nabble.com/Exception-while-trying-to-upgrade-webapp-from-Grails-1.1-to-1.1.1-to23541298.html">this Thread</a>, probably we&#8217;ll get something here!</p>
<p>Thanks!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/05/14/yuuuuh-we-got-grails-111/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking forward Grails 1.1.1</title>
		<link>http://blog.lucastex.com/2009/05/14/looking-forward-grails-111/</link>
		<comments>http://blog.lucastex.com/2009/05/14/looking-forward-grails-111/#comments</comments>
		<pubDate>Thu, 14 May 2009 11:19:48 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[1.1.1]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=397</guid>
		<description><![CDATA[Hi,
Yesterday Guillaume Laforge annouced that finally groovy 1.6.3 is out. That means we&#8217;ll have the Grails 1.1.1 release in a few days (hoping this for today). Graeme Rocher said that with groovy 1.6.3 released, Grails 1.1.1 is imminent. 
So let&#8217;s wait!
I&#8217;m specially waiting this release since it corrects a little bug in WAR generation using [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Yesterday Guillaume Laforge <a href="http://twitter.com/glaforge/status/1785140957">annouced</a> that finally groovy 1.6.3 is out. That means we&#8217;ll have the Grails 1.1.1 release in a few days (hoping this for today). Graeme Rocher said that with groovy 1.6.3 released, <a href="http://twitter.com/graemerocher/status/1785238604">Grails 1.1.1 is imminent</a>. </p>
<p>So let&#8217;s wait!</p>
<p>I&#8217;m specially waiting this release since it corrects a little bug in WAR generation using the &#8211;nojars options.<br />
Ohhh, and of course, with Grails 1.1.1 we&#8217;ll have support to use Grails in the Google Java App Engine!!</p>
<p>Thanks <a href="http://twitter.com/glaforge">Guillaume</a> and <a href="http://twitter.com/graemerocher">Graeme</a>!</p>
<p>[]s,</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/05/14/looking-forward-grails-111/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing the default locale for your grails application</title>
		<link>http://blog.lucastex.com/2009/04/20/changing-the-default-locale-for-your-grails-application/</link>
		<comments>http://blog.lucastex.com/2009/04/20/changing-the-default-locale-for-your-grails-application/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 17:57:41 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=378</guid>
		<description><![CDATA[Thank god grails has a wonderful i18n native support. It&#8217;s great change all your application language just by setting one more parameter in the URL (lang). If you do not know this behaviour, check this out. 
But sometimes you have to preset the default language because not all your applications will be in english, yap [...]]]></description>
			<content:encoded><![CDATA[<p>Thank god <a href="http://www.grails.org">grails</a> has a wonderful i18n native support. It&#8217;s great change all your application language just by setting one more parameter in the URL (lang). If you do not know this behaviour, <a href="http://grails.org/doc/1.1/guide/single.html#10.%20Internationalization">check this out</a>. </p>
<p>But sometimes you have to preset the default language because not all your applications will be in english, yap ? To make this you&#8217;ll have to set your localeResolver in your resources.groovy spring configuration file. just add this code to it. (note that my code is setting my language to brazilian portuguese &#8211; pt_BR)</p>
<pre class="brush: groovy;">
//this is your resources.groovy file
//
beans = {
   localeResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) {
      defaultLocale = new Locale(&quot;pt&quot;,&quot;BR&quot;)
      java.util.Locale.setDefault(defaultLocale)
   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/04/20/changing-the-default-locale-for-your-grails-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[4/25] Jasper Reports in Grails with Dynamic-Jasper</title>
		<link>http://blog.lucastex.com/2009/04/16/4of25-jasper-reports-in-grails-with-dynamic-jasper/</link>
		<comments>http://blog.lucastex.com/2009/04/16/4of25-jasper-reports-in-grails-with-dynamic-jasper/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:45:29 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[dynamic-jasper]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[jasper]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[reportable]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=336</guid>
		<description><![CDATA[This tutorial will talk about producing Jasper PDF reports (or any other format you&#8217;d like) in you grails app.Â  I took a look in grails plugins portal I found two plugins that could be used to do this.Â  The Jasper Plugin and the DynamicJasper Plugin. Depending on what you really need you&#8217;ll choose one.
I see [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will talk about producing Jasper PDF reports (or any other format you&#8217;d like) in you grails app.Â  I took a look in <a href="http://grails.org/plugins">grails plugins portal</a> I found two plugins that could be used to do this.Â  The <a href="http://grails.org/plugin/jasper">Jasper Plugin</a> and the <a href="http://grails.org/plugin/dynamic-jasper">DynamicJasper Plugin</a>. Depending on what you really need you&#8217;ll choose one.</p>
<p>I see the JasperPlugin as a more customizable plugin since you&#8217;ll use it o link to an existing jasper report (.jrxml / .jasper) you have. You&#8217;ll have some work building it, modeling it and sometimes even &#8220;drawing&#8221; it, but if you really need to do your and just your jasper, I recommend this one (congratulations for the Brazilians responsible for this plugin).</p>
<p>Otherwise (and covered in this tutorial), if you just need a simple report for your domain classes (an poor-but-effective PDF view of your scaffold listing) like I need in one project here, the DynamicJasper Plugin is gonna let you rock!</p>
<p>It&#8217;s a simple, and versatile plugin that generate its output entirely dynamic. This means that you won&#8217;t need to open iReport and show us your drawing skills (as a good programmer, you may suck drawing!).</p>
<p>We&#8217;ll work only with the Entities Report that Dynamic Jasper offer us, if you need complex queries on the reports, I recommend you reading the &#8220;named reports&#8221; in the plugins official documentation.</p>
<p>Are you following me and reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a> andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<h3>Tutorial Info</h3>
<p>Groovy Version: 1.6<br />
Grails Version: 1.1<br />
Plugin Version: 0.5<br />
Plugin Documentation: <a href="http://grails.org/plugin/dynamic-jasper">http://grails.org/plugin/dynamic-jasper</a><br />
Download: <a href="http://flv.lucastex.com/jasper/agenda.zip">source code </a></p>
<h3>Basic setup</h3>
<p>Well, our example this time will be a simple agenda, so, let&#8217;s create our agenda app, install the dynamic jasper plugin and then create our domain class with some constraints.</p>
<pre class="brush: groovy;">grails create-app agenda
grails install-plugin dynamic-jasper
grails create-domain-class Contact</pre>
<p>Our initial Contact class will be this one</p>
<pre class="brush: groovy;">class Contact {
   String name
   String nickname
   Date bornAt
   String email
   String website
   String phone
   String mobilePhone
   String gender

   static constraints = {
      name(maxLength: 255)
      nickname(nullable: true)
      bornAt(nullable:true)
      email(email:true)
      website(link:true, nullable:true)
      phone()
      mobilePhone()
      gender(inList:[&amp;quot;M&amp;quot;,&amp;quot;F&amp;quot;])
   }
}</pre>
<h3>Running the application and making it reportable</h3>
<p>That&#8217;s it, you can run your application and test it if you want. Now we&#8217;re going to create our first report, the simplest one we can have. To do this just add this code to your domain class:</p>
<pre class="brush: groovy;">static def reportable = [:]</pre>
<p>This <a href="http://groovy.codehaus.org/JN1035-Maps">map notation</a> will tell what fields will be shown in the report and what options of it you&#8217;re configuring. As we do not specified any, all propeties will be there and the default report will be generated.</p>
<p>After this you can visit the report generator url at <a href="http://localhost:8080/agenda/djReport/index?entity=contact">http://localhost:8080/agenda/djReport/index?entity=contact</a> and this will generate a simple report file (no extension, you should add .pdf) of your contacts.</p>
<p>Very very simple, hÃ£!</p>
<h3>More options (personalization)</h3>
<p>Now let&#8217;s configure some basic options of our report. First of all, I&#8217;ll not get all this properties in our agenda report, let&#8217;s get only the main fields (nick, phone, email):</p>
<pre class="brush: groovy;">def static reportable = [
   columns: ['nickname', 'email', 'phone']
]</pre>
<p>You can run again the report, it will be similar to this one:</p>
<p style="text-align: center;"><img class="size-full wp-image-358 aligncenter" title="report" src="http://blog.lucastex.com/wp-content/uploads/2009/04/report.png" alt="report" width="538" height="62" /></p>
<p>Now, there are some other basic options you might want to configure, like the filename, the report title and other stuff:</p>
<p><strong>title</strong>: The report&#8217;s title, by default if you do not set anything it will be &#8220;[entity-name] report&#8221;.<br />
<strong>fileName</strong>: The name that the response file generated will have<br />
<strong>columns</strong>: the columns shown<br />
</p>
<pre class="brush: groovy;">def static reportable = [
   title: 'My agenda',
   fileName: 'agenda',
   columns: ['nickname', 'email', 'phone']
]</pre>
<p><img class="aligncenter size-full wp-image-371" title="Second report" src="http://blog.lucastex.com/wp-content/uploads/2009/04/screen-capture.png" alt="Second report" width="563" height="69" /></p>
<p>This three will help you start in this great plugin. Take a look in the plugin&#8217;s page to see all you can do.</p>
<p>It&#8217;s a simple but powerful plugin, you can adjust all the page layout, group properties, change the column titles, everything that does not involve the usual iReport drawing process.</p>
<h3>Important Note<strong><br />
</strong></h3>
<p>This note may be valid to other plugins either, but since grails 1.1, the installed plugins is not available in the project&#8217;s folder but in your <strong>HOME_DIR/.grails/1.1/projects/&lt;project&gt;/plugins</strong></p>
<p>So, if you want to use advanced configuration of this (and others) plugin, you shoud enter its folder in <strong>~/.grails/1.1/projects/agenda/plugins/</strong>, and get the configuration file of it, (in our case, <strong>DynamicJasperConfig.groovy</strong>) in its conf folder and save in our <strong>agenda/conf</strong> folder.</p>
<p>This file holds all plugin configuration and it can be used to setup the report layout and configure the named reports I said before.</p>
<p>Again, take a look in the plugin page and you&#8217;ll find everything you need! This is just an introduction of the plugin!</p>
<p>[]s,</p>
<p>Are you following me and reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a> andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/04/16/4of25-jasper-reports-in-grails-with-dynamic-jasper/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Discovering your grails application version</title>
		<link>http://blog.lucastex.com/2009/04/03/discovering-your-grails-application-version/</link>
		<comments>http://blog.lucastex.com/2009/04/03/discovering-your-grails-application-version/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 18:04:20 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[grailsapplication]]></category>
		<category><![CDATA[quicktips]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=333</guid>
		<description><![CDATA[In many projects around, one of the requisites is that our customer should know what version of the application was running in the environment. The first approach that people reaches is to insert a comment in the HTML source code or some static page that contains this info.
Using grails, we manage our application versions using [...]]]></description>
			<content:encoded><![CDATA[<p>In many projects around, one of the requisites is that our customer should know what version of the application was running in the environment. The first approach that people reaches is to insert a comment in the HTML source code or some static page that contains this info.</p>
<p>Using grails, we manage our application versions using the set-version grails command as you should know. After creating your grails application, the default version your application assumes is the 0.1. After some development you&#8217;re highly recommended on changing this. There is infinite approaches on managing app versions, I really like this one:</p>
<pre class="brush: groovy;">grails set-version 20090403-1</pre>
<p>That says this is the first (1) version of today (2009 april&#8217;s third). After that, whe you create your war, the version will be appended in the war file&#8217;s name.</p>
<p>Ok, now that you have your application &#8220;versioned&#8221;, you can retrieve it with this simple line:</p>
<pre class="brush: groovy;">def version = grailsApplication.metadata['app.version']</pre>
<p>Simple and useful!!! This will get the <a href="http://grails.org/doc/1.1/api/org/codehaus/groovy/grails/commons/GrailsApplication.html">grailsApplication</a> reference, that can get this information for you.</p>
<p>Are you following me and reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a> andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/04/03/discovering-your-grails-application-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[3/25] Building a RSS Reader with Quartz Plugin &#8211; Grails Tutorial</title>
		<link>http://blog.lucastex.com/2009/04/02/3of25-building-a-rss-reader-with-quartz-plugin-a-simple-grails-tutorial/</link>
		<comments>http://blog.lucastex.com/2009/04/02/3of25-building-a-rss-reader-with-quartz-plugin-a-simple-grails-tutorial/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 03:40:36 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Nenhuma]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[quartz]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=317</guid>
		<description><![CDATA[Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ signing up to my feedÂ andÂ following me on twitter!
Â 
Groovy Version: 1.6
Grails Version: 1.1
Plugin Version: 0.4.1-SNAPSHOT
Plugin Docs: http://grails.org/plugin/quartz
Download Resources: source code screencast 1Â screencast 2
Hello,
In this tutorial, we&#8217;ll talk about the Quartz plugin used to schedule jobs executions in your application. The [...]]]></description>
			<content:encoded><![CDATA[<p>Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a>Â andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<p>Â </p>
<p><span style="text-decoration: underline;">Groovy Version</span>: 1.6<br />
<span style="text-decoration: underline;">Grails Version</span>: 1.1<br />
<span style="text-decoration: underline;">Plugin Version</span>: 0.4.1-SNAPSHOT<br />
<span style="text-decoration: underline;">Plugin Docs</span>: http://grails.org/plugin/quartz<br />
<span style="text-decoration: underline;">Download Resources</span>: <a href="http://flv.lucastex.com/quartz/feedreader.zip">source code</a> <a href="http://flv.lucastex.com/quartz/quartz_1.swf">screencast 1</a>Â <a href="http://flv.lucastex.com/quartz/quartz_2.swf">screencast 2</a></p>
<p>Hello,</p>
<p>In this tutorial, we&#8217;ll talk about the <a href="http://www.grails.org/plugin/quartz">Quartz plugin</a> used to schedule jobs executions in your application. The plugin is build on top of the <a href="http://www.opensymphony.com/quartz/">Quartz Job Scheduler Library</a> from <a href="http://www.opensymphony.com/">OpenSymphony</a>. OpenSympony is the company that built the <a href="http://www.opensymphony.com/webwork">WebWork</a> framework, that is now called Struts2 after Apache &#8220;aquisition&#8221;.</p>
<p>&#8220;Scheduling jobs&#8221; is very useful in your application to cover background needs. Some tasks you&#8217;ll need to execute undercover your application some times (invalidating old users that have not logged for more than 1 month) or even async processes that you&#8217;ll have to do if you do not have a JMS infrastructure, for example, sending e-mails to a lot of people.</p>
<p>In our example, we&#8217;ll build a simple RSS Reader that will use the quartz plugin to schedule fetchs it will be done in the feeds and insert in the database. Our application will mainly have one domain class called Post (seen in the <a href="http://tinyurl.com/2of5-searchable">last tutorial</a>), a Feed domain class to store our feeds and a similar RSS Parser from technorati. Â (Yes, I love the RSS format).</p>
<p>Initially, we&#8217;ll create the app, install the quartz plugin, create the domain classes and the Feed scaffold structure</p>
<pre class="brush: groovy;">grails create-app feedreader
cd feedreader
grails install-plugin quartz
grails create-domain-class Post</pre>
<p>We&#8217;ll insert the Post domain class code</p>
<pre class="brush: groovy;">class Post {
Â Â  Â String title
Â Â  Â String link
Â Â  Â String body
}</pre>
<p>We have to create the Feed domain class and its scaffold structure.</p>
<pre class="brush: groovy;">grails create-domain-class Feed</pre>
<pre class="brush: groovy;">class Feed {
Â Â  Â String word
Â Â  Â String url
}</pre>
<p>Scaffolding&#8230;</p>
<pre class="brush: groovy;">grails generate-all Feed</pre>
<p><strong>screencast-1</strong><br />
<a href="http://flv.lucastex.com/quartz/quartz_1.swf"><img src="http://blog.lucastex.com/sc.jpg" alt="screencast" /></a></p>
<p>After this, we&#8217;ll create our Technorati Feed Parser from this code above.</p>
<pre class="brush: groovy;">class TechnoratiService {
Â Â  Â boolean transactional = false
Â Â  Â def parseAndSave(rss) {
Â Â  Â Â Â  Â def rssObj = new XmlSlurper().parse(rss)
Â Â  Â Â Â  Â rssObj.channel.item.each {
Â Â  Â Â Â  Â Â Â  Â def post = new Post(title: it.title.toString(),
Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â link: it.link.toString(),
Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â body: it.description.toString())
Â Â  Â Â Â  Â Â Â  Â post.save()
Â Â  Â Â Â  Â Â Â  Â println &quot;Post [${post}] saved.&quot;
Â Â  Â Â Â  Â }
Â Â  Â }
}</pre>
<p>We&#8217;ll run our application using the <strong>grails run-app</strong> command and insert some feeds. Note that we&#8217;ve configured our datasource to use hsqldb storing in the filesystem instead of regular memory setup.Â </p>
<p>Note that we have one JobController that Quartz install for us, forget about it, ok? We&#8217;ll create our own job after the second screencast.</p>
<p><strong>screencast-2</strong><br />
<a href="http://flv.lucastex.com/quartz/quartz_2.swf"><img src="http://blog.lucastex.com/sc.jpg" alt="screencast" /></a></p>
<p>Now, we have to understant some quartz properties and commands.Â </p>
<p>When we install the quatz plugin, it installs another command for us the <strong>grails create-job MyJob</strong>, with it we&#8217;ll create our FeedParserJob. Note that we use convention over configuration with all jobs having <em>*Job</em>Â names.Â </p>
<pre class="brush: groovy;">grails create-job FeedParser</pre>
<p>Job classes have to implement the execute() method. This method is the one that Quartz will trigger when it&#8217;s time to execute the job. To define when the job it will be executed and what&#8217;s the interval between executions, I suggest you read the <a href="http://grails.org/plugin/quartz">plugin documentation</a> witch shows N ways to do this. In our example we&#8217;ll use a <a href="http://en.wikipedia.org/wiki/CRON_expression">cron expression</a> similar to *N*X OS systems setting our job to execute once in five minutes.</p>
<p>Our cron expression will be like this: Â <strong>&#8220;0 0/5 * * * ?&#8221;</strong></p>
<p>Depending on your jobs requisites, it may run concurrently with another instance of it or not. In our case, we&#8217;ll not start other job execution if the last on is still running. To prevent thisÂ behavior, we can set the concurrent property to false</p>
<pre class="brush: groovy;">def concurrent = false</pre>
<p>Our job will essentially look for the feeds we&#8217;ve inserted on the database, and for each one it will call the Technorati service asking for new Posts. The final source for our job is the one below:</p>
<pre class="brush: groovy;">class FeedParserJob {
Â Â  Â def concurrent = false
Â Â  Â def cronExpression = &quot;0 0/5 * * * ?&quot;
Â Â  Â 
Â Â  Â def technoratiService

Â Â  Â def execute() {
Â Â  Â  Â  Â def feedList = Feed.findAll()
Â Â  Â Â Â  Â for (Feed feed : feedList) {
Â Â  Â Â Â  Â Â Â  Â println &quot;Reading feed ${feed.word} @ ${feed.url}&quot;
Â Â  Â Â Â  Â Â Â  Â technoratiService.parseAndSave(feed.url)
Â Â  Â Â Â  Â }
Â Â Â  }
}</pre>
<p>As you can see in the example above, you can inject any spring bean in your job, just declare it as I did with my TechnoratiService! <img src='http://blog.lucastex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (this is really great!)</p>
<p>That&#8217;s it, if you run you application you&#8217;ll see that every 5 minutes (minutes 0,5,10,15&#8230;) the job will be called and every posts technorati returns will be inserted on your database. Note that in this simple example we did not check if the post had been already inserted in the database before inserting it, this will just grow our database with a lot of instances representing the same post. This can be avoided checking if the post already exists before inserting it Â (just check if you have any Post with the same link), but I&#8217;ll left this for you!</p>
<p>Before finish this, let&#8217;s just improve a little bit our post list view.</p>
<p>Â </p>
<div class="mceTemp mceIEcenter">
<dl class="wp-caption aligncenter" style="width: 780px;">
<dt class="wp-caption-dt"><img title="Tela de posts" src="http://blog.lucastex.com/wp-content/uploads/2009/03/quartz.png" alt="Tela de posts" width="770" height="831" /></dt>
</dl>
</div>
<p>Â </p>
<p>Â </p>
<p>Now, try to enrich its interface, adding some ajax to get only the new posts since the last fech! Maybe you can start from this your new Google Reader killer! <img src='http://blog.lucastex.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Now, let me know, are you using this plugin in your production environment? What for? What kind of jobs you do with it?Â </p>
<p>Thanks!</p>
<p>Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a>Â andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<p>Â </p>
<p>Next tutorial: [4of25] Jasper Plugin</p>
<p>Past tutorials:<br />
Â Â  Â Â Â  Â <a href="http://tinyurl.com/2of25-searchable">[2of25] Searchable Plugin</a><br />
Â Â  Â Â Â  Â <a href="http://tinyurl.com/1of25-acegi">[1of25] AcegiSecurity Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/04/02/3of25-building-a-rss-reader-with-quartz-plugin-a-simple-grails-tutorial/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[2/25] Searchable: Full text indexed search in grails</title>
		<link>http://blog.lucastex.com/2009/03/25/2of25-searchable-full-text-indexed-search-in-grails/</link>
		<comments>http://blog.lucastex.com/2009/03/25/2of25-searchable-full-text-indexed-search-in-grails/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:09:50 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[enterprise architecture]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[Lucene]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[searchable]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=225</guid>
		<description><![CDATA[Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ signing up to my feed andÂ following me on twitter!
Introduction
Groovy Version: 1.6
Grails Version: 1.1
Plugin Version: 0.5.3
Plugin Docs: http://www.grails.org/plugin/searchable
Download resources: source code screencast
-
Overview
The Searchable Plugin provides integration between Grails and, IMO, one of the most powerful open source libraries that we [...]]]></description>
			<content:encoded><![CDATA[<p>Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up to my feed</a> andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<h1><strong>Introduction</strong></h1>
<p><span style="text-decoration: underline;">Groovy Version</span>: 1.6<br />
<span style="text-decoration: underline;">Grails Version</span>: 1.1<br />
<span style="text-decoration: underline;">Plugin Version</span>: 0.5.3<br />
<span style="text-decoration: underline;">Plugin Docs</span>: <a href="http://www.grails.org/plugin/searchable">http://www.grails.org/plugin/searchable</a><br />
<span style="text-decoration: underline;">Download resources</span>: <a href="http://blog.lucastex.com/wp-content/uploads/tutorials/25_searchable.zip">source code</a> <a href="flv.lucastex.com/searchable/searchable_1.zip">screencast</a></p>
<p>-</p>
<h1><strong>Overview</strong></h1>
<p>The Searchable Plugin provides integration between Grails and, IMO, one of the most powerful open source libraries that we have. The <a href="http://lucene.apache.org">Apache Lucene Project</a>. I must admit that I&#8217;m a <a href="http://www.theserverside.com/tt/articles/article.tss?l=ILoveLucene">Lucene Lover</a>, since my last project where I was leading a technical team for the largest brazilian e-commerce company and fourth worldwide. The project was totally lucene-driven to store everything you see thereÂ (yes, no database, believe me!); products, prices, categories, everything.Â Of course, the integration processes running backstage took allÂ responsibilityÂ for update product prices and other stuff. For this project, we also used other important frameworks such as <a href="http://lucene.apache.org/solr">Apache Solr</a>.Â I recommend you all look into Apache Lucene. It&#8217;s the base of the <a href="http://www.compass-project.org/">Compass Project</a>, that is the framework that the Searchable Plugin integrates into our app.</p>
<p>All of this will provide us an excellent indexing tool to index our domain classes that will be searchable across our application. Searching in the Lucene index is infinitely lighter and faster than doing a &#8220;LIKE&#8221; select in any kind of relational database, and that&#8217;s why it is so awesome. So, let&#8217;s do it!</p>
<p>-</p>
<h1><strong>Download and Install</strong></h1>
<p>To do this example, we&#8217;ll create an application that searches in our posts archive! I&#8217;ll not save a lot of fake news articles in our bootstrap (as everybody is used to). I&#8217;ll use this tutorial to also show how to read a remote feed/rss! So, I will ask technorati what people are writing about groovy, and we&#8217;ll search on this database, I believ that this is a more realistic example <img src='http://blog.lucastex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>We&#8217;ll have a simple Post class that has only the post title, link and text, and make it searchable.</p>
<p>Creating the application</p>
<div>
<pre class="brush: groovy;">grails create-app postsearch
cdÂ postsearch
grails install-plugin searchable
grails create-domain-class Post</pre>
</div>
<p>This is the Post class</p>
<pre class="brush: groovy;">class Post {
    String title
    String link
    String body

    static searchable = true
    static constraints = {
        //constraints...
    }
}</pre>
<p>Note that doing this:</p>
<pre class="brush: groovy;">static searchable = true</pre>
<p>we are telling the searchable plugin that all instances of this domain class have to be indexed so we can search it later.</p>
<p>Take a look, now in action:</p>
<p><a href="http://flv.lucastex.com/searchable/searchable_1.swf"><img src="http://blog.lucastex.com/sc.jpg" alt="screencast" /></a></p>
<p>-</p>
<h1>Technorati Integration</h1>
<p>To get the technorati feed we&#8217;ll use to search, I build a simple class that will get the search results feed and iterate over the results and save one post for each entry. On technorati, I&#8217;ll search the following words: <strong>groovy</strong>, <strong>grails</strong>, <strong>java</strong>, <strong>griffon</strong>, <strong>springsource</strong>, <strong>g2one</strong>, <strong>acegi</strong>, <strong>groovyws</strong>, andÂ <strong>codehaus. </strong>This will give us approximately 200 posts. I&#8217;ll create a simple controller that will just do this.</p>
<pre class="brush: groovy;">grails create-controller technorati</pre>
<p>and this is its content</p>
<pre class="brush: groovy;">class TechnoratiController {
    def index = {
        def totalPosts = 0
        def wordList = ['groovy', 'grails', 'java', 'griffon', 'springsource',
                'g2one', 'acegi', 'groovyws', 'codehaus'].each() { word -&gt;
            def rss = &quot;http://feeds.technorati.com/search/${word}&quot;
            def rssObj = new XmlSlurper().parse(rss)
            rssObj.channel.item.each { item -&gt;
                def post = new Post(title: item.title.toString(),
                        link: item.link.toString(),
                        body: item.description.toString())
                if (post.save())
                    totalPosts++
            }
        }
        render &quot;${totalPosts} posts indexed&quot;
    }
}</pre>
<p>Maybe we can turn this into a plugin later! <img src='http://blog.lucastex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  That&#8217;s it, no view for it, we just need to request it to feed our database.</p>
<p>-</p>
<h1>Searching with SearchController</h1>
<p>After this you can go to the SearchableController that is installed in our application:</p>
<p><a href="http://localhost:8080/postsearch/searchable">http://localhost:8080/postsearch/searchable</a></p>
<p>Try searching for &#8220;grails&#8221; or any other word that may have been in our technorati posts.</p>
<p>Note that this view uses the toString() method, so lets beautify it.</p>
<pre class="brush: groovy;">String toString() {
    return &quot;${title}: ${body}&quot;
}</pre>
<p><a href="http://blog.lucastex.com/wp-content/uploads/2009/03/screen-capture.png"><img class="size-medium wp-image-287 alignnone" title="SearchController" src="http://blog.lucastex.com/wp-content/uploads/2009/03/screen-capture-300x264.png" alt="SearchController screen" width="300" height="264" /></a><a href="http://blog.lucastex.com/wp-content/uploads/2009/03/posts_tostring.png"><img class="alignnone size-medium wp-image-307" src="http://blog.lucastex.com/wp-content/uploads/2009/03/posts_tostring-280x300.png" alt="" width="280" height="300" /></a></p>
<p>-</p>
<h1>Changing the way fields are indexed</h1>
<p>Our Post class is indexed using the default configuration for the Searchable plugin and that&#8217;s not the best way since the post URL is indexed as well and currently has the same relevance as its title (this is wrong, believe me). IMO, the link should not be indexed, just the title and the text of the post, and the title is <strong>much more</strong> important that its description.</p>
<p>To do this, we&#8217;ll use some plugin options. This plugin has A LOT of options, (it deserves a book of it, really), and all the options are described <a href="http://grails.org/plugin/searchable">here</a>. I strongly recommend you to read this if you use this plugin in your production environment.</p>
<p>Here we&#8217;ll just stick to the basics, we&#8217;ll exclude some properties being indexed and boost one field (title) that is more important. This means that when you search for &#8220;grails&#8221;, posts with &#8220;grails&#8221; in the title will come with a higher score than posts with &#8220;grails&#8221; only in the body of it.</p>
<h2>Excluding link from being indexed</h2>
<p>This is easy! We&#8217;ll change the static searchable = true for this one with the &#8216;except&#8217; property.</p>
<pre class="brush: groovy;">static searchable = {
    except = ['link']
}</pre>
<p>That&#8217;s it, no link will be indexed anymore. It&#8217;s recommended to index ONLY properties you really &#8216;ll need, otherwise your lucene index can grow to be quite large.</p>
<h2>Boosting the title</h2>
<p>This is easier (I don&#8217;t remember anything difficult using grails) than the last one, we&#8217;ll add the property <strong>boost</strong> to our title, and this is the final mapping closure:</p>
<pre class="brush: groovy;">static searchable = {
    except = ['link']
    title boost: 2.0
}</pre>
<p>This will give our searches what we really want.</p>
<p>-</p>
<h1>Searching &#8211; Domain classes</h1>
<p>After installed, the plugins offer us (for domain classes marked as searchable) some methods that will search on the index. Here I&#8217;ll explain some of the most important ones.</p>
<h3>search</h3>
<p>The main method of this plugin. Will search across all instances of this domain class for the requested string (and options)</p>
<pre class="brush: groovy;">def postsListSeachResult = Post.search(&quot;grails&quot;)
def postsListOrderedSearchResult = Post.search(&quot;grails&quot;, [sort: 'title'])</pre>
<p>Remember that ordering searches is not a good idea since you will lose all effective relevance-based scoring that lucene gives to each hit entry.</p>
<h3>countHits</h3>
<p>This method returns just the number of hits that your query retrieved in the index, useful to know how many entries will be returned if the search method was used instead. You can use as <strong>search</strong> method.</p>
<pre class="brush: groovy;">[groovy]def postsListSeachResultCount = Post.countHits(&quot;grails&quot;)
def postsListOrderedSearchResultCount = Post.countHits(&quot;grails&quot;, [sort: 'title'])</pre>
<h3>moreLikeThis and suggestQuery</h3>
<p>&#8220;moreLikeThis&#8221; and &#8220;suggestQuery&#8221; (aka spell checking) can be done easily with Seachable Plugin, all you have to do is set these properties to the mapping closure.</p>
<p>Take a look <a href="http://www.grails.org/Searchable+Plugin+-+Methods+-+moreLikeThis">here</a> and <a href="http://www.grails.org/Searchable+Plugin+-+Methods+-+suggestQuery">here</a> for more information.</p>
<p>-</p>
<h1>Conclusion</h1>
<p>This plugin is one of my favorites. If you&#8217;re planning a grails website in a production environment, this one will be your friend.</p>
<p>Ohh remember that this plugin is much more powerful than shown here, most configuration options available for Compass and Lucene have not been demonstrated here. This is just a small part of it!</p>
<p>Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting articleÂ <a href="http://feeds2.feedburner.com/lucastex">signing up my feed</a> andÂ <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<p>Last Tutorial: Â <a href="http://blog.lucastex.com/2009/03/19/1of25-secure-your-grails-application-with-no-pain-using-acegi/">[1/25] Acegi: Secure your grails application with no pain</a></p>
<p>Next Tutorial: [3/25] Quartz: Easy job scheduling plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/03/25/2of25-searchable-full-text-indexed-search-in-grails/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>My TinyUrl plugin released!</title>
		<link>http://blog.lucastex.com/2009/03/24/my-tinyurl-plugin-released/</link>
		<comments>http://blog.lucastex.com/2009/03/24/my-tinyurl-plugin-released/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 15:05:37 +0000</pubDate>
		<dc:creator>lucastex</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tinyurl]]></category>

		<guid isPermaLink="false">http://blog.lucastex.com/?p=268</guid>
		<description><![CDATA[Hi,
This is the first plugin I release on my own. This is very very simple, and the main reason to do this, is actually to learn how to deal with your own grails plugins.
It&#8217;s called TinyUrl plugin and provides a to your application a service to integrate with TinyUrlÂ URL shrinker website, It&#8217;s simple to user, [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p><a href="http://www.grails.org/plugin/TinyUrl">This is the first plugin I release on my own</a>. This is very very simple, and the main reason to do this, is actually to learn how to deal with your own grails plugins.</p>
<p>It&#8217;s called TinyUrl plugin and provides a to your application a service to integrate with <a href="http://tinyurl.com">TinyUrl</a>Â URL shrinker website, It&#8217;s simple to user, and I recommend to everyone that sends URLs through twitter or other services. Imagine after you insert a post into your blog, you&#8217;ll twitter it:</p>
<p>Inject the service</p>
<pre class="brush: groovy;">def tinyurlService</pre>
<p>and in your action:</p>
<pre class="brush: groovy;">def post = new Post(params)
//save your post

def newUrl = tinyurlService.tiny(post.link)

//set your twitter status
twitter.post(&quot;I've just posted about ${post.title} right here: ${newUrl}&quot;)</pre>
<p>That&#8217;s it!, visit its page:Â <a href="http://www.grails.org/plugin/TinyUrl">http://www.grails.org/plugin/TinyUrl</a></p>
<p>Are you reading my blog&#8217;s feed? Be the first to know when I publish some interesting article <a href="http://feeds2.feedburner.com/lucastex">signing up my feed</a> and <a href="http://www.twitter.com/lucastex">following me on twitter</a>!</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lucastex.com/2009/03/24/my-tinyurl-plugin-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
