KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > process > ReportColumnSet_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 Column Set at the end of the Column Set
23  *
24  * @author Jorg Janke
25  * @version $Id: ReportColumnSet_Copy.java,v 1.6 2003/08/04 03:54:46 jjanke Exp $
26  */

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

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

37     /** Source Line Set */
38     private int m_PA_ReportColumnSet_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_ReportColumnSet_ID"))
52                 m_PA_ReportColumnSet_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_ReportColumnSet_ID=" + m_PA_ReportColumnSet_ID + ", To=" + to_ID);
67         if (to_ID < 1)
68             throw new Exception JavaDoc(MSG_SaveErrorRowNotFound);
69         //
70
MReportColumnSet to = new MReportColumnSet(getCtx(), to_ID);
71         MReportColumnSet rcSet = new MReportColumnSet(getCtx(), m_PA_ReportColumnSet_ID);
72         MReportColumn[] rcs = rcSet.getColumns();
73         for (int i = 0; i < rcs.length; i++)
74         {
75             MReportColumn rc = MReportColumn.copy (getCtx(), to.getAD_Client_ID(), to.getAD_Org_ID(), to_ID, rcs[i]);
76             rc.save();
77         }
78         return "@Copied@=" + rcs.length;
79     } // doIt
80

81 } // ReportColumnSet_Copy
82
Popular Tags