}
// *********************************************************************
if (DebugFile.trace) DebugFile.writeln("new IndexWriter("+sDirectory+",[Analyzer], true)");
IndexWriter oIWrt = new IndexWriter(sDirectory, (Analyzer) oAnalyzer.newInstance(), true);
if (DebugFile.trace)
DebugFile.writeln("DriverManager.getConnection(" + oProps.getProperty("dburl") + ", ...)");
Connection oConn = DriverManager.getConnection(oProps.getProperty("dburl"), oProps.getProperty("dbuser"),oProps.getProperty("dbpassword"));
oConn.setAutoCommit(true);
Statement oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet oRSet;
if (sTableName.equalsIgnoreCase("k_bugs")) {
if (DebugFile.trace)
DebugFile.writeln("Statement.executeQuery(SELECT p.gu_workarea,p.nm_project,b.gu_bug,b.tl_bug,b.dt_modified," + IfNull(oConn) + "(b.nm_reporter,'')," + IfNull(oConn) + "(b.tx_bug_brief,'')," + IfNull(oConn) + "(b.tx_comments,'') FROM k_bugs b, k_projects p WHERE b.gu_project=p.gu_project AND p.gu_owner='"+sWorkArea+"')");
oRSet = oStmt.executeQuery("SELECT p.gu_owner,p.nm_project,b.gu_bug,b.pg_bug,b.tl_bug,b.dt_modified," + IfNull(oConn) + "(b.nm_reporter,'')," + IfNull(oConn) + "(b.tx_comments,'')," + IfNull(oConn) + "(b.tx_bug_brief,'') FROM k_bugs b, k_projects p WHERE b.gu_project=p.gu_project AND p.gu_owner='"+sWorkArea+"'");
while (oRSet.next()) {
sWorkArea = oRSet.getString(1);
sContainer = oRSet.getString(2);
sGuid = oRSet.getString(3);
iNumber = oRSet.getInt(4);
sTitle = oRSet.getString(5);
dtCreated = oRSet.getDate(6);
sAuthor = oRSet.getString(7);
sComments = oRSet.getString(8);
if (null==sComments) sComments = "";
sText = oRSet.getString(9);
if (null==sText) sText = "";
BugIndexer.addBug(oIWrt, sGuid, iNumber, sWorkArea, sContainer, sTitle, sAuthor, dtCreated, sComments, sText);
} // wend
oRSet.close();
}
else if (sTableName.equalsIgnoreCase("k_newsmsgs")) {
if (DebugFile.trace)
DebugFile.writeln("Statement.executeQuery(SELECT g.gu_workarea,c.nm_category,m.gu_msg,m.tx_subject,m.dt_published," + IfNull(oConn) + "(b.nm_author,'')," + IfNull(oConn) + "(b.tx_msg,'') FROM k_newsmsgs m, k_categories c, k_newsgroups g, k_x_cat_objs x WHERE m.id_status=0 AND m.gu_msg=x.gu_object AND x.gu_category=g.gu_newsgrp AND c.gu_category=g.gu_newsgrp AND g.gu_workarea='"+sWorkArea+"')");
oRSet = oStmt.executeQuery("SELECT g.gu_workarea,c.nm_category,m.gu_msg,m.tx_subject,m.dt_published," + IfNull(oConn) + "(m.nm_author,'')," + IfNull(oConn) + "(m.tx_msg,'') FROM k_newsmsgs m, k_categories c, k_newsgroups g, k_x_cat_objs x WHERE m.id_status=0 AND m.gu_msg=x.gu_object AND x.gu_category=g.gu_newsgrp AND c.gu_category=g.gu_newsgrp AND g.gu_workarea='"+sWorkArea+"'");
while (oRSet.next()) {
sWorkArea = oRSet.getString(1);
sContainer = oRSet.getString(2);
sGuid = oRSet.getString(3);
sTitle = oRSet.getString(4);
dtCreated = oRSet.getDate(5);
sAuthor = oRSet.getString(6);
sText = oRSet.getString(7);
NewsMessageIndexer.addNewsMessage(oIWrt, sGuid, sWorkArea, sContainer, sTitle, sAuthor, dtCreated, sText);
} // wend
oRSet.close();
}
// Inicio I2E 2009-12-23
else if (sTableName.equalsIgnoreCase("k_contacts")) {
Map<String,ContactRecord> contacts = new HashMap<String,ContactRecord>();
String consultas[] = new String[6];
consultas[0] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, csc.nm_scourse, csc.lv_scourse FROM k_contacts c, k_contact_short_courses csc WHERE c.gu_workarea='" + sWorkArea + "' AND csc.gu_contact = c.gu_contact";
consultas[1] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, ccsl.tr_es,ccsl2.tr_es FROM k_contacts c, k_contact_computer_science ccc, k_contact_computer_science_lookup ccsl, k_contact_computer_science_lookup ccsl2 WHERE c.gu_workarea='"+ sWorkArea +"' AND ccc.gu_contact = c.gu_contact AND ccc.nm_skill = ccsl.vl_lookup AND ccc.lv_skill = ccsl2.vl_lookup";
consultas[2] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, ccsl.tr_en,ccsl2.tr_en FROM k_contacts c, k_contact_computer_science ccc, k_contact_computer_science_lookup ccsl, k_contact_computer_science_lookup ccsl2 WHERE c.gu_workarea='"+ sWorkArea +"' AND ccc.gu_contact = c.gu_contact AND ccc.nm_skill = ccsl.vl_lookup AND ccc.lv_skill = ccsl2.vl_lookup";
consultas[3] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, ed.nm_degree,'' as level FROM k_contacts c,k_contact_education ce,k_education_degree ed WHERE c.gu_workarea='"+ sWorkArea +"' AND ce.gu_contact = c.gu_contact AND ce.gu_degree= ed.gu_degree";
consultas[4] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, ll.tr_lang_es,cll.tr_es FROM k_contacts c, k_contact_languages cl, k_lu_languages ll,k_contact_languages_lookup cll WHERE c.gu_workarea='"+ sWorkArea +"' AND c.gu_contact = cl.gu_contact AND cl.id_language = ll.id_language AND cl.lv_language_degree = cll.vl_lookup";
consultas[5] = "SELECT c.gu_contact, c.gu_workarea, c.tx_name, c.tx_surname, ll.tr_lang_en,cll.tr_en FROM k_contacts c, k_contact_languages cl, k_lu_languages ll,k_contact_languages_lookup cll WHERE c.gu_workarea='"+ sWorkArea +"' AND c.gu_contact = cl.gu_contact AND cl.id_language = ll.id_language AND cl.lv_language_degree = cll.vl_lookup";
for(int i=0;i<consultas.length;i++){
if (DebugFile.trace)
DebugFile.writeln("Statement.executeQuery(" + consultas[i] + ")");
oRSet = oStmt.executeQuery(consultas[i]);
while (oRSet.next()) {
sGuid = oRSet.getString(1);
sWorkArea = oRSet.getString(2);
String sName = oRSet.getString(3);
String sSurname = oRSet.getString(4);
String sValue = oRSet.getString(5);
String sLevel = oRSet.getString(6);
if(sLevel==null) sLevel="";
ContactRecord contact = contacts.get(sGuid);
if(contact==null){
contact = new ContactRecord(null,sName+" "+ sSurname,sWorkArea,sGuid);
contacts.put(sGuid, contact);
}
contact.addValue(sValue, sLevel);
//ContactIndexer.addDocument(oIWrt, sGuid, sWorkArea, sName, sSurname, ContactRecord.COURSE, sValue, sLevel,null);
}
oRSet.close();
}
ContactRecord arrayContactos[] = contacts.values().toArray(new ContactRecord[contacts.size()]);
for(int i=0;i<arrayContactos.length;i++){
ContactIndexer.addDocument(oIWrt,arrayContactos[i]);
}
}
//Fin i2E
else if (sTableName.equalsIgnoreCase("k_mime_msgs")) {
LinkedList oIndexedGuids = new LinkedList();
PreparedStatement oRecp = oConn.prepareStatement("SELECT tx_personal,tx_email FROM k_inet_addrs WHERE tp_recipient<>'to' AND gu_mimemsg=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (DebugFile.trace)
DebugFile.writeln("Statement.executeQuery(SELECT g.gu_workarea,c.nm_category,m.gu_mimemsg,m.tx_subject,m.nm_from,m.tx_mail_from,m.pg_mimemsg,m.de_mimemsg,m.dt_sent,m.len_mimemsg,m.by_content FROM k_mime_msgs m, k_categories c WHERE m.bo_deleted<>0 AND m.bo_draft<>0 AND m.gu_category=c.gu_category AND m.gu_workarea='"+sWorkArea+"')");
oRSet = oStmt.executeQuery("SELECT g.gu_workarea,c.nm_category,m.gu_mimemsg,m.tx_subject,m.nm_from,m.tx_mail_from,m.pg_mimemsg,m.de_mimemsg,m.dt_sent,m.len_mimemsg,m.by_content FROM k_mime_msgs m, k_categories c WHERE m.bo_deleted<>0 AND m.bo_draft<>0 AND m.gu_category=c.gu_category AND m.gu_workarea='"+sWorkArea+"'");
while (oRSet.next()) {
sWorkArea = oRSet.getString(1);
sContainer = oRSet.getString(2);
sGuid = oRSet.getString(3);
sTitle = oRSet.getString(4);
sAuthor = oRSet.getString(5);
if (oRSet.wasNull()) sAuthor = "";
sAuthor += " " + oRSet.getString(6);
dNumber = oRSet.getBigDecimal(7);
if (oRSet.wasNull()) dNumber = dZero;
sComments = oRSet.getString(8);
dtCreated = oRSet.getDate(9);
iSize = oRSet.getInt(10);
if (DebugFile.trace) DebugFile.writeln("Indexing message "+sGuid+" - "+sTitle);
InputStream oStrm = oRSet.getBinaryStream(11);
String sRecipients = "";
oRecp.setString(1, sGuid);
ResultSet oRecs = oRecp.executeQuery();
while (oRecs.next()) {
sRecipients += oRecs.getString(1)+" "+oRecs.getString(2)+" ";
} // wend
oRecs.close();
MailIndexer.addMail(oIWrt, sGuid, dNumber, sWorkArea, sContainer, sTitle,
sAuthor, sRecipients, dtCreated, sComments, oStrm, iSize);
oIndexedGuids.add(sGuid);
} // wend
oRSet.close();
oRecp.close();
PreparedStatement oUpdt = oConn.prepareStatement("UPDATE k_mime_msgs SET bo_indexed=1 WHERE gu_mimemsg=?");
ListIterator oIter = oIndexedGuids.listIterator();
while (oIter.hasNext()) {
oUpdt.setObject(1, oIter.next(), java.sql.Types.CHAR);
oUpdt.executeUpdate();
} // wend
oUpdt.close();
} // fi
oStmt.close();
oConn.close();
if (DebugFile.trace) DebugFile.writeln("IndexWriter.optimize()");
oIWrt.optimize();
if (DebugFile.trace) DebugFile.writeln("IndexWriter.close()");
oIWrt.close();
if (DebugFile.trace) {
DebugFile.decIdent();
DebugFile.writeln("End Indexer.rebuild()");
}