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