KickJava   Java API By Example, From Geeks To Geeks.

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


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.model;
15
16 import java.sql.*;
17 import java.util.*;
18 import java.math.*;
19
20 import org.compiere.util.*;
21
22 /**
23  * Resource Assignment Model
24  *
25  * @author Jorg Janke
26  * @version $Id: MAssignment.java,v 1.8 2003/07/06 18:39:44 jjanke Exp $
27  */

28 public class MAssignment extends X_S_ResourceAssignment
29 {
30     /**
31      * Assignment Constructor.
32      * @param ctx context
33      * @param S_ResourceAssignment_ID ID
34      */

35     public MAssignment (Properties ctx, int S_ResourceAssignment_ID)
36     {
37         super (ctx, S_ResourceAssignment_ID);
38         p_info.setUpdateable(true); // default table is not updateable
39
// Default values
40
if (S_ResourceAssignment_ID == 0)
41         {
42             setAssignDateFrom(new Timestamp(System.currentTimeMillis()));
43             setQty(new BigDecimal(1.0));
44             setName(".");
45             setIsConfirmed(false);
46         }
47     } // MAssignment
48

49     /**
50      * String Representation
51      * @return string
52      */

53     public String JavaDoc toString()
54     {
55         StringBuffer JavaDoc sb = new StringBuffer JavaDoc ("MAssignment[ID=");
56         sb.append(getID())
57             .append(",S_Resource_ID=").append(getS_Resource_ID())
58             .append(",From=").append(getAssignDateFrom())
59             .append(",To=").append(getAssignDateTo())
60             .append(",Qty=").append(getQty())
61             .append("]");
62         return sb.toString();
63     } // toString
64

65     /*************************************************************************/
66
67     /**
68      * Set Resource ID
69      * @param S_Resource_ID resource
70      */

71     public void setS_Resource_ID (int S_Resource_ID)
72     {
73         if (S_Resource_ID == 0)
74             setValue("S_Resource_ID", null);
75         else
76             super.setS_Resource_ID(S_Resource_ID);
77     } // getS_Resource_ID
78

79     /*************************************************************************/
80
81     /**
82      * Delete (set inactive)
83      * @return true i deleted
84      */

85     public boolean delete()
86     {
87         // allow to delete, when not confirmed
88
if (isConfirmed())
89             return false;
90
91         StringBuffer JavaDoc sql = new StringBuffer JavaDoc ("UPDATE ");
92         sql.append(getTableName()).append( " SET IsActive='N' WHERE ");
93         sql.append(" WHERE ").append(getTableName()).append("_ID=").append(getID());
94         int no = DB.executeUpdate(sql.toString());
95         return no == 1;
96     }
97
98     /*************************************************************************/
99
100     public void setAssignDateFrom(Timestamp AssignDateFrom)
101     {
102         super.setAssignDateFrom(AssignDateFrom);
103     }
104     public void setAssignDateTo(Timestamp AssignDateTo)
105     {
106         super.setAssignDateTo(AssignDateTo);
107     }
108     public void setQty(BigDecimal Qty)
109     {
110         super.setQty(Qty);
111     } // delete
112

113 } // MAssignment
114

115
Popular Tags