Source Code Cross Referenced for BaseProfileInstance.java in  » Web-Framework » roma-webwizard » org » romaframework » module » users » view » domain » baseprofile » 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 » Web Framework » roma webwizard » org.romaframework.module.users.view.domain.baseprofile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.romaframework.module.users.view.domain.baseprofile;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.Collections;
022:        import java.util.Iterator;
023:        import java.util.Map;
024:        import java.util.TreeMap;
025:        import java.util.Map.Entry;
026:
027:        import org.romaframework.aspect.core.annotation.AnnotationConstants;
028:        import org.romaframework.aspect.core.annotation.CoreClass;
029:        import org.romaframework.aspect.reporting.annotation.ReportingField;
030:        import org.romaframework.aspect.session.SessionAspect;
031:        import org.romaframework.aspect.session.SessionInfo;
032:        import org.romaframework.aspect.view.ViewCallback;
033:        import org.romaframework.aspect.view.annotation.ViewClass;
034:        import org.romaframework.aspect.view.annotation.ViewField;
035:        import org.romaframework.aspect.view.feature.ViewFieldFeatures;
036:        import org.romaframework.core.flow.ObjectContext;
037:        import org.romaframework.core.schema.SchemaAction;
038:        import org.romaframework.core.schema.SchemaClass;
039:        import org.romaframework.core.schema.SchemaField;
040:        import org.romaframework.core.schema.SchemaManager;
041:        import org.romaframework.core.validation.CustomValidation;
042:        import org.romaframework.core.validation.ValidationException;
043:        import org.romaframework.module.crud.CRUDInstance;
044:        import org.romaframework.module.users.domain.BaseFunction;
045:        import org.romaframework.module.users.domain.BaseProfile;
046:
047:        @CoreClass(orderFields="entity availableClassNames availableMembers functions")
048:        @ViewClass(entity=BaseProfile.class)
049:        public class BaseProfileInstance extends CRUDInstance<BaseProfile>
050:                implements  CustomValidation, ViewCallback {
051:            private static final String DEF_HOME_PAGE = "HomePage";
052:
053:            private static final String CLASS_ELEMENT = "< Class >";
054:
055:            @ViewField(selectionField="selectedAvailableClassName",enabled=AnnotationConstants.FALSE)
056:            @ReportingField(visible=AnnotationConstants.FALSE)
057:            protected ArrayList<String> availableClassNames;
058:
059:            @ViewField(selectionField="selectedAvailableMember",enabled=AnnotationConstants.FALSE)
060:            protected ArrayList<String> availableMembers;
061:
062:            @ViewField(visible=AnnotationConstants.FALSE)
063:            protected String selectedAvailableMember;
064:
065:            protected SchemaClass selectedAvailableClass;
066:
067:            @ViewField(visible=AnnotationConstants.FALSE)
068:            private BaseFunction selectedFunction;
069:
070:            @ViewField(label="Mode",render="select",selectionField="entity.mode",selectionMode=ViewFieldFeatures.SELECTION_MODE_INDEX)
071:            @ReportingField(visible=AnnotationConstants.FALSE)
072:            public String[] getModes() {
073:                return BaseProfileHelper.MODES;
074:            }
075:
076:            @ViewField(selectionField="selectedFunction",enabled=AnnotationConstants.TRUE)
077:            public Map<String, BaseFunction> getFunctions() {
078:                return entity.getFunctions();
079:            }
080:
081:            @Override
082:            public void onCreate() {
083:                getEntity().setMode(BaseProfile.MODE_ALLOW_ALL_BUT);
084:                getEntity().setFunctions(new TreeMap<String, BaseFunction>());
085:                getEntity().setHomePage(DEF_HOME_PAGE);
086:            }
087:
088:            @Override
089:            public void save() {
090:                // CHECK FOR FUNCTION UPDATING
091:                String key;
092:
093:                boolean found = false;
094:                while (!found) {
095:                    found = true;
096:
097:                    for (Entry<String, BaseFunction> fun : getEntity()
098:                            .getFunctions().entrySet()) {
099:                        key = fun.getKey();
100:                        if (!getEntity().getFunctions().get(key).getName()
101:                                .equals(key)) {
102:                            // FOUND INCHOERENCE: FIX IT
103:                            getEntity().getFunctions().put(
104:                                    fun.getValue().getName(), fun.getValue());
105:                            getEntity().getFunctions().remove(key);
106:
107:                            found = false;
108:                            break;
109:                        }
110:                    }
111:                }
112:
113:                super .save();
114:
115:                // UPDATE ALL IN-MEMORY USERS ACCOUNT
116:                Collection<SessionInfo> activeSessions = ObjectContext
117:                        .getInstance().getComponent(SessionAspect.class)
118:                        .getSessionInfos();
119:
120:                synchronized (activeSessions) {
121:                    for (SessionInfo s : activeSessions) {
122:                        if (s.getAccount() != null
123:                                && s.getAccount().getProfile().equals(
124:                                        getEntity()))
125:                            // REPLACE IT WITH CURRENT ENTITY
126:                            s.getAccount().setProfile(getEntity());
127:                    }
128:                }
129:            }
130:
131:            @Override
132:            public void onShow() {
133:                SchemaManager schemaMgr = ObjectContext.getInstance()
134:                        .getComponent(SchemaManager.class);
135:                Collection<SchemaClass> infos = schemaMgr.getAllClassesInfo();
136:
137:                availableClassNames = new ArrayList<String>();
138:                for (SchemaClass cls : infos)
139:                    availableClassNames.add(cls.getName());
140:
141:                Collections.sort(availableClassNames);
142:            }
143:
144:            public void setSelectedAvailableClassName(String iSelection) {
145:                availableMembers = new ArrayList<String>();
146:                selectedAvailableClass = ObjectContext.getInstance()
147:                        .getComponent(SchemaManager.class).getClassInfo(
148:                                iSelection);
149:                availableMembers.add(CLASS_ELEMENT);
150:
151:                for (Iterator<SchemaAction> it = selectedAvailableClass
152:                        .getActionIterator(); it.hasNext();)
153:                    availableMembers.add(it.next().getName() + "()");
154:
155:                for (Iterator<SchemaField> it = selectedAvailableClass
156:                        .getFieldIterator(); it.hasNext();)
157:                    availableMembers.add(it.next().getName());
158:
159:                ObjectContext.getInstance().refresh(this , "availableMembers");
160:            }
161:
162:            public void add() {
163:                if (availableMembers == null)
164:                    return;
165:
166:                String funcName = selectedAvailableClass.getName();
167:                if (!selectedAvailableMember.equals(CLASS_ELEMENT)) {
168:                    funcName += "." + selectedAvailableMember;
169:                    if (funcName.endsWith("()"))
170:                        funcName = funcName.substring(0, funcName.length() - 2);
171:                }
172:
173:                boolean allowFunction = getEntity().getMode().byteValue() == BaseProfile.MODE_DENY_ALL_BUT;
174:
175:                getEntity().addFunction(funcName, allowFunction);
176:
177:                ObjectContext.getInstance().refresh(this , "functions");
178:            }
179:
180:            @ViewField(visible=AnnotationConstants.FALSE)
181:            public String getSelectedAvailableClassName() {
182:                if (selectedAvailableClass != null)
183:                    return selectedAvailableClass.getName();
184:                return null;
185:            }
186:
187:            public ArrayList<String> getAvailableMembers() {
188:                return availableMembers;
189:            }
190:
191:            public void setAvailableMembers(ArrayList<String> availableMembers) {
192:                this .availableMembers = availableMembers;
193:            }
194:
195:            public String getSelectedAvailableMember() {
196:                return selectedAvailableMember;
197:            }
198:
199:            public void setSelectedAvailableMember(
200:                    String selectedAvailableMember) {
201:                this .selectedAvailableMember = selectedAvailableMember;
202:            }
203:
204:            public void validate() throws ValidationException {
205:            }
206:
207:            public ArrayList<String> getAvailableClassNames() {
208:                return availableClassNames;
209:            }
210:
211:            public void setAvailableClassNames(
212:                    ArrayList<String> availableClassNames) {
213:                this .availableClassNames = availableClassNames;
214:            }
215:
216:            public BaseFunction getSelectedFunction() {
217:                return selectedFunction;
218:            }
219:
220:            public void setSelectedFunction(BaseFunction selectedFunction) {
221:                this.selectedFunction = selectedFunction;
222:            }
223:
224:        }
ww_w___.___ja__v_a___2___s._co___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.