I am pretty new to Grails/groovy and looking for a optimized way to write a code.
Domain class:
class Visitors {
int ID;
String destination;
String status; // Status can be OK, FAIL, DONE, REDO, NEW, LAST, FIRST
.........
..........
}
Now in a controller:
class VisitorsController {
def getVisitors() {
Visitors.findAllByStatus().each { } // This is where i have confusion
}
}
At the commented line above, i want to get all Visitors objects that doesn't have status = OK and then go through a loop and update there status = REDO.
The statuses are defined in another class:
public enum VisitorsStatusEnum { NEW, OK, FAIL, DONE, REDO, LAST, FIRST }
Any suggestions?