Changeset 632
- Timestamp:
- Jul 1, 2010, 12:31:49 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r545 r632 41 41 } 42 42 43 def simple wizard = {43 def simpleWizard = { 44 44 render(view:"index_simple", model:[studies:Study.list(), entities: grailsApplication.config.gscf.domain.importableEntities]) 45 45 } 46 46 47 def advanced wizard = {47 def advancedWizard = { 48 48 render(view:"index_advanced", model:[templates:Template.list()]) 49 49 } … … 62 62 session.importer_template_id = params.template_id 63 63 session.importer_workbook = wb 64 65 66 64 67 65 render (view:"step1_advanced", model:[header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5)]) … … 90 88 } 91 89 92 //import workbook93 //session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header)94 95 //println "DAS" + session.importer_header96 97 //render(view:"step2_simple", model:[datamatrix:session.importer_importeddata])98 90 def templates = Template.get(session.importer_template_id) 99 91 100 render(view:"step2_simple", model:[entities: selectedentities, header:session.importer_header, templates:templates])92 render(view:"step2_simple", model:[entities: selectedentities, header:session.importer_header, datamatrix:ImporterService.getDatamatrix(wb, 0, 5), templates:templates]) 101 93 } 102 94 … … 118 110 119 111 /** 112 * @param entity entity class we are using (dbnp.studycapturing.Subject etc.) 113 */ 114 115 def saveMissingProperties = { 116 println params.entity 117 118 session.importer_importeddata.each { table -> 119 table.each { entity -> 120 entity.giveFields().each { field -> 121 print ":" + params["entity_" + entity.hashCode() + "_" + field.escapedName()] 122 entity.setFieldValue (field.toString(), params["entity_" + entity.hashCode() + "_" + field.escapedName()]) 123 } 124 } 125 } 126 127 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 128 //render("Succesful") 129 } 130 131 /** 120 132 * User has assigned all entities and templatefieldtypes to the columns and continues to the next step (assigning properties to columns) 121 133 * All information of the columns is stored in a session as MappingColumn object … … 127 139 * @see celltype: http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html 128 140 */ 129 def save preview = {141 def savePreview = { 130 142 def tft = null 131 143 def identifiercolumnindex = (params.identifier!=null) ? params.identifier.toInteger() : -1 … … 198 210 * 199 211 */ 200 def save properties = {212 def saveProperties = { 201 213 202 214 params.columnproperty.index.each { columnindex, property -> … … 204 216 205 217 def entityClass = Class.forName(session.importer_header[columnindex.toInteger()].entity.getName(), true, this.getClass().getClassLoader()) 206 def entityObj = entityClass.newInstance(template:template) 207 218 def entityObj = entityClass.newInstance(template:template) 208 219 209 220 session.importer_header[columnindex.toInteger()].property = property … … 218 229 session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header) 219 230 220 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 221 } 222 223 def savepostview = { 231 if (params.layout=="horizontal") 232 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata]) 233 else if (params.layout=="vertical") 234 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 235 } 236 237 def savePostview = { 224 238 ImporterService.saveDatamatrix(session.importer_study, session.importer_importeddata) 225 239 render(view:"step4") … … 234 248 def ajaxGetTemplatesByEntity = { 235 249 def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity 250 236 251 237 252 // fetch all templates for a specific entity 238 def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader())) 253 //def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader())) 254 def templates = Template.list() 255 256 println templates.dump() 239 257 240 258 // render as JSON -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r589 r632 63 63 def headercell = sheet.getRow(sheet.getFirstRowNum()).getCell(index) 64 64 def tft = TemplateFieldType.STRING //default templatefield type 65 66 65 67 66 // Check for every celltype, currently redundant code, but possibly this will be … … 295 294 def record = [] 296 295 297 def study = new Study(t itle:"New study", template:template)298 def subject = new Subject( name:"New subject", species:Term.findByName("Homo sapiens"),template:template)299 def event = new Event( eventdescription:"New event",template:template)300 def sample = new Sample( name:"New sample",template:template)296 def study = new Study(template:template) 297 def subject = new Subject(template:template) 298 def event = new Event(template:template) 299 def sample = new Sample(template:template) 301 300 302 301 for (HSSFCell cell: excelrow) { -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r545 r632 50 50 } 51 51 52 def datapreview = { attrs -> 53 def datamatrix = attrs['datamatrix'] 54 out << render (template:"common/datapreview", model:[datamatrix:datamatrix]) 55 } 56 57 /** 58 * Show missing properties 59 */ 60 def missingProperties = { attrs -> 61 def datamatrix = attrs['datamatrix'] 62 out << render (template:"common/missingproperties", model:[datamatrix:datamatrix]) 63 } 64 52 65 /** 53 66 * @param entities array containing selected entities 67 * @param header array containing mappingcolumn objects 68 * @param allfieldtypes if set, show all fields 69 * @param layout constant value: "horizontal" or "vertical" 54 70 */ 55 71 def properties = { attrs -> … … 57 73 def entities = attrs['entities'] 58 74 def allfieldtypes = (attrs['allfieldtypes']==null) ? "false" : "true" 75 def layout = (attrs['layout']==null) ? "vertical" : attrs['layout'] 76 77 //choose template for vertical layout (default) or horizontal layout 78 def template = (layout == "vertical") ? "common/properties_vertical" : "common/properties_horizontal" 59 79 60 61 out << render ( template:"common/properties", 80 out << render ( template:template, 62 81 model:[selectedentities:entities, 63 82 standardentities:grailsApplication.config.gscf.domain.importableEntities, 64 83 header:header, 65 allfieldtypes:allfieldtypes] 84 allfieldtypes:allfieldtypes, 85 layout:layout] 66 86 ) 67 87 } -
trunk/grails-app/views/importer/common/_preview.gsp
r359 r632 62 62 </tr> 63 63 </g:each> 64 64 65 <tr> 65 66 <td align="right" colspan="${datamatrix.length}"><input type="submit" value="Next"></td> -
trunk/grails-app/views/importer/common/_properties_vertical.gsp
r599 r632 13 13 */ 14 14 %> 15 <g:form name="propertiesform" action="save properties">15 <g:form name="propertiesform" action="saveProperties"> 16 16 <table> 17 17 <g:each var="stdentity" in ="${standardentities}"> … … 45 45 <tr> 46 46 <td> 47 <input type="hidden" name="layout" value="${params.layout}"> 47 48 <input type="submit" name="savebutton" value="Next"/> 48 49 </td> -
trunk/grails-app/views/importer/index.gsp
r417 r632 17 17 <ol> 18 18 <li> 19 <g:link controller="importer" action="simple wizard">Simple wizard</g:link>19 <g:link controller="importer" action="simpleWizard">Simple wizard</g:link> 20 20 </li> 21 21 <li> 22 <g:link controller="importer" action="advanced wizard">Advanced wizard</g:link>22 <g:link controller="importer" action="advancedWizard">Advanced wizard</g:link> 23 23 </li> 24 24 </ol> -
trunk/grails-app/views/importer/index_simple.gsp
r534 r632 5 5 6 6 <%@ page contentType="text/html;charset=UTF-8" %> 7 <g:setProvider library="jquery"/>8 7 9 8 <html> … … 11 10 <meta name="layout" content="main"/> 12 11 <title>Importer wizard (simple)</title> 12 13 <g:javascript library="jquery"/> 13 14 14 15 <g:javascript> -
trunk/grails-app/views/importer/step2.gsp
r496 r632 28 28 selections.</p> 29 29 30 <importer:properties entities="${entities}" header="${header}" templates="${templates}" />30 <importer:properties entities="${entities}" header="${header}" templates="${templates}" layout="vertical"/> 31 31 </body> 32 32 </html> -
trunk/grails-app/views/importer/step2_simple.gsp
r489 r632 27 27 <p>The next step is to assign properties to the columns. Below you see the columns, please assign every column to 28 28 a property.</p> 29 <importer:properties entities="${entities}" header="${header}" templates="${templates}" allfieldtypes="true"/>29 <importer:properties entities="${entities}" header="${header}" datamatrix="${datamatrix}" templates="${templates}" allfieldtypes="true" layout="horizontal"/> 30 30 </body> 31 31 </html> -
trunk/web-app/css/importer.css
r328 r632 25 25 } 26 26 27 .importer .table { 28 color:green; 29 } 30 31 .importer .tr { 32 color:red; 33 } 34 35 .importer .td { 36 color:blue; 37 }
Note: See TracChangeset
for help on using the changeset viewer.