Groovy web console

subscribe to the feed Subscribe
to this
site
test (via #groovywebconsole)
tweet this snippet Tweet
this
script

test

Published 10 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def list1 = [[project_no:'0-10060', case_no:'01757560'], [project_no:'1-153246461', case_no:'02039960'], [project_no:'1-175858654', case_no:'01995271'], [project_no:'1-224323229', case_no:'01912596'], [project_no:'1-228256337', case_no:'02039596'], [project_no:'1-53795134', case_no:'02029418'], [project_no:'2-00073626', case_no:'01998455']]
def list2 = [[project_no:'0-10060', case_no:'01757560'], [project_no:'1-224323229', case_no:'01912596'], [project_no:'1-228256337', case_no:'02039596'], [project_no:'1-233412391', case_no:'02060631']]
 
def result = list1+list2
def projNos = result.inject([]) { keys, item ->  keys << item.project_no } as Set
 
 
def finalResult = []
projNos.each { proj ->
def cases = []
result.each { item ->
if (item.project_no == proj) {
cases << item.case_no
}
}
finalResult << [ 'project_no': proj, 'case_no' : cases ]
}
 
println finalResult