01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.contact;
18:
19: /**
20: * DOCUMENT ME!
21: *
22: */
23: public class ContactHelper {
24: /* use SQL for the moment, since there is no deleteAll in a single transaction */
25: /*
26: public static void delete( String contactId, GenericDelegator delegator)
27: throws GenericDataSourceException
28: {
29:
30: Statement stmt = null;
31: ResultSet rs = null;
32: Connection conn = null;
33: boolean useTX = true;
34:
35: try {
36: SQLUtil sqlUtil = new SQLUtil();
37: conn = sqlUtil.getConnection( delegator );
38:
39: try { conn.setAutoCommit(false); }
40: catch(SQLException sqle) { useTX = false; }
41:
42: stmt = conn.createStatement();
43: String contactIdClause = "'" + contactId + "'";
44:
45: // need to delete related info from contacts and deals
46: stmt.executeUpdate("delete from contact where contact_id = " + contactIdClause);
47: stmt.executeUpdate("delete from activity where contact_id = " + contactIdClause);
48: stmt.executeUpdate("delete from address where address_owner_id = " + contactIdClause);
49: stmt.executeUpdate("delete from party where party_id = " + contactIdClause);
50:
51: if(useTX) conn.commit();
52: }
53: catch(SQLException sqle) {
54: //Debug.logWarning("[GenericDAO.insert]: SQL Exception while executing insert. Error was:");
55: //Debug.logWarning(sqle.getMessage());
56:
57: try { if(useTX) conn.rollback(); }
58: catch(SQLException sqle2) {
59: Debug.logWarning("[GenericDAO.insert]: SQL Exception while rolling back store. Error was:");
60: Debug.logWarning(sqle2);
61: }
62: throw new GenericDataSourceException("SQL Exception occured in deleteContact", sqle);
63: }
64: finally {
65: try { if(conn != null) conn.close(); } catch (SQLException sqle) { Debug.logWarning(sqle.getMessage()); }
66: }
67: }
68: */
69: }
|