~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/artimus/WEB-INF/src/java/org/apache/artimus/wizard/Model.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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 $
 
3
 * $Revision: 1.4 $
 
4
 * $Date: 2004/03/14 07:15:06 $
 
5
 *
 
6
 * Copyright 2001-2004 The Apache Software Foundation.
 
7
 * 
 
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
 
11
 * 
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
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.
 
19
 */
 
20
 
 
21
 
 
22
package org.apache.artimus.wizard;
 
23
 
 
24
 
 
25
import java.util.Collection;
 
26
import java.sql.SQLException;
 
27
import java.sql.Timestamp;
 
28
 
 
29
import org.apache.scaffold.model.ModelException;
 
30
import org.apache.scaffold.model.ModelResourceException;
 
31
import org.apache.scaffold.sql.StatementUtils;
 
32
 
 
33
import org.apache.artimus.wizard.sql.Commands;
 
34
import org.apache.artimus.wizard.sql.Statements;
 
35
 
 
36
 
 
37
/**
 
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
 
41
 * from the database.
 
42
 * From the package's viewpoint, this class <b>is</b>
 
43
 * the database (or "model").
 
44
 * <p>
 
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 $
 
48
 */
 
49
public final class Model {
 
50
 
 
51
    /**
 
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 $
 
56
    **/
 
57
    public synchronized static final Integer allocateKey()
 
58
            throws ModelException {
 
59
        try {
 
60
 
 
61
             return org.apache.artimus.keys.sql.Statements.allocateKey(
 
62
                 Commands.WIZARD_TABLE);
 
63
 
 
64
        }
 
65
        catch (SQLException e) {
 
66
            throw new ModelResourceException(e);
 
67
        }
 
68
 
 
69
    }
 
70
 
 
71
 
 
72
    /**
 
73
     * Insert new entry into ARTICLE table.
 
74
     * <p>
 
75
     * @return 0 if fails
 
76
     * @exception ModelException if SQL error occurs
 
77
    **/
 
78
    public static final int insert (
 
79
                 Integer id, Timestamp date, Float amount, Byte check,
 
80
                 String phone, String zip, String email, String text,
 
81
                 Integer wizard
 
82
            ) throws ModelException {
 
83
        try {
 
84
 
 
85
            return Statements.execute(Commands.WIZARD_INSERT,
 
86
                id, date,  amount,  check,
 
87
                phone,  zip,  email,  text,  wizard
 
88
            );
 
89
        }
 
90
        catch (SQLException e) {
 
91
            throw new ModelResourceException(e);
 
92
        }
 
93
    }
 
94
 
 
95
 
 
96
    /**
 
97
     * Update entry in ARTICLE table.
 
98
     * <p>
 
99
     * @return 0 if fails
 
100
     * @exception ModelException if SQL error occurs
 
101
    **/
 
102
    public static final int update (
 
103
                 Integer id, Timestamp date, Float amount, Byte check,
 
104
                 String phone, String zip, String email, String text,
 
105
                 Integer wizard
 
106
            ) throws ModelException {
 
107
         try {
 
108
 
 
109
            return Statements.execute(Commands.WIZARD_UPDATE,
 
110
                  id, date,  amount,  check,
 
111
                  phone,  zip,  email,  text, wizard
 
112
            );
 
113
        }
 
114
        catch (SQLException e) {
 
115
            throw new ModelResourceException(e);
 
116
        }
 
117
    }
 
118
 
 
119
 
 
120
    /**
 
121
     * Select record from WIZARD table by primary key.
 
122
     * <p>
 
123
     * @return Collection with record or empty collection
 
124
     * @exception ModelException if SQL error occurs
 
125
     * @param key
 
126
     * @param target Object object to create Collection from ResultSet
 
127
     * @version $Revision: 1.4 $ $Date: 2004/03/14 07:15:06 $
 
128
    **/
 
129
    public static final Collection select(Object target, int key)
 
130
            throws ModelException {
 
131
        try {
 
132
 
 
133
            return StatementUtils.getCollection("WIZARD",
 
134
                target,Commands.WIZARD_SELECT_KEY,key);
 
135
 
 
136
        }
 
137
        catch (SQLException e) {
 
138
            throw new ModelResourceException(e);
 
139
        }
 
140
   }
 
141
 
 
142
    public static final Collection select(Object target)
 
143
            throws ModelException {
 
144
        try {
 
145
 
 
146
            return StatementUtils.getCollection("WIZARD",
 
147
                target,Commands.WIZARD_SEARCH_BASE);
 
148
 
 
149
        }
 
150
        catch (SQLException e) {
 
151
            throw new ModelResourceException(e);
 
152
        }
 
153
   }
 
154
 
 
155
} // ---- End Model -----
 
 
b'\\ No newline at end of file'