But it is much simpler than that.
Just go to
grails-app/init/webtracker.api/Application
and right click on Application and select Debug 'Application.main()'
There we go
Intellij will remember these and you can get to them quick in the Build menu
Code Snippets, Ideas and Rants from a Tech Lead interested primarily in server side web development and leading teams who build web apps.
grails-app/init/webtracker.api/Application
and right click on Application and select Debug 'Application.main()'
logger('org.hibernate.SQL', DEBUG, ['STDOUT'], false)
logger('org.hibernate.type', TRACE, ['STDOUT'], false)
The false eliminated duplicate entries
package com.webtracker.api.prodcat import com.webtracker.api.Company import com.webtracker.api.Project import com.webtracker.api.WpActivationKey import grails.test.mixin.integration.Integration import grails.transaction.Rollback import spock.lang.Specification /** * Sanity domain Integration tests, uses development DB * * Created by demian on 14/06/16. */ @Integration @Rollback class DomainSpec extends Specification{ def setup() { } def cleanup() { } void "Can we list and load an activation key"() { when: def keys = WpActivationKey.list() def key1 = WpActivationKey.get keys[0].id def key2 = WpActivationKey.findByActivationKey keys[0].activationKey then: keys.size() > 0 key1 == key2 } void "Can we list and load a company"() { when: def companies = Company.list() def company1 = Company.get companies[0].id def company2 = Company.findByName companies[0].name then: companies.size() > 0 company1 == company2 } void "Can we list and load a project"() { when: def projects = Project.list() then: projects.size() > 0 } }
Date dateCreated Long projectId static mapping = { version false } static constraints = { activationKey maxSize: 100, unique: true dateCreated column: 'created_date' }
Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.TimestampThis is because that is a valid SQL date but not in Gorm, this was fixed by appending the following to application.yml datasource:url: connection string
?zeroDateTimeBehavior=convertToNull
package com.webtracker.api.prodcat import grails.compiler.GrailsCompileStatic import grails.converters.JSON import org.apache.catalina.connector.Response /** * This method is expensive as it can be called before every controller */ @GrailsCompileStatic class TokenInterceptor { TokenInterceptor() { matchAll() } boolean before() { if (params?.apikey) { WpActivationKey key = WpActivationKey.findByActivationKey(params?.apikey) if (key) { true } else { response.status = Response.SC_FORBIDDEN render([errors: ['api key not valid']] as JSON) false } } else { response.status = Response.SC_FORBIDDEN render([errors: ['no api key specified']] as JSON) false } } boolean after() { true } void afterView() { // no-op } }
@Cacheable("activationKeys")
import scala.concurrent._
import ExecutionContext.Implicits.global
import scala.util.{Try,Success,Failure}
object Actors3 {
println("Actors3----")
val r = scala.util.Random
val usdQuote = future {
Thread.sleep(1000)
r.nextInt(10)
}
val canQuote = future {
Thread.sleep(1000)
r.nextInt(10)
}
val purchase = for {
usd <- usdQuote
can <- canQuote
if (can > usd)
} yield "Can Strong"
purchase onSuccess {
case e => println(s"e1=${e}")
}
println("This is the most interesting")
val purchase2 = usdQuote flatMap {
usd => canQuote.withFilter(can => (can > usd)).map(can => "Can Strong")
} recover {
case _ => "Falsies"
}
println(s"purchase2=${purchase2}")
purchase2 onSuccess {
case e => println(s"e2=${e}")
}
Thread.sleep(4000)
println("End----")
}