Source Code Cross Referenced for BOAttributeImpl.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 javax.naming.Context;
018:        import javax.naming.InitialContext;
019:        import javax.naming.NamingException;
020:
021:        import com.metaboss.enterprise.bo.BOException;
022:        import com.metaboss.enterprise.bo.BOIllegalArgumentException;
023:        import com.metaboss.enterprise.bo.BOInvalidOperationForReadOnlyObjectException;
024:        import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
025:        import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
026:        import com.metaboss.enterprise.ps.PSException;
027:        import com.metaboss.sdlctools.domains.enterprisemodel.BOAttribute;
028:        import com.metaboss.sdlctools.domains.enterprisemodel.BODatatype;
029:        import com.metaboss.sdlctools.domains.enterprisemodel.BOEntity;
030:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSEntity;
031:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STAttribute;
032:        import com.metaboss.sdlctools.types.enterprisemodel.AttributeStereotype;
033:        import com.oldboss.framework.bo.BOTransaction;
034:        import com.oldboss.framework.bo.impl.BOObjectImpl;
035:
036:        public class BOAttributeImpl extends BOObjectImpl implements 
037:                BOAttribute {
038:            protected BOMetaBossDomainImpl mMetaBossDomainImpl = null;
039:            private String mAttributeRef = null;
040:            private BOEntity mOwnerEntity = null;
041:            private STAttribute mDetailsBackup = null;
042:            protected STAttribute mDetails = null;
043:
044:            /* Instance creator */
045:            public static BOAttribute createInstanceForExisting(
046:                    BOMetaBossDomainImpl pMetaBossDomainImpl,
047:                    BOEntity pOwnerEntity, STAttribute pDetails)
048:                    throws BOException {
049:                // Do some argument checking
050:                if (pDetails == null)
051:                    throw new BOIllegalArgumentException(
052:                            "Empty details structure");
053:                String lAttributeRef = pOwnerEntity.getRef() + "."
054:                        + pDetails.Name;
055:                // See if we have this object in cache
056:                BOAttributeImpl lImpl = (BOAttributeImpl) pMetaBossDomainImpl
057:                        .retrieveExistingBOInstance(BOAttribute.class,
058:                                lAttributeRef);
059:                if (lImpl != null)
060:                    return lImpl;
061:                lImpl = new BOAttributeImpl();
062:                lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
063:                lImpl.mOwnerEntity = pOwnerEntity;
064:                lImpl.mDetails = pDetails;
065:                lImpl.mAttributeRef = lAttributeRef;
066:                lImpl.setupForExisting();
067:                pMetaBossDomainImpl.saveNewBOInstance(BOAttribute.class,
068:                        lAttributeRef, lImpl);
069:                return lImpl;
070:            }
071:
072:            /* Instance creator */
073:            public static BOAttribute createInstanceForNew(
074:                    BOTransaction pTransaction,
075:                    BOMetaBossDomainImpl pMetaBossDomainImpl,
076:                    BOEntity pOwnerEntity, String pName) throws BOException {
077:                String lAttributeRef = pOwnerEntity.getRef() + "." + pName;
078:                // See if we have this object in cache already
079:                BOAttributeImpl lImpl = (BOAttributeImpl) pMetaBossDomainImpl
080:                        .retrieveExistingBOInstance(BOAttribute.class,
081:                                lAttributeRef);
082:                if (lImpl != null)
083:                    throw new BOIllegalArgumentException(
084:                            "Attribute already exists. AttributeRef: "
085:                                    + lAttributeRef);
086:                lImpl = new BOAttributeImpl();
087:                lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
088:                lImpl.mOwnerEntity = pOwnerEntity;
089:                lImpl.mDetails = new STAttribute();
090:                lImpl.mDetails.Name = pName;
091:                lImpl.mAttributeRef = lAttributeRef;
092:                lImpl.setupForNew(pTransaction);
093:                pMetaBossDomainImpl.saveNewBOInstance(BOAttribute.class,
094:                        lAttributeRef, lImpl);
095:                return lImpl;
096:            }
097:
098:            /* Private constructor restricts instance creation from outside */
099:            private BOAttributeImpl() throws BOException {
100:            }
101:
102:            /* Returns entity which owns this attribute */
103:            public BOEntity getEntity() throws BOException {
104:                return mOwnerEntity;
105:            }
106:
107:            /* Retrieves element's name. Name is only unique within parent entity */
108:            public String getName() throws BOException {
109:                return mDetails.Name;
110:            }
111:
112:            /* Retrieves element's reference. eference is unique globally for the type. */
113:            public String getRef() throws BOException {
114:                return mAttributeRef;
115:            }
116:
117:            /* Returns true if this attribute can be used for ordering */
118:            public boolean getCanUseForOrdering() throws BOException {
119:                return mDetails.CanUseForOrdering;
120:            }
121:
122:            /* Sets flag if this attribute can be use for ordering */
123:            public void setCanUseForOrdering(boolean pCanUseForOrdering)
124:                    throws BOException {
125:                if (!isBeingEdited())
126:                    throw new BOInvalidOperationForReadOnlyObjectException();
127:                mDetails.CanUseForOrdering = pCanUseForOrdering;
128:            }
129:
130:            /* Returns element's  description */
131:            public String getDescription() throws BOException {
132:                return mDetails.Description;
133:            }
134:
135:            /* Sets description */
136:            public void setDescription(String pDescription) throws BOException {
137:                if (!isBeingEdited())
138:                    throw new BOInvalidOperationForReadOnlyObjectException();
139:                mDetails.Description = pDescription;
140:            }
141:
142:            /* Returns stereotype for this attribute */
143:            public AttributeStereotype getStereotype() throws BOException {
144:                return mDetails.Stereotype;
145:            }
146:
147:            /* Sets stereotype for this attribute */
148:            public void setStereotype(AttributeStereotype pStereotype)
149:                    throws BOException {
150:                if (!isBeingEdited())
151:                    throw new BOInvalidOperationForReadOnlyObjectException();
152:                mDetails.Stereotype = pStereotype;
153:            }
154:
155:            /* Retrieves corresponing data type */
156:            public BODatatype getDatatype() throws BOException {
157:                return BODatatypeImpl.createInstanceForExisting(
158:                        mMetaBossDomainImpl, mDetails.DataTypeRef);
159:            }
160:
161:            /* Sets datatype for this attribute */
162:            public void setDatatype(BODatatype pDatatype) throws BOException {
163:                if (!isBeingEdited())
164:                    throw new BOInvalidOperationForReadOnlyObjectException();
165:                mDetails.DataTypeRef = pDatatype.getRef();
166:            }
167:
168:            /* Overriden to provide check reference equality */
169:            public boolean equals(Object pOther) {
170:                if (pOther == null)
171:                    return false;
172:                if (!(pOther instanceof  BOAttributeImpl))
173:                    return false;
174:                return ((BOAttributeImpl) pOther).mAttributeRef
175:                        .equals(mAttributeRef);
176:            }
177:
178:            // Overriden to de-register from the owner and ensure that
179:            // it is not referenced in any place
180:            protected void onDelete() throws BOException {
181:                BOEntityAttributeListImpl lEntityAttributeListImpl = (BOEntityAttributeListImpl) mOwnerEntity
182:                        .getAttributes();
183:                lEntityAttributeListImpl.beginEdit(fetchTransaction());
184:                lEntityAttributeListImpl.onDeleteAttribute(this );
185:            }
186:
187:            // Overriden to load details and backup original list
188:            protected void onBeginEdit() throws BOException {
189:                // Preserve old values
190:                mDetailsBackup = mDetails;
191:            }
192:
193:            /* Encapsulates commit action by this object */
194:            protected void onCommitCreation() throws BOException {
195:                try {
196:                    // Get the instance of the enterprise ps home via jndi
197:                    Context lCtx = new InitialContext();
198:                    PSEntity lPs = (PSEntity) lCtx
199:                            .lookup(PSEntity.COMPONENT_URL);
200:                    lPs.insertAttribute(mOwnerEntity.getRef(), mDetails);
201:                } catch (NamingException e) {
202:                    throw new BONamingAndDirectoryServiceInvocationException(
203:                            "", e);
204:                } catch (PSException e) {
205:                    throw new BOPersistenceServiceInvocationException("", e);
206:                }
207:            }
208:
209:            /* Encapsulates commit action by this object */
210:            protected void onCommitUpdate() throws BOException {
211:                try {
212:                    // Get the instance of the enterprise ps home via jndi
213:                    Context lCtx = new InitialContext();
214:                    PSEntity lPs = (PSEntity) lCtx
215:                            .lookup(PSEntity.COMPONENT_URL);
216:                    lPs.updateAttribute(mOwnerEntity.getRef(), mDetails);
217:                } catch (NamingException e) {
218:                    throw new BONamingAndDirectoryServiceInvocationException(
219:                            "", e);
220:                } catch (PSException e) {
221:                    throw new BOPersistenceServiceInvocationException("", e);
222:                }
223:            }
224:
225:            protected void onCommitDeletion() throws BOException {
226:                try {
227:                    // Get the instance of the enterprise ps home via jndi
228:                    Context lCtx = new InitialContext();
229:                    PSEntity lPs = (PSEntity) lCtx
230:                            .lookup(PSEntity.COMPONENT_URL);
231:                    lPs.deleteAttribute(mOwnerEntity.getRef(), mDetails.Name);
232:                } catch (NamingException e) {
233:                    throw new BONamingAndDirectoryServiceInvocationException(
234:                            "", e);
235:                } catch (PSException e) {
236:                    throw new BOPersistenceServiceInvocationException("", e);
237:                }
238:            }
239:
240:            /* Encapsulates an action after successfull commit */
241:            public void onCommitSucceeded() throws BOException {
242:                mDetailsBackup = null;
243:                if (isDeleted())
244:                    mMetaBossDomainImpl.removeExistingBOInstance(
245:                            BOAttribute.class, mAttributeRef);
246:            }
247:
248:            // Overriddden to cleanup this object from cache
249:            protected void onRollbackCreation() throws BOException {
250:                mMetaBossDomainImpl.removeExistingBOInstance(BOAttribute.class,
251:                        mAttributeRef);
252:            }
253:
254:            // Overriddden to restore this object's status to pre-begin edit state
255:            protected void onRollbackUpdate() throws BOException {
256:                mDetails = mDetailsBackup;
257:                mDetailsBackup = null;
258:            }
259:
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.