Changeset 1792
- Timestamp:
- Apr 27, 2011, 2:35:16 PM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy
r1734 r1792 1 1 package dbnp.studycapturing 2 import java.util.ArrayList; 3 2 4 import org.dbnp.gdt.* 3 5 … … 160 162 return this.sampleUUID; 161 163 } 164 165 /** 166 * Returns a human readable string of a list of samples, with a maximum number 167 * of characters 168 * 169 * @param sampleList List with Sample objects 170 * @param maxChars maximum number of characters returned 171 * @return human readble string with at most maxChars characters, representing the samples given. 172 */ 173 public static String trimSampleNames(ArrayList sampleList, Integer maxChars) { 174 def simpleSamples = sampleList.name.join(', '); 175 def showSamples 176 177 // If the subjects will fit, show them all 178 if (!maxChars || simpleSamples.size() < maxChars) { 179 showSamples = simpleSamples; 180 } else { 181 // Always add the first name 182 def sampleNames = sampleList[0]?.name; 183 184 // Continue adding names until the length is to long 185 def id = 0; 186 sampleList.each { sample -> 187 if (id > 0) { 188 if (sampleNames?.size() + sample.name?.size() < maxChars - 15) { 189 sampleNames += ", " + sample.name; 190 } else { 191 return; 192 } 193 } 194 id++; 195 } 196 197 // Add a postfix 198 sampleNames += " and " + (sampleList?.size() - id) + " more"; 199 200 showSamples = sampleNames; 201 } 202 203 return showSamples 204 } 205 162 206 } -
trunk/grails-app/views/study/show_assays.gsp
r1689 r1792 1 <%@ page import="dbnp.studycapturing.Sample" %> 1 2 <g:if test="${studyList*.assays?.flatten()?.size()==0}"> 2 3 No assays in these studies … … 39 40 <td> 40 41 <% sortedAssaySamples = assay?.samples.sort( { a, b -> a.name <=> b.name } as Comparator ) %> 41 ${ sortedAssaySamples.name.join( ', ')}42 ${Sample.trimSampleNames( sortedAssaySamples, 400 )} 42 43 </td> 43 44 </tr>
Note: See TracChangeset
for help on using the changeset viewer.