for example, I have the following xml document:
def CAR_RECORDS = '''
<records>
<car name='HSV Maloo' make='Holden' year='2006'/>
<car name='P50' make='Peel' year='1962'/>
<car name='Royale' make='Bugatti' year='1931'/>
</records>
'''
and I want to move the car "Royale" up to first one, and insert a new ca...
I'm using a groovy code snippet in an ant build file. Inside the groovy code I'm trying to reference a fileset that has been defined outside of the groovy part, like this:
<target name="listSourceFiles" >
<fileset id="myfileset" dir="${my.dir}">
<patternset refid="mypatterns"/>
</fileset>
<groovy>
def ant = ...
When I use this code to output some XML I parsed (and modified) with XmlParser
XmlParser parser = new XmlParser()
def root = parser.parseText(feedUrl.toURL().text)
def writer = new StringWriter()
new XmlNodePrinter(new PrintWriter(writer)).print(root)
println writer.toString()
the namespace declarations on the roo...
How can I read an Open Office 3.0 spreadsheet (.ods) from Groovy? I'd like to select specific columns from a named worksheet. Ideally, it would be useful to add a 'where' clause, or other criteria clause.
...
given this in a grails action:
def xml = {
rss(version: '2.0') {
...
}
}
render(contentType: 'application/rss+xml', xml)
i see this:
<rss><channel><title></title><description></description><link></link><item></item></channel></rss>
is there an easy way to pretty print the xml? something built into the render method,...
I am starting a project with Grails since I already use Eclipse, it was my first choice. But I don´t think its good enough, had some problems and the plugging is poor in functionalities.
Anyone uses/tested others IDEs(NetBeans, InteliJ(not free)...)?
Which one is the best?
thanks.
...
How do I drop a Groovlet into a Grails app? Say, for example, in web-app/groovlet.groovy
import java.util.Date
if (session == null) {
session = request.getSession(true);
}
if (session.counter == null) {
session.counter = 1
}
println """
<html>
<head>
<title>Groovy Servlet</title>
</head>
<body>
Hello, ${requ...
My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two):
Table: Post
Columns: PostID, Name, Desc
Table: Tag
Columns: TagID, Name
Table: PostTag
Columns: PostID, TagID
What is the best way to save a space separated string (e.g. "smart funny wonderful") into the 3 databas...
What are the best free resources that I can give someone to learn Groovy/Grails? Blogs, tutorials, sample code, sample apps, or presentations would all be helpful.
...
If I have a URL (eg. http://www.foo.com/alink.pl?page=2), I want to determine if I am being redirected to another link. I'd also like to know the final URL (eg. http://www.foo.com/other_link.pl). Finally, I want to be able to do this in Perl and Groovy.
...
I want to simplify my execution of a Groovy script that makes calls to an Oracle database. How do I add the ojdbc jar to the default classpath so that I can run
groovy RunScript.groovy
instead of
groovy -cp ojdbc5.jar RunScript.groovy
...
I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models
ClientContact{
static hasMany = [owners: Person]
static belongsTo = [Person]
}
Person{
static hasMany = [clientContacts:ClientContact]
}
When I try to retrieve all the ClientContacts with a specific owner (Person), I'm running into...
Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Criteria (Importance out of 10, 10 being most important)
Richness of API/libraries available (eg. maths, plotting, networking) (9)
Ability to embed in desktop (java/c++) applications (8)
Ease of deployment (8)
Ability to interface with DLLs/Shared Lib...
I'm still learning Grails and seem to have hit a stumbling block.
Here are the 2 domain classes:
class Photo {
byte[] file
static belongsTo = Profile
}
class Profile {
String fullName
Set photos
static hasMany = [photos:Photo]
}
The relevant controller snippet:
class PhotoController {
.....
def vie...
If I have a comma separated file like the following:
foo,bar,n
,a,bc,d
one,two,three
,a,bc,d
And I want to join the \n, to produce this:
foo,bar,n,a,bc,d
one,two,three,a,bc,d
What is the regex trick? I thought that an if (/\n,/) would catch this.
Also, will I need to do anything special for a UTF-8 encoded file?
Finally, a sol...
I'm working now together with others in a grails project. I have to write some Java-classes. But I need access to an searchable object created with groovy. It seems, that this object has to be placed in the default-package. My question is: Exists a way to access this object in the default-package from a Java-class in a named package?
...
I have heard some things about Groovy from several different sources. One said Groovy is a great test harness for Java. Another said Groovy is Java's answer to Ruby. I am not sure what I've heard that is correct.
What is Groovy and why should I learn more about it? Obviously I have a vague idea about groovy, but the emphasis is on the w...
Why would I choose to use Groovy when I could use Jython or Jruby? Does the language provide any inherent advantages to make up for the fact that Jython and Jruby skills are applicable to their parent languages outside of the JVM?
Keep in mind that I purposely keeping this question generic, but if there are any advantages that exist in...
Given the following domain classes:
class Post {
SortedSet tags
static hasMany = [tags:Tag]
}
class Tag {
static belongsTo = Post
static hasMany = [posts:Post]
}
From my understanding so far, using a hasMany will result in hibernate SET mapping.
However, in order to maintain uniqueness/order, Hibernate needs to load t...
Over the years, I think I have seen and tried every conceivable way of generating stub data structures (fake data) for complex object graphs. It always gets hairy in java.
* * * *
A---B----C----D----E
(Pardon cheap UML)
The key issue is that there are certain relationships between the values, so a certain instance of C m...