Source Code Cross Referenced for SearchController.java in  » Project-Management » EmForce » ru » emdev » EmForge » wiki » web » bean » 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 » Project Management » EmForce » ru.emdev.EmForge.wiki.web.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.wiki.web.bean;
002:
003:        import java.io.IOException;
004:        import java.util.ArrayList;
005:        import java.util.Collection;
006:
007:        import org.apache.commons.lang.StringUtils;
008:
009:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
010:
011:        import com.ecyrd.jspwiki.SearchResult;
012:        import com.ecyrd.jspwiki.WikiContext;
013:        import com.ecyrd.jspwiki.WikiPage;
014:        import com.ecyrd.jspwiki.providers.ProviderException;
015:
016:        public class SearchController extends BaseWikiControllerImpl {
017:
018:            private String m_query = "Search...";
019:
020:            public static final String SEARCH = "Search";
021:            public static final String SEARCH_RESULT_PAGE = "search";
022:            public static final String QUERY_PARAM = "query";
023:
024:            @Override
025:            protected void init() {
026:                if (getParam(QUERY_PARAM) != null) {
027:                    m_query = getParam(QUERY_PARAM);
028:                }
029:            }
030:
031:            @Override
032:            public MainMenuItem getSelectionItemOnMainMenu() {
033:                return null;
034:            }
035:
036:            @Override
037:            public String getTitleImpl() {
038:                return SEARCH;
039:            }
040:
041:            @Override
042:            public Crumb getTrailCrumbInfo() {
043:                return null;
044:            }
045:
046:            public void setQuery(String i_query) {
047:                m_query = i_query;
048:            }
049:
050:            public String getQuery() {
051:                return m_query;
052:            }
053:
054:            public String go() {
055:                if (StringUtils.isNotEmpty(m_query)) {
056:                    redirect(SEARCH_RESULT_PAGE + "/" + m_query);
057:                }
058:
059:                return null;
060:            }
061:
062:            public boolean isSearchResultEmpty() {
063:                return m_isEmpty;
064:            }
065:
066:            private boolean m_isEmpty = false;
067:
068:            @SuppressWarnings("unchecked")
069:            public Collection<EmForgeSearchResult> getSearchResults() {
070:                Collection result = new ArrayList<Object>();
071:                if (StringUtils.isNotEmpty(m_query)) {
072:                    try {
073:                        Collection<SearchResult> luceneResults = m_wikiEngine
074:                                .findPages(m_query);
075:                        //
076:                        // Conversion the lucene result to own result.
077:                        // It necessary that each result stores 'view' that is required to make a navigation link to either a page or a process.
078:                        // for a page: "wiki/pageName";
079:                        // for a process "process/processId";
080:                        //
081:                        for (SearchResult luceneResult : luceneResults) {
082:                            result.add(new EmForgeSearchResult(luceneResult));
083:                        }
084:
085:                        // addFoundedProcessToResult(result);
086:
087:                    } catch (ProviderException e) {
088:                        logger.error(e);
089:                        return result;
090:                    } catch (IOException e) {
091:                        logger.error(e);
092:                        return result;
093:                    }
094:                }
095:                m_isEmpty = result.isEmpty();
096:                return result;
097:            }
098:
099:            /** adds a process if exists to the result
100:             * 
101:             * @param io_searchResult
102:             * @param i_query
103:             */
104:            /* seems it is not required 
105:            private void addFoundedProcessToResult(Collection<EmForgeSearchResult> io_searchResult) {
106:            	if (Helper.isNumber(m_query)) {
107:            		WikiPage processPage = m_wikiEngine.getPage(m_query);
108:            		if (processPage != null) {
109:            			EmForgeSearchResult procPageResult = new EmForgeSearchResult(processPage);
110:            			io_searchResult.add(procPageResult);
111:            		}
112:            	}
113:            }
114:             */
115:
116:            public class EmForgeSearchResult {
117:                WikiPage m_page;
118:                String[] m_fragments = new String[0];
119:                int m_score;
120:                String m_view;
121:
122:                public EmForgeSearchResult(SearchResult i_searchResult) {
123:                    m_page = i_searchResult.getPage();
124:                    m_fragments = i_searchResult.getContexts();
125:                    m_score = i_searchResult.getScore();
126:                    m_view = m_urlConstructor.makeURL(WikiContext.VIEW, m_page
127:                            .getName(), false, null);
128:                }
129:
130:                public EmForgeSearchResult(WikiPage i_page) {
131:                    m_page = i_page;
132:                    m_fragments = new String[1];
133:                    m_view = "process";
134:                }
135:
136:                public void setView(String i_view) {
137:                    m_view = i_view;
138:                }
139:
140:                public String getView() {
141:                    return m_view;
142:                }
143:
144:                public WikiPage getPage() {
145:                    return m_page;
146:                }
147:
148:                public int getScore() {
149:                    return m_score;
150:                }
151:
152:                public String getFragment() {
153:                    if (m_fragments.length > 0) {
154:                        return m_fragments[0];
155:                    }
156:                    return null;
157:                }
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.