2
* $Header: /home/cvs/jakarta-struts/contrib/artimus/WEB-INF/src/java/org/apache/artimus/wizard/Model.java,v 1.4 2004/03/14 07:15:06 sraeburn Exp $
4
* $Date: 2004/03/14 07:15:06 $
6
* Copyright 2001-2004 The Apache Software Foundation.
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
22
package org.apache.artimus.wizard;
25
import java.util.Collection;
26
import java.sql.SQLException;
27
import java.sql.Timestamp;
29
import org.apache.scaffold.model.ModelException;
30
import org.apache.scaffold.model.ModelResourceException;
31
import org.apache.scaffold.sql.StatementUtils;
33
import org.apache.artimus.wizard.sql.Commands;
34
import org.apache.artimus.wizard.sql.Statements;
38
* Data access methods for Wizard package.
39
* This class brings together SQL Commands and SQL Statements
40
* to execute update queries or return collections of beans
42
* From the package's viewpoint, this class <b>is</b>
43
* the database (or "model").
45
* This class could be based on an interface if another
46
* (non-SQL) type of access was needed.
47
* @version $Revision: 1.4 $ $Date: 2004/03/14 07:15:06 $
49
public final class Model {
52
* Return next key for WIZARD table.
53
* @return The Integer key value to be inserted
54
* @exception ModelException if SQL error occurs
55
* @version $Revision: 1.4 $ $Date: 2004/03/14 07:15:06 $
57
public synchronized static final Integer allocateKey()
58
throws ModelException {
61
return org.apache.artimus.keys.sql.Statements.allocateKey(
62
Commands.WIZARD_TABLE);
65
catch (SQLException e) {
66
throw new ModelResourceException(e);
73
* Insert new entry into ARTICLE table.
76
* @exception ModelException if SQL error occurs
78
public static final int insert (
79
Integer id, Timestamp date, Float amount, Byte check,
80
String phone, String zip, String email, String text,
82
) throws ModelException {
85
return Statements.execute(Commands.WIZARD_INSERT,
86
id, date, amount, check,
87
phone, zip, email, text, wizard
90
catch (SQLException e) {
91
throw new ModelResourceException(e);
97
* Update entry in ARTICLE table.
100
* @exception ModelException if SQL error occurs
102
public static final int update (
103
Integer id, Timestamp date, Float amount, Byte check,
104
String phone, String zip, String email, String text,
106
) throws ModelException {
109
return Statements.execute(Commands.WIZARD_UPDATE,
110
id, date, amount, check,
111
phone, zip, email, text, wizard
114
catch (SQLException e) {
115
throw new ModelResourceException(e);
121
* Select record from WIZARD table by primary key.
123
* @return Collection with record or empty collection
124
* @exception ModelException if SQL error occurs
126
* @param target Object object to create Collection from ResultSet
127
* @version $Revision: 1.4 $ $Date: 2004/03/14 07:15:06 $
129
public static final Collection select(Object target, int key)
130
throws ModelException {
133
return StatementUtils.getCollection("WIZARD",
134
target,Commands.WIZARD_SELECT_KEY,key);
137
catch (SQLException e) {
138
throw new ModelResourceException(e);
142
public static final Collection select(Object target)
143
throws ModelException {
146
return StatementUtils.getCollection("WIZARD",
147
target,Commands.WIZARD_SEARCH_BASE);
150
catch (SQLException e) {
151
throw new ModelResourceException(e);
155
} // ---- End Model -----
b'\\ No newline at end of file'