- Timestamp:
- Mar 18, 2010, 10:17:02 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r274 r283 151 151 * @param sheetindex sheet to use when using multiple sheets 152 152 * @param rowindex first row to start with reading the actual data (NOT the header) 153 * @return two dimensional array containing records (with entities) 153 154 * 154 155 * @see dbnp.importer.MappingColumn … … 163 164 } 164 165 165 table.each {166 /*table.each { 166 167 it.each { entity -> 167 168 entity.giveFields().each { field -> … … 170 171 println 171 172 } 172 } 173 } 173 }*/ 174 175 return table 176 } 177 178 /** 179 * @param datamatrix two dimensional array containing entities with values read from Excel file 180 */ 181 def savedata(datamatrix) { 182 datamatrix.each { record -> 183 record.each { entity -> 184 switch (entity.getClass()) { 185 case Study : print "Persisting Study `" + entity.title + "`: " 186 entity.save() 187 println "OK" 188 break 189 case Subject : print "Persisting Subject `" + entity.name + "`: " 190 entity.save() 191 println "OK" 192 break 193 case Event : print "Persisting Event `" + entity.eventdescription + "`: " 194 entity.save() 195 println "OK" 196 break 197 case Protocol: print "Persisting Protocol `" + entity.name + "`: " 198 entity.save() 199 println "OK" 200 break 201 case Sample : print "Persisting Sample `" + entity.name +"`: " 202 entity.save() 203 println "OK" 204 break 205 default : println "Skipping persistance of `" + entity.getclass() +"`" 206 break 207 } 208 } 209 } 210 } 211 174 212 /** 175 213 * This method created a record (array) containing entities with values 214 * 215 * @param template_id template identifier 216 * @param excelrow POI based Excel row containing the cells 217 * @param mcmap map containing MappingColumn objects 176 218 */ 177 219 def createRecord(template_id, HSSFRow excelrow, mcmap) { … … 181 223 182 224 def study = new Study(title:"New study", template:template) 183 def subject = new Subject(title:"New subject", template:template) 184 def event = new Event(title:"New event", template:template) 185 def protocol = new Protocol(title:"New protocol", template:template) 186 def sample = new Sample(title:"New sample", template:template) 187 188 /*record.add(study) 189 record.add(subject) 190 record.add(event) 191 record.add(protocol) 192 record.add(sample)*/ 225 def subject = new Subject(name:"New subject", template:template) 226 def event = new Event(eventdescription:"New event", template:template) 227 def protocol = new Protocol(name:"New protocol", template:template) 228 def sample = new Sample(name:"New sample", template:template) 193 229 194 230 for (HSSFCell cell: excelrow) {
Note: See TracChangeset
for help on using the changeset viewer.