It is not planned to extend the ivyscript functionality in any way. Its more likely that in the future another scripting language like Groovy will be supported to configure process elements.
I'd only use ivyscript for simple mappings or short snippets ( <= 20 lines of code). More complex code is normally easier to maintain and especially easiert to test if is written in plain java and then called from ivyscript.
Especially if I look at your code example. I'd anyway encapsulate it in a simple DAO class.
public class IncidentDao{
private static final String PERSISTENT_CRM_UNIT = "EventDashboard2";
protected static IIvyEntityManager getEntityManager() {
return Ivy.persistence().get(PERSISTENT_CRM_UNIT);
}
public static Incident getIncidientByService(String service){
// your code...
// getEntityManager().createQuery(...)
}
}