root/trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy @ 147

Revision 147, 1.2 KB (checked in by tabma, 4 years ago)

- basic skeleton for the importer/previewer

  • Property svn:keywords set to Date Author Rev
Line 
1/**
2 * Importer controller
3 *
4 * The importer controller handles the uploading of tabular, comma delimited and Excel format
5 * based files. When uploaded a preview is shown of the data and the user can adjust the column
6 * type. Data in cells which don't correspond to the specified column type will be represented as "#error".
7 *
8 * The importer controller catches the actions and consecutively performs the
9 * logic behind it.
10 *
11 * @package     importer
12 * @author      t.w.abma@umcutrecht.nl
13 * @since       20100126
14 *
15 * Revision information:
16 * $Rev$
17 * $Author$
18 * $Date$
19 */
20
21package dbnp.importer
22
23class ImporterController {
24    def ImporterService
25
26    def index = { }
27
28    /**
29    * This method will move the uploaded file to a temporary path and send the header
30    * and the first n rows to the preview
31    */
32    def upload = {
33        def downloadedfile = request.getFile('importfile');
34        def tempfile = new File("/tmp/" + System.currentTimeMillis() + ".nmcdsp")
35
36        downloadedfile.transferTo(tempfile)
37       
38        def wb = ImporterService.getWorkbook(new FileInputStream(tempfile))
39       
40        def header = ImporterService.getHeader(wb)
41        render (view:"preview", model:[header:header])
42    }
43}
Note: See TracBrowser for help on using the browser.