Source Code Cross Referenced for RobotClassRuleListModel.java in  » Portal » Open-Portal » com » sun » portal » search » admin » model » 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 » Portal » Open Portal » com.sun.portal.search.admin.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.search.admin.model;
007:
008:        import java.lang.*;
009:        import java.util.*;
010:        import java.io.*;
011:        import java.net.*;
012:        import javax.servlet.http.HttpServletRequest;
013:
014:        import com.iplanet.jato.model.*;
015:        import com.iplanet.jato.view.html.*;
016:        import com.iplanet.jato.util.*;
017:        import com.sun.portal.search.admin.CSConfig;
018:        import com.sun.portal.search.admin.Rule;
019:        import com.sun.portal.search.admin.CnConfig;
020:        import com.sun.portal.search.admin.resources.SearchResource;
021:
022:        /**
023:         * This class supports the MenuListView by providing the data in the
024:         * format expected by the view.
025:         */
026:        public class RobotClassRuleListModel extends DefaultModel implements 
027:                DatasetModel, RetrievingModel, DeletingModel {
028:            public static final String MODEL_NAME = "RobotClassRuleListModel";
029:            public static final String FIELD_SRC = "Src";
030:            public static final String FIELD_METHOD = "Method";
031:            public static final String FIELD_CRITERIA = "Criteria";
032:            public static final String FIELD_CLASSIFICATION = "Classification";
033:            public static final String FIELD_DELETE = "Delete";
034:            static final String[] FIELDS = { FIELD_SRC, FIELD_METHOD,
035:                    FIELD_CRITERIA, FIELD_CLASSIFICATION };
036:            public Locale userLocale = Locale.getDefault();
037:            static final String[] methodValues = new String[] {
038:                    CnConfig.METHOD_EXACT, CnConfig.METHOD_SUBSTR,
039:                    CnConfig.METHOD_PREFIX, CnConfig.METHOD_SUFFIX,
040:                    CnConfig.METHOD_REGEX };
041:
042:            private CnConfig cnconfig = new CnConfig(CSConfig.getServerRoot());
043:
044:            /**
045:             * @param req The HttpServletRequest object passed to the super class.
046:             * @param rbName The name of the resource bundle.
047:             */
048:            public RobotClassRuleListModel() {
049:                super ();
050:                /*	try {
051:                 retrieve(null);
052:                 }
053:                 catch (Exception e) {}*/
054:            }
055:
056:            private void ValidateList() throws ModelControlException {
057:                ArrayList delObjs = new ArrayList();
058:                beforeFirst();
059:                while (next()) {
060:                    for (int i = 0; i < FIELDS.length; i++) {
061:                        if (getValue(FIELDS[i]) == null) {
062:                            delObjs.add(getCurrentContext().getValueList().get(
063:                                    getRowIndex()));
064:                            break;
065:                        }
066:                    }
067:                }
068:                for (int i = 0; i < delObjs.size(); i++) {
069:                    getCurrentContext().getValueList().remove(delObjs.get(i));
070:                }
071:                return;
072:            }
073:
074:            // Model execution methods
075:            ////////////////////////////////////////////////////////////////////////////////
076:
077:            /**
078:             *
079:             *
080:             */
081:            public Object execute(ModelExecutionContext context)
082:                    throws ModelControlException {
083:                String operationName = null;
084:                if (context != null)
085:                    operationName = context.getOperationName();
086:                else
087:                    operationName = ModelExecutionContext.OPERATION_RETRIEVE;
088:
089:                Object result = null;
090:                if (operationName
091:                        .equals(ModelExecutionContext.OPERATION_RETRIEVE)) {
092:                    result = retrieve(context);
093:                } else if (operationName
094:                        .equals(ModelExecutionContext.OPERATION_DELETE)) {
095:                    result = delete(context);
096:                }
097:
098:                return result;
099:            }
100:
101:            /**
102:             *
103:             *
104:             */
105:            public Object delete(ModelExecutionContext context)
106:                    throws ModelControlException {
107:                beforeFirst();
108:                int deltaIndex = 0;
109:                while (next()) {
110:                    String isDelete = (String) getValue(this .FIELD_DELETE);
111:                    if (isDelete != null && isDelete.compareTo("true") == 0) {
112:                        int index = getRowIndex();
113:                        cnconfig.delete(index - deltaIndex);
114:                        deltaIndex++;
115:                    }
116:                }
117:                /* checking any deletion happened */
118:                if (deltaIndex > 0) {
119:                    cnconfig.save();
120:                }
121:                return null;
122:            }
123:
124:            public int getNumOfRules() {
125:                return cnconfig.getNumberOfRules();
126:            }
127:
128:            /* used for forced reload*/
129:            private void loadRules() {
130:                String server_root = CSConfig.getServerRoot();
131:                cnconfig = new CnConfig(server_root);
132:            }
133:
134:            /**
135:             *
136:             *
137:             */
138:            public Object retrieve(ModelExecutionContext context)
139:                    throws ModelControlException {
140:                OptionList srcOptions = getSrcLst(userLocale);
141:                OptionList methodOptions = getMethodLst(userLocale);
142:
143:                clear();
144:                ArrayList rules = cnconfig.getRulesList();
145:                int n = rules.size();
146:                for (int i = 0; i < n; i++) {
147:                    Rule rule = (Rule) rules.get(i);
148:                    appendRow();
149:                    String label = srcOptions.getValueLabel(rule.getSrc());
150:                    setValue(FIELD_SRC, (label == null) ? rule.getSrc() : label);
151:                    label = methodOptions.getValueLabel(rule.getMethod());
152:                    setValue(FIELD_METHOD, (label == null) ? rule.getMethod()
153:                            : label);
154:                    setValue(FIELD_CRITERIA, rule.getName());
155:                    setValue(FIELD_CLASSIFICATION, rule.getAction());
156:                }
157:                beforeFirst();
158:
159:                // Nothing useful to return
160:                return null;
161:            }
162:
163:            public static OptionList getSrcLst(Locale userLocale) {
164:
165:                OptionList srcLst = new OptionList(SearchResource.geti18nArray(
166:                        "classrules.src.options", ",", userLocale),
167:                        SearchResource.geti18nArray("classrules.src.values",
168:                                ",", userLocale));
169:
170:                String[] schLst = (new SchemaListModel()).getSchemaList();
171:
172:                if (schLst != null) {
173:                    for (int i = 0; i < schLst.length; i++) {
174:                        srcLst.add(i, schLst[i], schLst[i]);
175:                    }
176:                }
177:                return srcLst;
178:            }
179:
180:            public static OptionList getMethodLst(Locale userLocale) {
181:                OptionList methodLst = new OptionList(SearchResource
182:                        .geti18nArray("classrules.method.options", ",",
183:                                userLocale), methodValues);
184:                return methodLst;
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.