I'm trying to convert a date string from another application in Groovy. Something like
"18-sep-2009 10:25:11 Romance Daylight Time"
It looks like Java does not understand the Romance as timezone alias. "18-sep-2009 10:25:11 Pacific Daylight Time" works fine.
Is there a fix for this other than parse the string and replace "Romance Dayl...
Do I have to know groovy before learning grails?
Thank you!
...
Hi!
I have a groovy application which is using an Oracle DB as DataSource.
In DataSource.groovy I've set:
dataSource {
pooled = true
driverClassName = "oracle.jdbc.driver.OracleDriver"
username = "scott"
password = "tiger
//loggingSql = true
}
For some performance reasons at some points I am accesing the DB using sql in the followin...
Hey, i try to trim each string item of an list in groovy
list.each() { it = it.trim(); }
But this only works within the closure, in the list the strings are still " foo", "bar " and " groovy ".
How can i achieve that?
...
Can i get for example the node structure or something like this from the validator? Something like a listener or an handler. The exception is not enough. I have to select the node where the error occured. Thats what i build so far.
def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
def schema = factory.newSchema...
Started work with SoapUI and can't catch idea how to treat Soap responses with Groovy.
Currently my project opened in NetBeans and after debuging will be copy-pasted to the SoapUI (eviware)
My question is:
def Input = """ <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body>
<ns2:getSalesAuditsResponse xmln...
I've encountered a Groovy meta-programming problem which I'm unable to solve.
When adding the static method foo() to the class FooBar, then FooBar.foo() works as expected:
FooBar.metaClass.static.foo = {
println "hello"
}
FooBar.foo()
However, I instead add the same static method foo() to the class Object, then FooBar.foo() fails...
Right now, when I'm trying to eval a piece of code in Groovy, I have to do something like this :
new GroovyShell(new Binding([var1:var1])).evaluate(line)
This can be pretty nasty when you have a lot of variables defined. Is there a better way of doing this? Is there something like Python's locals, or something similar that lists all t...
Hi,
Previously I'd thought that a property in Groovy is indicated by the omission of a scoping keyword. In other words
class Test {
def prop = "i am a property"
public notProp = "i am not"
}
However, it appears I'm incorrect about this, because the following script prints "getter val"
class Foo {
public bar = "init val"
p...
Hi, I have a groovy list of lists i.e.
list = [[2, 0, 1], [1, 5, 2], [1, 0, 3]]
I would like sort it by order of the first element, then second, then third.
Expected
assert list == [[1, 0, 3], [1, 5, 2], [2, 0, 1]]
I started with list = list.sort{ a,b -> a[0] <=> b[0] } but that only sorts the first element. How do you finish?
Th...
I have a simple groovy script that generates xml
def builder = new groovy.xml.StreamingMarkupBuilder()
def person1 = {
person(id:99){
firstname("John" )
lastname("Smith" )
}
}
def person2 = {
person(id:100){
firstname("Jane" )
lastname("Doe" )
}
}
def personList = {
"person-list" {
out << person1
out << person2
}
}
println builder.bind(...
I have the following xml snippet:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="reports">
<typeAlias alias="Header" type="VerificationVO"/>
</sqlMap>
While trying to parse this xml using:
def s...
I understand how to create XML in Groovy using MarkupBuilder. How do you add/insert elements into a MarkupBuilder object after the initial creation? For example, start with:
def builder = new MarkupBuilder(writer)
def items = builder.items{
item(name: "book")
}
Which would produce:
<items>
<item name="book/>
</it...
Hey,
how do you name your groovy scripts? Does it depends on the enviroment? Do you name groovy classes diffent to groovy scripts?
Example:
convert_csv_to_xml.groovy
ConvertCSVtoXML.groovy
...
What do you think?
...
Hi all,
I'm currently facing a variable substitution related problem in groovy. While this is quite trivial:
Map map = [s1:"Hello", s2:"World"]
println "${map.s1} ${map.s2}!" // "Hello World!"
As this works, I'm pretty sure that something like this should work as well:
Map map = [s1:"Hello", s2:"World"]
def dynamic = loadStringFromF...
Hey,
are there any improvements where i can improve this code? Maybe there are some groovy language features? This snippet flattens a xml file to: node/node/node
def root = new XmlParser().parse("src/your_xml.xml")
root.depthFirst().each { n ->
def name = n.name()
while(n?.parent()){
name = "${n?.parent()?.name()}/${name}";
n =...
Hi!
I have a groovy system configured using tomcat and Oracle 10g.
I have a groovy class which defines an follows: (reduced version)
class ChangeTicket {
static constraints = {
chngNr(nullable:false)
}
String chngNr
}
My controller has defined a save method:
if (changeTicketInstance.validate() && !changeTicketInstance.hasErr...
Hi,
In the Groovy code below I replace the values of the feck, arse, drink properties of an instance of Foo with those of an instance of Foo2
class Foo {
def feck = "fe"
def arse = "ar"
def drink = "dr"
}
class Foo2 {
def feck = "fe2"
def arse = "ar2"
def drink = "dr2"
}
def f = new Foo()
def f2 = new Fo...
I have the following string. I have broken it into two lines below for clarity but they are one line.
WHEN NVL(somevar1, 0) > 0 THEN
(CAST(NVL(somevar2, 0) AS
FLOAT(53)) / CAST(NVL(somevar3, 0) AS FLOAT(53))) * 100
I want to write a Regex so that I can get somevar1, somevar2 and somevar3.
I was trying with something like this...
We've got a fairly large project written in a mix of Java and Groovy. For a variety of reasons, we're looking to switch from Javadoc/groovydoc to doxygen for our code documentation generation needs.
The Java code, of course, works fine. Doxygen, however, has no native support for groovy, and google doesn't seem to have turned up a dox...