-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementação inicial de Tipo de Documento e Espécie Documental
- Loading branch information
Guilherme Andrade Del Cantoni
committed
Mar 27, 2017
1 parent
3b97147
commit cdf8042
Showing
20 changed files
with
924 additions
and
9 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
grails-app/controllers/working/docweb/EspecieController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package working.docweb | ||
|
||
import static org.springframework.http.HttpStatus.* | ||
import grails.transaction.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
class EspecieController { | ||
|
||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond Especie.list(params), model:[especieCount: Especie.count()] | ||
} | ||
|
||
def show(Especie especie) { | ||
respond especie | ||
} | ||
|
||
def create() { | ||
respond new Especie(params) | ||
} | ||
|
||
@Transactional | ||
def save(Especie especie) { | ||
if (especie == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
if (especie.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond especie.errors, view:'create' | ||
return | ||
} | ||
|
||
especie.save flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.created.message', args: [message(code: 'especie.label', default: 'Especie'), especie.id]) | ||
redirect especie | ||
} | ||
'*' { respond especie, [status: CREATED] } | ||
} | ||
} | ||
|
||
def edit(Especie especie) { | ||
respond especie | ||
} | ||
|
||
@Transactional | ||
def update(Especie especie) { | ||
if (especie == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
if (especie.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond especie.errors, view:'edit' | ||
return | ||
} | ||
|
||
especie.save flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.updated.message', args: [message(code: 'especie.label', default: 'Especie'), especie.id]) | ||
redirect especie | ||
} | ||
'*'{ respond especie, [status: OK] } | ||
} | ||
} | ||
|
||
@Transactional | ||
def delete(Especie especie) { | ||
|
||
if (especie == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
especie.delete flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.deleted.message', args: [message(code: 'especie.label', default: 'Especie'), especie.id]) | ||
redirect action:"index", method:"GET" | ||
} | ||
'*'{ render status: NO_CONTENT } | ||
} | ||
} | ||
|
||
protected void notFound() { | ||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.not.found.message', args: [message(code: 'especie.label', default: 'Especie'), params.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*'{ render status: NOT_FOUND } | ||
} | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
grails-app/controllers/working/docweb/TipoDocumentoController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package working.docweb | ||
|
||
import static org.springframework.http.HttpStatus.* | ||
import grails.transaction.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
class TipoDocumentoController { | ||
|
||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond TipoDocumento.list(params), model:[tipoDocumentoCount: TipoDocumento.count()] | ||
} | ||
|
||
def show(TipoDocumento tipoDocumento) { | ||
respond tipoDocumento | ||
} | ||
|
||
def create() { | ||
respond new TipoDocumento(params) | ||
} | ||
|
||
@Transactional | ||
def save(TipoDocumento tipoDocumento) { | ||
if (tipoDocumento == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
if (tipoDocumento.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond tipoDocumento.errors, view:'create' | ||
return | ||
} | ||
|
||
tipoDocumento.save flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.created.message', args: [message(code: 'tipoDocumento.label', default: 'TipoDocumento'), tipoDocumento.id]) | ||
redirect tipoDocumento | ||
} | ||
'*' { respond tipoDocumento, [status: CREATED] } | ||
} | ||
} | ||
|
||
def edit(TipoDocumento tipoDocumento) { | ||
respond tipoDocumento | ||
} | ||
|
||
@Transactional | ||
def update(TipoDocumento tipoDocumento) { | ||
if (tipoDocumento == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
if (tipoDocumento.hasErrors()) { | ||
transactionStatus.setRollbackOnly() | ||
respond tipoDocumento.errors, view:'edit' | ||
return | ||
} | ||
|
||
tipoDocumento.save flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.updated.message', args: [message(code: 'tipoDocumento.label', default: 'TipoDocumento'), tipoDocumento.id]) | ||
redirect tipoDocumento | ||
} | ||
'*'{ respond tipoDocumento, [status: OK] } | ||
} | ||
} | ||
|
||
@Transactional | ||
def delete(TipoDocumento tipoDocumento) { | ||
|
||
if (tipoDocumento == null) { | ||
transactionStatus.setRollbackOnly() | ||
notFound() | ||
return | ||
} | ||
|
||
tipoDocumento.delete flush:true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.deleted.message', args: [message(code: 'tipoDocumento.label', default: 'TipoDocumento'), tipoDocumento.id]) | ||
redirect action:"index", method:"GET" | ||
} | ||
'*'{ render status: NO_CONTENT } | ||
} | ||
} | ||
|
||
protected void notFound() { | ||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.not.found.message', args: [message(code: 'tipoDocumento.label', default: 'TipoDocumento'), params.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*'{ render status: NOT_FOUND } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package working.docweb | ||
|
||
class Especie { | ||
|
||
String nome | ||
static constraints = { | ||
nome blank: false, unique: true | ||
} | ||
|
||
@Override | ||
String toString() { | ||
return (nome != null && nome != '') ? nome.toString() : super.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="layout" content="main" /> | ||
<g:set var="entityName" value="${message(code: 'especie.label', default: 'Especie')}" /> | ||
<title><g:message code="default.create.label" args="[entityName]" /></title> | ||
</head> | ||
<body> | ||
<a href="#create-especie" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content…"/></a> | ||
<div class="nav" role="navigation"> | ||
<ul> | ||
<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li> | ||
<li><g:link class="list" action="index"><g:message code="default.list.label" args="[entityName]" /></g:link></li> | ||
</ul> | ||
</div> | ||
<div id="create-especie" class="content scaffold-create" role="main"> | ||
<h1><g:message code="default.create.label" args="[entityName]" /></h1> | ||
<g:if test="${flash.message}"> | ||
<div class="message" role="status">${flash.message}</div> | ||
</g:if> | ||
<g:hasErrors bean="${this.especie}"> | ||
<ul class="errors" role="alert"> | ||
<g:eachError bean="${this.especie}" var="error"> | ||
<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li> | ||
</g:eachError> | ||
</ul> | ||
</g:hasErrors> | ||
<g:form action="save"> | ||
<fieldset class="form"> | ||
<f:all bean="especie"/> | ||
</fieldset> | ||
<fieldset class="buttons"> | ||
<g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /> | ||
</fieldset> | ||
</g:form> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.