groovy

Charting amount of dated events in columns/bars

I want to create bar charts similar to web server logs. I have events in my database which all took place at a certain moment, I would like to grab all these events and then chart how many occurred each day, week, month, whatever on a bar (column) graph. For example I want to chart how many visitors I had in a month in 31 columns, each ...

Sorting on multiple fields with criteria in Grails

Hi, I have the following query which id like to sorty by "raceDate" and by "raceNo" asc. I can figure out how to sort by one field, but not by two, any ideas? def list = { params.max = Math.min( params.max ? params.max.toInteger() : 20, 100) params.offset = params?.offset?.toInteger() ?: 0 params.sort = "raceDate" ...

Using variables in XmlSlurper's GPath

Is there a way to have XmlSlurper get arbitrary elements through a variable? e.g. so I can do something like input file: <file> <record name="some record" /> <record name="some other record" /> </file> def xml = new XmlSlurper().parse(inputFile) String foo = "record" return xml.{foo}.size() I've tried using {} and ${} and () ...

Grails in Eclipse

I'm trying to follow some of the introduction to Grails tutorials and am at the point where I want to try to see if I can use a debugger in Eclipse with my Grails applications. My grails application runs fine when I use the command to execute, but when I tried to use the Eclipse run configuration, I get the following error: Exception in...

Scala vs. Groovy vs. Clojure

Can someone please explain the major differences between Scala, Groovy and Clojure. I know each of these compiles to run on the JVM but I'd like a simple comparison between them. ...

Where is the Groovy/Grails support in NetBeans?

After repeatedly hearing good things about the Grails support in NetBeans and being frustrated by eclipse's lack thereof, I've decided to give it a try, but now said support doesn't seem to exist: I've downloaded the bunde containing NetBeans 6.7 along with the latest Java 5 JDK from Sun The About box says: NetBeans IDE 6.7 (Build 2009...

JSON in Groovy / Grails

I'm trying to access a site via their JSON export. The URL is: http://neotest.dabbledb.com/publish/neotest/f820728c-4451-41f6-b346-8cba54e52c6f/projects.jsonp I'm using HTTPBuilder to try and accomplish this in Groovy, but am having trouble. I used the example code from http://groovy.codehaus.org/HTTP+Builder to come up with this: ...

Grails - Problem with filter and POST or how to un-filter?

Im working on a groovy on grails conference management system which was written by a student temp a few months ago. Unfortunately theres only a very poor documentation and the style of programming is not that nice (check out the comments)... well, heres the problem: there is a domain class "participant" - within the view there is a poss...

GSP taglib import

I'm trying to use GSP outside grails and ran to my first problem. I cannot seem to do a taglib import in my GSPs. Given <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> When I run my app, I am getting a javax.servlet.ServletException: Creation of template failed: groovy.lang.GroovyRuntimeException: Failed to p...

Groovy: editing a file

I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 ( asdfa ) CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 ( asdfas ) some other text in file I want to convert this file into following: CREATE GLOBAL TEMPORARY TABLE 1 ( asdfa ) CREATE GLOBAL TEMPORARY TABLE 2 ( asdfas ) some other text in file ...

groovysh and groovy classes visibility and annotation parsing

Hello Everyone, I started using groovy intensely to prototype everything. This is amazing. But I faced the problem with groovy shell. Next code I run with groovy filename.groovy and everything works as expected. But within groovysh command load filename.groovy Doesn't work: it can't find class Book. The code: import org.hibern...

Running a script from Groovy

In order to get my setup a bit closer to "one click deployment", I would like to use groovy scripts to start/stop other processes controlled by bat scripts, running in different parts of the filesystem and even on different machines. How to execute these scripts and how to do it from their respective working directory? I know Java's ...

How do I efficiently test a Griffon application with easyb?

At the moment I am playing with Griffon. Everything works very smooth except for the testing. I like to test the separate controller methods without starting the whole Griffon application. To do this it seems to me, that I have to mock the view and the model which are used in the controller. Because of the mocking with Expando objec...

is it possible to break out of closure in groovy

is there a way to 'break' out of a groovy closure. maybe something like this: [1, 2, 3].each { println(it) if (it == 2) break } ...

Add Jars to Grails Project Using Ivy

I'm following the Grails Mail tutorial: http://grails.org/A+simple+EmailerService and it mentions "Then copy two jar files into the application local lib: activations.jar and mail.jar.". Though I can do the manual copy, I was wondering if there's some way I could update my Ivy configuration file to do that pulling automatically instead. ...

Overriding grails.views.default.codec='html' config back to 'none'

If I leave grails.views.default.code='none' in the grails Config.groovy, it's up to me to HTML encode my expressions explicitly in the GSP files: ${myValue?.encodeAsHTML()}. If I set grails.views.default.codec='html" in the Config.groovy, then the HTML encoding happens automatically for every expression: ${myValue}. My question: If I s...

Groovy - How to transfer XML nodes between documents?

Hi everyone, to the %subj%, I've tried: def xp = new XmlParser(); def testsuite = xp.parseText( "<testsuite/>" ); def testsuite1 = new XmlParser().parse( "testsuite.xml" ); testsuite1.testcase.each { testsuite.append( it ); } But this gives me an exception: groovy.lang.MissingMethodException: No signature of method: groovy.util.N...

Groovy way to log process output

I would like to start a long-running command-line process in my Grails application, log each line of output to the console when it arrives, and do other stuff asynchronously, while the process and logging activities keep going. (At some point, I'll want to do something else with each line of output, like log to a file or look for certain...

Can I configure Grails with no datasource?

I have a Grails app that loads its data from xml files and delivers rss feeds via rome. I don't have any domain classes and my app has no datasource. I don't want Grails to load an in memory hsql db when the application has no need for it. Deleting the DataSource.groovy file prevents me from launching the web app, it seems as though the ...

Howto make namespace attribute with groovy xml builder

How can i create an attribute with a namespace? To get the following output? <tns:catalogItem xsi:type="specialItem" /> This is how i do it yet: catalogItem( type:"specialItem"); But this generates the attribute without namespace, so its invalid <tns:catalogItem type="tns:specialItem" /> so i'm searching for something like this ...