org.cristalise.dsl.scaffold.entity_changeName_groovy.tmpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cristalise-dsl Show documentation
Show all versions of cristalise-dsl Show documentation
CRISTAL-iSE Domain Specific Language module for bootstrapping and funtional testing
import org.cristalise.kernel.common.ObjectAlreadyExistsException
import org.cristalise.kernel.lifecycle.instance.predefined.ChangeName
import org.cristalise.kernel.utils.Logger
//--------------------------------------------------
// item, agent and job are injected by the Script class
// automatically so these declaration are only needed
// to write the script with code completion.
// COMMENT OUT before you run the module generators
//--------------------------------------------------
// ItemProxy item
// AgentProxy agent
// Job job
//--------------------------------------------------
def outcome = job.getOutcome()
def currentName = item.getName()
def newName = outcome.getField('Name')
if (currentName && newName && (newName != currentName)) {
def params = new String[2]
params[0] = currentName
params[1] = newName
agent.execute(item, ChangeName.getClass(), params)
}
else
Logger.msg(5, "New name or current name were empty or new name is equal to the current one")