KickJava   Java API By Example, From Geeks To Geeks.

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


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
17 import java.math.*;
18
19 import org.compiere.model.*;
20
21 /**
22  * Copy GL Batch Journal/Lines
23  *
24  * @author Jorg Janke
25  * @version $Id: CopyFromJournal.java,v 1.2 2003/08/11 05:55:38 jjanke Exp $
26  */

27 public class CopyFromJournal extends SvrProcess
28 {
29     private int m_GL_JournalBatch_ID = 0;
30
31     /**
32      * Prepare - e.g., get Parameters.
33      */

34     protected void prepare()
35     {
36         ProcessInfoParameter[] para = getParameter();
37         for (int i = 0; i < para.length; i++)
38         {
39             String JavaDoc name = para[i].getParameterName();
40             if (para[i].getParameter() == null)
41                 ;
42             else if (name.equals("GL_JournalBatch_ID"))
43                 m_GL_JournalBatch_ID = ((BigDecimal)para[i].getParameter()).intValue();
44             else
45                 log.error("prepare - Unknown Parameter: " + name);
46         }
47     } // prepare
48

49     /**
50      * Perrform process.
51      * @return Message (clear text)
52      * @throws Exception if not successful
53      */

54     protected String JavaDoc doIt() throws Exception JavaDoc
55     {
56         int To_GL_JournalBatch_ID = getRecord_ID();
57         log.info("doIt - From GL_JournalBatch_ID=" + m_GL_JournalBatch_ID + " to " + To_GL_JournalBatch_ID);
58         if (To_GL_JournalBatch_ID == 0)
59             throw new IllegalArgumentException JavaDoc("Target GL_JournalBatch_ID == 0");
60         if (m_GL_JournalBatch_ID == 0)
61             throw new IllegalArgumentException JavaDoc("Source GL_JournalBatch_ID == 0");
62         MJournalBatch from = new MJournalBatch (getCtx(), m_GL_JournalBatch_ID);
63         MJournalBatch to = new MJournalBatch (getCtx(), To_GL_JournalBatch_ID);
64         //
65
int no = to.copyDetailsFrom (from);
66         //
67
return "@Copied@=" + no;
68     } // doIt
69

70 }
Popular Tags