Posts

Showing posts with the label groovy

Groovy : Constructor call must be the first statement in a constructor

Image
Clash Royale CLAN TAG #URR8PPP Groovy : Constructor call must be the first statement in a constructor New to Groovy. Using scripts as part of Jenkins pipeline. Editing in Sublime with only a linter. Receiving this error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/var/jenkins_home/jobs/{repo}/branches/master/builds/9/libs/{jenkins-library-name}/src/{srcPath}/Pom_EX.groovy: 12: Constructor call must be the first statement in a constructor. at line: 12 column: 11. 1 Answer 1 Really beat myself up here for taking so long to see it. I didn't see it, since I've been working in Java for a few years now - and the IDE points out this type of mistake. Name of the constructor didn't match the class.... I reproduced the problem with a dummy class. Running DUMMY d = new DUMMY('blah') produced : DUMMY d = new DUMMY('blah') 1 compilation...

Grails 2.5.11 / Postgresql 10 , Upload Image and Display in GSP

Image
Clash Royale CLAN TAG #URR8PPP Grails 2.5.11 / Postgresql 10 , Upload Image and Display in GSP Hi i am new to grails and postgresql and i am trying to make a form that stores user's data and i want to be able to upload multiply photos. service: Cars carInstance = new Cars() carInstance.carimg = params.carimg.getBytes() gsp: <input type="file" id="carimg" name="carimg" multiple /> and i call a saveCar action in controller that save all the data user will input. And i want to display the data with the image in a showCar gsp this way : <img src="${createLink(controller: 'garage', action: 'getImage', params: ['id': Cars.id])}"/> also the getImage action that get the image and pass it to gsp is this : def getImage(){ def item = Cars.get(params.id.toLong()) byte imageInByte=item.carimg response.contentType = 'image/png' response.outputStream << imageInByte response.outputStream.flu...

Gate : breakline after each loop in groovy

Image
Clash Royale CLAN TAG #URR8PPP Gate : breakline after each loop in groovy I have this code that prints in the same line after each loop. For example: "categorie=extragraphique","remarque=confusion_consonne","mot=article","categorie=logogrammique","remarque=aposthrophe","mot=conjonction" i would like to linebreak after each loop: "categorie=extragraphique","remarque=confusion_consonne","mot=article" "categorie=logogrammique","remarque=aposthrophe","mot=conjonction" new File("/outfile.txt").withWriterAppend{ out -> (doc.getNamedAnnotationSets() + [Default:(doc.getAnnotations())]).each{ setName, set -> set.each{ anno -> if( anno.getFeatures() ) anno.getFeatures().each{ fValue -> out.write(/"${fValue}",/) } else out.write(/"${anno.getId()},,/) } } } Thnaks in advance ...

Scenebuilder throws nullpointer exception when using customcomponent

Image
Clash Royale CLAN TAG #URR8PPP Scenebuilder throws nullpointer exception when using customcomponent I have a custom component like this: class SelectableVBox extends VBox { Node selectedNode private static PseudoClass selected = PseudoClass.getPseudoClass("selected") SelectableVBox() { super() addEventFilter(MouseEvent.MOUSE_CLICKED, { MouseEvent event -> if (event.button == MouseButton.PRIMARY) { def intersectedNode = NodeUtility.firstParentFullfilling(event.pickResult.intersectedNode, { node -> children.contains(node) }) if (intersectedNode == null) { return } if (selectedNode != null) { selectedNode.pseudoClassStateChanged(selected, false) } selectedNode = intersectedNode selectedNode.pseudoClassStateChanged(selected, true) } }) } } Basically it's a VBox which implements a very light selectionmodel that can then be used t...

Why is micronaut invoking the wrong controller method?

Image
Clash Royale CLAN TAG #URR8PPP Why is micronaut invoking the wrong controller method? I have a micronaut API like this: @Get("/") List<Club> listClubs() @Get("/{id}") Club show(Long id) In my unit test, when I invoke the show method, the listClubs() method is actually getting invoked, instead. show listClubs() Why is this happening? Details: Thinking that my URL mappings must be wrong, I started debugging into Netty to try to understand how the framework constructs URLs. In HttpClientIntroductionAdvice , the context shows the API method like this: HttpClientIntroductionAdvice Club show(Long param0) Club show(Long param0) The interceptor is setting param0 in the parameter map, which doesn't match the actual parameter name of my method. When the URI template is expanded, this causes the ID to get dropped (thus the URI becomes / instead of /1 ). param0 / /1 I am trying to follow this example: https://github.com/alvarosanchez/micronaut-work...

Calling Processor from Inside Bean

Image
Clash Royale CLAN TAG #URR8PPP Calling Processor from Inside Bean New to Camel, so maybe I'm misunderstanding how processors and beans should interact. We have some logging to a database that we want to do throughout a camel route. The idea was to do this in a processor. However, we'd also like to do this logging from w/in the beans. Is that possible? I know I could pass it back as a return field from the bean...but it is already passing back a return. A related question is how to pass that status, thinking it would be an exchange property or header. Basically I want something along the lines of processor class EventStatusProcessor implements Processor { @Override void process(Exchange exchange) throws Exception { // do some stuff, thinking this will be a header } } route from("direct:route1") .bean(doSomething, 'doSomething') .process(new EventStatusProcessor()) bean @Component @Slf4j class DoSomething{ ...