KickJava   Java API By Example, From Geeks To Geeks.

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


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 Smart 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.report.*;
20
21 /**
22  * Copy Line Set at the end of the Line Set
23  *
24  * @author Jorg Janke
25  * @version $Id: ReportLineSet_Copy.java,v 1.6 2003/08/04 03:54:46 jjanke Exp $
26  */

27 public class ReportLineSet_Copy extends SvrProcess
28 {
29     /**
30      * Constructor
31      */

32     public ReportLineSet_Copy()
33     {
34         super();
35     } // ReportLineSet_Copy
36

37     /** Source Line Set */
38     private int m_PA_ReportLineSet_ID = 0;
39
40     /**
41      * Prepare - e.g., get Parameters.
42      */

43     protected void prepare()
44     {
45         ProcessInfoParameter[] para = getParameter();
46         for (int i = 0; i < para.length; i++)
47         {
48             String JavaDoc name = para[i].getParameterName();
49             if (para[i].getParameter() == null)
50                 ;
51             else if (name.equals("PA_ReportLineSet_ID"))
52                 m_PA_ReportLineSet_ID = ((BigDecimal)para[i].getParameter()).intValue();
53             else
54                 log.error("prepare - Unknown Parameter: " + name);
55         }
56     } // prepare
57

58     /**
59      * Perrform process.
60      * @return Message
61      * @throws Exception
62      */

63     protected String JavaDoc doIt() throws Exception JavaDoc
64     {
65         int to_ID = super.getRecord_ID();
66         log.info("From PA_ReportLineSet_ID=" + m_PA_ReportLineSet_ID + ", To=" + to_ID);
67         if (to_ID < 1)
68             throw new Exception JavaDoc(MSG_SaveErrorRowNotFound);
69         //
70
MReportLineSet to = new MReportLineSet(getCtx(), to_ID);
71         MReportLineSet rlSet = new MReportLineSet(getCtx(), m_PA_ReportLineSet_ID);
72         MReportLine[] rls = rlSet.getLiness();
73         for (int i = 0; i < rls.length; i++)
74         {
75             MReportLine rl = MReportLine.copy (getCtx(), to.getAD_Client_ID(), to.getAD_Org_ID(), to_ID, rls[i]);
76             rl.save();
77             MReportSource[] rss = rls[i].getSources();
78             if (rss != null)
79             {
80                 for (int ii = 0; ii < rss.length; ii++)
81                 {
82                     MReportSource rs = MReportSource.copy (getCtx(), to.getAD_Client_ID(), to.getAD_Org_ID(), rl.getID(), rss[ii]);
83                     rs.save();
84                 }
85             }
86         }
87         return "@Copied@=" + rls.length;
88     } // doIt
89

90 } // ReportLineSet_Copy
91
Popular Tags