2
* $Header: /home/cvs/jakarta-struts/contrib/artimus/WEB-INF/src/java/org/apache/artimus/wizard/Store.java,v 1.3 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.
21
package org.apache.artimus.wizard;
23
import java.sql.SQLException;
25
import org.apache.scaffold.lang.Tokens;
26
import org.apache.scaffold.model.ModelBeanBase;
27
import org.apache.scaffold.model.ModelException;
28
import org.apache.scaffold.model.ModelResult;
29
import org.apache.scaffold.model.ModelResultBase;
31
import org.apache.artimus.lang.Messages;
35
* Insert or update an article.
36
* @version $Revision: 1.3 $ $Date: 2004/03/14 07:15:06 $
38
public class Store extends Bean {
40
// ------------------------------------------------------------ Public Methods
44
* Allocate next key for article table.
45
* @return key to use for insertion
46
* @exception SQLException if SQL error occurs
48
public void allocateKey() throws ModelException {
50
setWizard(Model.allocateKey());
55
* Insert <code>key</code> record.
56
* @returns Number of records inserted.
58
public void insert() throws ModelException {
76
* Update <code>key</code> record.
77
* @returns Number of records updated.
79
public void update() throws ModelException {
97
* Execute model for this bean, and return outcome in ModelResult.
98
* @exception Collects and returns any Exceptions
99
* @returns Null on success, or a collection of Exceptions
101
public ModelResult execute(Object source, Object target)
102
throws ModelException {
104
ModelResult modelResult = new ModelResultBase();
106
if (isBlank(getKey())) {
109
modelResult.addMessage(Tokens.DATA_RECORD_INSERTED);
113
modelResult.addMessage(Tokens.DATA_RECORD_UPDATED);
115
modelResult.addMessage(getKey());
117
modelResult.add(target);