10.07.2015 Views

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}In this particular application, the bot calls the questionSearch() method(Example 3-15) to perform the actual search of the back-end Notes database. Itcreates a Notes session (in this example, using the remote CORBA classes),then does a full-text search of the database for the phrase the end user entered.If it finds a match, it returns the answer text contained within the matchingquestion document. If there is more than one match, the bot displays all matchesand the user is prompted to refine their search. If there are no matches, a newdocument is created in the database so that this particular question may beadded to the list of frequently asked ones if appropriate.Example 3-15 questionSearch() methodpublic String questionSearch(String query){String strQuestionSearch = "";Session session = null;try{//Start a notes session to access the FAQBot config databaseNotesThread.sinitThread();session = NotesFactory.createSession("itsotest-st31.cam.itso.ibm.com");Database db = session.getDatabase("itsotest-st31/ITSOST31","FAQBotConfig.nsf");if (db == null){System.out.println("Can't get a handle on the Database");}else{//Do a full text search on the databaseDocumentCollection dc = db.FTSearch("[PossibleQuestions] Contains \"" +query + "\"");Document doc;if (dc.getCount() > 1){//If there is more than 1 match...strQuestionSearch = "Do you mean: ";doc = dc.getFirstDocument();while (doc != null){strQuestionSearch = strQuestionSearch +doc.getItemValueString("TrueQuestion");doc = dc.getNextDocument(doc);68 <strong>Lotus</strong> <strong>Instant</strong> <strong>Messaging</strong>/<strong>Web</strong> <strong>Conferencing</strong> (Sametime): Building Sametime-Enabled Applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!