Subversion Repositories bacoAlunos

Rev

Rev 485 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 485 Rev 1306
1
package pt.estgp.estgweb.services.common;
1
package pt.estgp.estgweb.services.common;
2
 
2
 
3
import jomm.ir.lucene.LuceneUtils;
3
import jomm.ir.lucene.LuceneUtils;
4
import org.apache.log4j.Logger;
4
import org.apache.log4j.Logger;
5
import pt.estgp.estgweb.Globals;
5
import pt.estgp.estgweb.Globals;
6
import pt.estgp.estgweb.domain.DomainObject;
6
import pt.estgp.estgweb.domain.DomainObject;
7
import pt.estgp.estgweb.domain.UserSession;
7
import pt.estgp.estgweb.domain.UserSession;
8
import pt.estgp.estgweb.services.common.impl.CommonSearchResults;
8
import pt.estgp.estgweb.services.common.impl.CommonSearchResults;
9
import pt.estgp.estgweb.services.common.impl.DefaultResult;
9
import pt.estgp.estgweb.services.common.impl.DefaultResult;
10
import pt.estgp.estgweb.services.common.impl.DefaultSearchResults;
10
import pt.estgp.estgweb.services.common.impl.DefaultSearchResults;
11
import pt.estgp.estgweb.services.common.impl.DefaultToDoCat;
11
import pt.estgp.estgweb.services.common.impl.DefaultToDoCat;
12
import pt.estgp.estgweb.web.UserSessionProxy;
12
import pt.estgp.estgweb.web.UserSessionProxy;
13
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
13
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
14
import pt.estgp.estgweb.web.utils.TestHttpServletRequest;
14
import pt.estgp.estgweb.web.utils.TestHttpServletRequest;
15
import pt.utl.ist.berserk.logic.filterManager.exceptions.FilterRetrieveException;
15
import pt.utl.ist.berserk.logic.filterManager.exceptions.FilterRetrieveException;
16
 
16
 
17
import java.util.ArrayList;
17
import java.util.ArrayList;
18
import java.util.List;
18
import java.util.List;
19
 
19
 
20
/**
20
/**
21
 * @author Jorge Machado
21
 * @author Jorge Machado
22
 * @date 24/Abr/2008
22
 * @date 24/Abr/2008
23
 * @time 14:55:22
23
 * @time 14:55:22
24
 * @see pt.estgp.estgweb.services.common
24
 * @see pt.estgp.estgweb.services.common
25
 */
25
 */
26
public class CommonServicesManager
26
public class CommonServicesManager
27
{
27
{
28
 
28
 
29
    private static final int SEARCH_FRAGMENT_SIZE = Globals.SEARCH_BEST_FRAGMENTS_MAX_FRAGMENT_SIZE;
29
    private static final int SEARCH_FRAGMENT_SIZE = Globals.SEARCH_BEST_FRAGMENTS_MAX_FRAGMENT_SIZE;
30
    private static final int SEARCH_MAX_FRAGMENTS = Globals.SEARCH_BEST_FRAGMENTS_MAX_FRAGMENTS;
30
    private static final int SEARCH_MAX_FRAGMENTS = Globals.SEARCH_BEST_FRAGMENTS_MAX_FRAGMENTS;
31
    private static final int SEARCH_MAX_RESULTS = Globals.SEARCH_MAX_RESULTS;
31
    private static final int SEARCH_MAX_RESULTS = Globals.SEARCH_MAX_RESULTS;
32
 
32
 
33
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CommonServicesManager.class);
33
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CommonServicesManager.class);
34
 
34
 
35
    private static CommonServicesManager ourInstance = new CommonServicesManager();
35
    private static CommonServicesManager ourInstance = new CommonServicesManager();
36
 
36
 
37
    public static CommonServicesManager getInstance()
37
    public static CommonServicesManager getInstance()
38
    {
38
    {
39
        return ourInstance;
39
        return ourInstance;
40
    }
40
    }
41
 
41
 
42
    private CommonServicesManager()
42
    private CommonServicesManager()
43
    {
43
    {
44
    }
44
    }
45
 
45
 
46
    /**
46
    /**
47
     * @param userSession    asking
47
     * @param userSession    asking
48
     * @param query      to execute
48
     * @param query      to execute
49
     * @param searchType see SearchTypeEnum
49
     * @param searchType see SearchTypeEnum
50
     * @return Cluster of Results for each Module with total module results, only return modules with results
50
     * @return Cluster of Results for each Module with total module results, only return modules with results
51
     * @throws Throwable on notAuthorized or internal error
51
     * @throws Throwable on notAuthorized or internal error
52
     */
52
     */
53
    public ICommonSearchResults search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
53
    public ICommonSearchResults search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
54
    {
54
    {
55
        return search(userSession,query,searchType,null);
55
        return search(userSession,query,searchType,null);
56
    }
56
    }
57
 
57
 
58
    /**
58
    /**
59
     * @param userSession    asking
59
     * @param userSession    asking
60
     * @param query      to execute
60
     * @param query      to execute
61
     * @param searchType see SearchTypeEnum
61
     * @param searchType see SearchTypeEnum
62
     * @param from interface from
62
     * @param from interface from
63
     * @return Cluster of Results for each Module with total module results, only return modules with results
63
     * @return Cluster of Results for each Module with total module results, only return modules with results
64
     * @throws Throwable on notAuthorized or internal error
64
     * @throws Throwable on notAuthorized or internal error
65
     */
65
     */
66
    public ICommonSearchResults search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType, 1.5.0/docs/api/java/lang/String.html">String from) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
66
    public ICommonSearchResults search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType, 1.5.0/docs/api/java/lang/String.html">String from) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
67
    {
67
    {
68
 
68
 
69
        if (searchType == null)
69
        if (searchType == null)
70
            searchType = SearchTypeEnum.AllWords;
70
            searchType = SearchTypeEnum.AllWords;
71
        CommonSearchResults commonSearchResults = new CommonSearchResults();
71
        CommonSearchResults commonSearchResults = new CommonSearchResults();
72
        if(query != null && query.trim().length() > 0)
72
        if(query != null && query.trim().length() > 0)
73
        {
73
        {
74
 
74
 
75
 
75
 
76
            List<ISearchResults> results = new ArrayList<ISearchResults>();
76
            List<ISearchResults> results = new ArrayList<ISearchResults>();
77
 
77
 
78
            for (ModuleEnum module : ModuleEnum.values())
78
            for (ModuleEnum module : ModuleEnum.values())
79
            {
79
            {
80
                if (module.getModuleCommonServices() != null)
80
                if (module.getModuleCommonServices() != null)
81
                {
81
                {
82
                    List<ISearchResults> iSearchResultsList = search(userSession, query, searchType, module,null, 0, from);
82
                    List<ISearchResults> iSearchResultsList = search(userSession, query, searchType, module,null, 0, from);
83
                    if(iSearchResultsList != null && iSearchResultsList.size() > 0)
83
                    if(iSearchResultsList != null && iSearchResultsList.size() > 0)
84
                        for(ISearchResults iSearchResults: iSearchResultsList)
84
                        for(ISearchResults iSearchResults: iSearchResultsList)
85
                        {
85
                        {
86
                            if (iSearchResults != null && iSearchResults.getTotalResults() > 0)
86
                            if (iSearchResults != null && iSearchResults.getTotalResults() > 0)
87
                            {
87
                            {
88
                                results.add(iSearchResults);
88
                                results.add(iSearchResults);
89
                                commonSearchResults.addMoreResults(iSearchResults.getTotalResults());
89
                                commonSearchResults.addMoreResults(iSearchResults.getTotalResults());
90
                            }
90
                            }
91
                        }
91
                        }
92
                }
92
                }
93
            }
93
            }
94
            commonSearchResults.setResults(results);
94
            commonSearchResults.setResults(results);
95
        }
95
        }
96
        else
96
        else
97
        {
97
        {
98
            commonSearchResults.setResults(new ArrayList<ISearchResults>());
98
            commonSearchResults.setResults(new ArrayList<ISearchResults>());
99
        }
99
        }
100
        commonSearchResults.setQuery(query);
100
        commonSearchResults.setQuery(query);
101
        commonSearchResults.setSearchType(searchType.getMessageKey());
101
        commonSearchResults.setSearchType(searchType.getMessageKey());
102
        return commonSearchResults;
102
        return commonSearchResults;
103
    }
103
    }
104
 
104
 
105
 
105
 
106
    /**
106
    /**
107
     * The service called inside implements method
107
     * The service called inside implements method
108
     * <p/>
108
     * <p/>
109
     * public ISearchResults search(String search, SearchTypeEnum searchType, int page, int maxResults, UserSession userSession);
109
     * public ISearchResults search(String search, SearchTypeEnum searchType, int page, int maxResults, UserSession userSession);
110
     *
110
     *
111
     * @param userSession    asking
111
     * @param userSession    asking
112
     * @param query      to execute
112
     * @param query      to execute
113
     * @param searchType see SearchTypeEnum
113
     * @param searchType see SearchTypeEnum
114
     * @param moduleKey  to search in
114
     * @param moduleKey  to search in
115
     * @param page       of start result
115
     * @param page       of start result
116
     * @param from interface from
116
     * @param from interface from
117
     * @return searchResults
117
     * @return searchResults
118
     * @throws Throwable on not authorized and internal error
118
     * @throws Throwable on not authorized and internal error
119
     */
119
     */
120
    public List<ISearchResults> search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType, ModuleEnum moduleKey,1.5.0/docs/api/java/lang/String.html">String moduleInternalKey, int page, 1.5.0/docs/api/java/lang/String.html">String from) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
120
    public List<ISearchResults> search(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String query, SearchTypeEnum searchType, ModuleEnum moduleKey,1.5.0/docs/api/java/lang/String.html">String moduleInternalKey, int page, 1.5.0/docs/api/java/lang/String.html">String from) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
121
    {
121
    {
122
        try
122
        try
123
        {
123
        {
124
//            sm = ServiceManager.getInstance();
124
//            sm = ServiceManager.getInstance();
125
//            String[] names = new String[]{};
125
//            String[] names = new String[]{};
126
//            Object[] args = new Object[]{query, searchType, page, SEARCH_MAX_RESULTS};
126
//            Object[] args = new Object[]{query, searchType, page, SEARCH_MAX_RESULTS};
127
 
127
 
128
            List<ISearchResults> searchResultsList = moduleKey.getModuleCommonServices().searchList(moduleInternalKey, from, query, searchType, page, SEARCH_MAX_RESULTS, userSession); //(DefaultSearchResults) sm.execute(requester, moduleKey.getSearchService(), "search", args, names);
128
            List<ISearchResults> searchResultsList = moduleKey.getModuleCommonServices().searchList(moduleInternalKey, from, query, searchType, page, SEARCH_MAX_RESULTS, userSession); //(DefaultSearchResults) sm.execute(requester, moduleKey.getSearchService(), "search", args, names);
129
            if(searchResultsList == null || searchResultsList.size() == 0)
129
            if(searchResultsList == null || searchResultsList.size() == 0)
130
                return null;
130
                return null;
131
            for(ISearchResults iSearchResults: searchResultsList)
131
            for(ISearchResults iSearchResults: searchResultsList)
132
            {
132
            {
133
                DefaultSearchResults searchResults = (DefaultSearchResults) iSearchResults;
133
                DefaultSearchResults searchResults = (DefaultSearchResults) iSearchResults;
134
 
134
 
135
                searchResults.setPage(page);
135
                searchResults.setPage(page);
136
                searchResults.setMaxResultsPage(SEARCH_MAX_RESULTS);
136
                searchResults.setMaxResultsPage(SEARCH_MAX_RESULTS);
137
                searchResults.setQuery(query.replace("'", " "));
137
                searchResults.setQuery(query.replace("'", " "));
138
                searchResults.setSearchType(searchType.getMessageKey());
138
                searchResults.setSearchType(searchType.getMessageKey());
139
                if (searchResults.getTotalResults() > 0)
139
                if (searchResults.getTotalResults() > 0)
140
                {
140
                {
141
                    for (IResult result : searchResults.getResults())
141
                    for (IResult result : searchResults.getResults())
142
                    {
142
                    {
143
                        DefaultResult defaultResult = (DefaultResult) result;
143
                        DefaultResult defaultResult = (DefaultResult) result;
144
                        if(defaultResult.getBestFragments() == null || defaultResult.getBestFragments().trim().length() == 0)
144
                        if(defaultResult.getBestFragments() == null || defaultResult.getBestFragments().trim().length() == 0)
145
                        {
145
                        {
146
                            defaultResult.setBestFragments(LuceneUtils.doStandardHighlights(defaultResult.getText(), query, SEARCH_FRAGMENT_SIZE, SEARCH_MAX_FRAGMENTS));
146
                            defaultResult.setBestFragments(LuceneUtils.doStandardHighlights(defaultResult.getText(), query, SEARCH_FRAGMENT_SIZE, SEARCH_MAX_FRAGMENTS));
147
                        }
147
                        }
148
                        if (!defaultResult.isTitleKey())
148
                        if (!defaultResult.isTitleKey())
149
                        {
149
                        {
150
                            1.5.0/docs/api/java/lang/String.html">String title = defaultResult.getTitle();
150
                            1.5.0/docs/api/java/lang/String.html">String title = defaultResult.getTitle();
151
                            defaultResult.setTitle(LuceneUtils.highlight(defaultResult.getTitle(), query));
151
                            defaultResult.setTitle(LuceneUtils.highlight(defaultResult.getTitle(), query));
152
                            if (defaultResult.getTitle() == null || defaultResult.getTitle().length() == 0)
152
                            if (defaultResult.getTitle() == null || defaultResult.getTitle().length() == 0)
153
                                defaultResult.setTitle(title);
153
                                defaultResult.setTitle(title);
154
                        }
154
                        }
155
                        if (!defaultResult.isSubTitleKey())
155
                        if (!defaultResult.isSubTitleKey())
156
                        {
156
                        {
157
                            1.5.0/docs/api/java/lang/String.html">String subTitle = defaultResult.getSubTitle();
157
                            1.5.0/docs/api/java/lang/String.html">String subTitle = defaultResult.getSubTitle();
158
                            defaultResult.setSubTitle(LuceneUtils.highlight(defaultResult.getSubTitle(), query));
158
                            defaultResult.setSubTitle(LuceneUtils.highlight(defaultResult.getSubTitle(), query));
159
                            if (defaultResult.getSubTitle() == null || defaultResult.getSubTitle().length() == 0)
159
                            if (defaultResult.getSubTitle() == null || defaultResult.getSubTitle().length() == 0)
160
                                defaultResult.setSubTitle(subTitle);
160
                                defaultResult.setSubTitle(subTitle);
161
                        }
161
                        }
162
                        if(defaultResult.getText() != null && defaultResult.getText().trim().length() > 0)
162
                        if(defaultResult.getText() != null && defaultResult.getText().trim().length() > 0)
163
                        {
163
                        {
164
                            1.5.0/docs/api/java/lang/String.html">String text = defaultResult.getText();
164
                            1.5.0/docs/api/java/lang/String.html">String text = defaultResult.getText();
165
 
165
 
166
                            defaultResult.setText(LuceneUtils.highlight(defaultResult.getText(), query));
166
                            defaultResult.setText(LuceneUtils.highlight(defaultResult.getText(), query));
167
                            if (defaultResult.getText() == null || defaultResult.getText().length() == 0)
167
                            if (defaultResult.getText() == null || defaultResult.getText().length() == 0)
168
                                defaultResult.setText(text);
168
                                defaultResult.setText(text);
169
                        }
169
                        }
170
 
170
 
171
                        if(defaultResult.getCreator() != null && defaultResult.getCreator().trim().length() > 0)
171
                        if(defaultResult.getCreator() != null && defaultResult.getCreator().trim().length() > 0)
172
                        {
172
                        {
173
                            1.5.0/docs/api/java/lang/String.html">String creator = defaultResult.getCreator();
173
                            1.5.0/docs/api/java/lang/String.html">String creator = defaultResult.getCreator();
174
 
174
 
175
                            defaultResult.setCreator(LuceneUtils.highlight(defaultResult.getCreator(), query));
175
                            defaultResult.setCreator(LuceneUtils.highlight(defaultResult.getCreator(), query));
176
                            if (defaultResult.getCreator() == null || defaultResult.getCreator().length() == 0)
176
                            if (defaultResult.getCreator() == null || defaultResult.getCreator().length() == 0)
177
                                defaultResult.setCreator(creator);
177
                                defaultResult.setCreator(creator);
178
                        }
178
                        }
179
                    }
179
                    }
180
                }
180
                }
181
            }
181
            }
182
            return searchResultsList;
182
            return searchResultsList;
183
        }
183
        }
184
        catch (FilterRetrieveException e)
184
        catch (FilterRetrieveException e)
185
        {
185
        {
186
            logger.error(e, e);
186
            logger.error(e, e);
187
            throw new NotAuthorizedException(e.toString());
187
            throw new NotAuthorizedException(e.toString());
188
        }
188
        }
189
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
189
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
190
        {
190
        {
191
            logger.error(moduleKey.getMessageKey() + " - query:" + query + ": " + e, e);
191
            logger.error(moduleKey.getMessageKey() + " - query:" + query + ": " + e, e);
192
            throw e;
192
            throw e;
193
        }
193
        }
194
    }
194
    }
195
 
195
 
196
    public List<IToDoCat> getToDosCats(UserSession userSession) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
196
    public List<IToDoCat> getToDosCats(UserSession userSession) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
197
    {
197
    {
198
        List<IToDoCat> toDoCats = new ArrayList<IToDoCat>();
198
        List<IToDoCat> toDoCats = new ArrayList<IToDoCat>();
199
 
199
 
200
        for (ModuleEnum module : ModuleEnum.values())
200
        for (ModuleEnum module : ModuleEnum.values())
201
        {
201
        {
202
            if (module.getModuleCommonServices() != null)
202
            if (module.getModuleCommonServices() != null)
203
            {
203
            {
204
                IToDoCat toDoCat = getToDoCats(userSession, module);
204
                IToDoCat toDoCat = getToDoCats(userSession, module);
205
                if (toDoCat != null)
205
                if (toDoCat != null)
206
                {
206
                {
207
                    toDoCats.add(toDoCat);
207
                    toDoCats.add(toDoCat);
208
                }
208
                }
209
            }
209
            }
210
        }
210
        }
211
        return toDoCats;
211
        return toDoCats;
212
    }
212
    }
213
 
213
 
214
    public List<IToDoCat> getAllToDosCats(UserSession userSession) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
214
    public List<IToDoCat> getAllToDosCats(UserSession userSession) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
215
    {
215
    {
216
        List<IToDoCat> toDoCats = new ArrayList<IToDoCat>();
216
        List<IToDoCat> toDoCats = new ArrayList<IToDoCat>();
217
        for (ModuleEnum module : ModuleEnum.values())
217
        for (ModuleEnum module : ModuleEnum.values())
218
        {
218
        {
219
            if (module.getModuleCommonServices() != null)
219
            if (module.getModuleCommonServices() != null)
220
            {
220
            {
221
                IToDoCat toDoCat = getAllToDoCats(userSession, module);
221
                IToDoCat toDoCat = getAllToDoCats(userSession, module);
222
                if (toDoCat != null && toDoCat.getTotalToDo() > 0)
222
                if (toDoCat != null && toDoCat.getTotalToDo() > 0)
223
                {
223
                {
224
                    toDoCats.add(toDoCat);
224
                    toDoCats.add(toDoCat);
225
                }
225
                }
226
            }
226
            }
227
        }
227
        }
228
        return toDoCats;
228
        return toDoCats;
229
    }
229
    }
230
 
230
 
231
    public IToDoCat getToDoCats(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String moduleKey) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
231
    public IToDoCat getToDoCats(UserSession userSession, 1.5.0/docs/api/java/lang/String.html">String moduleKey) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
232
    {
232
    {
233
        return getToDoCats(userSession, ModuleEnum.parse(moduleKey));
233
        return getToDoCats(userSession, ModuleEnum.parse(moduleKey));
234
    }
234
    }
235
 
235
 
236
 
236
 
237
    /**
237
    /**
238
     * @param userSession asking
238
     * @param userSession asking
239
     * @param module  to search
239
     * @param module  to search
240
     * @return Number of ToDos in given module
240
     * @return Number of ToDos in given module
241
     * @throws Throwable on Error or NotAuthorized Exception
241
     * @throws Throwable on Error or NotAuthorized Exception
242
     */
242
     */
243
    public IToDoCat getToDoCats(UserSession userSession, ModuleEnum module) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
243
    public IToDoCat getToDoCats(UserSession userSession, ModuleEnum module) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
244
    {
244
    {
245
//        IServiceManager sm;
245
//        IServiceManager sm;
246
        try
246
        try
247
        {
247
        {
248
            return module.getModuleCommonServices().getToDo(userSession);
248
            return module.getModuleCommonServices().getToDo(userSession);
249
//            sm = ServiceManager.getInstance();
249
//            sm = ServiceManager.getInstance();
250
//            String[] names = new String[]{};
250
//            String[] names = new String[]{};
251
//            Object[] args = new Object[]{};
251
//            Object[] args = new Object[]{};
252
//            return (IToDoCat) sm.execute(requester, module.getGetToDoService(), "getToDo", args, names);
252
//            return (IToDoCat) sm.execute(requester, module.getGetToDoService(), "getToDo", args, names);
253
        }
253
        }
254
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
254
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
255
        {
255
        {
256
            logger.error(e, e);
256
            logger.error(e, e);
257
            throw e;
257
            throw e;
258
        }
258
        }
259
    }
259
    }
260
 
260
 
261
    /**
261
    /**
262
     * @param userSession asking
262
     * @param userSession asking
263
     * @param module    to search
263
     * @param module    to search
264
     * @return Number of ToDos in given module
264
     * @return Number of ToDos in given module
265
     * @throws Throwable on Error or NotAuthorized Exception
265
     * @throws Throwable on Error or NotAuthorized Exception
266
     */
266
     */
267
    public IToDoCat getAllToDoCats(UserSession userSession, ModuleEnum module) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
267
    public IToDoCat getAllToDoCats(UserSession userSession, ModuleEnum module) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
268
    {
268
    {
269
//        IServiceManager sm;
269
//        IServiceManager sm;
270
        try
270
        try
271
        {
271
        {
272
//            sm = ServiceManager.getInstance();
272
//            sm = ServiceManager.getInstance();
273
//            String[] names = new String[]{};
273
//            String[] names = new String[]{};
274
//            Object[] args = new Object[]{};
274
//            Object[] args = new Object[]{};
275
//            List<IToDo> todos = (List<IToDo>) sm.execute(requester, module.getAllToDosService(), "getAllToDos", args, names);
275
//            List<IToDo> todos = (List<IToDo>) sm.execute(requester, module.getAllToDosService(), "getAllToDos", args, names);
276
            List<IToDo> todos = module.getModuleCommonServices().getAllToDos(userSession);
276
            List<IToDo> todos = module.getModuleCommonServices().getAllToDos(userSession);
277
            DefaultToDoCat toDoCat = new DefaultToDoCat();
277
            DefaultToDoCat toDoCat = new DefaultToDoCat();
278
            toDoCat.setAllToDos(todos);
278
            toDoCat.setAllToDos(todos);
279
            toDoCat.setDescription(module.getMessageKey());
279
            toDoCat.setDescription(module.getMessageKey());
280
            return toDoCat;
280
            return toDoCat;
281
        }
281
        }
282
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
282
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
283
        {
283
        {
284
            logger.error(e, e);
284
            logger.error(e, e);
285
            throw e;
285
            throw e;
286
        }
286
        }
287
    }
287
    }
288
 
288
 
289
    /**
289
    /**
290
     * Advise modules for new object creation
290
     * Advise modules for new object creation
291
     * @param domainObject created
291
     * @param domainObject created
292
     */
292
     */
293
    public void adviseNew(DomainObject domainObject)
293
    public void adviseNew(DomainObject domainObject)
294
    {
294
    {
295
        for (ModuleEnum module : ModuleEnum.values())
295
        for (ModuleEnum module : ModuleEnum.values())
296
        {
296
        {
297
            module.getModuleCommonServices().adviseNew(domainObject);
297
            module.getModuleCommonServices().adviseNew(domainObject);
298
        }
298
        }
299
    }
299
    }
300
 
300
 
301
    /**
301
    /**
302
     * Advise modules for new object creation
302
     * Advise modules for new object creation
303
     * @param domainObject created
303
     * @param domainObject created
304
     */
304
     */
305
    public void adviseUpdate(DomainObject domainObject)
305
    public void adviseUpdate(DomainObject domainObject)
306
    {
306
    {
307
        for (ModuleEnum module : ModuleEnum.values())
307
        for (ModuleEnum module : ModuleEnum.values())
308
        {
308
        {
309
            module.getModuleCommonServices().adviseUpdate(domainObject);
309
            module.getModuleCommonServices().adviseUpdate(domainObject);
310
        }
310
        }
311
    }
311
    }
312
 
312
 
313
 
313
 
314
 
314
 
315
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
315
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable
316
    {
316
    {
317
        ICommonSearchResults commonSearchResults = new CommonServicesManager().search(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null), "teste", SearchTypeEnum.AllWords);
317
        ICommonSearchResults commonSearchResults = new CommonServicesManager().search(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null), "teste", SearchTypeEnum.AllWords);
318
        for (ISearchResults searchResults : commonSearchResults.getSearchResults())
318
        for (ISearchResults searchResults : commonSearchResults.getSearchResults())
319
        {
319
        {
320
            1.5.0/docs/api/java/lang/System.html">System.out.println("-----------------------------------------------------");
320
            1.5.0/docs/api/java/lang/System.html">System.out.println("-----------------------------------------------------");
321
            1.5.0/docs/api/java/lang/System.html">System.out.println("Module" + searchResults.getModule().getMessageKey());
321
            1.5.0/docs/api/java/lang/System.html">System.out.println("Module" + searchResults.getModule().getMessageKey());
322
            for (IResult result : searchResults.getResults())
322
            for (IResult result : searchResults.getResults())
323
            {
323
            {
324
                1.5.0/docs/api/java/lang/System.html">System.out.println("");
324
                1.5.0/docs/api/java/lang/System.html">System.out.println("");
325
                1.5.0/docs/api/java/lang/System.html">System.out.println("\ttitle:" + result.getTitle());
325
                1.5.0/docs/api/java/lang/System.html">System.out.println("\ttitle:" + result.getTitle());
326
                1.5.0/docs/api/java/lang/System.html">System.out.println("\tsubTitle:" + result.getSubTitle());
326
                1.5.0/docs/api/java/lang/System.html">System.out.println("\tsubTitle:" + result.getSubTitle());
327
                1.5.0/docs/api/java/lang/System.html">System.out.println("\ttext:" + result.getText());
327
                1.5.0/docs/api/java/lang/System.html">System.out.println("\ttext:" + result.getText());
328
                1.5.0/docs/api/java/lang/System.html">System.out.println("\turl:" + result.getUrl());
328
                1.5.0/docs/api/java/lang/System.html">System.out.println("\turl:" + result.getUrl());
329
                1.5.0/docs/api/java/lang/System.html">System.out.println("\tbestFragments:" + result.getBestFragments());
329
                1.5.0/docs/api/java/lang/System.html">System.out.println("\tbestFragments:" + result.getBestFragments());
330
 
330
 
331
            }
331
            }
332
//            System.out.println("NEXT PAGE TEST>>>>>>>>>>>>>>>>>>>");
332
//            System.out.println("NEXT PAGE TEST>>>>>>>>>>>>>>>>>>>");
333
//            ISearchResults searchResults2 = new CommonServicesManager().search("18D0D23A7C07FF478CE8DAFEBA58D37A","teste",SearchTypeEnum.AllWords,searchResults.getModule(),1);
333
//            ISearchResults searchResults2 = new CommonServicesManager().search("18D0D23A7C07FF478CE8DAFEBA58D37A","teste",SearchTypeEnum.AllWords,searchResults.getModule(),1);
334
//            for(IResult result2: searchResults2.getResults())
334
//            for(IResult result2: searchResults2.getResults())
335
//            {
335
//            {
336
//                System.out.println("");
336
//                System.out.println("");
337
//                System.out.println("\ttitle:" +result2.getTitle());
337
//                System.out.println("\ttitle:" +result2.getTitle());
338
//                System.out.println("\tsubTitle:" +result2.getSubTitle());
338
//                System.out.println("\tsubTitle:" +result2.getSubTitle());
339
//                System.out.println("\ttext:" +result2.getText());
339
//                System.out.println("\ttext:" +result2.getText());
340
//                System.out.println("\turl:" + result2.getUrl());
340
//                System.out.println("\turl:" + result2.getUrl());
341
//                System.out.println("\tbestFragments:" + result2.getBestFragments());
341
//                System.out.println("\tbestFragments:" + result2.getBestFragments());
342
//            }
342
//            }
343
 
343
 
344
        }
344
        }
345
        CommonServicesManager.getInstance().getAllToDosCats(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null));
345
        CommonServicesManager.getInstance().getAllToDosCats(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null));
346
        1.5.0/docs/api/java/lang/System.html">System.out.println(CommonServicesManager.getInstance().getAllToDosCats(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null)));
346
        1.5.0/docs/api/java/lang/System.html">System.out.println(CommonServicesManager.getInstance().getAllToDosCats(UserSessionProxy.loadUserSession(new TestHttpServletRequest("2093FFF41F61E375D2CB4CBEDE4400E9"),null)));
347
    }
347
    }
348
 
348
 
349
}
349
}
350
 
350