I have been working on some ideas with the goal of making Groovy a viable alternative to mini-language. I already committed some code that allows methods within a Groovy script to be called, so that multiple services can be included in one file - just like in Java or mini-language.

My next step is to create a Groovy script that contains utility methods that mimic many of the existing mini-language elements - particularly the ones that do a lot of work in one line. The utility script (ScriptUtil) will be in the Groovy context so it will be easy to access. For example:

<simple-method method-name="createPartyRole">
    <entity-one entity-name="PartyRole" value-field="partyRole"/>
    <if-empty field="partyRole">
        <make-value entity-name="PartyRole" value-field="newEntity"/>
        <set-pk-fields map="parameters" value-field="newEntity"/>
        <create-value value-field="newEntity"/>
    </if-empty>
</simple-method>

becomes

Map createPartyRole() {
    partyRole = ScriptUtil.entityOne("PartyRole");
    if (partyRole == null) {
        partyRole = ScriptUtil.makeValue("PartyRole");
        partyRole.setPKFields(parameters, true);
        delegator.create(partyRole, true);
    }
    return ServiceUtil.returnSuccess();
}

The ScriptUtil methods will duplicate the mini-language Java code so they will be interchangeable.

The bottom line is, I'm trying to bring some of mini-language's ease of use to Groovy. Before I proceed any further, I wanted to find out if there was any interest in it.

What do you think?

-Adrian

Reply via email to