Source Code Cross Referenced for BODatatypeImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » domains » enterprisemodel » impl » 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 » UML » MetaBoss » com.metaboss.sdlctools.domains.enterprisemodel.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.domains.enterprisemodel.impl;
016:
017:        import java.util.Iterator;
018:        import java.util.Properties;
019:        import java.util.StringTokenizer;
020:
021:        import javax.naming.Context;
022:        import javax.naming.InitialContext;
023:        import javax.naming.NamingException;
024:
025:        import com.metaboss.enterprise.bo.BOException;
026:        import com.metaboss.enterprise.bo.BOIllegalArgumentException;
027:        import com.metaboss.enterprise.bo.BOInvalidOperationForReadOnlyObjectException;
028:        import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
029:        import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
030:        import com.metaboss.enterprise.ps.PSException;
031:        import com.metaboss.sdlctools.domains.enterprisemodel.BODatatype;
032:        import com.metaboss.sdlctools.domains.enterprisemodel.BOSystem;
033:        import com.metaboss.sdlctools.domains.enterprisemodel.BOTypetemplate;
034:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSDatatype;
035:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STDatatype;
036:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STProperty;
037:        import com.oldboss.framework.bo.BOTransaction;
038:        import com.oldboss.framework.bo.impl.BOObjectImpl;
039:
040:        public class BODatatypeImpl extends BOObjectImpl implements  BODatatype {
041:            private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
042:            private BOSystem mOwnerSystem = null; // Optional
043:            private String mDatatypeRef = null;
044:            private STDatatype mDetails = null;
045:
046:            /* Instance creator */
047:            public static BODatatype createInstanceForExisting(
048:                    BOMetaBossDomainImpl pMetaBossDomainImpl,
049:                    String pDatatypeRef) throws BOException {
050:                // See if we have this object in cache
051:                BODatatypeImpl lImpl = (BODatatypeImpl) pMetaBossDomainImpl
052:                        .retrieveExistingBOInstance(BODatatype.class,
053:                                pDatatypeRef);
054:                if (lImpl != null)
055:                    return lImpl;
056:                lImpl = new BODatatypeImpl();
057:                lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
058:                lImpl.mDatatypeRef = pDatatypeRef;
059:                if (!pDatatypeRef.startsWith(".")) {
060:                    StringTokenizer lTokenizer = new StringTokenizer(
061:                            pDatatypeRef, ".", false);
062:                    if (lTokenizer.countTokens() <= 2)
063:                        throw new BOIllegalArgumentException(
064:                                "Invalid DatatypeRef:" + pDatatypeRef);
065:                    lImpl.mOwnerSystem = BOSystemImpl
066:                            .createInstanceForExisting(pMetaBossDomainImpl,
067:                                    lTokenizer.nextToken() + "."
068:                                            + lTokenizer.nextToken());
069:                }
070:                lImpl.setupForExisting();
071:                return lImpl;
072:            }
073:
074:            /* Instance creator */
075:            public static BODatatype createInstanceForNew(
076:                    BOTransaction pTransaction,
077:                    BOMetaBossDomainImpl pMetaBossDomainImpl,
078:                    String pDatatypeRef) throws BOException {
079:                // See if we have this object in cache
080:                BODatatypeImpl lImpl = (BODatatypeImpl) pMetaBossDomainImpl
081:                        .retrieveExistingBOInstance(BODatatype.class,
082:                                pDatatypeRef);
083:                if (lImpl != null)
084:                    throw new BOIllegalArgumentException(
085:                            "Datatype already exists. DatatypeRef: "
086:                                    + pDatatypeRef);
087:                lImpl = new BODatatypeImpl();
088:                lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
089:                lImpl.mDatatypeRef = pDatatypeRef;
090:                lImpl.mDetails = new STDatatype();
091:                lImpl.mDetails.DatatypeRef = pDatatypeRef;
092:                if (!pDatatypeRef.startsWith(".")) {
093:                    StringTokenizer lTokenizer = new StringTokenizer(
094:                            pDatatypeRef, ".", false);
095:                    if (lTokenizer.countTokens() <= 2)
096:                        throw new BOIllegalArgumentException(
097:                                "Invalid DatatypeRef:" + pDatatypeRef);
098:                    lImpl.mOwnerSystem = BOSystemImpl
099:                            .createInstanceForExisting(pMetaBossDomainImpl,
100:                                    lTokenizer.nextToken() + "."
101:                                            + lTokenizer.nextToken());
102:                }
103:                lImpl.setupForNew(pTransaction);
104:                pMetaBossDomainImpl.saveNewBOInstance(BODatatype.class,
105:                        pDatatypeRef, lImpl);
106:                return lImpl;
107:            }
108:
109:            /* Private constructor restricts instance creation from outside */
110:            private BODatatypeImpl() throws BOException {
111:            }
112:
113:            /* Retrieves unique reference */
114:            public String getRef() throws BOException {
115:                return mDatatypeRef;
116:            }
117:
118:            /** @return BOSystem which owns this datatype if this datatype is owned by System or null otherwise */
119:            public BOSystem getOwnerSystem() throws BOException {
120:                return mOwnerSystem;
121:            }
122:
123:            /* Retrieves dataype name. Usually last part of the reference.
124:             *  name is only unique within its package */
125:            public String getName() throws BOException {
126:                String lRef = getRef();
127:                return lRef.substring(lRef.lastIndexOf(".") + 1);
128:            }
129:
130:            /* Retrieves description */
131:            public String getDescription() throws BOException {
132:                loadDetailsIfNecessary();
133:                return mDetails.Description;
134:            }
135:
136:            /* Retrieves description */
137:            public void setDescription(String pDescription) throws BOException {
138:                if (!isBeingEdited())
139:                    throw new BOInvalidOperationForReadOnlyObjectException();
140:                mDetails.Description = pDescription;
141:            }
142:
143:            /* Returns properties to be used during datatype generation */
144:            public Properties getTypetemplateProperties() throws BOException {
145:                loadDetailsIfNecessary();
146:                Properties lReturn = new Properties();
147:                for (int i = 0; i < mDetails.TypeTemplateProperties.length; i++) {
148:                    STProperty lProp = mDetails.TypeTemplateProperties[i];
149:                    lReturn.setProperty(lProp.Name, lProp.Value);
150:                }
151:                return lReturn;
152:            }
153:
154:            /* Stores storage class properties */
155:            public void setTypetemplateProperties(
156:                    Properties pTypetemplateProperties) throws BOException {
157:                if (!isBeingEdited())
158:                    throw new BOInvalidOperationForReadOnlyObjectException();
159:                if (pTypetemplateProperties == null) {
160:                    mDetails.TypeTemplateProperties = new STProperty[0];
161:                    return;
162:                }
163:                mDetails.TypeTemplateProperties = new STProperty[pTypetemplateProperties
164:                        .size()];
165:                Iterator lIter = pTypetemplateProperties.entrySet().iterator();
166:                for (int i = 0; lIter.hasNext(); i++) {
167:                    java.util.Map.Entry lEntry = (java.util.Map.Entry) lIter
168:                            .next();
169:                    STProperty lProperty = new STProperty();
170:                    lProperty.Name = (String) lEntry.getKey();
171:                    lProperty.Value = (String) lEntry.getValue();
172:                    mDetails.TypeTemplateProperties[i] = lProperty;
173:                }
174:            }
175:
176:            /* Retrieves optional type template */
177:            public BOTypetemplate getTypetemplate() throws BOException {
178:                loadDetailsIfNecessary();
179:                if (mDetails.TypeTemplateRef != null
180:                        && mDetails.TypeTemplateRef.length() > 0)
181:                    return BOTypetemplateImpl.createInstanceForExisting(
182:                            mMetaBossDomainImpl, mDetails.TypeTemplateRef);
183:                return null;
184:            }
185:
186:            // By setting typetemplate this datatype is made into a template data type (not explicit)
187:            public void setTypetemplate(BOTypetemplate pTypetemplate)
188:                    throws BOException {
189:                if (!isBeingEdited())
190:                    throw new BOInvalidOperationForReadOnlyObjectException();
191:                if (pTypetemplate == null)
192:                    mDetails.TypeTemplateRef = null;
193:                else
194:                    mDetails.TypeTemplateRef = pTypetemplate.getRef();
195:            }
196:
197:            /* Retrieves the data type property or null if none exists */
198:            public String getSource() throws BOException {
199:                loadDetailsIfNecessary();
200:                try {
201:                    // Get the instance of the enterprise ps home via jndi
202:                    Context ctx = new InitialContext();
203:                    PSDatatype lPs = (PSDatatype) ctx
204:                            .lookup(PSDatatype.COMPONENT_URL);
205:
206:                    String lSource = lPs.getDatatypeSource(mDatatypeRef);
207:                    if (lSource == null)
208:                        throw new BOException(
209:                                "Source for the Datatype not found. (DatatypeRef:"
210:                                        + mDatatypeRef + ")");
211:                    return lSource;
212:                } catch (NamingException e) {
213:                    throw new BONamingAndDirectoryServiceInvocationException(
214:                            "", e);
215:                } catch (PSException e) {
216:                    throw new BOPersistenceServiceInvocationException("", e);
217:                }
218:            }
219:
220:            /* Retrieves the data type storage  source */
221:            public String getJDBCHelperSource() throws BOException {
222:                loadDetailsIfNecessary();
223:                try {
224:                    // Get the instance of the enterprise ps home via jndi
225:                    Context ctx = new InitialContext();
226:                    PSDatatype lPs = (PSDatatype) ctx
227:                            .lookup(PSDatatype.COMPONENT_URL);
228:
229:                    String lSource = lPs.getJDBCHelperSource(mDatatypeRef);
230:                    if (lSource == null)
231:                        throw new BOException(
232:                                "JDBC Helper source for the Datatype not found. (DatatypeRef:"
233:                                        + mDatatypeRef + ")");
234:                    return lSource;
235:                } catch (NamingException e) {
236:                    throw new BONamingAndDirectoryServiceInvocationException(
237:                            "", e);
238:                } catch (PSException e) {
239:                    throw new BOPersistenceServiceInvocationException("", e);
240:                }
241:            }
242:
243:            protected void loadDetailsIfNecessary() throws BOException {
244:                if (mDetails == null) {
245:                    try {
246:                        // Get the instance of the enterprise ps home via jndi
247:                        Context ctx = new InitialContext();
248:                        PSDatatype lPs = (PSDatatype) ctx
249:                                .lookup(PSDatatype.COMPONENT_URL);
250:
251:                        mDetails = lPs.getDatatype(mDatatypeRef);
252:                        if (mDetails == null)
253:                            throw new BOException(
254:                                    "Datatype not found. (DatatypeRef:"
255:                                            + mDatatypeRef + ")");
256:                    } catch (NamingException e) {
257:                        throw new BONamingAndDirectoryServiceInvocationException(
258:                                "", e);
259:                    } catch (PSException e) {
260:                        throw new BOPersistenceServiceInvocationException(
261:                                "Exception caught during processing of Data Type. DatatypeRef : "
262:                                        + mDatatypeRef, e);
263:                    }
264:                }
265:            }
266:
267:            /* Overriden to provide check reference equality */
268:            public boolean equals(Object pOther) {
269:                if (pOther == null)
270:                    return false;
271:                if (!(pOther instanceof  BODatatypeImpl))
272:                    return false;
273:                return ((BODatatypeImpl) pOther).mDatatypeRef
274:                        .equals(mDatatypeRef);
275:            }
276:
277:            protected void onBeginEdit() throws BOException {
278:                // Fully load the object
279:                loadDetailsIfNecessary();
280:            }
281:
282:            protected void onCommitUpdate() throws BOException {
283:                try {
284:                    // Get the instance of the enterprise ps home via jndi
285:                    Context ctx = new InitialContext();
286:                    PSDatatype lPs = (PSDatatype) ctx
287:                            .lookup(PSDatatype.COMPONENT_URL);
288:                    lPs.updateDatatype(mDetails);
289:                } catch (NamingException e) {
290:                    throw new BONamingAndDirectoryServiceInvocationException(
291:                            "", e);
292:                } catch (PSException e) {
293:                    throw new BOPersistenceServiceInvocationException("", e);
294:                }
295:            }
296:
297:            protected void onCommitCreation() throws BOException {
298:                try {
299:                    // Get the instance of the enterprise ps home via jndi
300:                    Context ctx = new InitialContext();
301:                    PSDatatype lPs = (PSDatatype) ctx
302:                            .lookup(PSDatatype.COMPONENT_URL);
303:                    lPs.insertDatatype(mDetails);
304:                } catch (NamingException e) {
305:                    throw new BONamingAndDirectoryServiceInvocationException(
306:                            "", e);
307:                } catch (PSException e) {
308:                    throw new BOPersistenceServiceInvocationException("", e);
309:                }
310:            }
311:
312:            protected void onCommitDeletion() throws BOException {
313:                try {
314:                    // Get the instance of the enterprise ps home via jndi
315:                    Context ctx = new InitialContext();
316:                    PSDatatype lPs = (PSDatatype) ctx
317:                            .lookup(PSDatatype.COMPONENT_URL);
318:                    lPs.deleteDatatype(mDatatypeRef);
319:                } catch (NamingException e) {
320:                    throw new BONamingAndDirectoryServiceInvocationException(
321:                            "", e);
322:                } catch (PSException e) {
323:                    throw new BOPersistenceServiceInvocationException("", e);
324:                }
325:            }
326:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.