1 package ch.ige.edossier.transfer.server.dao;
2
3 import java.sql.*;
4 import ch.ige.edossier.transfer.vo.BfakturVO;
5 import ch.ige.edossier.util.DBHelper;
6
7
15 public class BfakturDAO
16 {
17
18
19
28 public BfakturVO select( int schutitKey, int ereigIdat, String artNr ) throws SQLException
29 {
30 String query = null;
31 BfakturVO bfakturVO = null;
32 Connection con = null;
33 PreparedStatement ps = null;
34 ResultSet rs = null;
35
36 try
37 {
38 query = "SELECT a.bfakt_id, b.text_long, c.inhaber, c.var_text, c.bfakt_dat " +
39 "FROM bfaktpos a, bfaktxt b, bfaktur c " +
40 "WHERE a.schutit_key=? AND a.ereig_idat=? AND a.art_nr=? AND a.text_nr = b.text_nr AND a.bfakt_id = c.bfakt_id";
41
42 con = DBHelper.getInstance().getConnection();
43 ps = con.prepareStatement( query );
44 ps.setInt( 1, schutitKey );
45 ps.setInt( 2, ereigIdat );
46 ps.setString( 3, artNr );
47
48 rs = ps.executeQuery();
49
50 if( rs.next() )
51 {
52 bfakturVO = new BfakturVO();
53 bfakturVO.bfaktId = rs.getInt( "bfakt_id" );
54 bfakturVO.textLong = rs.getString( "text_long" );
55 bfakturVO.inhaber = rs.getString( "inhaber" );
56 bfakturVO.varText = rs.getString( "var_text" );
57 bfakturVO.bfaktDat = rs.getDate( "bfakt_dat" );
58 }
59 }
60 finally
61 {
62 DBHelper.getInstance().close( con, ps );
63 }
64 return bfakturVO;
65 }
66
67
73 public String selectTitel( int bfaktId ) throws SQLException
74 {
75 String query = null;
76 String titel = null;
77 Connection con = null;
78 PreparedStatement ps = null;
79 ResultSet rs = null;
80
81 try
82 {
83 query = "SELECT b.text " +
84 "FROM bfaktur a, bformtxt_druck b " +
85 "WHERE a.bfakt_id=? AND a.formart_cd = b.formart_cd AND b.textart = 1 AND b.sprach_cd = a.sprach_cd";
86
87 con = DBHelper.getInstance().getConnection();
88 ps = con.prepareStatement( query );
89 ps.setInt( 1, bfaktId );
90
91 rs = ps.executeQuery();
92
93 if( rs.next() )
94 {
95 titel = rs.getString( "text" );
96 }
97 }
98 finally
99 {
100 DBHelper.getInstance().close( con, ps );
101 }
102 return titel;
103 }
104
105
111 public byte[] selectPdf( int bfaktId ) throws SQLException
112 {
113 String query = null;
114 Connection con = null;
115 PreparedStatement ps = null;
116 ResultSet rs = null;
117 byte[] printJobFile = null;
118 Blob myBlob = null;
119
120 try
121 {
122 query = "SELECT printjob_file " +
123 "FROM printjob " +
124 "WHERE report_id = ? AND typ = 'Letter' AND schacht_id = 1";
125
126 con = DBHelper.getInstance().getJippsConnection();
127 ps = con.prepareStatement( query );
128 ps.setInt( 1, bfaktId );
129
130 rs = ps.executeQuery();
131
132 if( rs.next() )
133 {
134 myBlob = ( java.sql.Blob )rs.getBlob( "printjob_file" );
136 printJobFile = myBlob.getBytes( new Long( "1" ).longValue(),
137 new Long( myBlob.length() ).intValue() );
138 }
139 }
140 finally
141 {
142 DBHelper.getInstance().close( con, ps );
143 }
144 return printJobFile;
145 }
146 }
147