<?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>REVERT TO CONSOLE &#187; Groovy</title>
	<atom:link href="http://www.reverttoconsole.com/blog/category/groovy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reverttoconsole.com</link>
	<description>for f in *;do echo &#124; sed &#039;i\rtc&#039; &#62;&#62; $f;done; java programming et al</description>
	<lastBuildDate>Thu, 25 Aug 2011 15:02:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Command Line Dictionary Using Groovy WS</title>
		<link>http://www.reverttoconsole.com/blog/general/command-line-dictionary-using-groovy-ws/</link>
		<comments>http://www.reverttoconsole.com/blog/general/command-line-dictionary-using-groovy-ws/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 22:37:18 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[dictionary command line groovy groovyws ws client bash]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=1015</guid>
		<description><![CDATA[Alas, another 15 years has passed since I&#8217;ve last posted. This time it was prompted by a fairly simple need: to lookup a word via the command line. Now, I already had a very simple solution to this using WordNet. That is simple enough: sudo apt-get install wordnet Then simply type: wn hello -over You [...]]]></description>
			<content:encoded><![CDATA[<p>Alas, another 15 years has passed since I&#8217;ve last posted.  This time it was prompted by a fairly simple need: to lookup a word via the command line.  Now, I already had a very simple solution to this using <a href="http://wordnet.princeton.edu/">WordNet</a>.  That is simple enough:</p>
<pre>
sudo apt-get install wordnet
</pre>
<p>Then simply type:</p>
<pre>
wn hello -over
</pre>
<p>You should see output similar to this:</p>
<p>Overview of noun hello</p>
<p>The noun hello has 1 sense (first 1 from tagged texts)</p>
<p>1. (1) hello, hullo, hi, howdy, how-do-you-do &#8212; (an expression of greeting; &#8220;every morning they exchanged polite hellos&#8221;)</p>
<p>That&#8217;s all well and good, until I typed this:</p>
<pre>wn smote -over</pre>
<p>And came up empty.  Indeed WordNet is useful but it is limited.  There are 2 solutions that immediately came to mind.	</p>
<ol>
<li>Figure out how to get more definitions loaded into my instance of WordNet</li>
<li>Find a dictionary service that is much more comprehensive than WordNet, and write a client for it</li>
</ol>
<p>After a couple of quick Google searches I decided on the latter.  And, since I&#8217;ve been doing a fair amount of Grails work lately, I thought, why not try this in Groovy?</p>
<p>One of those Google searches brought me to <a href="http://services.aonaware.com/DictService/">http://services.aonaware.com/DictService/</a>.  After a few trials with the simple front-end on the page, I was satisfied.  Then it was time to find a Groovy example, which I found quickly enough with <a href="http://groovy.codehaus.org/GroovyWS">Groovy WS</a>.</p>
<p>If you look at the code snippet on that page, it is incredibly simple.</p>
<pre>
@Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.2')
import groovyx.net.ws.WSClient

proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize()

result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"
</pre>
<p>I tried this example as is, but seemed to have problems with the annotation at the top.  Being rather impatient, I found a Groovy WS Standalone jar here at:<br />
<a href="http://snapshots.dist.codehaus.org/groovy/distributions/groovyws/groovyws-standalone-0.5-SNAPSHOT.jar">http://snapshots.dist.codehaus.org/groovy/distributions/groovyws/groovyws-standalone-0.5-SNAPSHOT.jar</a></p>
<p>I dropped it into my $GROOVY_HOME/lib directory, and then removed the annotation from the code.  The example worked perfectly.</p>
<p>So, using the <a href="http://services.aonaware.com/DictService/DictService.asmx?WSDL">WSDL</a> from the service I mentioned earlier, I made a few modifications and named it Pablo.groovy.  Why Pablo?  Why not?  When speed counts, who cares?!</p>
<pre>
import groovyx.net.ws.WSClient

proxy = new WSClient("http://services.aonaware.com/DictService/DictService.asmx?WSDL", this.class.classLoader)
proxy.initialize()

//Define is a name of the service method, see the service WSDL
result = proxy.Define(args[0])

if(result != null) {
	for(defin in result.definitions.definition) {
		println "${defin.wordDefinition}"
	}
}
</pre>
<p>I needed to analyze the WSDL to figure out how to interpret the results, but other than that, it was a pleasantly pain-free experience.</p>
<p>Now I type:</p>
<pre>groovy Pablo.groovy smote</pre>
<p>And I get a much more satisfying result, save the logging garbage at the top!</p>
<p>Jul 18, 2011 5:11:29 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory outputDebug<br />
INFO: Created classes: com.aonaware.services.webservices.ArrayOfDefinition, com.aonaware.services.webservices.ArrayOfDictionary, com.aonaware.services.webservices.ArrayOfDictionaryWord, com.aonaware.services.webservices.ArrayOfStrategy, com.aonaware.services.webservices.Define, com.aonaware.services.webservices.DefineInDict, com.aonaware.services.webservices.DefineInDictResponse, com.aonaware.services.webservices.DefineResponse, com.aonaware.services.webservices.Definition, com.aonaware.services.webservices.Dictionary, com.aonaware.services.webservices.DictionaryInfo, com.aonaware.services.webservices.DictionaryInfoResponse, com.aonaware.services.webservices.DictionaryList, com.aonaware.services.webservices.DictionaryListExtended, com.aonaware.services.webservices.DictionaryListExtendedResponse, com.aonaware.services.webservices.DictionaryListResponse, com.aonaware.services.webservices.DictionaryWord, com.aonaware.services.webservices.Match, com.aonaware.services.webservices.MatchInDict, com.aonaware.services.webservices.MatchInDictResponse, com.aonaware.services.webservices.MatchResponse, com.aonaware.services.webservices.ObjectFactory, com.aonaware.services.webservices.ServerInfo, com.aonaware.services.webservices.ServerInfoResponse, com.aonaware.services.webservices.Strategy, com.aonaware.services.webservices.StrategyList, com.aonaware.services.webservices.StrategyListResponse, com.aonaware.services.webservices.WordDefinition<br />
Jul 18, 2011 5:11:30 PM groovyx.net.ws.AbstractCXFWSClient getBindingOperationInfo<br />
WARNING:  Using SOAP version: 1.1<br />
Smite \Smite\ (sm[imac]t), v. t. [imp. {Smote} (sm[=o]t), rarely<br />
   {Smit} (sm[i^]t); p. p. {Smitten} (sm[i^]t&#8221;t&#8217;n), rarely<br />
   {Smit}, or {Smote}; p. pr. &#038; vb. n. {Smiting}<br />
   (sm[imac]t&#8221;[i^]ng).] [AS. sm[=i]tan to smite, to soil,<br />
   pollute; akin to OFries. sm[=i]ta to smite, LG. smiten, D.<br />
   smijten, G. schmeissen, OHG. sm[=i]zan to smear, stroke, OSw.<br />
   &#038; dial. Sw. smita to smite, Dan. smide to throw, Goth.<br />
   bismeitan, to anoint, besmear; cf. Skr. m[=e]d to be fat. The<br />
   original sense seems to have been, to daub on, to smear. Cf.<br />
   {Smut}.]<br />
   1. To strike; to inflict a blow upon with the hand, or with<br />
      any instrument held in the hand, or with a missile thrown<br />
      by the hand; as, to smite with the fist, with a rod,<br />
      sword, spear, or stone.<br />
      [1913 Webster]</p>
<p>Now to smote the logging and be rid of it; simply adding these few lines will do:</p>
<pre>
import java.util.logging.Level
import java.util.logging.LogManager

LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE)
</pre>
<p>Now the output is as tidy as I want it to be for now.</p>
<p>$ groovy Pablo.groovy smote<br />
Smite \Smite\ (sm[imac]t), v. t. [imp. {Smote} (sm[=o]t), rarely<br />
   {Smit} (sm[i^]t); p. p. {Smitten} (sm[i^]t&#8221;t&#8217;n), rarely<br />
   {Smit}, or {Smote}; p. pr. &#038; vb. n. {Smiting}<br />
   (sm[imac]t&#8221;[i^]ng).] [AS. sm[=i]tan to smite, to soil,<br />
   pollute; akin to OFries. sm[=i]ta to smite, LG. smiten, D.<br />
   smijten, G. schmeissen, OHG. sm[=i]zan to smear, stroke, OSw.<br />
   &#038; dial. Sw. smita to smite, Dan. smide to throw, Goth.<br />
   bismeitan, to anoint, besmear; cf. Skr. m[=e]d to be fat. The<br />
   original sense seems to have been, to daub on, to smear. Cf.<br />
   {Smut}.]<br />
   1. To strike; to inflict a blow upon with the hand, or with<br />
      any instrument held in the hand, or with a missile thrown<br />
      by the hand; as, to smite with the fist, with a rod,<br />
      sword, spear, or stone.<br />
      [1913 Webster]</p>
<p>            Whosoever shall smite thee on thy right cheek, turn<br />
            to him the other also.                &#8211;Matt. v. 39.<br />
      [1913 Webster]</p>
<p>            And David . . . took thence a stone, and slang it,<br />
            and smote the Philistine in his forehead. &#8211;1 Sam.<br />
                                                  xvii. 49.<br />
      [1913 Webster]</p>
<p>   2. To cause to strike; to use as an instrument in striking or<br />
      hurling.<br />
      [1913 Webster]</p>
<p>            Prophesy, and smite thine hands together. &#8211;Ezek.<br />
                                                  xxi. 14.<br />
      [1913 Webster]</p>
<p>            Saul . . . smote the javelin into the wall. &#8211;1 Sam.<br />
                                                  xix. 10.<br />
      [1913 Webster]</p>
<p>   3. To destroy the life of by beating, or by weapons of any<br />
      kind; to slay by a blow; to kill; as, to smite one with<br />
      the sword, or with an arrow or other instrument.<br />
      [1913 Webster]</p>
<p>   4. To put to rout in battle; to overthrow by war.<br />
      [1913 Webster]</p>
<p>   5. To blast; to destroy the life or vigor of, as by a stroke<br />
      or by some visitation.<br />
      [1913 Webster]</p>
<p>            The flax and the barly was smitten.   &#8211;Ex. ix. 31.<br />
      [1913 Webster]</p>
<p>   6. To afflict; to chasten; to punish.<br />
      [1913 Webster]</p>
<p>            Let us not mistake God&#8217;s goodness, nor imagine,<br />
            because he smites us, that we are forsaken by him.<br />
                                                  &#8211;Wake.<br />
      [1913 Webster]</p>
<p>   7. To strike or affect with passion, as love or fear.<br />
      [1913 Webster]</p>
<p>            The charms that smite the simple heart. &#8211;Pope.<br />
      [1913 Webster]</p>
<p>            Smit with the love of sister arts we came. &#8211;Pope.<br />
      [1913 Webster]</p>
<p>   {To smite off}, to cut off.</p>
<p>   {To smite out}, to knock out, as a tooth. &#8211;Exod. xxi. 27.</p>
<p>   {To smite with the tongue}, to reproach or upbraid; to<br />
      revile. [Obs.] &#8211;Jer. xviii. 18.<br />
      [1913 Webster]</p>
<p>Smite \Smite\ (sm[imac]t), v. t. [imp. {Smote} (sm[=o]t), rarely<br />
   {Smit} (sm[i^]t); p. p. {Smitten} (sm[i^]t&#8221;t&#8217;n), rarely<br />
   {Smit}, or {Smote}; p. pr. &#038; vb. n. {Smiting}<br />
   (sm[imac]t&#8221;[i^]ng).] [AS. sm[=i]tan to smite, to soil,<br />
   pollute; akin to OFries. sm[=i]ta to smite, LG. smiten, D.<br />
   smijten, G. schmeissen, OHG. sm[=i]zan to smear, stroke, OSw.<br />
   &#038; dial. Sw. smita to smite, Dan. smide to throw, Goth.<br />
   bismeitan, to anoint, besmear; cf. Skr. m[=e]d to be fat. The<br />
   original sense seems to have been, to daub on, to smear. Cf.<br />
   {Smut}.]<br />
   1. To strike; to inflict a blow upon with the hand, or with<br />
      any instrument held in the hand, or with a missile thrown<br />
      by the hand; as, to smite with the fist, with a rod,<br />
      sword, spear, or stone.<br />
      [1913 Webster]</p>
<p>            Whosoever shall smite thee on thy right cheek, turn<br />
            to him the other also.                &#8211;Matt. v. 39.<br />
      [1913 Webster]</p>
<p>            And David . . . took thence a stone, and slang it,<br />
            and smote the Philistine in his forehead. &#8211;1 Sam.<br />
                                                  xvii. 49.<br />
      [1913 Webster]</p>
<p>   2. To cause to strike; to use as an instrument in striking or<br />
      hurling.<br />
      [1913 Webster]</p>
<p>            Prophesy, and smite thine hands together. &#8211;Ezek.<br />
                                                  xxi. 14.<br />
      [1913 Webster]</p>
<p>            Saul . . . smote the javelin into the wall. &#8211;1 Sam.<br />
                                                  xix. 10.<br />
      [1913 Webster]</p>
<p>   3. To destroy the life of by beating, or by weapons of any<br />
      kind; to slay by a blow; to kill; as, to smite one with<br />
      the sword, or with an arrow or other instrument.<br />
      [1913 Webster]</p>
<p>   4. To put to rout in battle; to overthrow by war.<br />
      [1913 Webster]</p>
<p>   5. To blast; to destroy the life or vigor of, as by a stroke<br />
      or by some visitation.<br />
      [1913 Webster]</p>
<p>            The flax and the barly was smitten.   &#8211;Ex. ix. 31.<br />
      [1913 Webster]</p>
<p>   6. To afflict; to chasten; to punish.<br />
      [1913 Webster]</p>
<p>            Let us not mistake God&#8217;s goodness, nor imagine,<br />
            because he smites us, that we are forsaken by him.<br />
                                                  &#8211;Wake.<br />
      [1913 Webster]</p>
<p>   7. To strike or affect with passion, as love or fear.<br />
      [1913 Webster]</p>
<p>            The charms that smite the simple heart. &#8211;Pope.<br />
      [1913 Webster]</p>
<p>            Smit with the love of sister arts we came. &#8211;Pope.<br />
      [1913 Webster]</p>
<p>   {To smite off}, to cut off.</p>
<p>   {To smite out}, to knock out, as a tooth. &#8211;Exod. xxi. 27.</p>
<p>   {To smite with the tongue}, to reproach or upbraid; to<br />
      revile. [Obs.] &#8211;Jer. xviii. 18.<br />
      [1913 Webster]</p>
<p>Smote \Smote\,<br />
   imp. (&#038; rare p. p.) of {Smite}.<br />
   [1913 Webster]</p>
<p>smite<br />
     v 1: inflict a heavy blow on, with the hand, a tool, or a weapon<br />
     2: affect suddenly with deep feeling; &#8220;He was smitten with love<br />
        for this young girl&#8221;<br />
     3: cause pain or suffering in; &#8220;afflict with the plague&#8221;; &#8220;That<br />
        debasement of the verbal currency that afflicts terms used<br />
        in advertisement&#8221; [syn: {afflict}]<br />
     [also: {smote}, {smitten}, {smit}]</p>
<p>smote<br />
     See {smite}</p>
<p>The results are lengthy, but for right now, it&#8217;s all that I want.  And nay, I shan&#8217;t complain!</p>
<p>It was quick and easy, and as long as I use it less than several thousand times per day, I am operating well within the <a href="http://services.aonaware.com/DictService/tos.htm">terms of service</a>.</p>
<p>Till next time!</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgeneral%2Fcommand-line-dictionary-using-groovy-ws%2F&amp;title=Command+Line+Dictionary+Using+Groovy+WS" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/general/command-line-dictionary-using-groovy-ws/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gaelyk Chat Bot, Step By Step</title>
		<link>http://www.reverttoconsole.com/blog/groovy/gaelyk-chat-bot-step-by-step/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/gaelyk-chat-bot-step-by-step/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 00:58:49 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=633</guid>
		<description><![CDATA[Google App Engine&#8217;s support for chat is nice, and Gaelyk makes it really groovy. After reading the information about it on the Gaelyk tutorial I thought something must be missing &#8211; it seemed like it should be more complicated than it was! Here is what I did, step by step, to get a chat bot [...]]]></description>
			<content:encoded><![CDATA[<p>Google App Engine&#8217;s support for chat is nice, and Gaelyk makes it really groovy. After reading the information about it on the <a href="http://gaelyk.appspot.com/tutorial/">Gaelyk tutorial</a> I thought something must be missing &#8211; it seemed like it should be more complicated than it was!</p>
<p>Here is what I did, step by step, to get a chat bot going on my GAE site using gaelyk:</p>
<p>First I created a class to manage my chatting. It contains static references to GAE&#8217;s xmpp and datastore objects:<br />
<script src="http://gist.github.com/588956.js?file=chat%20groovy"></script></p>
<p>Next I created a simple form to manage invites, complete with backend to initiate the invitations. Keep in mind before you can send and receive messages you need to accept an invitation!:</p>
<p>Form:<br />
<script src="http://gist.github.com/588957.js?file=chat%20form%20gaelyk"></script></p>
<p>Groovy:<br />
<script src="http://gist.github.com/588958.js?file=groovylet"></script></p>
<p>Next, I enabled the inbound services on the appengine-web.xml, and the XmppServlet&#8217;s on the web.xml. This is described on the gaelyk tutorial.</p>
<p>Lastly, I created jabber.groovy in WEB-INF to handle incoming messages:<br />
<script src="http://gist.github.com/588965.js?file=jabber.groovy"></script></p>
<p>TODO:</p>
<ul>
<li>Uninvite, or block those previously invited</li>
<li>Mask appid with a better chat name</li>
</ul>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgaelyk-chat-bot-step-by-step%2F&amp;title=Gaelyk+Chat+Bot%2C+Step+By+Step" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/gaelyk-chat-bot-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Thoughtworks Rover Problem &#8211; Groovy Edition</title>
		<link>http://www.reverttoconsole.com/blog/groovy/the-product-of-scorn/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/the-product-of-scorn/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 18:43:46 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=542</guid>
		<description><![CDATA[I had some down time at work, and set about working on the Rover problem. There are three problems, I chose the middle one to start with. I wrote it in groovy and used the very groovy clibuilder M. Laforge recommended in his comment. I mavenized it to make it easier to share. You can [...]]]></description>
			<content:encoded><![CDATA[<p>I had some down time at work, and set about working on <a href="http://www.technicalypto.com/2010/02/thoughtworks-mass-rovers-coding-problem.html">the Rover problem</a>.</p>
<p>There are three problems, I chose the middle one to start with. I wrote it in groovy and used the <a href="http://www.reverttoconsole.com/blog/codesnippets/groovy-clibuilder-in-practice/">very groovy clibuilder M. Laforge recommended in his comment</a>. I mavenized it to make it easier to share.</p>
<p>You can find my solution <a href="http://github.com/ehemminger/groovy-rover">here </a>if you&#8217;re interested. It&#8217;s a good practice problem.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fthe-product-of-scorn%2F&amp;title=The+Thoughtworks+Rover+Problem+%26%238211%3B+Groovy+Edition" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/the-product-of-scorn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing Grails Apps in Eclipse</title>
		<link>http://www.reverttoconsole.com/blog/grails/developing-grails-apps-in-eclipse/</link>
		<comments>http://www.reverttoconsole.com/blog/grails/developing-grails-apps-in-eclipse/#comments</comments>
		<pubDate>Sat, 09 May 2009 21:11:53 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.reverttoconsole.com/?p=368</guid>
		<description><![CDATA[This was a post I was planning on linking to; a colleague of mine was going to write a post about it, but he hasn&#8217;t yet and I&#8217;ve just spent an extra hour trying to get this to work and am frustrated- and so here is the post you&#8217;ve all been waiting for. There are [...]]]></description>
			<content:encoded><![CDATA[<p>This was a post I was planning on linking to; a colleague of mine was going to write a post about it, but he hasn&#8217;t yet and I&#8217;ve just spent an extra hour trying to get this to work and am frustrated- and so here is the post you&#8217;ve all been waiting for.</p>
<p>There are lots of holes in the existing documentation about setting up eclipse to work with grails.</p>
<p>First off, you will want to generate groovy class files to a directory, like bin-groovy. It&#8217;s not just for debugging, it&#8217;s also for running unit tests. Running unit tests from eclipse is a lot faster than running them from the command line, because eclipse will generate the class files needed as you develop. It&#8217;s really nice to have.</p>
<p>Here&#8217;s where the fun starts- let&#8217;s assume you want to use a plugin. It&#8217;s a reasonable assumption, since there are so many cool plugins available. The first thing you need to know is where plugins download and install to. These go to a plugin directory in your .grails directory, which is normally in your home folder. You&#8217;ll need the jars from these plugins in your eclipse classpath, so you&#8217;ll need to unzip them and add them as external jars. Then, you&#8217;ll also need the source from those plugins in your classpath. For this, I added an External Class Folder to my Java Build Path- the folder was located in .grails/projects/<my project>/classes.</p>
<p>While you&#8217;ll want to uncheck the Disable Groovy Compiler Generating Class File checkbox, you&#8217;ll want to enable the Disable Check Package Matches Source Directory, otherwise you&#8217;ll have a compiler error from resources.groovy.</p>
<p>Finally, add bin-groovy as a class folder to your java build path libraries tab.</p>
<p><a href="http://enterprisejavatechblog.blogspot.com/2008/12/unit-testing-grails-in-eclipse.html">This entry was a big help</a>.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgrails%2Fdeveloping-grails-apps-in-eclipse%2F&amp;title=Developing+Grails+Apps+in+Eclipse" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/grails/developing-grails-apps-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Groovy Environment Scripting</title>
		<link>http://www.reverttoconsole.com/blog/groovy/groovy-environment-scripting/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/groovy-environment-scripting/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 20:30:08 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/?p=201</guid>
		<description><![CDATA[Problem: You want to use groovy all the time, but ignorant (but paying) forces keep you writing verbose tedious Java code instead. Solution: Use groovy instead of shell scripts! In large Java development projects, developing in a local environment comes with a maddening list of pulling levers, pushing buttons, and spinning wheels. Many of these [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong> You want to use groovy all the time, but ignorant (but paying) forces keep you writing verbose tedious Java code instead.</p>
<p><strong>Solution:</strong> Use groovy instead of shell scripts! In large Java development projects, developing in a local environment comes with a maddening list of pulling levers, pushing buttons, and spinning wheels. Many of these can be automated with scripts, and those that can can be Groovy scripts.</p>
<p>I wrote this script to clean up after <a href="http://www.liferay.com/web/guest/home">liferay portal</a> kruft:</p>
<p>[sourcecode language='java']<br />
#!/usr/bin/env groovy</p>
<p>class Build{<br />
    def ant = new AntBuilder()<br />
    def localhostDir = &#8220;C:/dev/liferay/tomcat/work/Catalina/localhost&#8221;<br />
    def portraitDir = localhostDir + &#8220;/portrait&#8221;<br />
    def liferayDir = &#8220;C:/Documents and Settings/ujxh744/liferay&#8221;<br />
    def luceneDir = liferayDir + &#8220;/lucene&#8221;<br />
    def classpath = ant.path {<br />
        dirset(dir: liferayDir){<br />
            include(name: &#8220;*&#8221;)<br />
        }<br />
        dirset(dir: localhostDir) {<br />
            include(name: &#8220;*&#8221;)<br />
        }<br />
   }</p>
<p>    void cleanUpLiferayShit() {<br />
        ant.delete(dir: portraitDir)<br />
        ant.delete(dir: luceneDir)<br />
    }</p>
<p>    void echoDirectories(dirPath) {<br />
        def pathList = dirPath.list()<br />
        println &#8220;There are &#8221; + dirPath.size() + &#8221; remaining directories&#8221;<br />
        dirPath.list().each{ arg -><br />
            println arg<br />
        }<br />
    }<br />
}</p>
<p>def b = new Build()<br />
b.cleanUpLiferayShit()<br />
b.echoDirectories( b.getClasspath())<br />
[/sourcecode]</p>
<p>Reference Links:<br />
<a href="http://www.javaworld.com/javaworld/jw-10-2004/jw-1004-groovy.html">Javaworld</a><br />
<a href="http://groovy.codehaus.org/Using+Ant+from+Groovy">Groovy Ant site</a></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-environment-scripting%2F&amp;title=Groovy+Environment+Scripting" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/groovy-environment-scripting/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Grails Extended ManyToMany GORM Example</title>
		<link>http://www.reverttoconsole.com/blog/grails/grails-manytomany-gorm-example/</link>
		<comments>http://www.reverttoconsole.com/blog/grails/grails-manytomany-gorm-example/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 21:51:47 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/194</guid>
		<description><![CDATA[This is a variation on this article. Having never been a big fan of writing XML, I&#8217;ll gladly opt for the XML-less version. The first example online I found has some formatting issues and just seems a little hard to follow. My step by step example follows after the jump. Call it the &#8220;Grails extended [...]]]></description>
			<content:encoded><![CDATA[<p>This is a variation on <a href="http://grails.org/Many-to-Many+Mapping+without+Hibernate+XML">this article</a>. Having never been a big fan of writing XML, I&#8217;ll gladly opt for the XML-less version. <a href="http://grails.org/Many-to-Many+Mapping+without+Hibernate+XML">The first example online</a> I found has some formatting issues and just seems a little hard to follow.</p>
<p>My step by step example follows after the jump. Call it the &#8220;Grails extended many-to-many step-by-step guide using the grails console, for dummies&#8221;.</p>
<p><span id="more-164"></span></p>
<p>Let&#8217;s start with a very simple example:</p>
<blockquote><p>A person has one or more characteristics. A characteristic can be applied to more than one person. A PersonCharacteristic relationship has an assignedValue.</p></blockquote>
<p>Here&#8217;s what I did:</p>
<pre>
<code>
grails create-domain-class person

grails create-domain-class characteristic

grails create-domain-class personCharacteristic
</code>
</pre>
<p>First I fleshed out Person:</p>
<pre>
class Person {

	static hasMany = [characteristics:PersonCharacteristic]

	String firstName
	String lastName

	List characteristics() {
		return characteristics.collect{it.characteristic}
	}

	List addCharacteristic(Characteristic characteristic) {
		return addCharacteristic(characteristic, new Integer(1))
	}

	List addCharacteristic(Characteristic characteristic, Integer assignedValue) {
		PersonCharacteristic.link(this, characteristic, assignedValue)
		return characteristics()
	}

	List removeFromCharacteristics(Characteristic characteristic) {
		PersonCharacteristic.unlink(this, characteristic)
		return characteristics()
	}

}
</pre>
<p>and Characteristic is pretty similar</p>
<pre>
class Characteristic {

	static hasMany = [people:PersonCharacteristic,employers:EmployerCharacteristic]

	String name
	String description
	Integer systemWeight = new Integer(1)

	List people() {
		return people.collect{it.person}
	}

	List employers() {
		return employers.collect{it.employer}
	}

	List addToEmployers(Employer employer) {
		EmployerCharacteristic.link(employer, this)
		return employers()
	}

	List addToPeople(Person person) {
		PersonCharacteristic.link(person, this)
		return people()
	}

	List removeFromEmployers(Employer employer) {
		EmployerCharacteristic.unlink(employer, this)
		return employers()
	}

	List removeFromPeople(Person person) {
		PersonCharacteristic.unlink(person, this)
		return people()
	}
}
</pre>
<p>and finally, PersonCharacteristic</p>
<pre>
class PersonCharacteristic {

	def Person person
	def Characteristic characteristic
	def Integer assignedValue

	static PersonCharacteristic link(Person person, Characteristic characteristic) {

		return link(person, characteristic, new Integer(1))
	}

	static PersonCharacteristic link(Person person, Characteristic characteristic, Integer assignedValue ) {
		def pc = PersonCharacteristic.findByPersonAndCharacteristic(person, characteristic)
		if (!pc) {
			pc = new PersonCharacteristic(userWeight:1)
			pc.person = person
			pc.characteristic = characteristic
			pc.assignedValue = assignedValue
			person?.addToCharacteristics(pc)
			characteristic?.addToPeople(pc)
			pc.save()
		}
		return pc
	}

	static void unlink(Person person, Characteristic characteristic) {
		def pc = PersonCharacteristic.findByPersonAndCharacteristic(person, characteristic)
		if (pc) {
			person?.removeFromCharacteristics(pc)
			characteristic?.removeFromPeople(pc)
			pc.delete()
		}
	}
}
</pre>
<p><strong>Note:</strong> if you want an explanation of this class <a href="http://grails.org/Many-to-Many+Mapping+without+Hibernate+XML">look here</a> and read the section <em>The Many-to-Many map</em>.</p>
<p>Now, with any luck we&#8217;ll be able to do this with the console&#8230;</p>
<p>(I would assume you know this but just in case&#8230; go to your project base dir and type&#8230;</p>
<pre>
grails console
</pre>
<p>Now here are some people and characteristics. This is the easy part.</p>
<pre>
def a = new Person(firstName: "Jeff", lastName: "Revert")
a.save()
def b = new Person(firstName: "Priyatam", lastName: "Console")
b.save()
def c = new Characteristic(name: "Stupid", description: "slow of mind")
c.save()
def d = new Characteristic(name: "Handsome", description: "a pleasing appearance")
d.save()
</pre>
<p>you should see this output if you&#8217;re following along correctly:</p>
<blockquote><p>
Result: Characteristic : 2
</p></blockquote>
<p>But why take my word for it? Test it!</p>
<pre>
def jeff = Person.findByFirstName('Jeff')
def priyatam = Person.findByFirstName('Priyatam')
def stupid = Characteristic.findByName('Stupid')
def handsome = Characteristic.findByName('Handsome')
if(jeff) {
    println "Found Jeff"
}
if(priyatam) {
    println "Found Priyatam"
}
if(stupid) {
    println "Found Stupid"
}
if(handsome) {
    println "Found Handsome"
}
</pre>
<p>You should see this output:</p>
<blockquote><p>
Found Jeff<br />
Found Priyatam<br />
Found Stupid<br />
Found Handsome
</p></blockquote>
<p>Next we need to add our characteristics to our people.</p>
<pre>
def person = Person.findByFirstName('Jeff')
def characteristic = Characteristic.findByName('Stupid')
person.addCharacteristic(characteristic)
</pre>
<p>and the resulting output:</p>
<blockquote><p>
Result: [Characteristic : 1]
</p></blockquote>
<p>I should be set with my many to many relationship!</p>
<p>Not convinced? I know how you feel&#8230;</p>
<p>One problem with Grails default database config is that you can&#8217;t easily go there and check out the schema. Well, I don&#8217;t know how to anyway, and I&#8217;m guessing I&#8217;m not alone. In my real world job I always check out the database. It&#8217;s like a security blanket, only with a penchant for evil. Anyway, it&#8217;s not that <a href="http://hsqldb.org/">HSQLDB</a> can&#8217;t provide it, it&#8217;s that the config isn&#8217;t running an in-memory database capable of connecting to. So change the development datasource url to this:</p>
<pre>
url = "jdbc:hsqldb:hsql://localhost:9001/devDB"
</pre>
<p>Open a new shell, go to your grails install directory, and run this:</p>
<pre>
java -cp ./lib/hsqldb-1.8.0.5.jar org.hsqldb.Server -database.0 mem:devDB -dbname.0 devDB
</pre>
<p>This will run an in memory database server that you can connect to with your favorite database exploring app. Now fire up the grails console again, and let&#8217;s add this stuff again.<br />
After adding the people and characteristics, and adding the PersonCharacteristic, check out the tables. I see PERSON, CHARACTERISTIC, and PERSON_CHARACTERISTIC.</p>
<pre>
select * from person_characteristic
</pre>
<p>and this shows I&#8217;ve got a PERSON_CHARACTERISTIC table with an ID, VERSION, CHARACTERISTIC_ID, PERSON_ID, and ASSIGNED_VALUE columns with values 1,0,1,1,1. So you get exactly what you&#8217;d expect. Not bad!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/grails/grails-manytomany-gorm-example/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>GORM Relationships in the Grails Console</title>
		<link>http://www.reverttoconsole.com/blog/grails/gorm-relationships-in-the-grails-console/</link>
		<comments>http://www.reverttoconsole.com/blog/grails/gorm-relationships-in-the-grails-console/#comments</comments>
		<pubDate>Thu, 29 May 2008 21:10:03 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/187</guid>
		<description><![CDATA[I&#8217;ve just started scratching the surface with Grails. A good starting point seems to be understanding GORM or Grails Object Relational Mapping, which is based on Hibernate3. In looking at the Grails tutorials online, you might be inclined to start using Grails via scaffolding and generating controllers and views. And this is fine, but another [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just started scratching the surface with Grails. A good starting point seems to be understanding <a href="http://docs.codehaus.org/display/GRAILS/GORM">GORM </a>or Grails Object Relational Mapping, which is based on <a href="http://www.hibernate.org/">Hibernate3</a>.</p>
<p>In looking at the Grails tutorials online, you might be inclined to start using Grails via scaffolding and generating controllers and views. And this is fine, but another perhaps smaller step alternative is to start with the <a href="http://grails.org/doc/1.0.x/ref/Command%20Line/console.html">Grails Console</a> and mess around with the relationships you&#8217;re likely to form in the database.</p>
<p>I found that diving in with some of the tutorials, it isn&#8217;t always obvious why you&#8217;d dynamically scaffold versus performing a static scaffold, or you might not pick up on the power of groovy pages immediately. So I found working with the grails console and GORM to start with eliminated some of the mystery, and provided a solid foundation for further learning. <a href="http://reverttoconsole.com/archives/186">In my previous post</a> I discussed some of the subtle, perhaps unexpected, issues with persisting domain objects in the grails console. Here&#8217;s how I added relationships (after the jump).</p>
<p><span id="more-159"></span></p>
<p>Let&#8217;s start with person and characteristic domain objects:</p>
<pre>
grails create-domain-class person
grails create-domain-class characteristic
</pre>
<p>This will create domain class Person, which we will edit to look like:</p>
<pre>
class Person {
        static hasMany = [characteristics:Characteristic]
	static optionals = ['middleInitial']
        static constraints = {middleInitial(maxLength:1)}
	String firstName
	String lastName
	String middleInitial
}
</pre>
<p>and the Characteristic class:</p>
<pre>
class Characteristic {

	static belongsTo = Person
	static optionals = ['displayName']
	String name
	String displayName
	Integer systemLevel
}
</pre>
<p>Now fire up the grails console, you can persist the relationship as follows:</p>
<p>[/java]<br />
def c = new Characteristic(name: &#8220;lazy&#8221;, displayName: &#8220;exudes laziness&#8221;, systemLevel: 1)<br />
def p = new Person(firstName: &#8220;Jeff&#8221;, lastName: &#8220;Smith&#8221;, middleInitial: &#8220;S&#8221;,<br />
characteristics:
<pre></pre>
<p>)<br />
p.save()<br />
[/java]</p>
<p>After executing, this should display:</p>
<pre>
Result: Person : 1
</pre>
<p>And how about some built-in querying?</p>
<p>Domain object plus .get(id) will retrieve by identifier:</p>
<pre>
def newGuy = Person.get(1)

if(newGuy) {
println newGuy.firstName
} else {
println "No new guy was found!"
}
</pre>
<p>You should see &#8220;Jeff&#8221; as the output.</p>
<p><a href="http://grails.org/doc/1.0.x/guide/single.html#5.4.1%20Dynamic%20Finders">Dynamic finders</a> are where you really see some interesting things:</p>
<pre>
def f = Person.findByFirstName('Jeff')
if(f) {
  println f.lastName
  println f.characteristics.each{ println it.name }
} else {
  println "No Person with the first name of Jeff was found!"
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/grails/gorm-relationships-in-the-grails-console/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grails Startup Pain</title>
		<link>http://www.reverttoconsole.com/blog/groovy/grails-startup-pain/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/grails-startup-pain/#comments</comments>
		<pubDate>Tue, 27 May 2008 16:06:10 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/186</guid>
		<description><![CDATA[Grails is a composed of a stack I like, a combination of technologies I&#8217;ve enjoyed using over the last few years- Groovy, HSQLDB, Spring, Hibernate, etc. And the whole seems greater than the sum of its parts, so while I&#8217;m complaining about it today, I do so knowing that with future releases Grails could really [...]]]></description>
			<content:encoded><![CDATA[<p>Grails is a composed of a stack I like, a combination of technologies I&#8217;ve enjoyed using over the last few years- Groovy, HSQLDB, Spring, Hibernate, etc. And the whole seems greater than the sum of its parts, so while I&#8217;m complaining about it today, I do so knowing that with future releases Grails could really deliver a great solution.</p>
<p>One thing that many new frameworks are striving to offer these days is a quick startup- you can push this button, pull this lever, and voila, you have a hello world and can build from there. Of course this sounds better than writing a domain class, a dao, a service class, then enter some BS in your web.xml, and wire your beans, and add a *-servlet.xml, configure log4j, etc etc etc. And it is. Except when it doesn&#8217;t work.</p>
<p>My initial attempt at creating a Grails project went like this:</p>
<ul>
<li><em>grails create-app</em> created my application.</li>
<li><em>import project</em> imported my project into Eclipse. I ended up with 25 or so classes in my base directory.</li>
<li><em>grails run-app</em> runs Jetty. I pull up a browser and can see my new site- everything appears to be going great.</li>
<li><em>grails create-domain-class</em> Create a domain class. Edit the domain class file, add a few properties. Easy.</li>
<li><em>grails create-controller</em> Creates a controller class. Remove the index() method and add def scaffold = domain class.</li>
<li><em>grails run-app</em> start my server again. This time I see my controller, click on it.
</ul>
<blockquote><p>NullPointerException</p></blockquote>
<p>The crazy thing is, this is after following directions from <a href="http://www.amazon.com/Definitive-Guide-Grails/dp/1590597583">the book written by the lead developer of the Grails</a> project! Ouch!</p>
<p>Here&#8217;s another example:</p>
<p><a href="http://grails.org/Quick+Start">The getting started with Grails documentation</a> highlights using Bootstrap.groovy in grails-app/conf as a place to inject test data.</p>
<p>So for example, using a domain class Bookmark, in the Bootstrap.groovy file you could write:</p>
<pre>
new Bookmark(property1: "value1", property2: "value2").save()
</pre>
<p>and have the bookmark show up in the Grails scaffolding.</p>
<p>With this approach I ended up with a &#8220;NoMethodException&#8221; saying that save() was not a valid method for this domain class.</p>
<p>Nice.</p>
<p>Another approach mentioned using the groovy console to add data. I could create an object, such as the Bookmark, but again I could not save it. This time it seemed like after creating it, it could not find the object in the stack.</p>
<p>I will continue to post about this as I find out the source of my problems.</p>
<p><strong>Update 5/28/08:</strong> After rereading the extensive <a href="http://docs.codehaus.org/display/GRAILS/Eclipse+IDE+Integration">&#8220;how to set up a Grails project in Eclipse&#8221;</a> documentation, it became clear that without disabling the Groovy plugin auto-compilation feature, I wouldn&#8217;t have much success. In fact, after last night&#8217;s effort I&#8217;ve made some nice progress and am beginning to see some similarities between Grails and Seam, at least in terms of work-cycle.</p>
<p>I&#8217;m frustrated though, by the fact that grails shell is not working for me. I believe the issue is that <a href="http://jira.codehaus.org/browse/GRAILS-163">I&#8217;m using cygwin</a>. It may be time to just switch over the linux entirely.</p>
<p><strong>Update: </strong> The &#8220;grails console&#8221; option appears to work.<br />
<img src="http://reverttoconsole.com/wiki/images/6/64/Grailsconsole.jpg" alt="Grails Console" /></p>
<p><strong>Update 5/29/08:</strong> One thing I&#8217;ve noticed is that given a domain object like this:</p>
<pre>
class Person {
	static optionals = ['middleInitial']
	String firstName
	String lastName
	String middleInitial
}
</pre>
<p>In the grails console, you MUST specify the optional property middleInitial in order to successfully create an object. Unfortunately, there&#8217;s no warning or explanation in the console. It just doesn&#8217;t work without all properties being passed in the constructor.</p>
<p>So this will work:</p>
<pre>
def p = new Person(firstName: "test", lastName: "test", middleInitial: "m")
p.save()
</pre>
<p>But this will not:</p>
<pre>
def p = new Person(firstName: "test", lastName: "test")
p.save()
</pre>
<p>And neither will this:</p>
<pre>
def p = new Person()
p.firstName = "test"
p.lastName = "test"
p.save()
</pre>
<p>But this will:</p>
<pre>
def p = new Person()
p.firstName = "test"
p.lastName = "test"
p.middleInitial  = "m"
p.save()
</pre>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgrails-startup-pain%2F&amp;title=Grails+Startup+Pain" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/grails-startup-pain/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>My Latest Issue with Groovy, Spring, and Hibernate</title>
		<link>http://www.reverttoconsole.com/blog/groovy/my-latest-issue-with-groovy-spring-and-hibernate/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/my-latest-issue-with-groovy-spring-and-hibernate/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 01:24:05 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Hibernate/JPA]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/160</guid>
		<description><![CDATA[I started this post about a year ago; I will admit my use of groovy has been a little tumultuous, and that&#8217;s prevented me from writing much about it. I&#8217;ve started a little webapp project &#8211; just something simple at first, to get back into doing the type of work that I enjoy doing (as [...]]]></description>
			<content:encoded><![CDATA[<p>I started this post about a year ago; I will admit my use of <a href="http://groovy.codehaus.org/">groovy</a> has been a little tumultuous, and that&#8217;s prevented me from writing much about it.</p>
<p>I&#8217;ve started a little webapp project &#8211; just something simple at first, to get back into doing the type of work that I enjoy doing (as opposed to what I have to do to earn a living)&#8230;</p>
<p>The thing is, I keep running into Groovy <a href="http://jira.codehaus.org/browse/GROOVY-1978">bugs</a> that appear to be <a href="http://jira.codehaus.org/browse/GROOVY-499">closed</a> but are still in the latest release, after debugging for an hour or two. In looking through the groovy website for a release candidate or some beta or alpha version, I didn&#8217;t see one. So rather than chalk up my efforts to a wasted attempt, I thought I&#8217;d post what I have here:</p>
<p><span id="more-135"></span></p>
<p>Here is what I put together for a simple spring config:</p>
<pre>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
			<value>classpath:org/reverttoconsole/mymediamanager/resource/mmm.properties</value>
		</property>
	</bean>

	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
			<ref bean="mmmDataSource"/>
		</property>
<property name="annotatedPackages">
<list>
				<value>org.reverttoconsole.mymediamanager.model</value>
			</list>
		</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.default_schema">
					${default.schema}
				</prop>
<prop key="hibernate.dialect">
					${hibernate.dialect}
				</prop>
<prop key="hibernate.cache.provider_class">
					org.hibernate.cache.EhCacheProvider
				</prop>
			</props>
		</property>
	</bean>

	<bean id="mmmHibernateTxManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
			<ref local="sessionFactory" />
		</property>
<property name="nestedTransactionAllowed"><value>true</value></property>
	</bean>

    <bean id="mmmDataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close">
<property name="driverClassName">
            <value>${driver.class}</value>
        </property>
<property name="url">
        	<value>${jdbc.url}</value>
        </property>
<property name="username">
            <value>${mmm.user}</value>
        </property>
<property name="password">
            <value>${mmm.password}</value>
        </property>
    </bean>

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
    </bean>

    <bean id="mediaDao" class="org.reverttoconsole.mymediamanager.dao.MediaDao">
<property name="hibernateTemplate">
    		<ref bean="hibernateTemplate"/>
    	</property>
    </bean>

</beans>
</pre>
<p>This is what I had in place for a model class:</p>
<pre>
package org.reverttoconsole.mymediamanager.model;

import javax.persistence.Entity
import javax.persistence.SequenceGenerator
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.persistence.Column
import javax.persistence.Table
import javax.persistence.Basic

@Entity
@Table(name="MEDIA")
@SequenceGenerator(
	    name="SEQ_GEN",
	    sequenceName="media_seq", allocationSize=20)
class Media {

	@Id
	@GeneratedValue(generator = "media_seq")
	@Column(name="MEDIA_ID")
	def mediaId

	@Basic(optional=false)
	@Column(nullable=false)
	def type

	@Basic(optional=false)
	@Column(nullable=false)
	def fileName

	@Basic(optional=false)
	@Column(nullable=false)
	directory
}
</pre>
<p>And a dao:</p>
<pre>
package org.reverttoconsole.mymediamanager.dao;

import org.reverttoconsole.mymediamanager.model.Media
import org.springframework.orm.hibernate3.support.HibernateDaoSupport

class MediaDao extends HibernateDaoSupport {

	void addMedia(def media){
		hibernateTemplate.save(media)
	}
}
</pre>
<p>My simple integration test looked like this:</p>
<pre>
package org.reverttoconsole.mymediamanager.integration

import org.apache.log4j.xml.DOMConfigurator
import org.springframework.context.support.ClassPathXmlApplicationContext

import org.reverttoconsole.mymediamanager.dao.MediaDao

class SimpleTest extends GroovyTestCase {

	def context
	def mediaDao

	void setUp() {
		DOMConfigurator.configure("src/org/reverttoconsole/mymediamanager/resource/log4j.xml")
		context =
			new ClassPathXmlApplicationContext("./org/reverttoconsole/mymediamanager/resource/mmmDatabaseContext.xml")
	}

	void testSomething() {
                assert context
		mediaDao = (MediaDao)context.getBean("mediaDao")
// still working on this...
	}

}
</pre>
<p>And I added an ant script:</p>
<pre>
<project name="mymediamanager" basedir=".">
<property name="web.dir"		value="web"/>
<property name="src.dir"		value="src"/>
<property name="test.src.dir"	value="test"/>
<property name="lib.dir"		value="${web.dir}/WEB-INF/lib"/>
<property name="classes.dir"	value="${web.dir}/WEB-INF/classes"/>
<path id="classpath">
		<fileset dir="${lib.dir}">
			<include name="/*.jar"/>
		</fileset>
	</path>
<path id="test.classpath">
<pathelement path="${classes.dir}"/>
<path refid="classpath"/>
	</path>

	<target name="clean">
		<delete dir="${classes.dir}"/>
	</target>

	<target name="print.classpath">
<pathconvert pathsep="${line.separator}"
	            property="print.classpath"
	            refid="classpath"/>
		<echo message="${print.classpath}"/>
	</target>

	<target name="print.test.classpath">
<pathconvert pathsep="${line.separator}"
	            property="print.classpath"
	            refid="test.classpath"/>
		<echo message="${print.classpath}"/>
	</target>

	<target name="compile.all">
		<antcall target="compile.mymediamanager" />
		<antcall target="compile.tests"/>
	</target>

	<target name="compile.mymediamanager">
		<groovyc srcdir="${src.dir}"
			destdir="${classes.dir}"
			includes="**/*.groovy"
			classpathref="classpath">
		</groovyc>
	</target>

	<target name="compile.tests">
		<groovyc srcdir="${test.src.dir}"
			destdir="${classes.dir}"
			includes="**/*.groovy"
			classpathref="test.classpath">
		</groovyc>
	</target>

	<target name="run.tests">
		<groovy src="test/org/reverttoconsole/mymediamanager/integration/SimpleTest.groovy"
			classpathref="test.classpath" />
	</target>

	<taskdef name="groovyc"
		classname="org.codehaus.groovy.ant.Groovyc"
		classpathref="classpath"/>
	<taskdef name="groovy"
	    classname="org.codehaus.groovy.ant.Groovy"
		classpathref="classpath"/>
</project>
</pre>
<p>The specific error I keep seeing is:</p>
<pre>
\home\Jeff\work\mymediamanager\build.xml:61: groovy.lang.MissingMethodException: No signature of method: org.reverttoconsole.mymediamanager.integration.SimpleTest.main() is applicable for argument types: ([Ljava.lang.String;) values: {[]}
</pre>
<p>Although I also see various compilation errors sporadically, which I attribute to my eclipse setup.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/my-latest-issue-with-groovy-spring-and-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy CLIBuilder In Practice</title>
		<link>http://www.reverttoconsole.com/blog/groovy/groovy-clibuilder-in-practice/</link>
		<comments>http://www.reverttoconsole.com/blog/groovy/groovy-clibuilder-in-practice/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 10:44:25 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://reverttoconsole.com/archives/130</guid>
		<description><![CDATA[Ok, it doesn&#8217;t get much easier than this to build a CLI: class ContentUpdaterMain { static void main(args) { def cli = new CliBuilder(usage: 'java -jar contentupdater.jar -su[dh] "update name"') cli.h(longOpt: 'help', 'usage information') cli.u(longOpt: 'update', 'update the provided table', args: 1) cli.s(longOpt: 'stage', 'stage the provided table', args: 1) cli.d(longOpt: 'debug', 'run the process [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, it doesn&#8217;t get much easier than this to build a CLI:</p>
<pre>
class ContentUpdaterMain {

static void main(args) {

def cli = new CliBuilder(usage: 'java -jar contentupdater.jar -su[dh] "update name"')
cli.h(longOpt: 'help', 'usage information')
cli.u(longOpt: 'update', 'update the provided table', args: 1)
cli.s(longOpt: 'stage', 'stage the provided table', args: 1)
cli.d(longOpt: 'debug', 'run the process with debugging enabled')
def opt = cli.parse(args)
if(!opt) return

if(opt.h) cli.usage()

if( opt.d ) {
//turn on debug
}

if(opt.u) {
//do updates
}

if( opt.s ) {
// run against staging db
}
}
}
</pre>
<p>This produces the following usage output:</p>
<pre>usage: java -jar contentupdater.jar -su[dh] "update name"
-d,--debug run the process with debugging enabled
-h,--help usage information
-s,--stage stage the provided table
-u,--update update the provided table</pre>
<p>And all that remains is to validate the input and invoke the processes!</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.reverttoconsole.com%2Fblog%2Fgroovy%2Fgroovy-clibuilder-in-practice%2F&amp;title=Groovy+CLIBuilder+In+Practice" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.reverttoconsole.com/blog/groovy/groovy-clibuilder-in-practice/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

