source: trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy @ 169

Last change on this file since 169 was 169, checked in by tabma, 9 years ago
  • created taglibrary for importer and first implementation detection of (cell) datatypes
  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 1.3 KB
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: 169 $
17 * $Author: tabma $
18 * $Date: 2010-02-03 14:50:14 +0000 (wo, 03 feb 2010) $
19 */
20
21package dbnp.importer
22import org.apache.poi.hssf.usermodel.HSSFCell
23import org.apache.poi.ss.usermodel.DataFormatter
24
25class ImporterController {
26    def ImporterService
27
28    def index = { }
29
30    /**
31    * This method will move the uploaded file to a temporary path and send the header
32    * and the first n rows to the preview
33    */
34    def upload = {
35        def downloadedfile = request.getFile('importfile');
36        def tempfile = new File("/tmp/" + System.currentTimeMillis() + ".nmcdsp")
37
38        downloadedfile.transferTo(tempfile)
39       
40        def wb = ImporterService.getWorkbook(new FileInputStream(tempfile))
41       
42        def header = ImporterService.getHeader(wb, 0)
43        def datamatrix= ImporterService.getDatamatrix(wb, 0, 5)
44
45        render (view:"step1", model:[header:header, datamatrix:datamatrix])
46
47    }
48}
Note: See TracBrowser for help on using the repository browser.