Changeset 1724


Ignore:
Timestamp:
Apr 7, 2011, 2:50:12 PM (12 years ago)
Author:
s.h.sikkema@…
Message:

changed Study.give[Readable,Writable]Studies to make max parameter optional; assay exporter now gives all readable studies instead of all owned studies

Location:
trunk/grails-app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy

    r1716 r1724  
    123123            action{
    124124                def user            = authenticationService.getLoggedInUser()
    125                 flow.userStudies    = Study.findAllByOwner(user)
     125                flow.userStudies    = Study.giveReadableStudies(user)
    126126            }
    127127            on("success").to "selectAssay"
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r1659 r1724  
    449449         * Returns a list of studies that are writable for the given user
    450450         */
    451         public static giveWritableStudies(SecUser user, int max) {
     451        public static giveWritableStudies(SecUser user, int max = null) {
    452452                // User that are not logged in, are not allowed to write to a study
    453453                if (user == null)
     
    459459                if (user.hasAdminRights()) {
    460460                        return c.listDistinct {
    461                                 maxResults(max)
     461                                if (max != null) maxResults(max)
    462462                                order("title", "asc")
    463463                               
     
    466466
    467467                return c.listDistinct {
    468                         maxResults(max)
     468                        if (max != null) maxResults(max)
    469469                        order("title", "asc")
    470470                        or {
     
    480480         * Returns a list of studies that are readable by the given user
    481481         */
    482         public static giveReadableStudies(SecUser user, int max, int offset = 0) {
     482        public static giveReadableStudies(SecUser user, int max = null, int offset = 0) {
    483483                def c = Study.createCriteria()
    484484
     
    486486                if (user == null) {
    487487                        return c.listDistinct {
    488                                 maxResults(max)
     488                                if (max != null) maxResults(max)
    489489                                firstResult(offset)
    490490                                order("title", "asc")
     
    496496                } else if (user.hasAdminRights()) {
    497497                        return c.listDistinct {
    498                                 maxResults(max)
     498                                if (max != null) maxResults(max)
    499499                                firstResult(offset)
    500500                                order("title", "asc")
     
    502502                } else {
    503503                        return c.listDistinct {
    504                                 maxResults(max)
     504                                if (max != null) maxResults(max)
    505505                                firstResult(offset)
    506506                                order("title", "asc")
Note: See TracChangeset for help on using the changeset viewer.