Changeset 1213 for trunk/grails-app/domain
- Timestamp:
- Nov 29, 2010, 4:56:48 PM (10 years ago)
- Location:
- trunk/grails-app/domain/dbnp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/authentication/SecUser.groovy
r1144 r1213 29 29 } 30 30 31 32 33 34 35 31 public boolean equals(Object y) 32 { 33 if( !( y instanceof SecUser ) ) { 34 return false; 35 } 36 36 37 37 if (y == null) return false; 38 38 39 return this.id == y.id 40 } 39 return this.id == y.id 40 } 41 42 public boolean hasAdminRights() { 43 return getAuthorities().contains( SecRole.findByAuthority( 'ROLE_ADMIN' ) ); 44 } 45 41 46 } -
trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy
r1198 r1213 68 68 return name 69 69 } 70 71 /** 72 * Returns a human readable string of a list of subjects, with a maximum number 73 * of characters 74 * 75 * @param subjectList List with Subject objects 76 * @param maxChars maximum number of characters returned 77 * @return human readble string with at most maxChars characters, representing the subjects given. 78 */ 79 public static String trimSubjectNames( ArrayList subjectList, Integer maxChars ) { 80 def simpleSubjects = subjectList.name.join( ', ' ); 81 def showSubjects 82 83 // If the subjects will fit, show them all 84 if( !maxChars || simpleSubjects.size() < maxChars ) { 85 showSubjects = simpleSubjects; 86 } else { 87 // Always add the first name 88 def subjectNames = subjectList[0]?.name; 89 90 // Continue adding names until the length is to long 91 def id = 0; 92 subjectList.each { subject -> 93 if( id > 0 ) { 94 if( subjectNames?.size() + subject.name?.size() < maxChars - 15 ) { 95 subjectNames += ", " + subject.name; 96 } else { 97 return; 98 } 99 } 100 id++; 101 } 102 103 // Add a postfix 104 subjectNames += " and " + ( subjectList?.size() - id ) + " more"; 105 106 showSubjects = subjectNames; 107 } 108 109 return showSubjects 110 } 70 111 } -
trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy
r1175 r1213 353 353 } 354 354 355 /** 356 * Checks whether this field is filled in any of the entities in the given list 357 * 358 * @param List List of TemplateEntities to search in 359 * @return boolean True iff any of the given entities has this field as template field, and has a value for it. False otherwise 360 */ 361 def isFilledInList( entityList ) { 362 if( !entityList ) 363 return false; 364 365 return true in entityList.collect { it.fieldExists( this.name ) && it.getFieldValue( this.name ) != null }?.flatten() 366 } 367 355 368 }
Note: See TracChangeset
for help on using the changeset viewer.