KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > model > MLotCtl


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.model;
15
16 import java.sql.ResultSet JavaDoc;
17 import java.util.Properties JavaDoc;
18
19 /**
20  * Lot Control Model
21  *
22  * @author Jorg Janke
23  * @version $Id: MLotCtl.java,v 1.2 2003/10/25 06:07:16 jjanke Exp $
24  */

25 public class MLotCtl extends X_M_LotCtl
26 {
27     /**
28      * Standard Constructor
29      * @param ctx context
30      * @param M_LotCtl_ID id
31      */

32     public MLotCtl (Properties JavaDoc ctx, int M_LotCtl_ID)
33     {
34         super (ctx, M_LotCtl_ID);
35         if (M_LotCtl_ID == 0)
36         {
37         // setM_LotCtl_ID (0);
38
setStartNo (1);
39             setCurrentNext (1);
40             setIncrementNo (1);
41         // setName (null);
42
}
43     } // MLotCtl
44

45     /**
46      * Load Constructor
47      * @param ctx context
48      * @param rs result set
49      */

50     public MLotCtl (Properties JavaDoc ctx, ResultSet JavaDoc rs)
51     {
52         super(ctx, rs);
53     } // MLotCtl
54

55     /**
56      * Create new Lot.
57      * Increments Current Next and Commits
58      * @param M_Product_ID product
59      * @return saved Lot
60      */

61     public MLot createLot (int M_Product_ID)
62     {
63         StringBuffer JavaDoc name = new StringBuffer JavaDoc();
64         if (getPrefix() != null)
65             name.append(getPrefix());
66         int no = getCurrentNext();
67         name.append(no);
68         if (getSuffix() != null)
69             name.append(getSuffix());
70         //
71
no += getIncrementNo();
72         setCurrentNext(no);
73         save();
74         //
75
MLot retValue = new MLot (getCtx(), M_Product_ID, name.toString());
76         retValue.setM_LotCtl_ID (getM_LotCtl_ID());
77         retValue.save();
78         return retValue;
79     } // createLot
80

81 } // MLotCtl
82
Popular Tags