01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.components;
19:
20: import java.util.Iterator;
21:
22: import de.finix.contelligent.CallData;
23: import de.finix.contelligent.Component;
24: import de.finix.contelligent.ComponentManager;
25: import de.finix.contelligent.content.Content;
26: import de.finix.contelligent.content.ContentProvider;
27: import de.finix.contelligent.content.TextContent;
28: import de.finix.contelligent.logging.LoggingService;
29: import de.finix.contelligent.search.Metainfo;
30:
31: public class SearchMetainfo extends Folder implements
32: de.finix.contelligent.SearchMetainfo {
33: final static org.apache.log4j.Logger log = LoggingService
34: .getLogger(SearchMetainfo.class);
35:
36: public boolean isDynamic() {
37: return false;
38: }
39:
40: public void putSearchMetainfo(Metainfo metainfo, CallData callData) {
41: super .putSearchMetainfo(metainfo, callData);
42: ComponentManager cm = getComponentContext()
43: .getPersistenceManager();
44: Iterator iterator = cm.getSubcomponentNames(this ).iterator();
45:
46: while (iterator.hasNext()) {
47: try {
48: String name = (String) iterator.next();
49: Component component = cm.getSubcomponent(this , name,
50: callData, true);
51: if (component instanceof ContentProvider) {
52: Content content = ((ContentProvider) component)
53: .getContent();
54: String value = content.getContentValue(callData)
55: .toString();
56:
57: if (content instanceof TextContent) {
58: metainfo.addText(name, value);
59: } else {
60: metainfo.addKeyword(name, value);
61: }
62: }
63: } catch (Exception e) {
64: log.warn("Error while building metainfo map", e);
65: }
66: }
67: }
68: }
|