groovy

Launching a process and waiting for a condition in Groovy or Java

I need to write a Groovy script which launches a process, reads the processes out & err streams, and wait for a particular line of text to be outputted. The wait should not be indefinite, but should time out after a while. This is what I came up with. Is there a better way? def proc = "groovy test.groovy".execute(null, new File(".")) d...

Importing csv files using groovy

Hi! I have developed a groovy application. Now it has been required that for feeding the DB a CSV interface must be provided. That is, I have to load a csv file, parse it and insert records into the DB in a transactional way. The question is if there exists for groovy something like ostermiller utils (a configurable csv parser). Than...

Grails: nested command objects

Hi, In my grails app I have an outer command object that contains a list of other command objects: public class OuterCommand { List<InnerCommand> innerCommands = ListUtils.lazyList([], FactoryUtils.instantiateFactory(InnerCommand)) } class InnerCommand { String code Long id String value static constraints = { ...

Is there a Java Scripting Language that Can Work Without Caching? Jython? Groovy? etc?

Hi all, We have an existing java-based heavyweight project that needed an interactive script interpreter. After a fair amount of research we eventually ended up with Jython, one of the reasons being that the customer's group already has a large amount of python expertise, and it's an easier sell to give them an api in a language c...

maven dependencies groovy

I'm running a project that has a dependency on groovy 1.7-beta-1. The gmaven plugin uses groovy version 1.6 as a dependency. In my pom, I specify in the dependency management section the grooyv-all version as : <dependencyManagement> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</arti...

Can you have too much of “dynamic” in dynamic languages?

In last few months I have been making a transition from Java to Groovy and I can appreciate many of the benefits it brings: less code, closures, builders, MOP that in the end makes framework like Grails possible, ease with mocking when writing tests etc. However, I have been “accused” by my coworkers that my code is not groovy enough. ...

Customizing Granite DS Actionscript code generation from Java classes

I'm using GraniteDS Actionscript code generation templates that let's me take a Java object and convert it to an Actionscript class. It's mainly used for BlazeDS Java to Flash communication but I'm adapting it to work with JSON webservices using XStream/JETTISON JSON. Is it possible to use the Granite DS Groovy templates to inspect an...

Grails dynamic database connections?

Where I'm working, we have multiple database we need to be able to query. Some of them are predefined and we're using Datasources to access. Others are named after the customer id #. For instance _2. We have hundreds of customers and some customers can pose as other customers and depending on which customer is using the interface at t...

Groovy csv parser and export to database

How can I parse my CSV file without parsing first line ? This class work but I don't want to parse the header of my CSV. import groovy.sql.Sql class CSVParserService { boolean transactional = false def sql = Sql.newInstance("jdbc:mysql://localhost/RProject", "xxx", "xxx", "com.mysql.jdbc.Driver") def CSVList = sql.dataS...

JSON to Groovy parser

I found many things about converting Groovy to JSON, but oddly enough, not the other way. What is the (best) JSON to Groovy parser around there ? ...

How to get all validation Errors from SAX-Parser?

Hello, i would like to get all validation Errors from the SAX-Parser, but with my snippet i only receive the first. How can i achieve this? Thank you! Snippet def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) def xml = new StreamSource(inputStream) def xsd = new StreamSource(new FileReader(schema), systemId)...

non java-developer question

Just a basic question about Java (haven't really done anything with it personally yet): Is it possible to write a Java program that runs in a web browser (via JRE) on the client machine? Is something like Groovy or JavaFX really a wrapper for something that technically could be written in Java? I assumed that JavaFX at least was inten...

Extracting a Date from "the meeting is on 12-DEC-2009 at 13:00" with Groovy

As the title states I have a string similar to: "lorem ispom 12-DEC-2009 fsasdfsd 12:00" OR "the meeting is on 12-DEC-2009 at 13:00" And I need to extract a Date with time from this. What is an elegant and robust way of doing this in Groovy ...

Grails GSP <g:set> tag set as integer?

Using Grails' GSP <g:set> tag, is it possible to specify the type of the variable? I want to declare an integer variable, but <g:set> always declares a sting. For example: <g:set var="x" value="100"/> ${x.getClass()} ${x+23} results in class java.lang.String 10023 I'd like to declare x as an integer. I noticed that using the JSP ta...

With groovy.sql.newInstance in grails - who closes the connection and when?

I'm using grails but I have lot's of stored procedures I'm trying to call from groovy.Sql.newInstance... In all the examples I've found I never see anyone actually calling close on the connection. But when I tried running a bunch of methods within one response that each uses its own call to newInstance, then it got an error that there ...

in Grails can you use both sql.newInstance and Domain class calls in the same method?

Can you have code that looks like this? def methodname () { proc = "sql to call a stored proc" def conn = Sql.newInstance(DB_CONN, DB_USERNAME, DB_PASSWORD, "org.postgresql.Driver") def result1 = conn.rows(proc) def result2 = MyClass.Find("from MyClass where foo='bar'") return [result1, result2] } If so are they using different connec...

Groovy paginate problem

Hi, I have an application written in groovy and I am having problems with the pagination of a resulting set. I have a Controller called ReportingController. This controller has two methods called listdoiTln and listdoiEv. Both methods are similar and at the end both have to render a list of reports. The last lines of both are as follows...

Embedding Processing in Java/Groovy

Is there a way to embed seamlessly Processing code into a Groovy application? If it not exists, is there a way to do it in Java? I mean something to attach a component like a JFrame with the content of a processing script having possibility to exchange data between both. ...

How to execute a Groovy Script from my Grails app?

Well, it seems a simple task but I didn't manage to make it run. I have a groovy script that runs fine under Windows Vista when calling from prompt: > cd MY_GAILS_PROJECT_DIR > groovy cp src/groovy scripts/myscript.groovy Now, I want to execute this script (and passing to it some input arguments) through my my Maintenance Service Cla...

Using Groovy MetaClass to overwrite Methods

I have a POJO that uses a service to do something: public class PlainOldJavaObject { private IService service; public String publicMethod(String x) { return doCallService(x); } public String doCallService(String x) { if(service == null) { throw new RuntimeException("Service must not be null...