Christopher Snow wrote:
Hi Adrian, I've been thinking about this too. I think there will be a
lot of merit in combining the power of minilang + the power of groovy.
I'm still reading about groovying meta programming and DSL's, and I
don't yet understand the service engine under the hood, so I'm really
just thinking aloud here:
Could the groovy service class instance have the following methods
injected: entityOne(), makeValue(), returnSuccess(), createEntity(),
etc? That way, we wouldn't need a reference to the ScriptUtil class:
Map createPartyRole() {
partyRole = entityOne('PartyRole')
if (partyRole == null) {
partyRole = makeValue('PartyRole')
partyRole.setPKFields(parameters, true)
createEntity(partyRole, true)
}
returnSuccess()
}
I considered method injection, but the drawback is name clash with
existing script methods.
Also, I was wondering whether we could manipulate the lists returned by
GenericValue like so:
party.getRelated("PartyRole").each() { roleTypeId -> switch roleTypeId
{
case 'CONTENT_USER':
// doSomething(party)
break
case 'XYZ':
// doSomethingElse(party)
break
}
}
Probably. I'm sure you can do anything Groovy supports.