KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > process > ImportReportLine


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.process;
15
16 import java.sql.*;
17 import java.math.*;
18
19 import org.compiere.util.*;
20
21 /**
22  * Import ReportLines from I_ReportLine
23  *
24  * @author Jorg Janke
25  * @version $Id: ImportReportLine.java,v 1.10 2003/11/06 07:08:06 jjanke Exp $
26  */

27 public class ImportReportLine extends SvrProcess
28 {
29     /**
30      * Import ReportLine Constructor
31      */

32     public ImportReportLine()
33     {
34         super();
35         Log.trace(Log.l1_User, "ImportReportLine");
36     } // ImportReportLine
37

38     /** Client to be imported to */
39     private int m_AD_Client_ID = 0;
40     /** Default Report Line Set */
41     private int m_PA_ReportLineSet_ID = 0;
42     /** Delete old Imported */
43     private boolean m_deleteOldImported = false;
44
45     /** Organization to be imported to */
46     private int m_AD_Org_ID = 0;
47     /** Effective */
48     private Timestamp m_DateValue = null;
49
50     /**
51      * Prepare - e.g., get Parameters.
52      */

53     protected void prepare()
54     {
55         ProcessInfoParameter[] para = getParameter();
56         for (int i = 0; i < para.length; i++)
57         {
58             String JavaDoc name = para[i].getParameterName();
59             if (para[i].getParameter() == null)
60                 ;
61             else if (name.equals("AD_Client_ID"))
62                 m_AD_Client_ID = ((BigDecimal)para[i].getParameter()).intValue();
63             else if (name.equals("PA_ReportLineSet_ID"))
64                 m_PA_ReportLineSet_ID = ((BigDecimal)para[i].getParameter()).intValue();
65             else if (name.equals("DeleteOldImported"))
66                 m_deleteOldImported = "Y".equals(para[i].getParameter());
67             else
68                 Log.error("ImportReportLine.prepare - Unknown Parameter: " + name);
69         }
70         if (m_DateValue == null)
71             m_DateValue = new Timestamp (System.currentTimeMillis());
72     } // prepare
73

74
75     /**
76      * Perrform process.
77      * @return Message
78      * @throws Exception
79      */

80     protected String JavaDoc doIt() throws java.lang.Exception JavaDoc
81     {
82         StringBuffer JavaDoc sql = null;
83         int no = 0;
84         String JavaDoc clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID;
85
86         // **** Prepare ****
87

88         // Delete Old Imported
89
if (m_deleteOldImported)
90         {
91             sql = new StringBuffer JavaDoc ("DELETE I_ReportLine "
92                 + "WHERE I_IsImported='Y'").append(clientCheck);
93             no = DB.executeUpdate(sql.toString());
94             Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Delete Old Impored =" + no);
95         }
96
97         // Set Client, Org, IsActive, Created/Updated
98
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
99             + "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),"
100             + " AD_Org_ID = COALESCE (AD_Org_ID, 0),"
101             + " IsActive = COALESCE (IsActive, 'Y'),"
102             + " Created = COALESCE (Created, SysDate),"
103             + " CreatedBy = COALESCE (CreatedBy, 0),"
104             + " Updated = COALESCE (Updated, SysDate),"
105             + " UpdatedBy = COALESCE (UpdatedBy, 0),"
106             + " I_ErrorMsg = NULL,"
107             + " I_IsImported = 'N' "
108             + "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
109         no = DB.executeUpdate(sql.toString());
110         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Reset=" + no);
111
112         // ReportLineSetName (Default)
113
if (m_PA_ReportLineSet_ID != 0)
114         {
115             sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
116                 + "SET ReportLineSetName=(SELECT Name FROM PA_ReportLineSet r"
117                 + " WHERE PA_ReportLineSet_ID=").append(m_PA_ReportLineSet_ID).append(" AND i.AD_Client_ID=r.AD_Client_ID) "
118                 + "WHERE ReportLineSetName IS NULL AND PA_ReportLineSet_ID IS NULL"
119                 + " AND I_IsImported<>'Y'").append(clientCheck);
120             no = DB.executeUpdate(sql.toString());
121             Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set ReportLineSetName Default=" + no);
122         }
123         // Set PA_ReportLineSet_ID
124
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
125             + "SET PA_ReportLineSet_ID=(SELECT PA_ReportLineSet_ID FROM PA_ReportLineSet r"
126             + " WHERE i.ReportLineSetName=r.Name AND i.AD_Client_ID=r.AD_Client_ID) "
127             + "WHERE PA_ReportLineSet_ID IS NULL"
128             + " AND I_IsImported<>'Y'").append(clientCheck);
129         no = DB.executeUpdate(sql.toString());
130         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set PA_ReportLineSet_ID=" + no);
131         //
132
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
133             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ReportLineSet, ' "
134             + "WHERE PA_ReportLineSet_ID IS NULL"
135             + " AND I_IsImported<>'Y'").append(clientCheck);
136         no = DB.executeUpdate(sql.toString());
137         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid ReportLineSet=" + no);
138
139         // Ignore if there is no Report Line Name or ID
140
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
141             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'Ignored=NoLineName, ' "
142             + "WHERE PA_ReportLine_ID IS NULL AND Name IS NULL"
143             + " AND I_IsImported<>'Y'").append(clientCheck);
144         no = DB.executeUpdate(sql.toString());
145         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid ReportLineSet=" + no);
146
147         // Validate ElementValue
148
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
149             + "SET C_ElementValue_ID=(SELECT C_ElementValue_ID FROM C_ElementValue e"
150             + " WHERE i.ElementValue=e.Value AND i.AD_Client_ID=e.AD_Client_ID) "
151             + "WHERE C_ElementValue_ID IS NULL AND ElementValue IS NOT NULL"
152             + " AND I_IsImported<>'Y'").append(clientCheck);
153         no = DB.executeUpdate(sql.toString());
154         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set C_ElementValue_ID=" + no);
155         // Validate C_ElementValue_ID
156
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
157             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ElementValue, ' "
158             + "WHERE C_ElementValue_ID IS NULL AND CalculationType<>'C'"
159             + " AND I_IsImported<>'Y'").append(clientCheck);
160         no = DB.executeUpdate(sql.toString());
161         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid AccountType=" + no);
162
163         // Set SeqNo
164
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
165             + "SET SeqNo=I_ReportLine_ID "
166             + "WHERE SeqNo IS NULL"
167             + " AND I_IsImported='N'").append(clientCheck);
168         no = DB.executeUpdate(sql.toString());
169         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set SeqNo Default=" + no);
170
171         // Copy/Sync from first Row of Line
172
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
173             + "SET (Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PostingType)="
174             + " (SELECT Description, SeqNo, IsSummary, IsPrinted, LineType, CalculationType, AmountType, PostingType"
175             + " FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID"
176             + " AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
177             + " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) "
178             + "WHERE EXISTS (SELECT *"
179             + " FROM I_ReportLine ii WHERE i.Name=ii.Name AND i.PA_ReportLineSet_ID=ii.PA_ReportLineSet_ID"
180             + " AND ii.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
181             + " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID))"
182             + " AND I_IsImported='N'").append(clientCheck); // not if previous error
183
no = DB.executeUpdate(sql.toString());
184         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Sync from first Row of Line=" + no);
185
186         // Validate IsSummary - (N) Y
187
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
188             + "SET IsSummary='N' "
189             + "WHERE IsSummary IS NULL OR IsSummary NOT IN ('Y','N')"
190             + " AND I_IsImported<>'Y'").append(clientCheck);
191         no = DB.executeUpdate(sql.toString());
192         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set IsSummary Default=" + no);
193
194         // Validate IsPrinted - (Y) N
195
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
196             + "SET IsPrinted='Y' "
197             + "WHERE IsPrinted IS NULL OR IsPrinted NOT IN ('Y','N')"
198             + " AND I_IsImported<>'Y'").append(clientCheck);
199         no = DB.executeUpdate(sql.toString());
200         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set IsPrinted Default=" + no);
201
202         // Validate Line Type - (S) C
203
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
204             + "SET LineType='S' "
205             + "WHERE LineType IS NULL OR LineType NOT IN ('S','C')"
206             + " AND I_IsImported<>'Y'").append(clientCheck);
207         no = DB.executeUpdate(sql.toString());
208         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set LineType Default=" + no);
209
210         // Validate Optional Calculation Type - A P R S
211
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
212             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' "
213             + "WHERE CalculationType IS NOT NULL AND CalculationType NOT IN ('A','P','R','S')"
214             + " AND I_IsImported<>'Y'").append(clientCheck);
215         no = DB.executeUpdate(sql.toString());
216         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid CalculationType=" + no);
217
218         // Validate Optional Amount Type -
219
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
220             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' "
221             + "WHERE AmountType IS NOT NULL AND UPPER(AmountType) NOT IN ('BP','CP','DP','QP', 'BY','CY','DY','QY', 'BT','CT','DT','QT')"
222             + " AND I_IsImported<>'Y'").append(clientCheck);
223         no = DB.executeUpdate(sql.toString());
224         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid AmountType=" + no);
225
226         // Validate Optional Posting Type - A B E S
227
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
228             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid CalculationType, ' "
229             + "WHERE PostingType IS NOT NULL AND PostingType NOT IN ('A','B','E','S')"
230             + " AND I_IsImported<>'Y'").append(clientCheck);
231         no = DB.executeUpdate(sql.toString());
232         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Invalid PostingType=" + no);
233
234         // Set PA_ReportLine_ID
235
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
236             + "SET PA_ReportLine_ID=(SELECT PA_ReportLine_ID FROM PA_ReportLine r"
237             + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID AND ROWNUM=1) "
238             + "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL"
239             + " AND I_IsImported='N'").append(clientCheck);
240         no = DB.executeUpdate(sql.toString());
241         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set PA_ReportLine_ID=" + no);
242
243         // -------------------------------------------------------------------
244
int noInsertLine = 0;
245         int noUpdateLine = 0;
246         Connection conn = DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED);
247
248         // **** Create Missing ReportLines
249
sql = new StringBuffer JavaDoc ("SELECT DISTINCT PA_ReportLineSet_ID, Name "
250             + "FROM I_ReportLine "
251             + "WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL"
252             + " AND I_IsImported='N'").append(clientCheck);
253         try
254         {
255             // Insert ReportLine
256
PreparedStatement pstmt_insertLine = conn.prepareStatement
257                 ("INSERT INTO PA_ReportLine "
258                 + "(PA_ReportLine_ID,PA_ReportLineSet_ID,"
259                 + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
260                 + "Name,SeqNo,IsPrinted,IsSummary,LineType)"
261                 + "SELECT ?,PA_ReportLineSet_ID,"
262                 + "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,"
263                 + "Name,SeqNo,IsPrinted,IsSummary,LineType "
264                 + "FROM I_ReportLine "
265                 + "WHERE PA_ReportLineSet_ID=? AND Name=? AND ROWNUM=1" // #2..3
266
+ clientCheck);
267
268             PreparedStatement pstmt = DB.prepareStatement(sql.toString());
269             ResultSet rs = pstmt.executeQuery();
270             while (rs.next())
271             {
272                 int PA_ReportLineSet_ID = rs.getInt(1);
273                 String JavaDoc Name = rs.getString(2);
274                 //
275
int PA_ReportLine_ID = DB.getKeyNextNo(m_AD_Client_ID, "PA_ReportLine");
276                 pstmt_insertLine.setInt(1, PA_ReportLine_ID);
277                 pstmt_insertLine.setInt(2, PA_ReportLineSet_ID);
278                 pstmt_insertLine.setString(3, Name);
279                 try
280                 {
281                     no = pstmt_insertLine.executeUpdate();
282                     Log.trace(10, "Insert ReportLine = " + no + ", PA_ReportLine_ID=" + PA_ReportLine_ID);
283                     noInsertLine++;
284                 }
285                 catch (SQLException ex)
286                 {
287                     Log.trace(10, "Insert ReportLine - " + ex.toString());
288                     continue;
289                 }
290             }
291             rs.close();
292             pstmt.close();
293             //
294
pstmt_insertLine.close();
295         }
296         catch (SQLException e)
297         {
298             Log.error("ImportReportLine - Create ReportLine", e);
299         }
300
301         // Set PA_ReportLine_ID (for newly created)
302
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
303             + "SET PA_ReportLine_ID=(SELECT PA_ReportLine_ID FROM PA_ReportLine r"
304             + " WHERE i.Name=r.Name AND i.PA_ReportLineSet_ID=r.PA_ReportLineSet_ID AND ROWNUM=1) "
305             + "WHERE PA_ReportLine_ID IS NULL AND PA_ReportLineSet_ID IS NOT NULL"
306             + " AND I_IsImported='N'").append(clientCheck);
307         no = DB.executeUpdate(sql.toString());
308         Log.trace(Log.l5_DData, "ImportReportLine.doIt", "Set PA_ReportLine_ID=" + no);
309
310         // **** Update ReportLine
311
sql = new StringBuffer JavaDoc ("UPDATE PA_ReportLine r "
312             + "SET (Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PostingType,Updated,UpdatedBy)="
313             + " (SELECT Description,SeqNo,IsSummary,IsPrinted,LineType,CalculationType,AmountType,PostingType,SysDate,UpdatedBy"
314             + " FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID"
315             + " AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
316             + " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID)) "
317             + "WHERE EXISTS (SELECT *"
318             + " FROM I_ReportLine i WHERE r.Name=i.Name AND r.PA_ReportLineSet_ID=i.PA_ReportLineSet_ID"
319             + " AND i.I_ReportLine_ID=(SELECT MIN(I_ReportLine_ID) FROM I_ReportLine iii"
320             + " WHERE i.Name=iii.Name AND i.PA_ReportLineSet_ID=iii.PA_ReportLineSet_ID AND i.I_IsImported='N'))")
321             .append(clientCheck);
322         noUpdateLine = DB.executeUpdate(sql.toString());
323         Log.trace(Log.l3_Util, "ImportReportLine.doIt", "Update PA_ReportLine=" + noUpdateLine);
324
325
326         // -------------------------------------------------------------------
327
int noInsertSource = 0;
328         int noUpdateSource = 0;
329
330         // **** Create ReportSource
331
sql = new StringBuffer JavaDoc ("SELECT I_ReportLine_ID, PA_ReportSource_ID "
332             + "FROM I_ReportLine "
333             + "WHERE PA_ReportLine_ID IS NOT NULL"
334             + " AND I_IsImported='N'").append(clientCheck);
335         try
336         {
337             // Insert ReportSource
338
PreparedStatement pstmt_insertSource = conn.prepareStatement
339                 ("INSERT INTO PA_ReportSource "
340                 + "(PA_ReportSource_ID,"
341                 + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
342                 + "PA_ReportLine_ID,ElementType,C_ElementValue_ID) "
343                 + "SELECT ?,"
344                 + "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,"
345                 + "PA_ReportLine_ID,'AC',C_ElementValue_ID "
346                 + "FROM I_ReportLine "
347                 + "WHERE I_ReportLine_ID=?"
348                 + " AND I_IsImported='N'"
349                 + clientCheck);
350
351             // Update ReportSource
352
PreparedStatement pstmt_updateSource = conn.prepareStatement
353                 ("UPDATE PA_ReportSource "
354                 + "SET (ElementType,C_ElementValue_ID,Updated,UpdatedBy)="
355                 + " (SELECT 'AC',C_ElementValue_ID,SysDate,UpdatedBy"
356                 + " FROM I_ReportLine"
357                 + " WHERE I_ReportLine_ID=?) "
358                 + "WHERE PA_ReportSource_ID=?"
359                 + clientCheck);
360
361             // Set Imported = Y
362
PreparedStatement pstmt_setImported = conn.prepareStatement
363                 ("UPDATE I_ReportLine SET I_IsImported='Y',"
364                 + " PA_ReportSource_ID=?, "
365                 + " Updated=SysDate, Processed='Y' WHERE I_ReportLine_ID=?");
366
367             PreparedStatement pstmt = DB.prepareStatement(sql.toString());
368             ResultSet rs = pstmt.executeQuery();
369             while (rs.next())
370             {
371                 int I_ReportLine_ID = rs.getInt(1);
372                 int PA_ReportSource_ID = rs.getInt(2);
373                 //
374
if (PA_ReportSource_ID == 0) // New ReportSource
375
{
376                     PA_ReportSource_ID = DB.getKeyNextNo(m_AD_Client_ID, "PA_ReportSource");
377                     pstmt_insertSource.setInt(1, PA_ReportSource_ID);
378                     pstmt_insertSource.setInt(2, I_ReportLine_ID);
379                     try
380                     {
381                         no = pstmt_insertSource.executeUpdate();
382                         Log.trace(10, "Insert ReportSource = " + no + ", I_ReportLine_ID=" + I_ReportLine_ID + ", PA_ReportSource_ID=" + PA_ReportSource_ID);
383                         noInsertSource++;
384                     }
385                     catch (SQLException ex)
386                     {
387                         Log.trace(10, "Insert ReportSource - " + ex.toString());
388                         sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
389                             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert ElementSource: " + ex.toString()))
390                             .append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
391                         DB.executeUpdate(sql.toString());
392                         continue;
393                     }
394                 }
395                 else // update Report Source
396
{
397                     pstmt_updateSource.setInt(1, I_ReportLine_ID);
398                     pstmt_updateSource.setInt(2, PA_ReportSource_ID);
399                     try
400                     {
401                         no = pstmt_updateSource.executeUpdate();
402                         Log.trace(10, "Update ReportSource = " + no + ", I_ReportLine_ID=" + I_ReportLine_ID + ", PA_ReportSource_ID=" + PA_ReportSource_ID);
403                         noUpdateSource++;
404                     }
405                     catch (SQLException ex)
406                     {
407                         Log.trace(10, "Update ReportSource - " + ex.toString());
408                         sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine i "
409                             + "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Update ElementSource: " + ex.toString()))
410                             .append("WHERE I_ReportLine_ID=").append(I_ReportLine_ID);
411                         DB.executeUpdate(sql.toString());
412                         continue;
413                     }
414                 } // update source
415

416                 // Set Imported to Y
417
pstmt_setImported.setInt(1, PA_ReportSource_ID);
418                 pstmt_setImported.setInt(2, I_ReportLine_ID);
419                 no = pstmt_setImported.executeUpdate();
420                 if (no != 1)
421                     Log.error("ImportReportLine.doIt - Set Imported=" + no);
422             }
423             rs.close();
424             pstmt.close();
425             //
426
pstmt_insertSource.close();
427             pstmt_updateSource.close();
428             pstmt_setImported.close();
429             //
430
conn.close();
431             conn = null;
432         }
433         catch (SQLException e)
434         {
435             try
436             {
437                 if (conn != null)
438                     conn.close();
439                 conn = null;
440             }
441             catch (SQLException ex)
442             {
443             }
444             throw new Exception JavaDoc ("ImportReportLine.doIt", e);
445         }
446         finally
447         {
448             if (conn != null)
449                 conn.close();
450             conn = null;
451         }
452
453         // Set Error to indicator to not imported
454
sql = new StringBuffer JavaDoc ("UPDATE I_ReportLine "
455             + "SET I_IsImported='N', Updated=SysDate "
456             + "WHERE I_IsImported<>'Y'").append(clientCheck);
457         no = DB.executeUpdate(sql.toString());
458         addLog (0, null, new BigDecimal (no), "@Errors@");
459         addLog (0, null, new BigDecimal (noInsertLine), "@PA_ReportLine_ID@: @Inserted@");
460         addLog (0, null, new BigDecimal (noUpdateLine), "@PA_ReportLine_ID@: @Updated@");
461         addLog (0, null, new BigDecimal (noInsertSource), "@PA_ReportSource_ID@: @Inserted@");
462         addLog (0, null, new BigDecimal (noUpdateSource), "@PA_ReportSource_ID@: @Updated@");
463
464         return "";
465     } // doIt
466

467 } // ImportReportLine
468
Popular Tags