- Timestamp:
- Feb 9, 2010, 10:28:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/CsvService.groovy
r327 r340 42 42 43 43 def columnIndex = 0 44 def nameColumnIndex = 0 44 45 def numberOfColumns = 0 45 46 def maxNumberOfColumns = 20 … … 91 92 92 93 def nextColumn = { 93 if( (columnIndex+2) > numberOfColumns ) { 94 nameColumnIndex = columnIndex 95 96 if( (columnIndex+1) < numberOfColumns ) { 97 // Capitalise and assign the name and description columns. 98 use(WordUtils) { 99 column.name = line[columnIndex].trim().capitalize() 100 column.description = line[++columnIndex].trim().capitalize() 101 } 102 } 103 else if( columnIndex < numberOfColumns ) { 104 // Capitalise and assign the name column with a blank description. 105 use(WordUtils) { 106 column.name = line[columnIndex].trim().capitalize() 107 column.description = '' 108 } 109 } 110 else { 94 111 log.info "No more columns on line: " + lineNumber 95 112 return false 96 113 } 97 if(!line[columnIndex]) { 98 log.info "No name at " + "line: " + lineNumber + " col: " + columnIndex 114 115 if(!column.name) { 116 log.info "No name at " + "line: " + lineNumber + " col: " + nameColumnIndex 99 117 return false 100 118 } 101 // Capitalise and assign the name and description columns. 102 use(WordUtils) { 103 column.name = line[columnIndex].trim().capitalize() 104 column.description = line[++columnIndex].trim().capitalize() 105 } 119 106 120 columnIndex++ 107 121 // Success.
Note: See TracChangeset
for help on using the changeset viewer.