Source Code Cross Referenced for PSAssociationRoleImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » domains » enterprisemodel » storage » xmlfileimpl » 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.storage.xmlfileimpl 
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.storage.xmlfileimpl;
016:
017:        import javax.xml.bind.JAXBException;
018:
019:        import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
020:        import com.metaboss.enterprise.ps.PSException;
021:        import com.metaboss.enterprise.ps.PSIllegalArgumentException;
022:        import com.metaboss.enterprise.ps.PSUnexpectedProgramConditionException;
023:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSAssociationRole;
024:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STAssociationRole;
025:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.AssociationDefType;
026:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.AssociationRoleDefType;
027:
028:        public class PSAssociationRoleImpl implements  PSAssociationRole {
029:            /** Returns details structure corresponding to Role, specified by role reference */
030:            public STAssociationRole getAssociationRole(
031:                    String pAssociationRoleRef) throws PSException {
032:                int lLastDot = pAssociationRoleRef.lastIndexOf('.');
033:                if (lLastDot <= 0)
034:                    throw new PSIllegalArgumentException(
035:                            "Invalid AssociationRoleRef: "
036:                                    + pAssociationRoleRef);
037:                String lAssociationRef = pAssociationRoleRef.substring(0,
038:                        lLastDot);
039:                String lAssociationRoleName = pAssociationRoleRef
040:                        .substring(lLastDot + 1);
041:                AssociationDefType lAssociationDef = Storage
042:                        .getAssociation(lAssociationRef);
043:                if (lAssociationDef == null)
044:                    return null;
045:                AssociationRoleDefType lAssociationRoleADef = (AssociationRoleDefType) lAssociationDef
046:                        .getAssociationRoleDef().get(0);
047:                if (lAssociationRoleADef.getName().equals(lAssociationRoleName))
048:                    return getRoleStruct(pAssociationRoleRef, true,
049:                            lAssociationRoleADef);
050:                AssociationRoleDefType lAssociationRoleBDef = (AssociationRoleDefType) lAssociationDef
051:                        .getAssociationRoleDef().get(1);
052:                if (lAssociationRoleBDef.getName().equals(lAssociationRoleName))
053:                    return getRoleStruct(pAssociationRoleRef, false,
054:                            lAssociationRoleBDef);
055:                return null;
056:            }
057:
058:            /** Returns details structure corresponding to RoleA or RoleB of the specified association */
059:            public STAssociationRole getAssociationRole(String pAssociationRef,
060:                    boolean pIsRoleA) throws PSException {
061:                AssociationDefType lAssociationDef = Storage
062:                        .getAssociation(pAssociationRef);
063:                if (lAssociationDef == null)
064:                    return null;
065:                AssociationRoleDefType lAssociationRoleDef = (AssociationRoleDefType) lAssociationDef
066:                        .getAssociationRoleDef().get(pIsRoleA ? 0 : 1);
067:                return getRoleStruct(pAssociationRef + "."
068:                        + lAssociationRoleDef.getName(), pIsRoleA,
069:                        lAssociationRoleDef);
070:            }
071:
072:            /* Inserts new association record into the database */
073:            public void insertAssociationRole(String pAssociationRef,
074:                    STAssociationRole pRecord) throws PSException {
075:                try {
076:                    AssociationDefType lAssociationDef = Storage
077:                            .getAssociation(pAssociationRef);
078:                    if (lAssociationDef == null)
079:                        throw new PSIllegalArgumentException(
080:                                "Association not found. AssociationRef: "
081:                                        + pAssociationRef);
082:                    AssociationRoleDefType lAssociationRoleDef = getRoleDef(pRecord);
083:                    lAssociationDef.getAssociationRoleDef().set(
084:                            (pRecord.IsRoleA ? 0 : 1), lAssociationRoleDef);
085:                    Storage.updateAssociation(lAssociationDef);
086:                } catch (JAXBException e) {
087:                    throw new PSDataSourceOperationInvocationException(
088:                            "Unable to insert new Association", e);
089:                }
090:            }
091:
092:            /* Updates new association record into the database */
093:            public void updateAssociationRole(String pAssociationRef,
094:                    STAssociationRole pRecord) throws PSException {
095:                try {
096:                    AssociationDefType lAssociationDef = Storage
097:                            .getAssociation(pAssociationRef);
098:                    if (lAssociationDef == null)
099:                        throw new PSIllegalArgumentException(
100:                                "Association not found. AssociationRef: "
101:                                        + pAssociationRef);
102:                    AssociationRoleDefType lAssociationRoleDef = getRoleDef(pRecord);
103:                    lAssociationDef.getAssociationRoleDef().set(
104:                            (pRecord.IsRoleA ? 0 : 1), lAssociationRoleDef);
105:                    Storage.updateAssociation(lAssociationDef);
106:                } catch (JAXBException e) {
107:                    throw new PSDataSourceOperationInvocationException(
108:                            "Unable to insert new Association", e);
109:                }
110:            }
111:
112:            public static STAssociationRole getRoleStruct(
113:                    String pAssociationRoleRef, boolean pIsRoleA,
114:                    AssociationRoleDefType pRoleDef) throws PSException {
115:                STAssociationRole lStruct = new STAssociationRole();
116:                if (pRoleDef != null) {
117:                    lStruct.EntityRef = pRoleDef.getEntityRef();
118:                    lStruct.Name = pRoleDef.getName();
119:                    lStruct.Description = pRoleDef.getDescription();
120:                    lStruct.Cardinality = com.metaboss.sdlctools.types.enterprisemodel.AssociationRoleCardinalityTextHelper
121:                            .fromTextObject(pRoleDef
122:                                    .getAssociationRoleCardinality());
123:                    lStruct.Stereotype = com.metaboss.sdlctools.types.enterprisemodel.AssociationRoleStereotypeTextHelper
124:                            .fromTextObject(pRoleDef
125:                                    .getAssociationRoleStereotype());
126:                    lStruct.PluralName = pRoleDef.getPluralName();
127:                    lStruct.IsRoleA = pIsRoleA;
128:                    // Good place for now to put some validation tests
129:                    if (lStruct.Name.equalsIgnoreCase("InstanceId"))
130:                        throw new PSUnexpectedProgramConditionException(
131:                                "Role name 'InstanceId' is reserved and can not be used in association definition. AssociationRoleRef : "
132:                                        + pAssociationRoleRef);
133:                    if (lStruct.Name.equalsIgnoreCase("VersionId"))
134:                        throw new PSUnexpectedProgramConditionException(
135:                                "Role name 'VersionId' is reserved and can not be used in association definition. AssociationRoleRef : "
136:                                        + pAssociationRoleRef);
137:                    if (lStruct.Name.equalsIgnoreCase("State"))
138:                        throw new PSUnexpectedProgramConditionException(
139:                                "Role name 'State' is reserved and can not be used in association definition. AssociationRoleRef : "
140:                                        + pAssociationRoleRef);
141:                    if (lStruct.Cardinality.isEmpty())
142:                        throw new PSUnexpectedProgramConditionException(
143:                                "Role cardinality can not be empty in the association definition. AssociationRoleRef : "
144:                                        + pAssociationRoleRef);
145:                }
146:                return lStruct;
147:            }
148:
149:            public static AssociationRoleDefType getRoleDef(
150:                    STAssociationRole pRoleStruct) throws JAXBException {
151:                AssociationRoleDefType lRoleDef = Util.getObjectFactory()
152:                        .createAssociationRoleDef();
153:                lRoleDef.setEntityRef(pRoleStruct.EntityRef);
154:                lRoleDef.setName(pRoleStruct.Name);
155:                lRoleDef.setPluralName(pRoleStruct.PluralName);
156:                lRoleDef.setDescription(pRoleStruct.Description);
157:                lRoleDef
158:                        .setAssociationRoleCardinality(com.metaboss.sdlctools.types.enterprisemodel.AssociationRoleCardinalityTextHelper
159:                                .toTextObject(pRoleStruct.Cardinality));
160:                lRoleDef
161:                        .setAssociationRoleStereotype(com.metaboss.sdlctools.types.enterprisemodel.AssociationRoleStereotypeTextHelper
162:                                .toTextObject(pRoleStruct.Stereotype));
163:                return lRoleDef;
164:            }
165:        }
w_w__w.j__a__v_a__2__s___.___c___o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.