Source Code Cross Referenced for BugIndexer.java in  » Groupware » hipergate » com » knowgate » lucene » 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 » Groupware » hipergate » com.knowgate.lucene 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.knowgate.lucene;
002:
003:        import java.util.Date;
004:        import java.util.Properties;
005:
006:        import java.io.IOException;
007:        import java.sql.SQLException;
008:
009:        import org.apache.lucene.index.IndexWriter;
010:        import org.apache.lucene.document.Document;
011:        import org.apache.lucene.document.Field;
012:
013:        import com.knowgate.jdc.JDCConnection;
014:        import com.knowgate.dataobjs.DB;
015:        import com.knowgate.projtrack.Bug;
016:        import com.knowgate.misc.Gadgets;
017:        import com.knowgate.dfs.FileSystem;
018:        import org.apache.lucene.analysis.Analyzer;
019:        import java.io.File;
020:        import java.util.HashMap;
021:        import org.apache.lucene.index.Term;
022:        import org.apache.lucene.index.IndexReader;
023:
024:        /**
025:         * Indexer subclass for hipergate bugs
026:         * @author Sergio Montoro Ten
027:         * @version 3.0
028:         */
029:        public class BugIndexer extends Indexer {
030:
031:            public BugIndexer() {
032:            }
033:
034:            /**
035:             * Add bug to index
036:             * @param oIWrt IndexWriter
037:             * @param sGuid String Bug GUID
038:             * @param iNumber int Bug Number
039:             * @param sWorkArea String GUID of WorkArea to which bug belongs
040:             * @param sProject String GUID of project to which bug belongs
041:             * @param sTitle String Title
042:             * @param sReportedBy String Author
043:             * @param dtCreated Date Created
044:             * @param sComments String Comments
045:             * @param sText String Bug Description
046:             * @throws ClassNotFoundException
047:             * @throws IOException
048:             * @throws IllegalArgumentException
049:             * @throws NoSuchFieldException
050:             * @throws IllegalAccessException
051:             * @throws InstantiationException
052:             * @throws NullPointerException
053:             */
054:            public static void addBug(IndexWriter oIWrt, String sGuid,
055:                    int iNumber, String sWorkArea, String sProject,
056:                    String sTitle, String sWriter, String sReportedBy,
057:                    Date dtCreated, String sType, Short oPriority,
058:                    Short oSeverity, String sStatus, String sComments,
059:                    String sText) throws ClassNotFoundException, IOException,
060:                    IllegalArgumentException, NoSuchFieldException,
061:                    IllegalAccessException, InstantiationException,
062:                    NullPointerException {
063:
064:                Document oDoc = new Document();
065:                oDoc.add(Field.Keyword("workarea", sWorkArea));
066:                oDoc.add(Field.Keyword("container", sProject));
067:                oDoc.add(Field.Keyword("guid", sGuid));
068:                oDoc.add(Field.Keyword("number", String.valueOf(iNumber)));
069:                oDoc.add(Field.Text("title", Gadgets.ASCIIEncode(sTitle)));
070:                oDoc.add(Field.Keyword("created", dtCreated));
071:                oDoc.add(Field.Keyword("writer", sWriter));
072:                if (null != sStatus)
073:                    oDoc.add(Field.Keyword("status", sStatus));
074:                if (null != sType)
075:                    oDoc.add(Field.Keyword("type", sType));
076:                if (null != oPriority)
077:                    oDoc.add(Field.Keyword("priority", oPriority.toString()));
078:                if (null != oSeverity)
079:                    oDoc.add(Field.Keyword("severity", oSeverity.toString()));
080:                if (null != sReportedBy)
081:                    oDoc.add(Field.Text("author", Gadgets
082:                            .ASCIIEncode(sReportedBy)));
083:                oDoc.add(Field.UnStored("comments", Gadgets
084:                        .ASCIIEncode(sComments)));
085:                if (null == sText) {
086:                    oDoc.add(Field.UnStored("text", ""));
087:                    oDoc.add(Field.UnStored("abstract", ""));
088:                } else {
089:                    oDoc
090:                            .add(Field.UnStored("text", Gadgets
091:                                    .ASCIIEncode(sText)));
092:                    if (sText.length() > 80)
093:                        oDoc.add(new Field("abstract", sText.substring(0, 80)
094:                                .replace('\n', ' '), true, false, false));
095:                    else
096:                        oDoc.add(new Field("abstract",
097:                                sText.replace('\n', ' '), true, false, false));
098:                }
099:                oIWrt.addDocument(oDoc);
100:            } // addBug
101:
102:            /**
103:             * Add bug to index
104:             * @param oIWrt IndexWriter
105:             * @param sGuid String Bug GUID
106:             * @param iNumber int Bug Number
107:             * @param sWorkArea String GUID of WorkArea to which bug belongs
108:             * @param sProject String GUID of project to which bug belongs
109:             * @param sTitle String Title
110:             * @param sReportedBy String Author
111:             * @param dtCreated Date Created
112:             * @param sComments String Comments
113:             * @param sText String Bug Description
114:             * @throws ClassNotFoundException
115:             * @throws IOException
116:             * @throws IllegalArgumentException
117:             * @throws NoSuchFieldException
118:             * @throws IllegalAccessException
119:             * @throws InstantiationException
120:             * @throws NullPointerException
121:             */
122:            public static void addBug(IndexWriter oIWrt, String sGuid,
123:                    int iNumber, String sWorkArea, String sProject,
124:                    String sTitle, String sReportedBy, Date dtCreated,
125:                    String sComments, String sText)
126:                    throws ClassNotFoundException, IOException,
127:                    IllegalArgumentException, NoSuchFieldException,
128:                    IllegalAccessException, InstantiationException,
129:                    NullPointerException {
130:                addBug(oIWrt, sGuid, iNumber, sWorkArea, sProject, sTitle,
131:                        null, sReportedBy, dtCreated, null, null, null, null,
132:                        sComments, sText);
133:            } // addBug
134:
135:            /**
136:             * Add bug to index
137:             * @param oIWrt IndexWriter
138:             * @param oCon JDCConnection
139:             * @param sWorkArea String GUID of WorkArea where bug must be added
140:             * @param oBug Bug
141:             * @throws SQLException
142:             * @throws IOException
143:             * @throws ClassNotFoundException
144:             * @throws NoSuchFieldException
145:             * @throws IllegalAccessException
146:             * @throws InstantiationException
147:             * @throws NullPointerException
148:             */
149:            public static void addBug(IndexWriter oIWrt, JDCConnection oCon,
150:                    String sWorkArea, Bug oBug) throws SQLException,
151:                    IOException, ClassNotFoundException, NoSuchFieldException,
152:                    IllegalAccessException, InstantiationException,
153:                    NullPointerException {
154:                Short oSeverity;
155:                Short oPriority;
156:
157:                if (null == oBug)
158:                    throw new NullPointerException(
159:                            "BugIndexer.addBug() Bug may not be null");
160:                if (null == oCon)
161:                    throw new NullPointerException(
162:                            "BugIndexer.addBug() JDBC Connection may not be null");
163:                if (oCon.isClosed())
164:                    throw new SQLException(
165:                            "BugIndexer.addBug() JDBC connection is closed");
166:
167:                if (oBug.isNull(DB.od_priority))
168:                    oPriority = null;
169:                else
170:                    oPriority = new Short(oBug.getShort(DB.od_priority));
171:
172:                if (oBug.isNull(DB.od_severity))
173:                    oSeverity = null;
174:                else
175:                    oSeverity = new Short(oBug.getShort(DB.od_severity));
176:
177:                addBug(oIWrt, oBug.getString(DB.gu_bug),
178:                        oBug.getInt(DB.pg_bug), oBug.getString(sWorkArea), oBug
179:                                .getString(DB.gu_project), oBug.getStringNull(
180:                                DB.tl_bug, ""), oBug.getString(DB.gu_writer),
181:                        oBug.getStringNull(DB.nm_reporter, ""), oBug
182:                                .getCreationDate(oCon), oBug.getStringNull(
183:                                DB.tp_bug, null), oPriority, oSeverity, oBug
184:                                .getStringNull(DB.tx_status, null), oBug
185:                                .getStringNull(DB.tx_comments, null), oBug
186:                                .getStringNull(DB.tx_bug_brief, null));
187:            }
188:
189:            /**
190:             * Add bug to index
191:             * @param oProps Properties
192:             * @param oCon JDCConnection
193:             * @param sWorkArea String
194:             * @param oBug Bug
195:             * @throws SQLException
196:             * @throws IOException
197:             * @throws ClassNotFoundException
198:             * @throws NoSuchFieldException
199:             * @throws IllegalAccessException
200:             * @throws InstantiationException
201:             * @throws NullPointerException
202:             * @throws NoSuchFieldException
203:             */
204:            public static void addBug(Properties oProps, JDCConnection oCon,
205:                    String sWorkArea, Bug oBug) throws SQLException,
206:                    IOException, ClassNotFoundException, NoSuchFieldException,
207:                    IllegalAccessException, InstantiationException,
208:                    NullPointerException, NoSuchFieldException {
209:
210:                String sDirectory = oProps.getProperty("luceneindex");
211:
212:                if (null == sDirectory)
213:                    throw new NoSuchFieldException(
214:                            "Cannot find luceneindex property");
215:
216:                sDirectory = Gadgets.chomp(sDirectory, File.separator)
217:                        + DB.k_bugs + File.separator + sWorkArea;
218:                File oDir = new File(sDirectory);
219:                if (!oDir.exists()) {
220:                    FileSystem oFS = new FileSystem();
221:                    try {
222:                        oFS.mkdirs(sDirectory);
223:                    } catch (Exception e) {
224:                        throw new IOException(e.getClass().getName() + " "
225:                                + e.getMessage());
226:                    }
227:                } // fi
228:
229:                Class oAnalyzer = Class.forName(oProps.getProperty("analyzer",
230:                        DEFAULT_ANALYZER));
231:
232:                IndexWriter oIWrt = new IndexWriter(sDirectory,
233:                        (Analyzer) oAnalyzer.newInstance(), true);
234:                addBug(oIWrt, oCon, sWorkArea, oBug);
235:                oIWrt.close();
236:            } // addBug
237:
238:            /**
239:             * Delete a bug with a given GUID
240:             * @param oProps Properties Collection containing luceneindex directory
241:             * @param sGuid Bug GUID
242:             * @return Number of documents deleted
243:             * @throws IllegalArgumentException If sTableName is not one of { k_bugs, k_newsmsgs, k_mime_msgs }
244:             * @throws NoSuchFieldException If luceneindex property is not found at oProps
245:             * @throws IllegalAccessException
246:             * @throws IOException
247:             * @throws NullPointerException If sGuid is <b>null</b>
248:             */
249:            public static int deleteBug(String sWorkArea, Properties oProps,
250:                    String sGuid) throws IllegalArgumentException,
251:                    NoSuchFieldException, IllegalAccessException, IOException,
252:                    NullPointerException {
253:                return Indexer.delete(DB.k_bugs, sWorkArea, oProps, sGuid);
254:            } // delete
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.