Source Code Cross Referenced for CmpRelationRole.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » ejb » cfg21 » 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 » EJB Server resin 3.1.5 » resin » com.caucho.ejb.cfg21 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *   Free SoftwareFoundation, Inc.
023:         *   59 Temple Place, Suite 330
024:         *   Boston, MA 02111-1307  USA
025:         *
026:         * @author Scott Ferguson
027:         */
028:
029:        package com.caucho.ejb.cfg21;
030:
031:        import com.caucho.ejb.cfg.*;
032:        import com.caucho.ejb.cfg21.CmpRelation;
033:        import com.caucho.amber.field.AbstractField;
034:        import com.caucho.config.ConfigException;
035:        import com.caucho.util.L10N;
036:
037:        import javax.annotation.PostConstruct;
038:        import java.util.Collection;
039:
040:        /**
041:         * Configuration for a cmp-relation.
042:         */
043:        public class CmpRelationRole {
044:            private static L10N L = new L10N(CmpRelationRole.class);
045:
046:            private CmpRelation _relation;
047:            private CmpRelationRole _target;
048:
049:            private String _location;
050:
051:            private String _ejbName;
052:            private String _fieldName;
053:
054:            private boolean _cascadeDelete;
055:            private String _multiplicity;
056:
057:            private SqlRelation[] _sqlColumns = new SqlRelation[0];
058:            private String _orderBy;
059:
060:            private AbstractField _amberField;
061:            private Class _javaType;
062:
063:            private boolean _isImplicit;
064:
065:            /**
066:             * Creates a new cmp-relation
067:             */
068:            public CmpRelationRole(CmpRelation relation) {
069:                _relation = relation;
070:            }
071:
072:            /**
073:             * Sets the description.
074:             */
075:            public void setDescription(String description) {
076:            }
077:
078:            /**
079:             * Gets the owning relation.
080:             */
081:            public CmpRelation getRelation() {
082:                return _relation;
083:            }
084:
085:            /**
086:             * Gets the target
087:             */
088:            public CmpRelationRole getTarget() {
089:                return _target;
090:            }
091:
092:            /**
093:             * Sets the target
094:             */
095:            public void setTarget(CmpRelationRole target) {
096:                _target = target;
097:            }
098:
099:            /**
100:             * Sets the location.
101:             */
102:            public void setConfigLocation(String filename, int line) {
103:                _location = filename + ":" + line + ": ";
104:            }
105:
106:            /**
107:             * Gets the location.
108:             */
109:            public String getLocation() {
110:                return _location;
111:            }
112:
113:            /**
114:             * Sets the ejb-relationship-role-name
115:             */
116:            public void setEjbRelationshipRoleName(String name) {
117:            }
118:
119:            /**
120:             * Returns the source ejb name.
121:             */
122:            public String getEJBName() {
123:                return _ejbName;
124:            }
125:
126:            /**
127:             * Sets the ejb-name.
128:             */
129:            public void setEJBName(String ejbName) {
130:                _ejbName = ejbName;
131:            }
132:
133:            /**
134:             * Returns the field name.
135:             */
136:            public String getFieldName() {
137:                return _fieldName;
138:            }
139:
140:            /**
141:             * Sets the field name.
142:             */
143:            public void setFieldName(String fieldName) {
144:                _fieldName = fieldName;
145:            }
146:
147:            /**
148:             * Returns the cascade-delete property.
149:             */
150:            public boolean getCascadeDelete() {
151:                return _cascadeDelete;
152:            }
153:
154:            /**
155:             * Sets the cascade-delete property.
156:             */
157:            public void setCascadeDelete(boolean cascadeDelete) {
158:                _cascadeDelete = cascadeDelete;
159:            }
160:
161:            /**
162:             * Returns the multiplicity property.
163:             */
164:            public String getMultiplicity() {
165:                return _multiplicity;
166:            }
167:
168:            /**
169:             * Sets the source multiplicity property.
170:             */
171:            public void setMultiplicity(String multiplicity)
172:                    throws ConfigException {
173:                _multiplicity = multiplicity;
174:
175:                if (multiplicity == null || !multiplicity.equals("One")
176:                        && !multiplicity.equals("Many"))
177:                    throw new ConfigException(
178:                            L
179:                                    .l(
180:                                            "'{0}' is an unknown multiplicity.  'One' and 'Many' are the only allowed values.",
181:                                            multiplicity));
182:            }
183:
184:            /**
185:             * Returns the source sql columns.
186:             */
187:            public SqlRelation[] getSQLColumns() {
188:                return _sqlColumns;
189:            }
190:
191:            /**
192:             * Add a sql columns.
193:             */
194:            public void addSQLColumn(String sqlColumn, String references) {
195:                SqlRelation relation = new SqlRelation(_fieldName);
196:
197:                relation.setSQLColumn(sqlColumn);
198:                relation.setReferences(references);
199:
200:                if (_sqlColumns == null)
201:                    _sqlColumns = new SqlRelation[] { relation };
202:                else {
203:                    SqlRelation[] newColumns = new SqlRelation[_sqlColumns.length + 1];
204:                    System.arraycopy(_sqlColumns, 0, newColumns, 0,
205:                            _sqlColumns.length);
206:
207:                    newColumns[_sqlColumns.length] = relation;
208:                    _sqlColumns = newColumns;
209:                }
210:            }
211:
212:            public SqlColumn createSqlColumn() {
213:                return new SqlColumn();
214:            }
215:
216:            /**
217:             * Returns the order-by property.
218:             */
219:            public String getOrderBy() {
220:                return _orderBy;
221:            }
222:
223:            /**
224:             * Sets the order-by property.
225:             */
226:            public void setOrderBy(String orderBy) {
227:                _orderBy = orderBy;
228:            }
229:
230:            /**
231:             * Returns true if the role is implicit.
232:             */
233:            public boolean isImplicit() {
234:                return _isImplicit;
235:            }
236:
237:            /**
238:             * Sets true if the role is implicit.
239:             */
240:            public void setImplicit(boolean isImplicit) {
241:                _isImplicit = isImplicit;
242:            }
243:
244:            /**
245:             * Sets the Java type.
246:             */
247:            public void setJavaType(Class cl) {
248:                _javaType = cl;
249:            }
250:
251:            /**
252:             * Sets the amber type.
253:             */
254:            public void setAmberField(AbstractField field) {
255:                _amberField = field;
256:            }
257:
258:            /**
259:             * Gets the amber type.
260:             */
261:            public AbstractField getAmberField() {
262:                return _amberField;
263:            }
264:
265:            /**
266:             * Return true for collections.
267:             */
268:            public boolean isCollection() {
269:                return _javaType != null
270:                        && Collection.class.isAssignableFrom(_javaType);
271:            }
272:
273:            /**
274:             * Merges with the target.
275:             */
276:            public void merge(CmpRelationRole newRole) {
277:                if (_sqlColumns.length == 0)
278:                    _sqlColumns = newRole.getSQLColumns();
279:            }
280:
281:            // EJB config
282:
283:            /**
284:             * Sets the relationship-role-source.
285:             */
286:            public RoleSource createRelationshipRoleSource() {
287:                return new RoleSource();
288:            }
289:
290:            /**
291:             * Sets the relationship-role-source.
292:             */
293:            public CmrField createCmrField() {
294:                return new CmrField();
295:            }
296:
297:            /**
298:             * Returns true if this is the same relation.
299:             */
300:            public boolean equals(Object o) {
301:                if (!(o instanceof  CmpRelationRole))
302:                    return false;
303:
304:                CmpRelationRole role = (CmpRelationRole) o;
305:
306:                if (!_ejbName.equals(role._ejbName))
307:                    return false;
308:
309:                if (_fieldName == null || role._fieldName == null)
310:                    return _fieldName == role._fieldName;
311:
312:                if (!_fieldName.equals(role._fieldName))
313:                    return false;
314:
315:                return true;
316:            }
317:
318:            public class RoleSource {
319:                public void setEJBName(String name) {
320:                    CmpRelationRole.this .setEJBName(name);
321:                }
322:            }
323:
324:            public class CmrField {
325:                public void setCmrFieldName(String name) {
326:                    CmpRelationRole.this .setFieldName(name);
327:                }
328:
329:                public void setCmrFieldType(String name) {
330:                    // XXX: CmpRelationRole.this.setFieldName(name);
331:                }
332:
333:                public SqlColumn createSqlColumn() {
334:                    return new SqlColumn();
335:                }
336:            }
337:
338:            public class SqlColumn {
339:                private String _value;
340:                private String _references;
341:
342:                public void setReferences(String references) {
343:                    _references = references;
344:                }
345:
346:                public void setValue(String value) {
347:                    _value = value;
348:                }
349:
350:                public void addText(String value) {
351:                    _value = value;
352:                }
353:
354:                @PostConstruct
355:                public void init() {
356:                    CmpRelationRole.this.addSQLColumn(_value, _references);
357:                }
358:            }
359:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.