SlideShare a Scribd company logo
Instituto de Inovação com TIC 
INTERVALO CESAR 
Inovação é a gente!
Grails – The search is over 
Aécio Costa 
Felipe Coutinho
Grails – The search is over 
Groovy 
Características 
Groovy x Java 
Regra dos 80/20 
Grails 
Cenário Atual do Desenvolvimento Web 
Características 
Arquitetura 
Demo
Grails – The search is over 
Groovy - Características 
Inspirada no Python, Ruby...; 
Linguagem Dinâmica; 
Plataforma Java; 
Especificação do JCP (JSR 241); 
Copy/Paste Compatibilty.
Grails – The search is over 
O que Groovy tem de diferente de Java? 
Tipagem dinâmica; 
Recurso: attribute accessor; 
Closure; 
Métodos Dinâmicos; 
e mais...
Grails – The search is over 
Tipagem dinâmica 
def name = “João” 
def names = [“João”, “José”, “Geraldo”]
Grails – The search is over 
Atribute accessor 
class User{ 
String nome 
Integer idade 
} 
def user = new User(name:”João”, age: 23) 
user.nome = “Pedro”
Grails – The search is over 
Closure 
def name = “Paulo” 
def printName = {println “Hello, ${name}”} 
printName() 
def listNames = [“Gabriela”, “Maria”] 
def sayHello = {println it} 
listNames.each(sayHello)
Grails – The search is over 
Métodos Dinâmicos 
def methodName = “getYearBorn” 
user.”${methodName}”() 
new User().”getDayBorn”()
Grails – The search is over 
Além de... 
Sobre carga de operadores; 
Ranges; 
MetaPrograming; 
e etc...
Grails – The search is over 
Groovy veio acabar com a Regra dos 80/20 
(Princípio de Pareto)
Grails – The search is over 
import java.util.ArrayList; 
import java.util.List; 
class Seletor { 
private List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
for (int i = 0; i < bookNames.size(); i++) { 
String candidate = (String) bookNames.get(i); 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} 
return resultado; 
} 
public static void main(String[] args) { 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
for (int i = 0; i < selected.size(); i++) { 
String sel = (String) selecionados.get(i); 
System.out.println(sel); 
} 
} 
}
Grails – The search is over 
O que realmente interessa no código anterior?
Grails – The search is over 
import java.util.ArrayList; 
import java.util.List; 
class Seletor { 
private List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
for (int i = 0; i < bookNames.size(); i++) { 
String candidate = (String) bookNames.get(i); 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} 
return resultado; 
} 
public static void main(String[] args) { 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
for (int i = 0; i < selected.size(); i++) { 
String sel = (String) selecionados.get(i); 
System.out.println(sel); 
} 
} 
}
Grails – The search is over
Grails – The search is over 
Closure e import implícito
Grails – The search is over 
import java.util.ArrayList; 
import java.util.List; 
class Seletor { 
private List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
for (int i = 0; i < bookNames.size(); i++) { 
String candidate = (String) bookNames.get(i); 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} 
return resultado; 
} 
public static void main(String[] args) { 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
for (int i = 0; i < selected.size(); i++) { 
String sel = (String) selecionados.get(i); 
System.out.println(sel); 
} 
} 
}
Grails – The search is over 
class Seletor { 
private List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
bookNames.each { String candidate -> 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} return resultado; 
} 
public static void main(String[] args) { 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { String sel -> 
System.out.println(sel); 
} 
} 
}
Grails – The search is over 
Closure e import implícito 
Declaração e Assinatura de Métodos
Grails – The search is over 
class Seletor { 
private List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
bookNames.each { String candidate -> 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} return resultado; 
} 
public static void main(String[] args) { 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { String sel -> 
System.out.println(sel); 
} 
} 
}
Grails – The search is over 
List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
bookNames.each { String candidate -> 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} return resultado; 
} 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { String sel -> 
System.out.println(sel); 
}
Grails – The search is over 
Closure e import implícito 
Declaração e Assinatura de Métodos 
Tipagem Estática
Grails – The search is over 
List selectBooksNameLessThan(List bookNames, int length) { 
List resultado = new ArrayList(); 
bookNames.each { String candidate -> 
if (candidate.length() < length) { 
resultado.add(candidate); 
} 
} return resultado; 
} 
List books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
Seletor s = new Seletor(); 
List selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { String sel -> 
System.out.println(sel); 
}
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
def resultado = new ArrayList(); 
bookNames.each { candidate -> 
if (candidate.size() < length) { 
resultado.add(candidate); 
} 
} 
return resultado; 
} 
def books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
def selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { sel -> 
System.out.println(sel); 
}
Grails – The search is over 
Closure e import implícito 
Declaração e Assinatura de Métodos 
Tipagem Estática 
Instância simplificada de Listas 
Não necessidade de “return” 
“;” não obrigatório 
Impressão simples
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
def resultado = new ArrayList(); 
bookNames.each { candidate -> 
if (candidate.size() < length) { 
resultado.add(candidate); 
} 
} 
return resultado; 
} 
def books = new ArrayList(); 
books.add("Harry Potter"); 
books.add("A Vila"); 
books.add(“O Exorcista"); 
def selected = s.selectBooksNameLessThan(books, 10); 
System.out.println("Total Selecionados: " + selecionados.size()); 
selected.each { sel -> 
System.out.println(sel); 
}
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
def resultado = []; 
bookNames.each { candidate -> 
if (candidate.size) < length) { 
resultado.add(candidate) 
} 
} 
resultado 
} 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = s.selectBooksNameLessThan(books, 10) 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
}
Grails – The search is over 
Closure e import implícito 
Declaração e Assinatura de Métodos 
Tipagem Estática 
Instância simplificada de Listas 
Não necessidade de “return” 
“;” não obrigatório 
Impressão simples 
Métódos Dinâmicos
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
def resultado = []; 
bookNames.each { candidate -> 
if (candidate.size) < length) { 
resultado.add(candidate) 
} 
} 
resultado 
} 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = s.selectBooksNameLessThan(books, 10) 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
}
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
bookNames.findAll { it.size() < length } 
} 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = s.selectBooksNameLessThan(books, 10) 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
}
Grails – The search is over 
def selectBooksNameLessThan(bookNames, length) { 
bookNames.findAll { it.size() < length } 
} 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = s.selectBooksNameLessThan(books, 10) 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
}
Grails – The search is over 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = books. findAll { it.size() <= 5} 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
}
Grails – The search is over 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = books. findAll { it.size() <= 5} 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
} 
Seletor.groovy
Grails – The search is over 
def books = ["Harry Potter”, "A Vila”, “O Exorcista”] 
def selected = books. findAll { it.size() <= 5} 
println "Total ${selecionados.size()}” 
selected.each { sel -> 
println sel 
} 
Seletor.groovy 
Groovy é Java
Grails – The search is over 
Cenário Atual Web 
 Persistência 
 Validações 
 Logs 
 Visualização 
 Controladores 
 Controle Transacional 
 Injeção de Dependências 
 Ajax 
 Redirecionador de URL’s 
 Configuração por ambiente 
 Internacionalização
Grails – The search is over
Grails – The search is over 
Welcome to
Grails – The search is over 
Framework Web de Alta produtividade para plataforma 
Java; 
Programação por convenção; 
MVC nativo; 
Fácil bootstrap; 
GORM; 
Scaffolding; 
Plugins; 
e tudo que você viu lá atras...
Grails – The search is over 
Arquitetura do Grails
Grails – The search is over 
Passos para criar a Aplicação 
$ grails create-app booklibrary 
$ grails run-app
Grails – The search is over 
Classes de domínio 
$ grails create-domain-class cesar.example.Book 
class Book { 
String title 
Date releaseDate 
String ISBN 
}
Grails – The search is over 
Scaffolding 
INSERT, UPDATE, DELETE, SEARCH 
$ grails generate-all cesar.example.Book
Grails – The search is over 
Validations (Constraints) 
DSL interna baseada no recurso builder da linguagem Groovy; 
Constraints: 
http://grails.org/doc/latest/ref/Constraints/Usage.html 
static constraints = { 
title(blank: false) 
ISBN(blank: false, unique: true) 
}
Grails – The search is over 
Relacionamento 
$ grails create-domain-class cesar.example.Person 
class Person { 
static hasMany = [books: Book] 
String name 
String email 
String password 
static constraints = { 
name(blank: false) 
email(blank: false, email: true) 
password(blank: false, password: true) 
} 
} 
Na classe Book: 
static belongsTo = [person: Person]
Grails – The search is over 
View 
.gsp 
i18n 
# Book 
book.label=Livro 
book.title.label=Titulo 
book.person.label=Pessoa 
book.releaseDate.label=Data de lancamento 
# Person 
person.label=Pessoa 
person.name.label=Nome 
person.password.label=Senha
Grails – The search is over 
GORM 
def books = Book.list(max:10, order:”name”) 
def books = Book.findByName(“The Developer”) 
def books = Book.findAllByPriceLessThan(10.0) 
def books = Book.findAllByTitleLikeAndPriceBetween(“Harry %”, 
40.0, 70.0)
Grails – The search is over 
GORM 
class BookController { 
def find() { 
def books = Book.findAllByTitleLike("%"+params.like+"%") 
render(view: "list", model: [bookInstanceList: books, 
bookInstanceTotal: books.size()]) 
} 
} 
<div> 
<br/> 
<g:form name="myForm" url="[controller:'book',action:'find']"> 
<g:actionSubmit value="Find" /> 
<g:textField name="like" value="" /> 
</g:form> 
</div>
Grails – The search is over 
WebService REST 
import grails.converters.* 
def showRest() { 
def bookInstance = Book.get(params.id) 
if(!bookInstance){ 
render new Book() as JSON 
return 
} 
render bookInstance as JSON 
}
Grails – The search is over 
Configuração por ambiente 
BuildConfig.groovy 
DataSource.groovy 
development { 
dataSource { 
pooled = true 
driverClassName = "com.mysql.jdbc.Driver” 
username = “root" 
password = “root" 
dbCreate = "create-drop" 
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect" 
url = "jdbc:mysql://localhost:3306/book_dev? 
autoreconnect=true" 
} 
} 
$ grails install-dependency mysql:mysql-connector-java:5.1.16
Grails – The search is over 
Plugins 
GWT 
LDAP 
Spring Security 
Spring WS 
Maill 
Feeds 
Quartz 
Axis2 
Wicket
Grails – The search is over 
Deploy 
$ grails war
bibliografia sugerida 
http://groovy.codehaus.org/ 
http://grails.org/
perguntas ???
contato 
Aécio Costa – aecio.costa@cesar.org.br – www.aeciocosta.com.br 
Felipe Coutinho – flc@cesar.org.br – www.felipelc.com
Grails - The search is over

More Related Content

What's hot

Realm to Json & Royal
Realm to Json & RoyalRealm to Json & Royal
Realm to Json & Royal
Leonardo Taehwan Kim
 
Scala for Java Developers - Intro
Scala for Java Developers - IntroScala for Java Developers - Intro
Scala for Java Developers - Intro
David Copeland
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
Richard Schneeman
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
Joni
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)Makoto Yamazaki
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
Jesper Kamstrup Linnet
 
The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196
Mahmoud Samir Fayed
 
Commonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate CodeCommonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate Code
Alistair McKinnell
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quizhnyb1002
 
What's new in Liferay Mobile SDK 2.0 for Android
What's new in Liferay Mobile SDK 2.0 for AndroidWhat's new in Liferay Mobile SDK 2.0 for Android
What's new in Liferay Mobile SDK 2.0 for Android
Silvio Gustavo de Oliveira Santos
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
Kerry Buckley
 
Building DSLs with Groovy
Building DSLs with GroovyBuilding DSLs with Groovy
Building DSLs with Groovy
Sten Anderson
 
Solr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg DonovanSolr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg Donovan
Gregg Donovan
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
Getting value from IoT, Integration and Data Analytics
 
Python tutorial
Python tutorialPython tutorial
Python tutorialRajiv Risi
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
Hiromi Ishii
 
Grails queries
Grails   queriesGrails   queries
Grails queries
Husain Dalal
 

What's hot (20)

Realm to Json & Royal
Realm to Json & RoyalRealm to Json & Royal
Realm to Json & Royal
 
Scala for Java Developers - Intro
Scala for Java Developers - IntroScala for Java Developers - Intro
Scala for Java Developers - Intro
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196
 
Commonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate CodeCommonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate Code
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
 
What's new in Liferay Mobile SDK 2.0 for Android
What's new in Liferay Mobile SDK 2.0 for AndroidWhat's new in Liferay Mobile SDK 2.0 for Android
What's new in Liferay Mobile SDK 2.0 for Android
 
php plus mysql
php plus mysqlphp plus mysql
php plus mysql
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Xm lparsers
Xm lparsersXm lparsers
Xm lparsers
 
7li7w devcon5
7li7w devcon57li7w devcon5
7li7w devcon5
 
Building DSLs with Groovy
Building DSLs with GroovyBuilding DSLs with Groovy
Building DSLs with Groovy
 
Solr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg DonovanSolr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg Donovan
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
 
Grails queries
Grails   queriesGrails   queries
Grails queries
 

Viewers also liked

Welcome to week 1 second semester
Welcome to week 1 second semesterWelcome to week 1 second semester
Welcome to week 1 second semesterKathy Sheridan
 
Acbsi syllabus _-_sheridan_(2)-1
Acbsi syllabus _-_sheridan_(2)-1Acbsi syllabus _-_sheridan_(2)-1
Acbsi syllabus _-_sheridan_(2)-1
Kathy Sheridan
 
BP Orientation Revised
BP Orientation RevisedBP Orientation Revised
BP Orientation RevisedKathy Sheridan
 
Math Quiz-Final round with answer
Math Quiz-Final round with answerMath Quiz-Final round with answer
Math Quiz-Final round with answer
Emam Khan
 

Viewers also liked (6)

Welcome to week 1
Welcome to week 1Welcome to week 1
Welcome to week 1
 
Welcome to week 1 second semester
Welcome to week 1 second semesterWelcome to week 1 second semester
Welcome to week 1 second semester
 
Acbsi syllabus _-_sheridan_(2)-1
Acbsi syllabus _-_sheridan_(2)-1Acbsi syllabus _-_sheridan_(2)-1
Acbsi syllabus _-_sheridan_(2)-1
 
BP Orientation Revised
BP Orientation RevisedBP Orientation Revised
BP Orientation Revised
 
Math Quiz-Final round with answer
Math Quiz-Final round with answerMath Quiz-Final round with answer
Math Quiz-Final round with answer
 
Math quiz
Math quizMath quiz
Math quiz
 

Similar to Grails - The search is over

Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
John Ferguson Smart Limited
 
Linq - an overview
Linq - an overviewLinq - an overview
Linq - an overviewneontapir
 
Productive Programming in Groovy
Productive Programming in GroovyProductive Programming in Groovy
Productive Programming in Groovy
Ganesh Samarthyam
 
Scala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldScala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereld
Werner Hofstra
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
Thomas Kaiser
 
Groovy
GroovyGroovy
JDK 8
JDK 8JDK 8
Java Generics
Java GenericsJava Generics
Java Generics
Zülfikar Karakaya
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
BTI360
 
About java
About javaAbout java
About javaJay Xu
 
Poly-paradigm Java
Poly-paradigm JavaPoly-paradigm Java
Poly-paradigm Java
Pavel Tcholakov
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
Jesper Kamstrup Linnet
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kirill Rozov
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
Intro C# Book
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
Sven Efftinge
 
TDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hypeTDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hype
tdc-globalcode
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
Benjamin Waye
 

Similar to Grails - The search is over (20)

Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 
Linq - an overview
Linq - an overviewLinq - an overview
Linq - an overview
 
Productive Programming in Groovy
Productive Programming in GroovyProductive Programming in Groovy
Productive Programming in Groovy
 
Scala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldScala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereld
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Groovy
GroovyGroovy
Groovy
 
JDK 8
JDK 8JDK 8
JDK 8
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
About java
About javaAbout java
About java
 
Poly-paradigm Java
Poly-paradigm JavaPoly-paradigm Java
Poly-paradigm Java
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Scala
ScalaScala
Scala
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
 
Java programs
Java programsJava programs
Java programs
 
TDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hypeTDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hype
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 

Recently uploaded

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 

Recently uploaded (20)

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 

Grails - The search is over

  • 1. Instituto de Inovação com TIC INTERVALO CESAR Inovação é a gente!
  • 2. Grails – The search is over Aécio Costa Felipe Coutinho
  • 3. Grails – The search is over Groovy Características Groovy x Java Regra dos 80/20 Grails Cenário Atual do Desenvolvimento Web Características Arquitetura Demo
  • 4. Grails – The search is over Groovy - Características Inspirada no Python, Ruby...; Linguagem Dinâmica; Plataforma Java; Especificação do JCP (JSR 241); Copy/Paste Compatibilty.
  • 5. Grails – The search is over O que Groovy tem de diferente de Java? Tipagem dinâmica; Recurso: attribute accessor; Closure; Métodos Dinâmicos; e mais...
  • 6. Grails – The search is over Tipagem dinâmica def name = “João” def names = [“João”, “José”, “Geraldo”]
  • 7. Grails – The search is over Atribute accessor class User{ String nome Integer idade } def user = new User(name:”João”, age: 23) user.nome = “Pedro”
  • 8. Grails – The search is over Closure def name = “Paulo” def printName = {println “Hello, ${name}”} printName() def listNames = [“Gabriela”, “Maria”] def sayHello = {println it} listNames.each(sayHello)
  • 9. Grails – The search is over Métodos Dinâmicos def methodName = “getYearBorn” user.”${methodName}”() new User().”getDayBorn”()
  • 10. Grails – The search is over Além de... Sobre carga de operadores; Ranges; MetaPrograming; e etc...
  • 11. Grails – The search is over Groovy veio acabar com a Regra dos 80/20 (Princípio de Pareto)
  • 12. Grails – The search is over import java.util.ArrayList; import java.util.List; class Seletor { private List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); for (int i = 0; i < bookNames.size(); i++) { String candidate = (String) bookNames.get(i); if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } public static void main(String[] args) { List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); for (int i = 0; i < selected.size(); i++) { String sel = (String) selecionados.get(i); System.out.println(sel); } } }
  • 13. Grails – The search is over O que realmente interessa no código anterior?
  • 14. Grails – The search is over import java.util.ArrayList; import java.util.List; class Seletor { private List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); for (int i = 0; i < bookNames.size(); i++) { String candidate = (String) bookNames.get(i); if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } public static void main(String[] args) { List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); for (int i = 0; i < selected.size(); i++) { String sel = (String) selecionados.get(i); System.out.println(sel); } } }
  • 15. Grails – The search is over
  • 16. Grails – The search is over Closure e import implícito
  • 17. Grails – The search is over import java.util.ArrayList; import java.util.List; class Seletor { private List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); for (int i = 0; i < bookNames.size(); i++) { String candidate = (String) bookNames.get(i); if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } public static void main(String[] args) { List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); for (int i = 0; i < selected.size(); i++) { String sel = (String) selecionados.get(i); System.out.println(sel); } } }
  • 18. Grails – The search is over class Seletor { private List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); bookNames.each { String candidate -> if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } public static void main(String[] args) { List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { String sel -> System.out.println(sel); } } }
  • 19. Grails – The search is over Closure e import implícito Declaração e Assinatura de Métodos
  • 20. Grails – The search is over class Seletor { private List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); bookNames.each { String candidate -> if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } public static void main(String[] args) { List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { String sel -> System.out.println(sel); } } }
  • 21. Grails – The search is over List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); bookNames.each { String candidate -> if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { String sel -> System.out.println(sel); }
  • 22. Grails – The search is over Closure e import implícito Declaração e Assinatura de Métodos Tipagem Estática
  • 23. Grails – The search is over List selectBooksNameLessThan(List bookNames, int length) { List resultado = new ArrayList(); bookNames.each { String candidate -> if (candidate.length() < length) { resultado.add(candidate); } } return resultado; } List books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); Seletor s = new Seletor(); List selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { String sel -> System.out.println(sel); }
  • 24. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { def resultado = new ArrayList(); bookNames.each { candidate -> if (candidate.size() < length) { resultado.add(candidate); } } return resultado; } def books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); def selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { sel -> System.out.println(sel); }
  • 25. Grails – The search is over Closure e import implícito Declaração e Assinatura de Métodos Tipagem Estática Instância simplificada de Listas Não necessidade de “return” “;” não obrigatório Impressão simples
  • 26. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { def resultado = new ArrayList(); bookNames.each { candidate -> if (candidate.size() < length) { resultado.add(candidate); } } return resultado; } def books = new ArrayList(); books.add("Harry Potter"); books.add("A Vila"); books.add(“O Exorcista"); def selected = s.selectBooksNameLessThan(books, 10); System.out.println("Total Selecionados: " + selecionados.size()); selected.each { sel -> System.out.println(sel); }
  • 27. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { def resultado = []; bookNames.each { candidate -> if (candidate.size) < length) { resultado.add(candidate) } } resultado } def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = s.selectBooksNameLessThan(books, 10) println "Total ${selecionados.size()}” selected.each { sel -> println sel }
  • 28. Grails – The search is over Closure e import implícito Declaração e Assinatura de Métodos Tipagem Estática Instância simplificada de Listas Não necessidade de “return” “;” não obrigatório Impressão simples Métódos Dinâmicos
  • 29. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { def resultado = []; bookNames.each { candidate -> if (candidate.size) < length) { resultado.add(candidate) } } resultado } def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = s.selectBooksNameLessThan(books, 10) println "Total ${selecionados.size()}” selected.each { sel -> println sel }
  • 30. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { bookNames.findAll { it.size() < length } } def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = s.selectBooksNameLessThan(books, 10) println "Total ${selecionados.size()}” selected.each { sel -> println sel }
  • 31. Grails – The search is over def selectBooksNameLessThan(bookNames, length) { bookNames.findAll { it.size() < length } } def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = s.selectBooksNameLessThan(books, 10) println "Total ${selecionados.size()}” selected.each { sel -> println sel }
  • 32. Grails – The search is over def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = books. findAll { it.size() <= 5} println "Total ${selecionados.size()}” selected.each { sel -> println sel }
  • 33. Grails – The search is over def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = books. findAll { it.size() <= 5} println "Total ${selecionados.size()}” selected.each { sel -> println sel } Seletor.groovy
  • 34. Grails – The search is over def books = ["Harry Potter”, "A Vila”, “O Exorcista”] def selected = books. findAll { it.size() <= 5} println "Total ${selecionados.size()}” selected.each { sel -> println sel } Seletor.groovy Groovy é Java
  • 35. Grails – The search is over Cenário Atual Web  Persistência  Validações  Logs  Visualização  Controladores  Controle Transacional  Injeção de Dependências  Ajax  Redirecionador de URL’s  Configuração por ambiente  Internacionalização
  • 36. Grails – The search is over
  • 37. Grails – The search is over Welcome to
  • 38. Grails – The search is over Framework Web de Alta produtividade para plataforma Java; Programação por convenção; MVC nativo; Fácil bootstrap; GORM; Scaffolding; Plugins; e tudo que você viu lá atras...
  • 39. Grails – The search is over Arquitetura do Grails
  • 40. Grails – The search is over Passos para criar a Aplicação $ grails create-app booklibrary $ grails run-app
  • 41. Grails – The search is over Classes de domínio $ grails create-domain-class cesar.example.Book class Book { String title Date releaseDate String ISBN }
  • 42. Grails – The search is over Scaffolding INSERT, UPDATE, DELETE, SEARCH $ grails generate-all cesar.example.Book
  • 43. Grails – The search is over Validations (Constraints) DSL interna baseada no recurso builder da linguagem Groovy; Constraints: http://grails.org/doc/latest/ref/Constraints/Usage.html static constraints = { title(blank: false) ISBN(blank: false, unique: true) }
  • 44. Grails – The search is over Relacionamento $ grails create-domain-class cesar.example.Person class Person { static hasMany = [books: Book] String name String email String password static constraints = { name(blank: false) email(blank: false, email: true) password(blank: false, password: true) } } Na classe Book: static belongsTo = [person: Person]
  • 45. Grails – The search is over View .gsp i18n # Book book.label=Livro book.title.label=Titulo book.person.label=Pessoa book.releaseDate.label=Data de lancamento # Person person.label=Pessoa person.name.label=Nome person.password.label=Senha
  • 46. Grails – The search is over GORM def books = Book.list(max:10, order:”name”) def books = Book.findByName(“The Developer”) def books = Book.findAllByPriceLessThan(10.0) def books = Book.findAllByTitleLikeAndPriceBetween(“Harry %”, 40.0, 70.0)
  • 47. Grails – The search is over GORM class BookController { def find() { def books = Book.findAllByTitleLike("%"+params.like+"%") render(view: "list", model: [bookInstanceList: books, bookInstanceTotal: books.size()]) } } <div> <br/> <g:form name="myForm" url="[controller:'book',action:'find']"> <g:actionSubmit value="Find" /> <g:textField name="like" value="" /> </g:form> </div>
  • 48. Grails – The search is over WebService REST import grails.converters.* def showRest() { def bookInstance = Book.get(params.id) if(!bookInstance){ render new Book() as JSON return } render bookInstance as JSON }
  • 49. Grails – The search is over Configuração por ambiente BuildConfig.groovy DataSource.groovy development { dataSource { pooled = true driverClassName = "com.mysql.jdbc.Driver” username = “root" password = “root" dbCreate = "create-drop" dialect = "org.hibernate.dialect.MySQL5InnoDBDialect" url = "jdbc:mysql://localhost:3306/book_dev? autoreconnect=true" } } $ grails install-dependency mysql:mysql-connector-java:5.1.16
  • 50. Grails – The search is over Plugins GWT LDAP Spring Security Spring WS Maill Feeds Quartz Axis2 Wicket
  • 51. Grails – The search is over Deploy $ grails war
  • 54. contato Aécio Costa – aecio.costa@cesar.org.br – www.aeciocosta.com.br Felipe Coutinho – flc@cesar.org.br – www.felipelc.com