1 package mircoders.producer;
7 import mircoders.storage.*;
8 import mircoders.module.*;
9 import mircoders.entity.*;
12 public class TopicStartPageProducerFactory implements ProducerFactory {
13 private String generatorIdentifier;
14 private String resourceBundle;
15 private String outputFileNameExpression;
16 private int nrNewswireItems;
17 private int nrFeatures;
19 public TopicStartPageProducerFactory(
20 String aGeneratorIdentifier,
21 String aResourceBundle,
22 String anOutputFileNameExpression,
24 int aNrNewswireItems) {
26 generatorIdentifier = aGeneratorIdentifier;
27 resourceBundle = aResourceBundle;
28 outputFileNameExpression = anOutputFileNameExpression;
29 nrFeatures = aNrFeatures;
30 nrNewswireItems = aNrNewswireItems;
34 public mir.producer.Producer makeProducer(String aVerb) throws ProducerException {
35 CompositeProducer result = new CompositeProducer();
36 Map values = new HashMap();
39 ModuleContent contentModule = new ModuleContent(DatabaseContent.getInstance());
40 ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
41 ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
43 EntityBrowser topicBrowser = new EntityBrowser(
44 DatabaseTopics.getInstance(),
49 while (topicBrowser.hasNext()) {
50 Entity topic = (Entity) topicBrowser.next();
51 values.put("title", topic.getValue("title"));
52 values.put("filename", topic.getValue("filename"));
53 values.put("main_url", topic.getValue("main_url"));
54 values.put("archiv_url", topic.getValue("archiv_url"));
57 // ML: ok, this is way to low-level for this place:
58 String orderBy = "webdb_create desc";
59 String topicSelection = "exists (select * from content_x_topic where content_id=content.id and topic_id='"+topic.getValue("id")+"')";
60 String featureWhereClause = "is_published='1' and to_article_type='2' and "+topicSelection;
61 String newsWireWhereClause = "is_published='1' and to_article_type='1' and "+topicSelection;
65 // "exists (select * from content_x_topic where content_id=content.id and topic_id="+topic.getValue("id")
66 new StartPageProducer(
69 ParameterExpander.expandExpression(values, outputFileNameExpression),
70 contentModule.getContent(newsWireWhereClause, orderBy, 0,nrNewswireItems),
71 contentModule.getContent(featureWhereClause, orderBy, 0,nrFeatures),
72 topicsModule .getTopicsList(),
73 breakingModule.getBreakingNews()));
81 throw new ProducerException(e);
85 public Iterator verbs() {
86 Vector verbList = new Vector();
90 return verbList.iterator();