Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/exporter/laf/LafExporter.java @ 1028:1c41c7b8f7c2 schema-update
Updated server application to new database model. THIS IS STILL WIP!!!
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 08 Jul 2016 15:32:36 +0200 |
parents | 9e733f44d8b0 |
children |
rev | line source |
---|---|
626
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
2 * Software engineering by Intevation GmbH |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
3 * |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
7 */ |
609
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.lada.exporter.laf; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import java.io.ByteArrayInputStream; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import java.io.IOException; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import java.io.InputStream; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.List; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import javax.inject.Inject; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.lada.exporter.ExportConfig; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.lada.exporter.ExportFormat; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.lada.exporter.Exporter; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.lada.util.auth.UserInfo; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 /** |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 * The LAF exporter implements {@link Exporter} to produce a LAF file. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 * |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 */ |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 @ExportConfig(format=ExportFormat.LAF) |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 public class LafExporter |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 implements Exporter |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 { |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 |
626
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
32 /** |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
33 * The creator used to generate content. |
9e733f44d8b0
Code style and comments.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
609
diff
changeset
|
34 */ |
609
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 @Inject |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 private LafCreator creator; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 /** |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 * Export the {@link LProbe} objects. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 * |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 * @param proben List of probe ids. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 * @param auth The authentication information. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 * @return InputStream with the LAF data. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 */ |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 @Override |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 public InputStream export( |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 List<Integer> proben, |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 UserInfo userInfo |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 ) { |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 String laf = ""; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 for (Integer probeId: proben) { |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 laf += creator.create(probeId.toString()); |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 } |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 laf += "%ENDE%"; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 InputStream in = new ByteArrayInputStream(laf.getBytes()); |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 try { |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 in.close(); |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 } |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 catch (IOException e) { |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 //TODO Exception handling. |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 } |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 return in; |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 } |
093bfdcdb09c
Added exporter impl. for laf file format.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 } |