Skip to content

Instantly share code, notes, and snippets.

def result = this.invoiceLineItems.collect { it.quantityNet }.inject(0.0G) { sum, ili ->
sum + ili
}
This code throws:
java.lang.ClassCastException: java.lang.Integer cannot be cast to groovy.lang.Closure
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:42)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:77)
at $Proxy1.getQuantityNet(Unknown Source)
void testCalculateDestinationTransportOrderDateOfArrivalScheduledShouldReturnTheTODateOfArrivalWhenThereIsATO () {
def lot = mockLot()
def to = new TransportOrderJpaImpl ()
def now = new Date ()
to.dateOfArrivalScheduled = now
lot.activeDestinationTransportOrders.returns([ to ])
lot.activeDestinationTransportOrders.returns([ to ])
play {
assertEquals(now, lot.calculateDestinationTransportOrderDateOfArrivalScheduled())
}
package models
import javax.persistence.*
import lib.ConversionUtils as CU
import lib.BigDecimalUtils as BDU
@Entity
@DiscriminatorValue("PO")
class PoLotJpaImpl extends LotJpaImpl {
String calculateStatus () {
// TODO Should we look at using a State pattern here? -Mark 11/10/09
def result = null
if (this.isCancelled()) {
return 'CANCELLED'
}
def calculateStatus (Lot lot) {
// TODO Should we look at using a State pattern here? -Mark 11/10/09
// TODO LoD refactoring
def tos = lot.incomingOrderLineItem.shipmentLineItems.container.transportOrderLineItems.transportOrder.findAll { it.status != 'CANCELLED' }
def result = null
// Status
log.debug "[ LotDependencyManagerImpl ]: [${lot.id}] : Calculating status "
class Person < ActiveRecord::Base
# Everything in here are methods on the Person object.
class << self
def find_by_name (name)
# implement it
end
end
# Assume the table has a name and address column.
2010-02-11 17:18:54.922:/quadran:WARN: rails: Failure to invoke rails: null
java.lang.IndexOutOfBoundsException
at org.jruby.util.ByteList.insert(ByteList.java:326)
at jdbc_adapter.JdbcMySQLSpec.quote_table_name(JdbcMySQLSpec.java:103)
at jdbc_adapter.JdbcMySQLSpecInvoker$quote_table_name_s_method_1_0.call(Unknown Source)
at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:155)
at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:332)
at org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:649)
at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:324)
at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:170)
[mark@Marks-MacBook-2:~]$ rvm list
rvm Rubies
jruby-1.4.0 [ [x86_64-java] ]
rbx-1.0.0-rc3 [ i386 ]
ruby-1.8.7-p249 [ i386 ]
=> ruby-1.9.1-p378 [ i386 ]
__rvm_select:187: command not found: __rvm_gemset_select
[mark@Marks-MacBook-2:tmp/jrubyc-test]$ cat foo.rb
require 'java'
java_require 'foo'
class Foo
java_signature 'void main(String[])'
def self.main(args)
bar(args[0], args[1])
end
@MarkMenard
MarkMenard / gist:340525
Created March 22, 2010 21:04
Example Ruby/Java JPA
require 'java'
java_require 'agreement_jpa_impl'
java_package 'models'
java_import 'javax.persistence.*'
java_annotation '@Entity (name="Agreement")'
java_annotation '@Table (name="agreement")'
java_annotation '@EntityListeners ({ QIdSetter.class })'