groovy

ALL time groovy compilation error

All time am getting below error message in groovy... Could not understand whats causing this " Unexpected token error" ???? I used to think only PERL give bad compilation error,now groovy outperforming it.. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: D:\Playground\groovy\release-b-work\cmd_line_s...

How to log in HibernateCriteriaBuilder

I try log some details in a namedQuery for a grails domain class but logging errors. static namedQueries = { firstThree { if (booleanValue) { log.trace "booleanValue = true" eq ('bar', foo) } maxResults(3) } } Error No such property: log for class: grails.orm.HibernateCriteriaBuilder How do I log in a ...

Generic type arguments in derived classes

Groovy seems to be unable to compile a class where I've derived from a Generic base class and overloaded a method returning a generic array. The same example in Java appears to compile correctly, which is surprising as I expected Groovy to have source-level compatibility [ref]. This can be reproduced with the following adapter example. ...

Grails find / findAll operation won't work?

Hello all, I'm trying to build a Grails application which can do LDAP lookups. I've been following a few guides (link text and some others) but to no end I'm afraid. Relevant source code: From config.groovy: ldap { directories { dir1 { url = "ldap://dc01" base = "ou=someou,dc=check,dc=nl" userDn = "cn=A...

Why a concatenation of gstrings returned from a function is an empty string - Groovy 1.7.4

I have the following code: public class TestGr { static String aaa = "wwww"; public static void main(args) { println "["+getAAA()+"]"; println "[" + getBBB() +"]"; } static String getAAA() { return "" + "${aaa}" } static String getBBB() { return "" + "${aaa}" } } The output of this code is:...

Grails: Splitting a string that contains a pipe

Hi, Im trying to split a string. Simple examples work groovy:000> print "abc,def".split(","); [abc, def]===> null groovy:000> Instead of a comma, I need to split by pipes, but i'm not getting the desired result. groovy:000> print "abc|def".split("|"); [, a, b, c, |, d, e, f]===> null groovy:000> Of course, my first choice would be...

How do I make a jQuery script work on Grails??

How do I make a jQuery function work with Grails?? I installed the jQuery plugin and added grails.views.javascript.library="jquery" at the end of conf/Config.groovy And when I trigger the function I get an error saying Object Expected I checked the code and is fine, you can check it out here: http://www.jsfiddle.net/dCy6f/ When I wr...

Groovy MockFor - how to handle calls to "with" methods on mocks

I faced with interesting problem while using mocking support in Groovy to test collaboration with dependency. We have two classes (example): class Dependency { void method() { throw new OperationNotSupportedException() } } class Dependent { Dependency dependency void useDependency() { dependency.with ...

Capturing the standard output in Gradle 0.8 builds

Say I have src/test/groovy/MyTest.groovy: class MyTest extends GroovyTestCase { void testDummy() { println 'DUMMY' } } And there is nothing special with my build.gradle: usePlugin 'groovy' repositories { mavenCentral() } dependencies { groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.5' testCom...

Apply Server Side Javascript Validation in Grails

Hi All... I am working on grails project where I need to apply server side validations. For client side validations I have created basic validation.js file which contains all the javascript functions. Now what should be the ideal way to achieve the server side validation using Ajax, to achieve the validations like Record Duplication c...

Parsing array of JSON arrays in Groovy

I have the following string from a REST JSON response: [{"uid":10512213, "name":"Bob"},{"uid":7208201, "name":"John"},{"uid":10570, "name":"Jim"},{"uid":1799657, "name":"Sally"}] The rest response definition is from Facebook: FB REST Link I am using Google App Engine + GAELYK which runs in Jetty. What is the best way to convert the a...

How to suppress exception logging for groovy DataSet operations?

I have some groovy code like this: def dest = destSql.dataSet('destination_table') sourceSql.eachRow('select * from source_table'){row -> try { dest.add(ID: row.id) } catch (SQLException) { //A FK constraint will case some inserts to fail dest.add(ID: 1) } } I'm running thi...

gmaven no test found

Hi i m running into some error I have a really small project in groovy. I want to use maven. I was able to compile my files, source and test(i have my .class in the target folder). But no test are executed. here is my pom file. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w...

migrating from google app engine with Groovy, Java and Gaelyk to another host

I currently have an application that is built on gaelyk, groovy and GAE. I would like to move this application as is to another host like Amazon EC2 and run it against MYSQL. Is this possible? I dont need the google USER services. ...

Regex help required

I am trying to replace two or more occurences of <br/> (like <br/><br/><br/>) tags together with two <br/><br/> with the following pattern Pattern brTagPattern = Pattern.compile("(<\\s*br\\s*/\\s*>\\s*){2,}", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); But there are some cases where '<br/> <br/>' tags come with a space and they ...

Regex help required - V2 formatted

Possible Duplicate: Regex help required I am trying to replace two or more occurences of <br/> (like <br/><br/><br/>)tags together with two <br/><br/> with the following pattern Pattern brTagPattern = Pattern.compile("(<\\s*br\\s*/\\s*>\\s*){2,}", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); But there are some cases wher...

Groovy:GPath - reading a xml file in which a node attribute is a map

I have following xml file: <doc_xml> <nodes> <node id='1' spec="{spec_a=0.9, spec_b=0.1}" /> <node id='2' spec="{spec_a=0.1, spec_b=0.3}" /> <node id='3' spec="{}" /> </nodes> </doc_xml> This code was created using Groovy MarkupBuilder. Now I would like to parse this file in a groovy script: def xml = new XmlParser().parseText...

What is the best way to import constants into a groovy script?

I have been setting up a scripting envrionment using Groovy. I have a groovy script called FrameworkiDatabase.groovy which contains a class of the same name. This works fine. I also have another file called connections.groovy which contains maps like the following: SUPPORT2=[ host:"host.name", port:"1521", db:"support2", user...

how to get an arbitrary file from an HTTP request in grails

I am trying to set up a web service in grails that can accept a file. How do I get the file from the request? I am testing this with something like curl -d somefile.tar http://localhost:8080/MyWebS/fileWS and my method looks like the following: def index = { switch(request.method){ case "POST": render "Ingesting file\n...

Groovy question

What's so good about groovy? Are they going to put the good stuff from this into java? ...