Subversion Repositories bacoAlunos

Rev

Rev 1814 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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