4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SuggestionManagerModule.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: SuggestionManagerModule.java
5  * Description: Class implements AnotServerModule calss for prupose of on server
6  * suggestion.
7  */
8 
9 /**
10  * @file SuggestionManagerModule.java
11  *
12  * @brief Class implements module for suggestiong of annotations.
13  */
14 
15 /**
16  * @package cz.vutbr.fit.knot.annotations.modules.suggestionManager
17  *
18  * @brief Classes responsible for management of suggestions
19  */
20 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
21 
27 
28 /**
29  * Class implements AnotServerModule calss for prupose of suggestiong of annotations.
30  * The module retrieves suggestions from NER or SEC API, stores them with their
31  * feedback and provides related services to the clients.
32  *
33  * @brief Class implements module for suggestiong of annotations.
34  *
35  * @author Martin Petr (xpetrm05)
36  */
38 
39  /**
40  * This method is called when client sent message and these message has been
41  * processed. Changes in types, annotations and in other entities are
42  * persisted after calling this method from all modules.
43  * It performs:
44  * - cleanup of suggestions in session after synchronization of document
45  *
46  * In this module it always returns empty string.
47  *
48  * @param requestInfo Informations about client request
49  * @return String with messages for client or empty string
50  */
51  @Override
52  public String processRequestBeforePersist(RequestInfo requestInfo) {
53  if (requestInfo.getSyncDocumentData() != null) { // if document was just synchronized
54  // Clean up
55  requestInfo.getSession().getSuggestionsCache().clear();
56  }
57  return "";
58  }
59 
60  /**
61  * This method is called when client sent message, these message has been
62  * processed and changes in entities are persisted. Composed response is sent
63  * to client after calling this method from all modules.
64  * It performs:
65  * - starting of new thread which will handles main functionality of this module
66  *
67  * @param requestInfo Informations about client request
68  * @param persistFailed True if changes not persisted, false otherwise.
69  * @return String with messages for client or empty string
70  */
71  @Override
72  public String processRequestAfterPersist(RequestInfo requestInfo, boolean persistFailed) {
73  if(persistFailed) {
74  return "";
75  }
76  SuggestionManager suggestThread = new SuggestionManager(requestInfo);
77  suggestThread.start();
78  return "";
79  }
80 
81  /**
82  * This method is called for each sleeping comet handler when he receives
83  * flier (part of informations about this or another client request).
84  *
85  * In this module it always returns empty string.
86  *
87  * @param flier Flier, which has been sent to all comet handlers.
88  * @param session Session associated with comet handler.
89  * @return If this handler hasn't react to this flier (not interested) return
90  * null, else return messages for client in single string.
91  */
92  @Override
93  public String messagesFromFlier(Flier flier, EditorSession session) {
94  return "";
95  }
96 
97  /**
98  * Returns name of this module. Name will be included in XML element
99  * attribute so usable characters are restricted.
100  *
101  * @param lang Requested language of name
102  * @return Name of this module
103  */
104  @Override
105  public String getModuleName(int lang) {
106  return "Suggestion Manager Module";
107  }
108 
109  /**
110  * Returns description of this module. It will be part of information
111  * about server functions.
112  *
113  * @param lang Requested language of description
114  * @return Description of this module
115  */
116  @Override
117  public String getModuleDescription(int lang) {
118  return "Suggestions module suggest annotations and actualize suggestions.";
119  }
120 } // public class SuggestionManagerModule
String processRequestAfterPersist(RequestInfo requestInfo, boolean persistFailed)
Class provides offerining of suggestions with usage of local knowledge repository.
Flier with informations for comet handlers.
Definition: Flier.java:31
Processed informations about client request.
Informations about client session.