Source code: recoinx/clef/irs/mysql/MySQLEnglishAdapter.java
1
2 package recoinx.clef.irs.mysql;
3
4 import java.util.Vector;
5
6 import org.apache.log4j.Logger;
7
8 import recoin.container.RetrievalContainer;
9 import recoin.exception.InitiationException;
10
11 import recoin.group.ComponentRunnable;
12 import recoin.group.ComponentSupport;
13
14 import recoinx.clef.CLEFConstants;
15
16 /**
17 * This class is a simple extension of the abstract CLEFMySQLAdapter that searches
18 * the indexes of the english CLEF collections.
19 * @author Jan H. Scheufen
20 * @version 0.2.9
21 */
22 public class MySQLEnglishAdapter extends CLEFMySQLAdapter
23 {
24 /**
25 * The logger of this class.
26 */
27 static Logger logger;
28
29 /**
30 * Creates a new MySQLEnglishAdapter.
31 */
32 public MySQLEnglishAdapter()
33 {
34 // Initialize the logger for this class.
35 logger = Logger.getLogger( MySQLEnglishAdapter.class.getName() );
36 }
37
38 /**
39 * Creates and returns a MySQLRunnable that searches the english collections.
40 * @see recoin.group.ComponentWorker#createComponentRunnable(recoin.container.RetrievalContainer)
41 */
42 public ComponentRunnable createComponentRunnable(RetrievalContainer container)
43 {
44 if( !component.isInitiated() )
45 {
46 try
47 {
48 initiate(component);
49 }
50 catch (InitiationException e)
51 {
52 logger.error(e);
53 return null;
54 }
55 }
56 logger.debug("Returning new MySQLRunnable.");
57 return new MySQLRunnable(container, this, CLEFConstants.ENGLISH);
58 }
59
60 /**
61 * Creates and returns a MySQLRunnable that searches the english collections.
62 * @see recoin.group.ComponentWorker#createComponentRunnable(RetrievalContainer, Vector)
63 */
64 public ComponentRunnable createComponentRunnable( RetrievalContainer container, Vector supports)
65 {
66 if( !component.isInitiated() )
67 {
68 logger.warn("ComponentWorker '"+component.getClassname()+"' was not initiated. Initiating now ...");
69 try
70 {
71 initiate(component);
72 }
73 catch (InitiationException e)
74 {
75 logger.error("Unable to initiate ComponentWorker.");
76 return null;
77 }
78 }
79 logger.debug("Returning new MySQLRunnable.");
80 return new MySQLRunnable( container, (ComponentSupport)supports.firstElement(), this, CLEFConstants.ENGLISH );
81 }
82
83 /**
84 * Creates and returns a MySQLRunnable that searches the english collections.
85 * @see recoin.group.ComponentWorker#createComponentRunnable(recoin.container.RetrievalContainer, Vector, recoin.group.ComponentRunnable)
86 */
87 public ComponentRunnable createComponentRunnable( RetrievalContainer container, Vector supports, ComponentRunnable runnable)
88 {
89 if( !component.isInitiated() )
90 {
91 try
92 {
93 initiate(component);
94 }
95 catch (InitiationException e)
96 {
97 return null;
98 }
99 }
100 logger.debug("Returning new MySQLRunnable.");
101 return new MySQLRunnable(container, (ComponentSupport)supports.firstElement(), runnable, this, CLEFConstants.ENGLISH);
102 }
103
104 }