Changeset 1553
- Timestamp:
- Feb 23, 2011, 4:32:09 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1536 r1553 61 61 switch (datamatrix_celltype) { 62 62 case Cell.CELL_TYPE_STRING: 63 63 //parse cell value as double 64 64 def doubleBoolean = true 65 65 def fieldtype = TemplateFieldType.STRING 66 66 67 67 // is this string perhaps a double? 68 68 try { 69 69 formatValue(datamatrix_celldata, TemplateFieldType.DOUBLE) … … 74 74 75 75 header[columnindex] = new dbnp.importer.MappingColumn(name: df.formatCellValue(headercell), 76 templatefieldtype: fieldtype,77 index: columnindex,78 entityclass: theEntity,79 property: property);76 templatefieldtype: fieldtype, 77 index: columnindex, 78 entityclass: theEntity, 79 property: property); 80 80 81 81 break … … 85 85 def longBoolean = true 86 86 87 87 // is this cell really an integer? 88 88 try { 89 89 Long.valueOf(datamatrix_celldata) … … 93 93 } 94 94 95 95 // it's not an long, perhaps a double? 96 96 if (!longBoolean) 97 97 try { … … 105 105 106 106 header[columnindex] = new dbnp.importer.MappingColumn(name: df.formatCellValue(headercell), 107 templatefieldtype: fieldtype,108 index: columnindex,109 entityclass: theEntity,110 property: property);107 templatefieldtype: fieldtype, 108 index: columnindex, 109 entityclass: theEntity, 110 property: property); 111 111 break 112 112 case Cell.CELL_TYPE_BLANK: 113 113 header[columnindex] = new dbnp.importer.MappingColumn(name: df.formatCellValue(headercell), 114 115 116 117 114 templatefieldtype: TemplateFieldType.STRING, 115 index: columnindex, 116 entityclass: theEntity, 117 property: property); 118 118 break 119 119 default: 120 120 header[columnindex] = new dbnp.importer.MappingColumn(name: df.formatCellValue(headercell), 121 122 123 124 121 templatefieldtype: TemplateFieldType.STRING, 122 index: columnindex, 123 entityclass: theEntity, 124 property: property); 125 125 break 126 126 } // end of switch … … 150 150 151 151 (0..header.size() - 1).each { columnindex -> 152 153 152 if (sheet.getRow(rowindex)) 153 row.add( sheet.getRow(rowindex).getCell(columnindex, Row.CREATE_NULL_AS_BLANK) ) 154 154 } 155 155 … … 204 204 def table = [] 205 205 def failedcells = [] // list of records 206 206 207 207 // walk through all rows and fill the table with records 208 208 (rowindex..sheet.getLastRowNum()).each { i -> … … 218 218 219 219 return [table, failedcells] 220 } 221 222 /** 223 * Removes a cell from the failedCells list, based on the entity and field. If the entity and field didn't fail before 224 * the method doesn't do anything. 225 * 226 * @param failedcell list of cells that have failed previously 227 * @param entity entity to remove from the failedcells list 228 * @param field field to remove the failed cell for. If no field is given, all cells for this entity will be removed 229 * @return List Updated list of cells that have failed 230 */ 231 def removeFailedCell(failedcells, entity, field = null ) { 232 if( !entity ) 233 return failedcells; 234 235 def filterClosure 236 if( field ) { 237 def entityIdField = "entity_" + entity.getIdentifier() + "_" + field.name.toLowerCase() 238 filterClosure = { cell -> cell.entityidentifier != entityIdField } 239 } else { 240 def entityIdField = "entity_" + entity.getIdentifier() + "_" 241 filterClosure = { cell -> !cell.entityidentifier.startsWith( entityIdField ) } 242 } 243 244 failedcells.each { record -> 245 record.importcells = record.importcells.findAll( filterClosure ) 246 } 247 248 return failedcells; 249 } 250 251 /** 252 * Returns the name of an input field as it is used for a specific entity in HTML. 253 * 254 * @param entity entity to retrieve the field name for 255 * @param field field to retrieve the field name for 256 * @return String Name of the HTML field for the given entity and field. Can also be used in the map 257 * of request parameters 258 */ 259 def getFieldNameInTableEditor(entity, field) { 260 if( field instanceof TemplateField ) 261 field = field.escapedName(); 262 263 return "entity_" + entity.getIdentifier() + "_" + field 264 } 265 266 /** 267 * Retrieves a mapping column from a list based on the given fieldname 268 * @param mappingColumns List of mapping columns 269 * @param fieldName Field name to find 270 * @return Mapping column if a column is found, null otherwise 271 */ 272 def findMappingColumn( mappingColumns, String fieldName ) { 273 return mappingColumns.find { it.property == fieldName.toLowerCase() } 220 274 } 221 275 … … 278 332 case Study: log.info ".importer wizard, persisting Study `" + entity + "`: " 279 333 entity.owner = authenticationService.getLoggedInUser() 280 281 282 283 284 285 286 287 288 289 290 291 334 335 if (study.validate()) { 336 if (!entity.save(flush:true)) { 337 log.error ".importer wizard, study could not be saved: " + entity 338 throw new Exception('.importer wizard, study could not be saved: ' + entity) 339 } 340 } else { 341 log.error ".importer wizard, study could not be validated: " + entity 342 throw new Exception('.importer wizard, study could not be validated: ' + entity) 343 } 344 345 break 292 346 case Subject: log.info ".importer wizard, persisting Subject `" + entity + "`: " 293 347 294 295 296 297 298 348 // is the current entity not already in the database? 349 //entitystored = isEntityStored(entity) 350 351 // this entity is new, so add it to the study 352 //if (entitystored==null) 299 353 300 354 study.addToSubjects(entity) … … 306 360 case Sample: log.info ".importer wizard, persisting Sample `" + entity + "`: " 307 361 308 362 // is this sample validatable (sample name unique for example?) 309 363 study.addToSamples(entity) 310 364 … … 391 445 boolean persistEntity(entity) { 392 446 /*log.info ".import wizard persisting ${entity}" 393 394 try { 395 entity.save(flush: true) 396 return true 397 398 } catch (Exception e) { 399 def session = sessionFactory.currentSession 400 session.setFlushMode(org.hibernate.FlushMode.MANUAL) 401 log.error ".import wizard, failed to save entity:\n" + org.apache.commons.lang.exception.ExceptionUtils.getRootCauseMessage(e) 402 } 403 404 return true*/ 405 //println "persistEntity" 447 try { 448 entity.save(flush: true) 449 return true 450 } catch (Exception e) { 451 def session = sessionFactory.currentSession 452 session.setFlushMode(org.hibernate.FlushMode.MANUAL) 453 log.error ".import wizard, failed to save entity:\n" + org.apache.commons.lang.exception.ExceptionUtils.getRootCauseMessage(e) 454 } 455 return true*/ 456 //println "persistEntity" 406 457 } 407 458 … … 441 492 } 442 493 443 try { 494 try { 444 495 // which entity does the current cell (field) belong to? 445 496 switch (mc.entityclass) { … … 466 517 log.error ".import wizard error could not set property `" + mc.property + "` to value `" + value + "`" 467 518 // store the mapping column and value which failed 468 519 def identifier 469 520 470 521 switch (mc.entityclass) { … … 503 554 case TemplateFieldType.TEXT: return value.trim() 504 555 case TemplateFieldType.LONG: return (long) Double.valueOf(value) 505 //case TemplateFieldType.FLOAT : return Float.valueOf(value.replace(",","."));556 //case TemplateFieldType.FLOAT : return Float.valueOf(value.replace(",",".")); 506 557 case TemplateFieldType.DOUBLE: return Double.valueOf(value.replace(",", ".")); 507 558 case TemplateFieldType.STRINGLIST: return value.trim() … … 520 571 521 572 dotProduct(l_histo, r_histo) / 522 Math.sqrt(dotProduct(l_histo, l_histo) *573 Math.sqrt(dotProduct(l_histo, l_histo) * 523 574 dotProduct(r_histo, r_histo)) 524 575 } … … 546 597 547 598 similarity(l_str.toString().toLowerCase().toCharArray(), 548 r_str.toString().toLowerCase().toCharArray(),549 degree)599 r_str.toString().toLowerCase().toCharArray(), 600 degree) 550 601 } 551 602 -
trunk/web-app/css/buttons.css
r1548 r1553 24 24 } 25 25 26 .options a.save { 27 background-image: url(../plugins/famfamfam-1.0.1/images/icons/page_save.png); 28 } 29 .options a.skip { 30 background-image: url(../plugins/famfamfam-1.0.1/images/icons/control_end_blue.png); 31 } 32 .options a.view { 33 background-image: url(../plugins/famfamfam-1.0.1/images/icons/application_form_magnify.png); 34 } 35 .options a.restart { 36 background-image: url(../plugins/famfamfam-1.0.1/images/icons/arrow_redo.png); 37 } 38 .options a.edit { 39 background-image: url(../plugins/famfamfam-1.0.1/images/icons/application_form_edit.png); 40 } 41 26 42 .options a.performAction { 27 43 background-image: url(../plugins/famfamfam-1.0.1/images/icons/brick_go.png); -
trunk/web-app/js/studywizard.js
r1508 r1553 148 148 function handleWizardTable() { 149 149 var that = this; 150 var wizardTables = $( ".ajaxFlow").find('div.tableEditor');150 var wizardTables = $('div.tableEditor'); 151 151 152 152 wizardTables.each(function() {
Note: See TracChangeset
for help on using the changeset viewer.