KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > compiere > custom > CalloutUser


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

14 package com.compiere.custom;
15
16 import java.sql.*;
17 import java.util.*;
18
19 import org.compiere.util.*;
20 import org.compiere.model.*;
21
22 /**
23  * User Callout Example.
24  *
25  * @author Jorg Janke
26  * @version $Id: CalloutUser.java,v 1.6 2003/10/11 05:21:57 jjanke Exp $
27  */

28 public class CalloutUser extends CalloutEngine
29 {
30     /**
31      * JustAnExample.
32      * The string in the Callout field is:
33      * <code>com.compiere.custom.CalloutEngine.justAnExample</code>
34      *
35      * @param ctx Context
36      * @param WindowNo current Window No
37      * @param mTab Model Tab
38      * @param mField Model Field
39      * @param value The new value
40      * @param oldValue The old value
41      * @return error message or "" if OK
42      */

43     public String JavaDoc justAnExample (Properties ctx, int WindowNo,
44         MTab mTab, MField mField, Object JavaDoc value, Object JavaDoc oldValue)
45     {
46         log.info("JustAnExample");
47         return "";
48     } // JustAnExample
49

50
51     /*************************************************************************/
52
53     /**
54      * Frie Value - convert to standardized Name
55      *
56      * @param value Name
57      * @return Name
58      */

59     public String JavaDoc Frie_Name (String JavaDoc value)
60     {
61         if (value == null || value.length() == 0)
62             return "";
63         //
64
String JavaDoc retValue = value;
65         String JavaDoc SQL = "SELECT FRIE_Name(?) FROM DUAL";
66         try
67         {
68             PreparedStatement pstmt = DB.prepareStatement(SQL);
69             pstmt.setString(1, value);
70             ResultSet rs = pstmt.executeQuery();
71             if (rs.next())
72                 retValue = rs.getString(1);
73             rs.close();
74             pstmt.close();
75         }
76         catch (SQLException e)
77         {
78             Log.error ("CalloutUser.Frie_Name", e);
79         }
80         return retValue;
81     } // Frie_Name
82

83
84     /**
85      * Frie Value - convert Name to Value
86      *
87      * @param value Name
88      * @return Value of Name
89      */

90     public String JavaDoc Frie_Value (String JavaDoc value)
91     {
92         if (value == null || value.length() == 0)
93             return "";
94         //
95
String JavaDoc retValue = value;
96         String JavaDoc SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL";
97         try
98         {
99             PreparedStatement pstmt = DB.prepareStatement(SQL);
100             pstmt.setString(1, value);
101             ResultSet rs = pstmt.executeQuery();
102             if (rs.next())
103                 retValue = rs.getString(1);
104             rs.close();
105             pstmt.close();
106         }
107         catch (SQLException e)
108         {
109             Log.error ("CalloutUser.Frie_Value", e);
110         }
111         return retValue;
112     } // Frie_Value
113

114
115     /**
116      * Frie Status - convert to Status.
117      *
118      * @param value value
119      * @return Status
120      */

121     public String JavaDoc Frie_Status (String JavaDoc value)
122     {
123         String JavaDoc retValue = "A"; // default (A)ctive
124
if (value != null && value.equals("A")) // Auslaufartikel
125
retValue = "O"; // (O)bsolete
126
return retValue;
127     } // Frie_Status
128

129 } // CalloutUser
130
Popular Tags