Changeset 328
- Timestamp:
- Apr 7, 2010, 11:24:56 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r321 r328 56 56 def datamatrix= ImporterService.getDatamatrix(wb, 0, 5) 57 57 58 session. header = header59 session.import template_id = params.template_id60 session. workbook = wb58 session.importer_header = header 59 session.importer_template_id = params.template_id 60 session.importer_workbook = wb 61 61 62 62 render (view:"step1", model:[header:header, datamatrix:datamatrix]) … … 77 77 def entities = request.getParameterValues("entity") 78 78 def templatefieldtypes = request.getParameterValues("templatefieldtype") 79 def identifiercolumnindex = params.identifier.toInteger()79 def identifiercolumnindex = (params.identifier!=null) ? params.identifier.toInteger() : -1 80 80 81 81 templatefieldtypes.each { t -> … … 102 102 default: break 103 103 } 104 session. header[columnindex].templatefieldtype = tft104 session.importer_header[columnindex].templatefieldtype = tft 105 105 } 106 106 … … 125 125 } 126 126 127 session. header[columnindex].identifier = (columnindex == identifiercolumnindex) ? true : false128 session. header[columnindex].index = columnindex129 session. header[columnindex].entity = clazz127 session.importer_header[columnindex].identifier = (columnindex == identifiercolumnindex) ? true : false 128 session.importer_header[columnindex].index = columnindex 129 session.importer_header[columnindex].entity = clazz 130 130 } 131 131 … … 133 133 // TODO: show template fields per entity 134 134 135 def templates = Template.get(session.import template_id)135 def templates = Template.get(session.importer_template_id) 136 136 137 render(view:"step2", model:[entities:entities, header:session. header, templates:templates])137 render(view:"step2", model:[entities:entities, header:session.importer_header, templates:templates]) 138 138 } 139 139 … … 143 143 */ 144 144 def saveproperties = { 145 def columnproperties = request.getParameterValues("columnproperty") 145 def columnproperties = request.getParameterValues("columnproperty") 146 session.importer_study = Study.get(params.study.id.toInteger()) 146 147 147 148 columnproperties.each { cp -> 148 149 def columnindex = cp.split(":")[0].toInteger() 149 150 def property_id = cp.split(":")[1].toInteger() 150 session. header[columnindex].property = TemplateField.get(property_id)151 session.importer_header[columnindex].property = TemplateField.get(property_id) 151 152 } 152 153 153 154 //import workbook 154 session.importe ddata = ImporterService.importdata(session.importtemplate_id, session.workbook, 0, 1, session.header)155 session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header) 155 156 156 render(view:"step3", model:[datamatrix:session.importe ddata])157 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 157 158 } 158 159 159 160 def savepostview = { 160 ImporterService.savedata(session.importe ddata)161 ImporterService.savedata(session.importer_study, session.importer_importeddata) 161 162 render(view:"step4") 162 163 } -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r322 r328 200 200 201 201 /** 202 * @param datamatrix two dimensional array containing entities with values read from Excel file 202 * Method to store a matrix containing the entities in a record like structure. Every row in the table 203 * contains one or more entity objects (which contain fields with values). So actually a row represents 204 * a record with fields from one or more different entities. 205 * 206 * @param study entity Study 207 * @param datamatrix two dimensional array containing entities with values read from Excel file * 203 208 */ 204 def savedata(datamatrix) { 209 def savedata(Study study, datamatrix) { 210 study.refresh() 211 205 212 datamatrix.each { record -> 206 213 record.each { entity -> … … 210 217 break 211 218 case Subject : print "Persisting Subject `" + entity.name + "`: " 212 persistEntity(entity) 219 persistEntity(entity) 220 study.addToSubjects(entity) 213 221 break 214 222 case Event : print "Persisting Event `" + entity.eventdescription + "`: " … … 225 233 } 226 234 } 227 } 235 } 228 236 } 229 237 … … 234 242 * 235 243 */ 236 def persistEntity(entity) { 237 println entity.dump() 238 if (entity.save(flush:true)) { //.merge? 239 println "OK" 244 def persistEntity(entity) { 245 if (entity.save(flush:true)) { //.merge? 240 246 } else entity.errors.allErrors.each { 241 247 println it -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r321 r328 84 84 // and session variables should not be used inside the service, migrate to controller 85 85 86 def t = Template.get(session.import template_id)86 def t = Template.get(session.importer_template_id) 87 87 def mc = attrs['mappingcolumn'] 88 88 -
trunk/grails-app/views/importer/common/_properties.gsp
r312 r328 14 14 %> 15 15 <g:form name="propertiesform" action="saveproperties"> 16 <p><g:select name="study.id" from="${dbnp.studycapturing.Study.list()}" optionKey="id" class="selectsmall"/></p> 16 17 <table> 17 18 <g:each var="stdentity" in ="${standardentities}"> -
trunk/grails-app/views/importer/step2.gsp
r319 r328 24 24 </head> 25 25 <body> 26 <h1>Step 2: import wizard entities/properties</h1> 27 <p> Please choose the study you want to add the data to.</p>28 <p>Below you see the entities and columns, assign properties to the columns.</p>26 <h1>Step 2: import wizard entities/properties</h1> 27 <p>First select the study you want to add the data to. The next step is to assign properties to the columns. Below you see the entities and columns, please make your 28 selections.</p> 29 29 <importer:properties entities="${entities}" header="${header}" templates="${templates}"/> 30 30 </body> -
trunk/grails-app/views/importer/step3.gsp
r299 r328 24 24 <body> 25 25 <h1>Step 3: import wizard imported data postview</h1> 26 <p> Below you see how all data was imported.</p>27 <importer:postview datamatrix="${datamatrix}"/>26 <p>A total of ${datamatrix.size()} rows were imported, below an overview of the rows is shown.</span> 27 <importer:postview datamatrix="${datamatrix}"/> 28 28 </body> 29 29 </html> -
trunk/web-app/css/importer.css
r322 r328 5 5 border-color: red; 6 6 background-color: #DDDDDD; 7 } 8 9 .selectsmall { 10 font-size: 10px; 7 11 } 8 12
Note: See TracChangeset
for help on using the changeset viewer.