Grails

Exception Testing using Spock in grails

Testing was never so easy and intuitive before the use of Spock. Earlier when I was using grails unit testing, it never attracted me to write more and more test cases but with Spock you always keen to test each and every line of your code, testing the exceptions is one of them. You can […]

Grails

Grails domain class and DDL sql file using schema-export

Grails Schema-export GANT script to generate DDL sql file of the grails project domains.

eg.
grails prod schema-export myProd.sql

Grails

A use case of Bitwise AND

Recently, I used bitwise Anding in my grails project. I am sharing the approach that we followed by means of an example. Suppose we have a domain class Person which can have multiple attributes like Smart, Intelligent, Talkative etc. What sort of relationship comes to our mind when we see this? I believe the obvious […]

Mohd Farid
Mohd Farid
Read

Grails

Groovy: Few ways to convert string into enum

Many at times, we have a string which needs to be converted into Enum. I will be sharing few options as stated by Mr.Haki, Isa Goksu and in the last the one I discovered during the process. Lets say we have a Enum AccountType as given below : [groovy] enum AccountType { CHECKING, SAVING } assert […]

Amit Jain
Amit Jain
Read

Grails

Grails fixture, a great way to bootstrap your data

In my current project, I was given a task to bootstrap some data for our application. Initially I was thinking of doing it in the old fashion way, that is, writing a full blown CREATE data code for data creation like [java] Book myBook=new Book(name:’MyBook’, publication:’lorem’,price:’200′) Author author1=new Author(name:’Partho’,country:’India’) author.addToBooks(myBook) [/java] and so on. But […]

Grails

Getting started with extJS

Ext.JS JavaScript Framework a cross-browser JavaScript library for building rich internet applications. It is built for developing high performance, customizable UI widgets and features a well designed, documented and extensible Component model. It is available in both Commercial and Open Source licenses are available. Step 1: First download the source css and js Step 2: […]

Anuj Aneja
Anuj Aneja
Read

Grails

Truncate Table ? executeUpdate OR createSQLQuery

In one of the modules that I was working on , I needed to delete the previous data from a table then load up the data into those tables again and then manipulate code through the ‘id’s’ on those tables. So this is what I was doing … [groovy] Event.executeUpdate(‘delete from Event’) EventInstance.executeUpdate(‘delete from EventInstance’) […]

Grails

Generating EAN-8 standard barcode using Barcode4J

Hi, In one of my project i needed to generate EAN-8 standard bar-code for identifying the various products. I searched for various libraries available for generating bar-code and found a library to do so. The library i used for generating the bar-code is Barcode4J. You can download it from here Barcode4J is a flexible generator […]

Grails

Git cherry-pick

git cherry-pick is yet another great feature of git.With the help of this command we can apply the changes in a branch, introduced by an existing commit in some other branch. So, it allows to copy commits from one branch to another, but one commit at a time. Syntax for this command is :-    git […]

shweta
shweta
Read
Services