Source Code Cross Referenced for DBMaint.java in  » J2EE » Expresso » com » jcorporate » expresso » services » controller » 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 » J2EE » Expresso » com.jcorporate.expresso.services.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jcorporate.expresso.services.controller;
002:
003:        /* ====================================================================
004:         * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
005:         *
006:         * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
007:         *
008:         * Redistribution and use in source and binary forms, with or without
009:         * modification, are permitted provided that the following conditions
010:         * are met:
011:         *
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions and the following disclaimer.
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions and the following disclaimer in
017:         *    the documentation and/or other materials provided with the
018:         *    distribution.
019:         *
020:         * 3. The end-user documentation included with the redistribution,
021:         *    if any, must include the following acknowledgment:
022:         *       "This product includes software developed by Jcorporate Ltd.
023:         *        (http://www.jcorporate.com/)."
024:         *    Alternately, this acknowledgment may appear in the software itself,
025:         *    if and wherever such third-party acknowledgments normally appear.
026:         *
027:         * 4. "Jcorporate" and product names such as "Expresso" must
028:         *    not be used to endorse or promote products derived from this
029:         *    software without prior written permission. For written permission,
030:         *    please contact info@jcorporate.com.
031:         *
032:         * 5. Products derived from this software may not be called "Expresso",
033:         *    or other Jcorporate product names; nor may "Expresso" or other
034:         *    Jcorporate product names appear in their name, without prior
035:         *    written permission of Jcorporate Ltd.
036:         *
037:         * 6. No product derived from this software may compete in the same
038:         *    market space, i.e. framework, without prior written permission
039:         *    of Jcorporate Ltd. For written permission, please contact
040:         *    partners@jcorporate.com.
041:         *
042:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
043:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
044:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
045:         * DISCLAIMED.  IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
046:         * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
047:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
048:         * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
049:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
050:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
051:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
052:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
053:         * SUCH DAMAGE.
054:         * ====================================================================
055:         *
056:         * This software consists of voluntary contributions made by many
057:         * individuals on behalf of the Jcorporate Ltd. Contributions back
058:         * to the project(s) are encouraged when you make modifications.
059:         * Please send them to support@jcorporate.com. For more information
060:         * on Jcorporate Ltd. and its products, please see
061:         * <http://www.jcorporate.com/>.
062:         *
063:         * Portions of this software are based upon other open source
064:         * products and are subject to their respective licenses.
065:         */
066:
067:        import com.jcorporate.expresso.core.controller.ControllerException;
068:        import com.jcorporate.expresso.core.controller.ControllerRequest;
069:        import com.jcorporate.expresso.core.controller.ControllerResponse;
070:        import com.jcorporate.expresso.core.controller.DBController;
071:        import com.jcorporate.expresso.core.controller.Input;
072:        import com.jcorporate.expresso.core.controller.State;
073:        import com.jcorporate.expresso.core.controller.Transition;
074:        import com.jcorporate.expresso.core.db.DBException;
075:        import com.jcorporate.expresso.core.dbobj.DBObject;
076:        import com.jcorporate.expresso.core.dbobj.Schema;
077:        import com.jcorporate.expresso.core.dbobj.SchemaFactory;
078:        import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
079:        import com.jcorporate.expresso.core.dbobj.ValidValue;
080:        import com.jcorporate.expresso.services.controller.dbmaint.Add;
081:        import com.jcorporate.expresso.services.controller.dbmaint.AddUpdate;
082:        import com.jcorporate.expresso.services.controller.dbmaint.List;
083:        import com.jcorporate.expresso.services.controller.dbmaint.Search;
084:        import com.jcorporate.expresso.services.controller.dbmaint.SearchList;
085:        import com.jcorporate.expresso.services.controller.dbmaint.Update;
086:        import com.jcorporate.expresso.services.controller.dbmaint.UpdateDelete;
087:        import com.jcorporate.expresso.services.controller.dbmaint.UpdateUpdate;
088:        import com.jcorporate.expresso.services.controller.dbmaint.ViewBlob;
089:        import com.jcorporate.expresso.services.dbobj.DBOtherMap;
090:        import com.jcorporate.expresso.services.dbobj.SchemaList;
091:        import org.apache.log4j.Logger;
092:
093:        import java.util.Enumeration;
094:        import java.util.Iterator;
095:        import java.util.Vector;
096:
097:        /**
098:         * Controller that enables basic maintenance (add/update/delete) of any DBObject
099:         * DBMaint acts more as a controller for allowing operations on DBObjects.
100:         * The real work for adding, deleting, searching and updating is carried out by
101:         * a series of classes that are dynamically instantiated and live in the
102:         * com.jcorporate.expresso.core.servlet.commands package. These classes
103:         * can be extended to add additional functionality.
104:         * <p/>
105:         * When tracking down code functionality, the core states are in package:<br/>
106:         * &nbsp;<code>com.jcorporate.expresso.services.dbmaint</code><br/>
107:         * </p> <p>
108:         * The only state handlers embedded in the class are minimalistic classes
109:         * for allowing admins to select the DBObjects to administer from dropdown lists.
110:         * </p>
111:         *
112:         * @author Michael Nash
113:         * @version $Revision: 1.19 $  $Date: 2004/11/17 20:48:17 $
114:         */
115:        public class DBMaint extends DBController {
116:
117:            /**
118:             * The log4j Logger
119:             */
120:            private static Logger log = Logger.getLogger(DBMaint.class);
121:            public static final String UPDATE = "Update";
122:            public static final String LIST = "List";
123:            public static final String ADD = "Add";
124:            public static final String SEARCH = "Search";
125:            public static final String PROMPT = "prompt";
126:
127:            /**
128:             * Default Constructor.  It constructs all the state
129:             */
130:            public DBMaint() {
131:                super ();
132:                State prompt = new State(PROMPT, "Prompt to Select Schema");
133:                addState(prompt);
134:                setInitialState("prompt");
135:
136:                State selDBObj = new State("selDBObj", "Select Database Object");
137:                selDBObj.addRequiredParameter("SchemaClass");
138:                addState(selDBObj);
139:
140:                State add = new Add(ADD, "Prompt for New Record");
141:                addState(add);
142:
143:                State addUpdate = new AddUpdate("AddUpdate", "Save New Record");
144:                addState(addUpdate);
145:
146:                State list = new List(LIST, "List Records");
147:                addState(list);
148:
149:                State search = new Search(SEARCH, "Prompt for Search Criteria");
150:                addState(search);
151:
152:                State searchList = new SearchList("SearchList",
153:                        "Display records found by Search");
154:                addState(searchList);
155:
156:                State update = new Update(UPDATE, "Present Record for Update");
157:                addState(update);
158:
159:                State updateDelete = new UpdateDelete("UpdateDelete",
160:                        "Delete Record");
161:                addState(updateDelete);
162:
163:                State updateUpdate = new UpdateUpdate("UpdateUpdate",
164:                        "Update Record");
165:                addState(updateUpdate);
166:
167:                this .addState(new ViewBlob());
168:
169:                this 
170:                        .setSchema(com.jcorporate.expresso.core.ExpressoSchema.class);
171:            } /* Constructor */
172:
173:            /**
174:             * Retrieve the title of this Controller
175:             *
176:             * @return java.lang.String The Title of the controller
177:             */
178:            public String getTitle() {
179:                return ("Database Maintenance");
180:            }
181:
182:            /**
183:             * This particular state is for helping users to select DBObjects through
184:             * the UI.  It should normally be only accessible to Administrators in
185:             * a live environment.
186:             * <p/>
187:             * This state creates an Input list of Schema objects that will be later
188:             * user to select DBObjects from.
189:             * </p>
190:             *
191:             * @param request  The <code>ControllerRequest</code> object
192:             * @param response The <code>ControllerResponse</code> object
193:             * @throws ControllerException upon error.
194:             */
195:            private void runPromptState(ControllerRequest request,
196:                    ControllerResponse response) throws ControllerException {
197:                try {
198:                    Input chooseSchema = new Input();
199:                    chooseSchema.setLabel("Choose Schema");
200:                    chooseSchema.setName("SchemaClass");
201:
202:                    Vector v2 = new Vector(2);
203:                    v2.addElement(new ValidValue("com.jcorporate.expresso."
204:                            + "core.ExpressoSchema", "General"));
205:
206:                    SchemaList sl = new SchemaList(
207:                            SecuredDBObject.SYSTEM_ACCOUNT);
208:                    sl.setDataContext(request.getDataContext());
209:
210:                    SchemaList oneSchema = null;
211:
212:                    for (Iterator e = sl.searchAndRetrieveList("Descrip")
213:                            .iterator(); e.hasNext();) {
214:                        oneSchema = (SchemaList) e.next();
215:                        v2.addElement(new ValidValue(oneSchema
216:                                .getField("SchemaClass"), oneSchema
217:                                .getField("Descrip")));
218:                    }
219:
220:                    chooseSchema.setValidValues(v2);
221:                    response.addInput(chooseSchema);
222:
223:                    Transition doDBObj = new Transition(
224:                            "Choose Database Object", getClass().getName());
225:                    doDBObj.setName("selDBObj");
226:                    doDBObj.addParam(STATE_PARAM_KEY, "selDBObj");
227:                    response.addTransition(doDBObj);
228:                } catch (DBException de) {
229:                    throw new ControllerException(de.getMessage());
230:                }
231:            } /* promptState() */
232:
233:            /**
234:             * Prompt for a database object to maintain from the specified schema.  The
235:             * schema is either a direct parameter or selected from the Prompt State.
236:             *
237:             * @param request  The <code>ControllerRequest</code> object
238:             * @param response The <code>ControllerResponse</code> object
239:             * @throws ControllerException upon error.
240:             */
241:            private void runSelDBObjState(ControllerRequest request,
242:                    ControllerResponse response) throws ControllerException {
243:                Input chooseDBobj = new Input();
244:                chooseDBobj.setLabel("Choose Database Object");
245:                chooseDBobj.setName("dbobj");
246:
247:                Vector v2 = new Vector();
248:
249:                try {
250:                    DBObject oneDBObject = null;
251:                    Schema mySchema = SchemaFactory.getInstance().getSchema(
252:                            request.getParameter("SchemaClass"));
253:                    if (mySchema == null) {
254:                        throw new ControllerException(
255:                                "Error instantiating Schema: "
256:                                        + request.getParameter("SchemaClass"));
257:                    }
258:
259:                    for (Enumeration e = mySchema.getMembers(); e
260:                            .hasMoreElements();) {
261:                        oneDBObject = (DBObject) e.nextElement();
262:                        String descrip = oneDBObject.getMetaData()
263:                                .getDescription(request.getLocale());
264:                        if (log.isDebugEnabled()) {
265:                            log.debug("Adding dataobject: " + descrip);
266:                        }
267:
268:                        v2.addElement(new ValidValue(oneDBObject.getClass()
269:                                .getName(), oneDBObject.getMetaData()
270:                                .getDescription(request.getLocale())));
271:                    }
272:
273:                    DBOtherMap otherDbobj = new DBOtherMap(
274:                            SecuredDBObject.SYSTEM_ACCOUNT);
275:                    otherDbobj.setDataContext(request.getDataContext());
276:
277:                } catch (DBException de) {
278:                    throw new ControllerException(de);
279:                }
280:
281:                chooseDBobj.setValidValues(v2);
282:                response.addInput(chooseDBobj);
283:                response.addTransition(new Transition(ADD, this ));
284:                response.addTransition(new Transition(LIST, this ));
285:                response.addTransition(new Transition(SEARCH, this ));
286:            } /* selDBObj(ControllerRequest, ControllerResponse) */
287:
288:        } /* DBMaint */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.