Source Code Cross Referenced for Attachment.java in  » Groupware » hipergate » com » knowgate » crm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.crm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright (C) 2003  Know Gate S.L. All rights reserved.
003:                              C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005:          Redistribution and use in source and binary forms, with or without
006:          modification, are permitted provided that the following conditions
007:          are met:
008:
009:          1. Redistributions of source code must retain the above copyright
010:             notice, this list of conditions and the following disclaimer.
011:
012:          2. The end-user documentation included with the redistribution,
013:             if any, must include the following acknowledgment:
014:             "This product includes software parts from hipergate
015:             (http://www.hipergate.org/)."
016:             Alternately, this acknowledgment may appear in the software itself,
017:             if and wherever such third-party acknowledgments normally appear.
018:
019:          3. The name hipergate must not be used to endorse or promote products
020:             derived from this software without prior written permission.
021:             Products derived from this software may not be called hipergate,
022:             nor may hipergate appear in their name, without prior written
023:             permission.
024:
025:          This library is distributed in the hope that it will be useful,
026:          but WITHOUT ANY WARRANTY; without even the implied warranty of
027:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029:          You should have received a copy of hipergate License with this code;
030:          if not, visit http://www.hipergate.org or mail to info@hipergate.org
031:         */
032:
033:        package com.knowgate.crm;
034:
035:        import java.sql.SQLException;
036:        import java.sql.Statement;
037:        import java.sql.ResultSet;
038:
039:        import com.knowgate.debug.DebugFile;
040:        import com.knowgate.jdc.JDCConnection;
041:        import com.knowgate.dataobjs.DB;
042:        import com.knowgate.dataobjs.DBBind;
043:        import com.knowgate.dataobjs.DBPersist;
044:        import com.knowgate.hipergate.Product;
045:
046:        /**
047:         * <p>Contact Attachment</p>
048:         * <p>Copyright: Copyright (c) KnowGate 2003</p>
049:         * @author Sergio Montoro Ten
050:         * @version 1.0
051:         */
052:
053:        public class Attachment extends DBPersist {
054:
055:            public Attachment() {
056:                super (DB.k_contact_attachs, "Attachment");
057:            }
058:
059:            // ----------------------------------------------------------
060:
061:            /**
062:             * <p>Store Product as Contact Attachment.</p>
063:             * <p>A Product object must have been stored at database prior to storing the
064:             * Attachment object.<br>
065:             * The link between Product and Attachment is done just by setting the
066:             * gu_product field at Attachment object.<br>
067:             * An Attachment progressive numeric identifier is automatically computed
068:             * for field pg_product of table k_contact_attachs if one is not explicitly set.<br>
069:             * Automatically generates dt_modified DATE if not explicitly set.<br></p>
070:             * k_contact.nu_attachs fields is incremented by 1
071:             * @param oConn Database Connection
072:             * @throws SQLException
073:             */
074:            public boolean store(JDCConnection oConn) throws SQLException {
075:                Statement oStmt;
076:                ResultSet oRSet;
077:                java.sql.Timestamp dtNow = new java.sql.Timestamp(DBBind
078:                        .getTime());
079:                boolean bRetVal;
080:
081:                if (DebugFile.trace) {
082:                    DebugFile.writeln("Begin Attachment.store([Connection])");
083:                    DebugFile.incIdent();
084:                }
085:
086:                replace(DB.dt_modified, dtNow);
087:
088:                if (!AllVals.containsKey(DB.pg_product)) {
089:
090:                    oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
091:                            ResultSet.CONCUR_READ_ONLY);
092:
093:                    if (DebugFile.trace)
094:                        DebugFile.writeln("Statement.executeQuery(SELECT "
095:                                + DBBind.Functions.ISNULL + "(MAX("
096:                                + DB.pg_product + "),0)+1 FROM "
097:                                + DB.k_contact_attachs + " WHERE "
098:                                + DB.gu_contact + "='"
099:                                + getStringNull(DB.gu_contact, "null") + "')");
100:
101:                    oRSet = oStmt.executeQuery("SELECT "
102:                            + DBBind.Functions.ISNULL + "(MAX(" + DB.pg_product
103:                            + "),0)+1 FROM " + DB.k_contact_attachs + " WHERE "
104:                            + DB.gu_contact + "='" + getString(DB.gu_contact)
105:                            + "'");
106:                    oRSet.next();
107:                    put(DB.pg_product, oRSet.getObject(1));
108:                    oRSet.close();
109:                    oStmt.close();
110:                }
111:
112:                bRetVal = super .store(oConn);
113:
114:                oStmt = oConn.createStatement();
115:
116:                if (DebugFile.trace)
117:                    DebugFile.writeln("Statement.executeUpdate(UPDATE "
118:                            + DB.k_contacts + " SET " + DB.nu_attachs + "="
119:                            + DB.nu_attachs + "+1 WHERE gu_contact='"
120:                            + getStringNull(DB.gu_contact, "null") + "')");
121:
122:                oStmt.executeUpdate("UPDATE " + DB.k_contacts + " SET "
123:                        + DB.nu_attachs + "=" + DB.nu_attachs
124:                        + "+1 WHERE gu_contact='" + getString(DB.gu_contact)
125:                        + "'");
126:                oStmt.close();
127:
128:                if (DebugFile.trace) {
129:                    DebugFile.decIdent();
130:                    DebugFile.writeln("End Attachment.store() : "
131:                            + String.valueOf(getInt(DB.pg_product)));
132:                }
133:
134:                return bRetVal;
135:            } // store
136:
137:            // ----------------------------------------------------------
138:
139:            /**
140:             * <p>Delete Attachment</p>
141:             * <p>The associated Product and physical files are automatically deleted as well.<br></p>
142:             * k_contact.nu_attachs fields is decremented by 1
143:             * @param oConn Database Connection
144:             * @throws SQLException
145:             */
146:            public boolean delete(JDCConnection oConn) throws SQLException {
147:                Statement oStmt;
148:                boolean bRetVal;
149:
150:                Product oProd = new Product(oConn, getString(DB.gu_product));
151:                bRetVal = oProd.delete(oConn);
152:
153:                if (bRetVal)
154:                    bRetVal = super .delete(oConn);
155:
156:                oStmt = oConn.createStatement();
157:                oStmt.executeUpdate("UPDATE " + DB.k_contacts + " SET "
158:                        + DB.nu_attachs + "=" + DB.nu_attachs
159:                        + "-1 WHERE gu_contact='" + getString(DB.gu_contact)
160:                        + "'");
161:                oStmt.close();
162:
163:                return bRetVal;
164:            }
165:
166:            // **********************************************************
167:            // Public Constants
168:
169:            public static final short ClassId = 94;
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.