001: //The Salmon Open Framework for Internet Applications (SOFIA)
002: //Copyright (C) 1999 - 2002, Salmon LLC
003: //
004: //This program is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU General Public License version 2
006: //as published by the Free Software Foundation;
007: //
008: //This program is distributed in the hope that it will be useful,
009: //but WITHOUT ANY WARRANTY; without even the implied warranty of
010: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: //GNU General Public License for more details.
012: //
013: //You should have received a copy of the GNU General Public License
014: //along with this program; if not, write to the Free Software
015: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
016: //
017: //For more information please visit http://www.salmonllc.com
018: package com.salmonllc.examples.example17;
019:
020: import javax.servlet.http.HttpServletRequest;
021:
022: import com.salmonllc.sql.*;
023:
024: /**
025: * ContactModel: A SOFIA generated model used for the Jasper Report example
026: */
027: public class ContactModel extends DataStore implements Remotable {
028:
029: //constants for columns
030: public static final String CONTACT_CONTACT_ID = "contact_id";
031: public static final String CONTACT_FIRST_NAME = "first_name";
032: public static final String CONTACT_LAST_NAME = "last_name";
033: public static final String CONTACT_EMAIL_ADDRESS = "email_address";
034: public static final String CONTACT_MAIN_PHONE = "main_phone";
035:
036: //$CUSTOMVARS$
037: //Put custom instance variables between these comments, otherwise they will be overwritten if the model is regenerated
038:
039: //$ENDCUSTOMVARS$
040:
041: /**
042: * Create a new ContactModel object.
043: * @param appName The SOFIA application name
044: */
045: public ContactModel(String appName) {
046: this (appName, null);
047: }
048:
049: /**
050: * Create a new ContactModel object.
051: * @param appName The SOFIA application name
052: * @param profile The database profile to use
053: */
054: public ContactModel(String appName, String profile) {
055: super (appName, profile);
056:
057: //add columns
058: addColumn(computeTableName("contact"), "contact_id",
059: DataStore.DATATYPE_INT, true, true, CONTACT_CONTACT_ID);
060: addColumn(computeTableName("contact"), "first_name",
061: DataStore.DATATYPE_STRING, false, true,
062: CONTACT_FIRST_NAME);
063: addColumn(computeTableName("contact"), "last_name",
064: DataStore.DATATYPE_STRING, false, true,
065: CONTACT_LAST_NAME);
066: addColumn(computeTableName("contact"), "email_address",
067: DataStore.DATATYPE_STRING, false, true,
068: CONTACT_EMAIL_ADDRESS);
069: addColumn(computeTableName("contact"), "main_phone",
070: DataStore.DATATYPE_STRING, false, true,
071: CONTACT_MAIN_PHONE);
072: }
073:
074: /**
075: * Retrieve the value of the contact.contact_id column for the current row.
076: * @return int
077: * @throws DataStoreException
078: */
079: public int getContactContactId() throws DataStoreException {
080: return getInt(CONTACT_CONTACT_ID);
081: }
082:
083: /**
084: * Retrieve the value of the contact.contact_id column for the specified row.
085: * @param row which row in the table
086: * @return int
087: * @throws DataStoreException
088: */
089: public int getContactContactId(int row) throws DataStoreException {
090: return getInt(row, CONTACT_CONTACT_ID);
091: }
092:
093: /**
094: * Set the value of the contact.contact_id column for the current row.
095: * @param newValue the new item value
096: * @throws DataStoreException
097: */
098: public void setContactContactId(int newValue)
099: throws DataStoreException {
100: setInt(CONTACT_CONTACT_ID, newValue);
101: }
102:
103: /**
104: * Set the value of the contact.contact_id column for the specified row.
105: * @param row which row in the table
106: * @param newValue the new item value
107: * @throws DataStoreException
108: */
109: public void setContactContactId(int row, int newValue)
110: throws DataStoreException {
111: setInt(row, CONTACT_CONTACT_ID, newValue);
112: }
113:
114: /**
115: * Retrieve the value of the contact.first_name column for the current row.
116: * @return String
117: * @throws DataStoreException
118: */
119: public String getContactFirstName() throws DataStoreException {
120: return getString(CONTACT_FIRST_NAME);
121: }
122:
123: /**
124: * Retrieve the value of the contact.first_name column for the specified row.
125: * @param row which row in the table
126: * @return String
127: * @throws DataStoreException
128: */
129: public String getContactFirstName(int row)
130: throws DataStoreException {
131: return getString(row, CONTACT_FIRST_NAME);
132: }
133:
134: /**
135: * Set the value of the contact.first_name column for the current row.
136: * @param newValue the new item value
137: * @throws DataStoreException
138: */
139: public void setContactFirstName(String newValue)
140: throws DataStoreException {
141: setString(CONTACT_FIRST_NAME, newValue);
142: }
143:
144: /**
145: * Set the value of the contact.first_name column for the specified row.
146: * @param row which row in the table
147: * @param newValue the new item value
148: * @throws DataStoreException
149: */
150: public void setContactFirstName(int row, String newValue)
151: throws DataStoreException {
152: setString(row, CONTACT_FIRST_NAME, newValue);
153: }
154:
155: /**
156: * Retrieve the value of the contact.last_name column for the current row.
157: * @return String
158: * @throws DataStoreException
159: */
160: public String getContactLastName() throws DataStoreException {
161: return getString(CONTACT_LAST_NAME);
162: }
163:
164: /**
165: * Retrieve the value of the contact.last_name column for the specified row.
166: * @param row which row in the table
167: * @return String
168: * @throws DataStoreException
169: */
170: public String getContactLastName(int row) throws DataStoreException {
171: return getString(row, CONTACT_LAST_NAME);
172: }
173:
174: /**
175: * Set the value of the contact.last_name column for the current row.
176: * @param newValue the new item value
177: * @throws DataStoreException
178: */
179: public void setContactLastName(String newValue)
180: throws DataStoreException {
181: setString(CONTACT_LAST_NAME, newValue);
182: }
183:
184: /**
185: * Set the value of the contact.last_name column for the specified row.
186: * @param row which row in the table
187: * @param newValue the new item value
188: * @throws DataStoreException
189: */
190: public void setContactLastName(int row, String newValue)
191: throws DataStoreException {
192: setString(row, CONTACT_LAST_NAME, newValue);
193: }
194:
195: /**
196: * Retrieve the value of the contact.email_address column for the current row.
197: * @return String
198: * @throws DataStoreException
199: */
200: public String getContactEmailAddress() throws DataStoreException {
201: return getString(CONTACT_EMAIL_ADDRESS);
202: }
203:
204: /**
205: * Retrieve the value of the contact.email_address column for the specified row.
206: * @param row which row in the table
207: * @return String
208: * @throws DataStoreException
209: */
210: public String getContactEmailAddress(int row)
211: throws DataStoreException {
212: return getString(row, CONTACT_EMAIL_ADDRESS);
213: }
214:
215: /**
216: * Set the value of the contact.email_address column for the current row.
217: * @param newValue the new item value
218: * @throws DataStoreException
219: */
220: public void setContactEmailAddress(String newValue)
221: throws DataStoreException {
222: setString(CONTACT_EMAIL_ADDRESS, newValue);
223: }
224:
225: /**
226: * Set the value of the contact.email_address column for the specified row.
227: * @param row which row in the table
228: * @param newValue the new item value
229: * @throws DataStoreException
230: */
231: public void setContactEmailAddress(int row, String newValue)
232: throws DataStoreException {
233: setString(row, CONTACT_EMAIL_ADDRESS, newValue);
234: }
235:
236: /**
237: * Retrieve the value of the contact.main_phone column for the current row.
238: * @return String
239: * @throws DataStoreException
240: */
241: public String getContactMainPhone() throws DataStoreException {
242: return getString(CONTACT_MAIN_PHONE);
243: }
244:
245: /**
246: * Retrieve the value of the contact.main_phone column for the specified row.
247: * @param row which row in the table
248: * @return String
249: * @throws DataStoreException
250: */
251: public String getContactMainPhone(int row)
252: throws DataStoreException {
253: return getString(row, CONTACT_MAIN_PHONE);
254: }
255:
256: /**
257: * Set the value of the contact.main_phone column for the current row.
258: * @param newValue the new item value
259: * @throws DataStoreException
260: */
261: public void setContactMainPhone(String newValue)
262: throws DataStoreException {
263: setString(CONTACT_MAIN_PHONE, newValue);
264: }
265:
266: /**
267: * Set the value of the contact.main_phone column for the specified row.
268: * @param row which row in the table
269: * @param newValue the new item value
270: * @throws DataStoreException
271: */
272: public void setContactMainPhone(int row, String newValue)
273: throws DataStoreException {
274: setString(row, CONTACT_MAIN_PHONE, newValue);
275: }
276:
277: //$CUSTOMMETHODS$
278: //Put custom methods between these comments, otherwise they will be overwritten if the model is regenerated
279:
280: /**
281: * By implementing Remoteable, the model can be used from a DataStoreProxy, which is required for the SOFIA Jasper Reports viewer.
282: */
283:
284: public boolean request(String reqType, HttpServletRequest req,
285: boolean sessionValid, String userID, String password,
286: String criteria) throws DataStoreException {
287: //this model is used for reports, allow read requests only, no updates
288: if (reqType.equals(DataStoreProxy.OPERATION_UPDATE))
289: return false;
290: else
291: return true;
292: }
293: //$ENDCUSTOMMETHODS$
294:
295: }
|