w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » GROOVY » Page 1
programatic actions in Kaleo workflow
If you're doing more complex operations in your workflow, the recommendation is to implement them in services - they're a lot easier to debug, have proper tooling etc. Scripts in the workflow definition work as well, but the tooling and debugging experience is a lot worse than with actual services (check documentation for Liferay Service Builder). In general, the workflow code is not different fr

Categories : Groovy

Getter and Setter AST Tranformation
I think that the problem is in your checkNodes method. This expression nodes[1] instanceof ClassNode evaluates to false because nodes[1] is instanceof FieldNode. You also don't have to filter and iterate over the fields, because this transformation will be applied to all fields annotated with @GetterAndSetter. That's why you have to only focus on a single case for annotated field. Usually all you

Categories : Groovy

Groovy c# expression eqivalent to evaluate property
The closest I could come to delivering this capability feels completely contrived and kludgy and ad hoc to me. It relies on the Java Bean API, facilitated by the Groovy @Vetoable annotation to keep most of the ugliness outside the class code: import groovy.beans.Vetoable import java.beans.PropertyChangeEvent import java.beans.PropertyVetoException class TestObj { @Vetoable def prop1 = "valu

Categories : Groovy

Groovy neo4j batch import
Did you miss relationships? Those are the most crucial And I forgot one in the original example, which is the neostore.relgroupstore.db=10MB 15 bytes per node 38 bytes per relationship 42 bytes per 4 properties And do you have actually 128GB of RAM? To accomodate for the memory mapping? What OS are you using? Oh and at the end it stops for quite a long time to create the indexes and constra

Categories : Groovy

Groovy File Traverse behavior when parsing file
I tested your code and worked fine. Which behaviour are you expecting? I find a couple of suspicious things: If fileText begins with "@Table " then indexOf will return 0 and the condition if(fileText.indexOf("@Table ") > 0) will not be satisfied. "@Table " has a trailing space, then a file containing, for example: "@Table(", will not be printed. You can also check that filterGroovyFiles h

Categories : Groovy

How to customize JSONBuilder results in Groovy?
The code below should work (but I'm not sure cause there's no full example provided): println new JsonBuilder(clients:resultset.collect {[ ID: it.ID, NAME: it.NAME, CONTACT: [ ADDR1: it.ADDR1, ADDR2: it.ADDR2, ZIP: it.ZIP, ], ]}).toPrettyString() Try it and let me know in case of any problems. Do You understand how it works?

Categories : Groovy

Copy console logs from Unix Jenkins master with Windows slaves to file share
The groovy-postbuild plugin provides access to the build and run objects and those can be used to do what you are asking. def smbShare = new File('/your/smbshare/location/something.log') smbshare.write( manager.build.getLogFile().text ) manager.build is a wrapper around the following api: http://javadoc.jenkins-ci.org/hudson/model/AbstractBuild.html and there are a couple getLog methods that m

Categories : Groovy

Accessing groovy getter instead of deferring to the @Delegate
you get more than you actually want here (the property handling from the map -- at least this is my guess here). Until someone finds a way to deal with this (excludes on the @Delegate did not work for me) you might be better off with just using the expando: @groovy.transform.InheritConstructors class Foo extends Expando { def getBar() { "Bar" } } def f = new Foo(baz:'baz') assert f.foo==nul

Categories : Groovy

XmlSlurper to return all xml elements into a map
You can swing the recursion weapon. ;) def xml = '''<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> <foot> <email>m@m.com</email> <sig>hello world</sig> </foot> </note>''' def slurper = new XmlSlurper().parseText( xml ) def convert

Categories : Groovy

OpenERP XMLRPC: How to create complete orders?
This code is a basis for how you can get the number and names of database in odoo, just create the correct package to it. And you need to add the following libraries to your java development environment 1.xmlrpc-client 2.xmlrpc-common 3.xmlrpc-server 4.ws-commons-util 5.xmlrpc you will find them here once you understand this you will figure out how to do the rest public class odooServices { pri

Categories : Groovy

How to pass a property collection to Gradle
-Pmyprop=value always gives a String value. You'd have to parse that String and turn it into a collection. Typically it's better to model common sets of arguments in the build script (e.g. by having a separate task per set of arguments).

Categories : Groovy

Gradle plugin extension and enum types
It works for myEnum because Groovy automatically converts strings assigned to enum properties. To make the same work for mySet, you'll have to add a method to the extension that accepts a string, converts it to the corresponding enum value (a simple cast will do in Groovy), and adds the latter to the set. You'll also have to initialize the set.

Categories : Groovy

Mixin empty interface
No, you can't do that. The code you have shown there is attempting to mix an interface into a per-instance metaClass, which you can't do. You also can't do it even if you try to mix the interface into the Boolean.metaClass, as opposed to the instance specific metaClass that you attempted to use. Even if you could do that, the particular example doesn't make any sense as there would be no benefi

Categories : Groovy

How to access request/params, etc. with Spring Boot and Groovy templates
Spring exposes a RequestContext to template views (see AbstractTemplateView). In Spring Boot 1.1 it is called "spring". In 1.2 it uses the default name from Spring MVC: "springMacroRequestContext".

Categories : Groovy

Not able to create new TinkerGraph in Tinkerpop3
You don't have the right syntax for TinkerPop3. To create the "classic" graph from TinkerPop2 you have to do: ,,,/ (o o) -----oOOo-(3)-oOOo----- plugin activated: tinkerpop.server plugin activated: tinkerpop.utilities plugin activated: tinkerpop.tinkergraph gremlin> g = TinkerFactory.createClassic() ==>tinkergraph[vertices:6 edges:6] gremlin> g.V() ==>v[1] ==>v[2

Categories : Groovy

Can I use Groovy scripts in SoapUI to enable/disable assertions?
You could use your Groovy script to set some kind of property testCase.setPropertyValue('expected', 'value'), based on which file you are reading. You could then use property expansion ${testCase#expected#} in the assertion content.

Categories : Groovy

Issue with my Gradle script: Could not find property 'groovy' on source set
did you tried syntax ?: groovy { srcDirs = ['src/end2end/groovy'] } But look what you have here : sourceSets { generated { java { srcDirs = [ 'build/generated-sources/java' ] } } in sourceSets you have only java closure, here you have to specify if compile sources with java or with groovy. The issue is probably that you have to add groovy to sou

Categories : Groovy

The Count Property in class Matcher in Groovy
A good start for this is Groovy Backstage and especially Groovy Method Invocation. Basically the classes get a metaClass augmented with a common set of tools (e.g. DefaultGroovyMethods (see below) for Object). On method invocation, groovy takes this into account for "what is there". count for Matcher is already some more special case, something much more common used on Object is e.g. println. I

Categories : Groovy

groovy call method name contains special character
It will work this way: class Test2 { void "test a"() { println "test a" } public static void main(String[] args) { def t = new Test2() def v = 'test a' t."$v"() } } As described here and here, but no idea why Your example doesn't work.

Categories : Groovy

gradle error "Execution failed for task ':app:compileDebugJava' " while build groovy in android studio
From your error it seems like you are calling Groovy class with Java. According to the Android Groovy plugin readme. it says Groovy sources must be found inside src/main/groovy. Note that the plugin follows the behavior of the Groovy plugin in Gradle, which means that if you want to be able to have Groovy classes referencing Java classes that themselves reference Groovy classes, then those Java

Categories : Groovy

Groovy File() not reporting correct size / length
I suspected that the Groovy script was running on the build master as opposed to the build node that this particular build was running on. I added some debug to print the hostname for which the Groovy script was running and sure enough it wasn't the same host that the shell variant of the script was running.

Categories : Groovy

Gradle, overload extension setter
Since I don't see any better answer yet, I am trying to suggest a possible alternative. If you can keep type of proj as a String in Foo and where you actually use the instance of Foo class, lookup the project using the findProject method on the project object available to your plugin. class FooPlugin implements Plugin<Project> { // ... void apply(Project project) { // ...

Categories : Groovy

groovy << is confusing
In groovy << is an operator that can be overloaded for various classes so it has different behavior depending on context in which it's being used, see here for docs and here for other answers. In the examples You provided is works as the following: def x = 2 assert x << 2 == 8 This is plain old bit shift. In DefaultGroovyMethods class (where most fancy methods are defined) there's

Categories : Groovy

File creation always adds blank line at the end in Groovy
You are appending a newline character to the end. You have that hardcoded in your example. You could replace this: File file = new File("$path/$fileName") txtFileInfo.each { file << ("${it.replaceAll("[ ]", "")} ") } With something like this... File file = new File("$path/$fileName") file << txtFileInfo.join(' ') I hope that helps.

Categories : Groovy

springloaded with Gradle, Groovy and spring-boot fails with java.lang.NoSuchFieldException: classCache
You don't mention which versions of Spring Framework or Spring Loaded you're using, but I would guess that you're trying to use Spring Loaded 1.2.0 with Spring Framework 4.1. It looks like you've hit this bug in Spring Loaded. You should upgrade to Spring Loaded 1.2.1 as it contains a change that fixes the problem and makes it compatible with Spring Framework 4.1.

Categories : Groovy

Caught: java.lang.StackOverflowError JsonBuilder closure
tl;dr: Your second (inner) each should be a collect instead. The real answer: The return value of each is the original Iterable that invoked it. In this case that would be the XML object collection defined by the expression xmlCar.countries.children(). Since the objects in that collection contain references back to their own parents your JSON build causes an infinite regress that results in a sta

Categories : Groovy

SoapUI Groovy Script that sets test case property not reflected in LoadUI
Thanks for the link SiKing, I think I actually ran across that while trying to figure out the cookies, which I eventually managed to get working by setting the headers manually using the script. In order to test if it was a cookie issue I used another property. I added the following line to the groovy script: tc.setPropertyValue("testprop","blah") ran it in SoapUI and the property value is se

Categories : Groovy

Why do we use context in Groovy
Context holds information about the environment and is required to freely navigate in the mentioned environment. @dmahapatro: context available in groovy scripts in SoapUI is the context of executions of a test case/test suit.

Categories : Groovy

Pentaho data source access from Groovy
Assuming that you have filled the default.properties as it says here, you should be able to access the data source with something like: import groovy.sql.Sql import javax.naming.InitialContext import javax.sql.DataSource class SqlClient { InitialContext context = new InitialContext() DataSource dataSource = context.lookup("SampleData") as DataSource def sql = new Sql(dataSource)

Categories : Groovy

How to split a gradle task execution
I was able to solve this issue as follows. The gradle task I wanted to run was the release task for running the Townsfolk gradle-release plugin. Normally this would be done as: ./gradlew release Due to various issue sI ran into with the svn support in this plugin and using it with Android I had to split the underlying sub-tasks for this plugin as follows: ./gradlew -PusesSnapshot=true -Pvers

Categories : Groovy

Exclude some compile dependencies for runtime in Gradle
It's the other way around: Groovy's transitive dependencies aren't normally required for compilation (except that due to a known limitation of the Groovy compiler, they sometimes are), but they are definitely needed at runtime. However, it's not worthwhile to optimize compile dependencies here, so just keep declaring Groovy dependencies as compile dependencies (which automatically makes them runti

Categories : Groovy

Interrupt processing in groovy shell
In windows Groovysh doesn't seem to forward ctrl-c to the app as an interrupt signal. If I run this: while(true)Thread.sleep(1000); or this: while(true); in groovyconsole it can be interrupted, but when I do the same thing in Groovysh it cannot, it just hangs until I kill the process. Some of this has to do with JLine which groovy uses for input, because if I disable jline like this: groo

Categories : Groovy

How to convert Int to Date format on Grails?
Date addDaysToDate(int noOfDays, Date initDate = null) { // If init date provided, add date to it otherwise // consider epoch (1/1/1970 GMT) as init date ( ( initDate ?: new Date(0) ) + noOfDays ).clearTime() } println addDaysToDate( 40000, Date.parse("MM/dd/yyyy", "1/1/1900") ) println addDaysToDate( 40000 )

Categories : Groovy

Groovy: Add prefix to each String in a List
def joined = ["test1", "test2", "test3"].collect { "pre/$it" }.join(' ') each returns unmodified collection - whereas collect returns collection with modified content.

Categories : Groovy

Groovy's "in" operator for lists with String and GString elements
You can use the *. spread operator to get Strings easily (see list2 example below). But your check there can be done alot easier with intersect. List<String> list = ["test-${1+2}", "test-${2+3}", "test-${3+4}"] List<String> subl = ["test-1", "test-2", "test-3"] assert subl.findAll{ it in list }==[] // wrong // use intersect for a shorter version, which uses equals assert subl.inters

Categories : Groovy

How to execute git command from build.gradle?
You have to do your own piping or call by shell (see answer from @topr). see the error: def p1 = 'git rev-list HEAD | wc -l | tr -d " "'.execute() p1.waitFor() println p1.exitValue() //-> 128 println p1.errorStream.text //-> fatal: ambiguous argument '|': unknown revision or path not in the working tree. //-> Use '--' to separate paths from revisions, like this: //-> 'git <command

Categories : Groovy

Getting an error while trying to print a string in Groovy
It should be: def str1 = 'C:\mkjk\sys' // single quotes or def str1 = "C:\mkjk\sys" // double quotes or def str1 = """C:\mkjk\sys""" // three double quotes (multiline string) or def str = '''C:\mkjk\sys''' // three single quotes (multiline string) or def str1 = /C:mkjksys/ // forward slashes (slashy string)

Categories : Groovy

Gradle / groovy setting up environment variables
You have to execute it as a cmd in the Exec task: commandLine 'cmd', '/c', DirLocation + 'deploy.bat'

Categories : Groovy

Reference things from imported class in groovysh
Modify SomeThings.groovy as below: //SomeThings.groovy someVar = 'abc' // remove def to make variable available to shell def someFunc(a) { a + 1 } Then the file has to be loaded to shell as below (load SomeThings.groovy can also be used instead). :h or :help will show its usage. groovy:000> . SomeThings.groovy ===> abc ===> true groovy:000> someVar ===> abc groovy:000> som

Categories : Groovy




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.