Source Code Cross Referenced for BOEnterpriseSystemListImpl.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.ArrayList;
018:        import java.util.Arrays;
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        import javax.naming.Context;
023:        import javax.naming.InitialContext;
024:        import javax.naming.NamingException;
025:
026:        import com.metaboss.enterprise.bo.BOException;
027:        import com.metaboss.enterprise.bo.BOIllegalArgumentException;
028:        import com.metaboss.enterprise.bo.BOInvalidOperationForObjectException;
029:        import com.metaboss.enterprise.bo.BOInvalidOperationForReadOnlyObjectException;
030:        import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
031:        import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
032:        import com.metaboss.enterprise.bo.BOUnexpectedProgramConditionException;
033:        import com.metaboss.enterprise.ps.PSException;
034:        import com.metaboss.sdlctools.domains.enterprisemodel.BOEnterprise;
035:        import com.metaboss.sdlctools.domains.enterprisemodel.BOEnterpriseSystemList;
036:        import com.metaboss.sdlctools.domains.enterprisemodel.BOSystem;
037:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSEnterprise;
038:        import com.oldboss.framework.bo.impl.BOObjectImpl;
039:
040:        public class BOEnterpriseSystemListImpl extends BOObjectImpl implements 
041:                BOEnterpriseSystemList {
042:            private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
043:            private BOEnterprise mEnterprise = null;
044:            private BOSystem[] mDetailsBackup = null;
045:            private List mDetails = null;
046:
047:            /* Instance creator */
048:            public static BOEnterpriseSystemList createInstanceForExisting(
049:                    BOMetaBossDomainImpl pMetaBossDomainImpl,
050:                    BOEnterprise pEnterprise) throws BOException {
051:                // List is cached individually by it's owner
052:                BOEnterpriseSystemListImpl lImpl = new BOEnterpriseSystemListImpl();
053:                lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
054:                lImpl.mEnterprise = pEnterprise;
055:                lImpl.setupForExisting();
056:                return lImpl;
057:            }
058:
059:            /* Private constructor restricts instance creation from outside */
060:            private BOEnterpriseSystemListImpl() throws BOException {
061:            }
062:
063:            /* Retrieves all systems defined in this enterprise */
064:            public BOSystem[] getAllSystems() throws BOException {
065:                loadDetailsIfNecessary();
066:                return (BOSystem[]) mDetails.toArray(new BOSystem[mDetails
067:                        .size()]);
068:            }
069:
070:            /* Retrieves the system corresponding to given reference from this enteprise */
071:            public BOSystem getSystem(String pSystemRef) throws BOException {
072:                if (pSystemRef == null
073:                        || pSystemRef.startsWith(mEnterprise.getRef()) == false)
074:                    return null; // No way this enteprise has given datatype
075:                loadDetailsIfNecessary();
076:                Iterator lIter = mDetails.iterator();
077:                while (lIter.hasNext()) {
078:                    BOSystem lSystem = (BOSystem) lIter.next();
079:                    if (lSystem.getRef().equals(pSystemRef))
080:                        return lSystem;
081:                }
082:                return null;
083:            }
084:
085:            /* Creates new system in this enterprise. */
086:            public BOSystem createSystem(String pSystemRef) throws BOException {
087:                // Check if this servicemodule even belongs to this enteprise
088:                if (!pSystemRef.startsWith(mEnterprise.getRef() + "."))
089:                    throw new BOIllegalArgumentException("SystemRef "
090:                            + pSystemRef
091:                            + " is not valid within enterprise. SystemRef: "
092:                            + pSystemRef + " EnterpriseRef: "
093:                            + mEnterprise.getRef());
094:                if (!isBeingEdited())
095:                    throw new BOInvalidOperationForReadOnlyObjectException();
096:                // Check if we can create system with the given ref
097:                BOSystem[] lSystems = getAllSystems();
098:                for (int i = 0; i < lSystems.length; i++) {
099:                    if (lSystems[i].getRef().equals(pSystemRef))
100:                        throw new BOIllegalArgumentException(
101:                                "Unable to create System with ref '"
102:                                        + pSystemRef
103:                                        + ".  System with the same ref already exists.");
104:                }
105:                BOSystem lSystem = BOSystemImpl.createInstanceForNew(
106:                        fetchTransaction(), mMetaBossDomainImpl, pSystemRef);
107:                mDetails.add(lSystem);
108:                return lSystem;
109:            }
110:
111:            private void loadDetailsIfNecessary() throws BOException {
112:                if (mDetails == null) {
113:                    try {
114:                        // Get the instance of the enterprise ps home via jndi
115:                        Context ctx = new InitialContext();
116:                        PSEnterprise lPs = (PSEnterprise) ctx
117:                                .lookup(PSEnterprise.COMPONENT_URL);
118:                        String[] lSystemRefs = lPs.getAllSystemRefs(mEnterprise
119:                                .getRef());
120:                        mDetails = new ArrayList();
121:                        if (lSystemRefs != null && lSystemRefs.length > 0) {
122:                            for (int i = 0; i < lSystemRefs.length; i++)
123:                                mDetails.add(BOSystemImpl
124:                                        .createInstanceForExisting(
125:                                                mMetaBossDomainImpl,
126:                                                lSystemRefs[i]));
127:                        }
128:                    } catch (NamingException e) {
129:                        throw new BONamingAndDirectoryServiceInvocationException(
130:                                "Error while loading all systems. EnterpriseRef: "
131:                                        + mEnterprise.getRef(), e);
132:                    } catch (PSException e) {
133:                        throw new BOPersistenceServiceInvocationException(
134:                                "Error while loading all systems. EnterpriseRef: "
135:                                        + mEnterprise.getRef(), e);
136:                    }
137:                }
138:            }
139:
140:            // Internal method<which allows to delete an attribute
141:            void onDeleteSystem(BOSystem pSystemToDelete) throws BOException {
142:                if (!isBeingEdited())
143:                    throw new BOInvalidOperationForReadOnlyObjectException();
144:                if (!mDetails.remove(pSystemToDelete))
145:                    throw new BOUnexpectedProgramConditionException(
146:                            "Attempt to remove system, which is not in the EnterpriseSystemList");
147:            }
148:
149:            // Overriden to refuse deletion. This is true for all lists
150:            protected void onDelete() throws BOException {
151:                throw new BOInvalidOperationForObjectException(
152:                        "EnterpriseSystem list can not be deleted. To empty the list - delete all systems");
153:            }
154:
155:            // Overriden to load details and backup original list
156:            protected void onBeginEdit() throws BOException {
157:                // Fully load the object and preserve old values
158:                loadDetailsIfNecessary();
159:                mDetailsBackup = (BOSystem[]) mDetails
160:                        .toArray(new BOSystem[mDetails.size()]);
161:            }
162:
163:            // Encapsulates an action after successfull commit
164:            public void onCommitSucceeded() throws BOException {
165:                mDetailsBackup = null;
166:            }
167:
168:            // Overriddden to restore this object's status to pre-begin edit state
169:            protected void onRollbackUpdate() throws BOException {
170:                mDetails.clear();
171:                mDetails.addAll(Arrays.asList(mDetailsBackup));
172:                mDetailsBackup = null;
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.