KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > print > MPrintFormatProcess


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-2002 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.print;
15
16 import java.util.*;
17 import java.math.*;
18
19 import org.compiere.process.*;
20
21 /**
22  * MPrintFormat Process.
23  * Performs Copy existing or Create from Table
24  * Called when pressing the Copy/Create button in Window Print Format
25  *
26  * @author Jorg Janke
27  * @version $Id: MPrintFormatProcess.java,v 1.3 2003/08/04 04:01:15 jjanke Exp $
28  */

29 public class MPrintFormatProcess extends SvrProcess
30 {
31     /**
32      * Constructor
33      */

34     public MPrintFormatProcess()
35     {
36         super();
37     } // MPrintFormatProcess
38

39     /** PrintFormat */
40     private BigDecimal m_AD_PrintFormat_ID;
41     /** Table */
42     private BigDecimal m_AD_Table_ID;
43
44     /**
45      * Prepare - get Parameters.
46      */

47     protected void prepare()
48     {
49         ProcessInfoParameter[] para = getParameter();
50         for (int i = 0; i < para.length; i++)
51         {
52             String JavaDoc name = para[i].getParameterName();
53             if (para[i].getParameter() == null)
54                 ;
55             else if (name.equals("AD_PrintFormat_ID"))
56                 m_AD_PrintFormat_ID = ((BigDecimal)para[i].getParameter());
57             else if (name.equals("AD_Table_ID"))
58                 m_AD_Table_ID = ((BigDecimal)para[i].getParameter());
59             else
60                 log.equals("prepare - Unknown Parameter=" + para[i].getParameterName());
61         }
62     } // prepare
63

64     /**
65      * Perrform process.
66      * <pre>
67      * If AD_Table_ID is not null, create from table,
68      * otherwise copy from AD_PrintFormat_ID
69      * </pre>
70      * @return Message
71      * @throws Exception
72      */

73     protected String JavaDoc doIt() throws Exception JavaDoc
74     {
75         if (m_AD_Table_ID != null && m_AD_Table_ID.intValue() > 0)
76         {
77             log.info("Create from AD_Table_ID=" + m_AD_Table_ID);
78             MPrintFormat pf = MPrintFormat.createFromTable(getCtx(), m_AD_Table_ID.intValue(), getRecord_ID());
79             return pf.getName() + " #" + pf.getItemCount();
80         }
81         else if (m_AD_PrintFormat_ID != null && m_AD_PrintFormat_ID.intValue() > 0)
82         {
83             log.info("MPrintFormatProcess - Copy from AD_PrintFormat_ID=" + m_AD_PrintFormat_ID);
84             MPrintFormat pf = MPrintFormat.copy (getCtx(), m_AD_PrintFormat_ID.intValue(), getRecord_ID());
85             return pf.getName() + " #" + pf.getItemCount();
86         }
87         else
88             throw new Exception JavaDoc (MSG_InvalidArguments);
89     } // doIt
90

91 } // MPrintFormatProcess
Popular Tags