KickJava   Java API By Example, From Geeks To Geeks.

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


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.model;
15
16 import java.util.*;
17 import java.sql.*;
18
19 import org.compiere.util.*;
20
21 /**
22  * Request Model
23  *
24  * @author Jorg Janke
25  * @version $Id: MRequest.java,v 1.2 2003/08/08 16:14:35 jjanke Exp $
26  */

27 public class MRequest extends X_R_Request
28 {
29     /**
30      * Constructor
31      * @param ctx context
32      * @param R_Request_ID request or 0 for new
33      */

34     public MRequest(Properties ctx, int R_Request_ID)
35     {
36         super (ctx, R_Request_ID);
37         if (R_Request_ID == 0)
38         {
39             setDueType (DUETYPE_Due);
40         // setSalesRep_ID (0);
41
// setDocumentNo (null);
42
setProcessed (false);
43             setRequestAmt (Env.ZERO);
44             setPriority (PRIORITY_Medium);
45         // setR_RequestType_ID (0);
46
// setSummary (null);
47
setIsEscalated (false);
48             setIsSelfService (false);
49         }
50     } // MRequest
51

52     /**
53      * Constructor
54      * @param ctx context
55      * @param SalesRep_ID SalesRep
56      * @param R_RequestType_ID request type
57      * @param Summary summary
58      * @param isSelfService self service
59      */

60     public MRequest(Properties ctx, int SalesRep_ID,
61         int R_RequestType_ID, String JavaDoc Summary, boolean isSelfService)
62     {
63         this(ctx, 0);
64         setSalesRep_ID (SalesRep_ID);
65         setR_RequestType_ID (R_RequestType_ID);
66         setSummary (Summary);
67         setIsSelfService(isSelfService);
68     } // MRequest
69

70
71     /**
72      * Load Constructor
73      * @param ctx context
74      * @param rs result set
75      */

76     public MRequest (Properties ctx, ResultSet rs)
77     {
78         super (ctx, rs);
79     } // MRequest
80

81     /** Default Request Type */
82     private Integer JavaDoc m_R_RequestType_ID;
83
84     /*************************************************************************/
85
86     /**
87      * Set Request Type.
88      * @param R_RequestType_ID request type, if 0 get default
89      */

90     public void setR_RequestType_ID (int R_RequestType_ID)
91     {
92         if (R_RequestType_ID == 0)
93         {
94             if (m_R_RequestType_ID != null)
95             {
96                 R_RequestType_ID = m_R_RequestType_ID.intValue();
97             }
98             else
99             {
100                 String JavaDoc sql = "SELECT R_RequestType_ID FROM R_RequestType ORDER BY IsDefault DESC";
101                 PreparedStatement pstmt = null;
102                 try
103                 {
104                     pstmt = DB.prepareStatement (sql);
105                     ResultSet rs = pstmt.executeQuery ();
106                     if (rs.next ())
107                     {
108                         R_RequestType_ID = rs.getInt (1);
109                         m_R_RequestType_ID = new Integer JavaDoc(R_RequestType_ID);
110                     }
111                     else
112                         log.error ("setR_RequestType_ID - No default found");
113                     rs.close ();
114                     pstmt.close ();
115                     pstmt = null;
116                 }
117                 catch (SQLException ex)
118                 {
119                     log.error ("setR_RequestType_ID", ex);
120                 }
121                 try
122                 {
123                     if (pstmt != null)
124                         pstmt.close ();
125                 }
126                 catch (SQLException ex1)
127                 {
128                 }
129                 pstmt = null;
130             }
131         }
132         super.setR_RequestType_ID(R_RequestType_ID);
133     } // setR_RequestType_ID
134

135     /**
136      * Set Summary
137      * @param Summary Summary
138      */

139     public void setSummary(String JavaDoc Summary)
140     {
141         if (Summary != null)
142         {
143             if (Summary.length() < 2000)
144                 super.setSummary (Summary);
145             else
146                 super.setSummary (Summary.substring (0, 1999));
147         }
148     } // setSummary
149

150 } // MRequest
151
Popular Tags