atg.svc.repository.service
Class RecommendedAnswerService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.svc.repository.service.BaseService
              extended by atg.svc.repository.service.SharedService
                  extended by atg.svc.repository.service.RecommendedAnswerService
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener

public class RecommendedAnswerService
extends SharedService

Business methods for RecommendedAnswer objects. A RecommendedAnswer is an file or solution-based answer to an issue. There are two types of recommended answers: contextual answers and non-contextual answers.

A contextual answer is an answer found via a search. A contextual answer captures the exceprt return from the search plus information about how to display the exceprt hightlighted with the document again. This includes the following information: contextId, and url The information is obtained from the Document associated with an SvcSearchResult

A non-contextual answer simply captures enough information to display the document or answer again without highlighting. For a solution, this simply is the solution id For a non-solution document, we must also must capture the url and contextId (TODO: Confirm this is the right information to retrieve a non-solution non view-in-context document from ATG Search.)

Recommended answers are captured in one of two scenarios:
a) as part of a KnowledgeSession associated with a ticket or
b) in a SelfService knowledge session that hasn't been escalated. If the KnowledgeSession is escalated, the KnowledgeSession and RecommendedAnswer should be associated with the ticket created during escalation.

A RecommendedAnswer is associated with a ticket by storing the ticket id in a property of the RecommendedAnswer. Use the method #findByTicket(String pTicketId) to locate the recommended answers associated with a ticket.

Here's an example of how to create and save a new recommended answer

 atg.svc.search.service.RecommendedAnswerService recommendedAnswerService = getRecommendedAnswerService();
 atg.svc.search.service.SearchService searchService = getSearchService();
 SvcSearchResults results = searchService.search(searchContext);
 SvcSearchResult result = (SvcSearchResult)results.getResults()[0];
 Response esResult = result.getESResult();
 RecommendedAnswer recAnswer = recommendedAnswerService.createRecommendedAnswer();
 recAnswer.setContextId(esResult.getContextId());
 recAnswer.setTitle(esResult.getTitle());
 recAnswer.setExcerpt(esResult.getExcerpt());
 recAnswer.setUrl(esResult.getUrl());
 if (result instanceof SolutionSearchResult) {
   SolutionSearchResult solutionResult = (SolutionSearchResult)result;
   recAnswer.setDocType(RecommendedAnswerDocType.getSolution());
   recAnswer.setSolutionId(solutionResult.getSolutionId());
 } else if (ItemFormatConstraint.PDF == docType) {
   recAnswer.setDocType(RecommendedAnswerDocType.getPDFDocument());
 } else {
   recAnswer.setDocType(RecommendedAnswerDocType.getDocument());
 }
 recommendedAnswerService.saveRecommendedAnswer(recAnswer);
 
Now let's update the recommended answer - in this case changing the state from to rejected.
 RecommendedAnswer updateAnswer = recommendedAnswerService.editRecommendedAnswer(recAnswer.getId());
 updateAnswer.setState(RecommendedAnswerState.getRejected());
 recommendedAnswerService.saveRecommendedAnswer(updateAnswer);
 


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RecommendedAnswerService()
           
 
Method Summary
 atg.svc.repository.beans.RecommendedAnswer createRecommendedAnswer()
          Creates a RecommendedAnswer with the create date, modifiedDate, createdBy and modifiedBy populated and an initial state of Suggested.
 void deleteRecommendedAnswer(java.lang.String pRecommendedAnswerId)
          Deletes a RecommendedAnswer.
 atg.svc.repository.beans.RecommendedAnswer editRecommendedAnswer(java.lang.String pRecommendedAnswerId)
          Gets an editable version of a RecommendedAnswer given the id.
 atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerById(java.lang.String pRecommendedAnswerId)
          Finds a recommended answer by it's repository id.
 java.util.Collection findRecommendedAnswerByTicket(java.lang.String pTicketId)
          Returns the collection of recommended answers associated with the given ticket id.
 atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerByTicketAndDocument(java.lang.String pTicketId, java.lang.String pDocUrl)
          Returns the RecommendedAnswer associated with the given docId and ticket id
 atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerByTicketAndSolution(java.lang.String pTicketId, java.lang.String pSolutionId)
          Returns the RecommendedAnswer associated with the given solution id and ticket id
 java.util.Collection findRecommendedAnswersByDocument(java.lang.String pDocId)
          Returns the collection of recommended answers associated with the given docId Return collection is ordered by createDate from newest to oldest
 java.util.Collection findRecommendedAnswersByDocumentSince(java.lang.String pDocUrl, java.util.Date pSince, atg.svc.repository.beans.RecommendedAnswerState pState)
          Returns the collection of recommended answers associated with the given document url that were created since pCreateDate and match pState.
 java.util.Collection findRecommendedAnswersBySolution(java.lang.String pSolutionId)
          Returns the collection of recommended answers associated with the given solution id Return collection is ordered by modifyDate from newest to oldest
 java.util.Collection findRecommendedAnswersBySolutionSince(java.lang.String pSolutionId, java.util.Date pSince, atg.svc.repository.beans.RecommendedAnswerState pState)
          Returns the collection of recommended answers associated with the given solution that were created since pCreateDate and match pState.
 java.util.Collection findRecommendedAnswersBySolutionWithPaging(java.lang.String pSolutionId, int pStartIdx, int pCount)
          Returns one page of the recommended answers associated with the given solution id.
 atg.svc.agent.events.EventTools getEventTools()
           
 int getRecommendedAnswersCountBySolution(java.lang.String pSolutionId)
          Returns the number of recommended answers associated with the given solution id Return collection is ordered by modifyDate from newest to oldest
 SessionService getSessionService()
           
 SolutionScoringService getSolutionScoringService()
           
 SolutionService getSolutionService()
           
 atg.svc.ticketing.TicketHolder getTicketHolder()
           
 java.lang.String getTicketHolderNucleusPath()
           
 SolutionService getVersionedSolutionService()
           
 java.lang.String saveRecommendedAnswer(atg.svc.repository.beans.RecommendedAnswer pRecommendedAnswer, boolean pRecordSession)
          Persists a recommended answer
 void setEventTools(atg.svc.agent.events.EventTools pEventTools)
           
 void setSessionService(SessionService pSessionService)
           
 void setSolutionScoringService(SolutionScoringService pSolutionScoringService)
           
 void setSolutionService(SolutionService pSolutionService)
           
 void setTicketHolderNucleusPath(java.lang.String pTicketHolderNucleusPath)
           
 void setVersionedSolutionService(SolutionService pVersionedSolutionService)
           
 
Methods inherited from class atg.svc.repository.service.SharedService
getServiceSharedBeanHomes, getServiceSharedBeanHomesName, getServiceSharedRepositoryHomes, getServiceSharedRepositoryHomesName, setServiceSharedBeanHomesName, setServiceSharedRepositoryHomesName
 
Methods inherited from class atg.svc.repository.service.BaseService
getRepositoryService, getToday, setRepositoryService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

RecommendedAnswerService

public RecommendedAnswerService()
Method Detail

getSolutionScoringService

public SolutionScoringService getSolutionScoringService()

setSolutionScoringService

public void setSolutionScoringService(SolutionScoringService pSolutionScoringService)

getEventTools

public atg.svc.agent.events.EventTools getEventTools()

setEventTools

public void setEventTools(atg.svc.agent.events.EventTools pEventTools)

getSolutionService

public SolutionService getSolutionService()

setSolutionService

public void setSolutionService(SolutionService pSolutionService)

getVersionedSolutionService

public SolutionService getVersionedSolutionService()

setVersionedSolutionService

public void setVersionedSolutionService(SolutionService pVersionedSolutionService)

getSessionService

public SessionService getSessionService()

setSessionService

public void setSessionService(SessionService pSessionService)

getTicketHolderNucleusPath

public java.lang.String getTicketHolderNucleusPath()

setTicketHolderNucleusPath

public void setTicketHolderNucleusPath(java.lang.String pTicketHolderNucleusPath)

getTicketHolder

public atg.svc.ticketing.TicketHolder getTicketHolder()

findRecommendedAnswerById

public atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerById(java.lang.String pRecommendedAnswerId)
                                                                     throws ObjectNotFoundException
Finds a recommended answer by it's repository id.

Parameters:
pRecommendedAnswerId - The repository id.
Returns:
The RecommendedAnswer ReposImpl
Throws:
ObjectNotFoundException - If the id is not found.

findRecommendedAnswerByTicket

public java.util.Collection findRecommendedAnswerByTicket(java.lang.String pTicketId)
                                                   throws ObjectNotFoundException
Returns the collection of recommended answers associated with the given ticket id. Return collection is ordered by createDate from newest to oldest

Parameters:
pTicketId - The repository id of the ticket
Returns:
Collection of RecommendedAnswer associated with the ticket.
Throws:
ObjectNotFoundException

findRecommendedAnswersByDocument

public java.util.Collection findRecommendedAnswersByDocument(java.lang.String pDocId)
                                                      throws ObjectNotFoundException
Returns the collection of recommended answers associated with the given docId Return collection is ordered by createDate from newest to oldest

Parameters:
pDocId - The solution id or document url that uniquely identifies the solution/document
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException

findRecommendedAnswersBySolution

public java.util.Collection findRecommendedAnswersBySolution(java.lang.String pSolutionId)
                                                      throws ObjectNotFoundException
Returns the collection of recommended answers associated with the given solution id Return collection is ordered by modifyDate from newest to oldest

Parameters:
pSolutionId - The solution repository id
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException

findRecommendedAnswersBySolutionWithPaging

public java.util.Collection findRecommendedAnswersBySolutionWithPaging(java.lang.String pSolutionId,
                                                                       int pStartIdx,
                                                                       int pCount)
                                                                throws ObjectNotFoundException
Returns one page of the recommended answers associated with the given solution id. Use this API call to implement paging of the linked tickets associated with a solution. Return collection is ordered by modifyDate from newest to oldest

Parameters:
pSolutionId - The solution repository id
pStartIdx - The offset into the list of recommended answers linked to the given solution (zero-based)
pCount - The number of recommended answers to return
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException

getRecommendedAnswersCountBySolution

public int getRecommendedAnswersCountBySolution(java.lang.String pSolutionId)
                                         throws ObjectNotFoundException,
                                                javax.ejb.FinderException
Returns the number of recommended answers associated with the given solution id Return collection is ordered by modifyDate from newest to oldest

Parameters:
pSolutionId - The solution repository id
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException
javax.ejb.FinderException

findRecommendedAnswerByTicketAndDocument

public atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerByTicketAndDocument(java.lang.String pTicketId,
                                                                                           java.lang.String pDocUrl)
                                                                                    throws ObjectNotFoundException
Returns the RecommendedAnswer associated with the given docId and ticket id

Parameters:
pTicketId - Repository id of the ticket. If you want to lookup by external ticket id, get the ATG ticket first and use it's repository id.
pDocUrl - The document url.
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException

findRecommendedAnswerByTicketAndSolution

public atg.svc.repository.beans.RecommendedAnswer findRecommendedAnswerByTicketAndSolution(java.lang.String pTicketId,
                                                                                           java.lang.String pSolutionId)
                                                                                    throws ObjectNotFoundException
Returns the RecommendedAnswer associated with the given solution id and ticket id

Parameters:
pTicketId - Repository id of the ticket. If you want to lookup by external ticket id, get the ATG ticket first and use it's repository id.
pSolutionId - The solution repository id.
Returns:
Collection of RecommendedAnswer
Throws:
ObjectNotFoundException

findRecommendedAnswersByDocumentSince

public java.util.Collection findRecommendedAnswersByDocumentSince(java.lang.String pDocUrl,
                                                                  java.util.Date pSince,
                                                                  atg.svc.repository.beans.RecommendedAnswerState pState)
Returns the collection of recommended answers associated with the given document url that were created since pCreateDate and match pState. Return collection is ordered by createDate from newest to oldest

Parameters:
pDocUrl - The document url that uniquely identifies the document
pSince - RecommendedAnswer was created since this date
pState - Suggested, helpful or rejected
Returns:
Collection of RecommendedAnswer associated with the ticket.

findRecommendedAnswersBySolutionSince

public java.util.Collection findRecommendedAnswersBySolutionSince(java.lang.String pSolutionId,
                                                                  java.util.Date pSince,
                                                                  atg.svc.repository.beans.RecommendedAnswerState pState)
Returns the collection of recommended answers associated with the given solution that were created since pCreateDate and match pState. Return collection is ordered by createDate from newest to oldest

Parameters:
pSolutionId - The solution id that uniquely identifies the solution
pSince - RecommendedAnswer was created since this date
pState - Suggested, helpful or rejected
Returns:
Collection of RecommendedAnswer associated with the ticket.

createRecommendedAnswer

public atg.svc.repository.beans.RecommendedAnswer createRecommendedAnswer()
                                                                   throws javax.ejb.CreateException
Creates a RecommendedAnswer with the create date, modifiedDate, createdBy and modifiedBy populated and an initial state of Suggested. Call saveRecommededAnswer to persist the recommended answer.

Throws:
javax.ejb.CreateException - If the create fails.

editRecommendedAnswer

public atg.svc.repository.beans.RecommendedAnswer editRecommendedAnswer(java.lang.String pRecommendedAnswerId)
                                                                 throws ObjectNotFoundException
Gets an editable version of a RecommendedAnswer given the id.

Parameters:
pRecommendedAnswerId - Repository id of the recommended answer
Returns:
A RecommendedAnswer ReposImpl.
Throws:
ObjectNotFoundException

saveRecommendedAnswer

public java.lang.String saveRecommendedAnswer(atg.svc.repository.beans.RecommendedAnswer pRecommendedAnswer,
                                              boolean pRecordSession)
                                       throws javax.ejb.CreateException,
                                              ObjectNotFoundException,
                                              PersistenceException,
                                              atg.search.client.SearchClientException
Persists a recommended answer

Parameters:
pRecommendedAnswer - Repository bean returned from either createRecommendedAnswer or editRecommendedAnswer
pRecordSession - - Should we record this in the knowledge session
Returns:
repository id of the saved RecommendedAnswer
Throws:
ObjectNotFoundException
PersistenceException
javax.ejb.CreateException
atg.search.client.SearchClientException

deleteRecommendedAnswer

public void deleteRecommendedAnswer(java.lang.String pRecommendedAnswerId)
                             throws ObjectNotFoundException,
                                    PersistenceException
Deletes a RecommendedAnswer. Provided for completeness, but recommended answers generally should be marked as rejected rather than deleted.

Parameters:
pRecommendedAnswerId - Repository id of a RecommendedAnswer
Throws:
ObjectNotFoundException
PersistenceException