1 package mircoders.producer;
7 import mircoders.storage.*;
8 import mircoders.module.*;
9 import mircoders.entity.*;
10 import mircoders.global.*;
11 import mircoders.localizer.*;
14 public class TopicStartPageProducerFactory implements ProducerFactory {
15 private String generatorIdentifier;
16 private String resourceBundle;
17 private String outputFileNameExpression;
18 private int nrNewswireItems;
19 private int nrFeatures;
21 public TopicStartPageProducerFactory(
22 String aGeneratorIdentifier,
23 String aResourceBundle,
24 String anOutputFileNameExpression,
26 int aNrNewswireItems) {
28 generatorIdentifier = aGeneratorIdentifier;
29 resourceBundle = aResourceBundle;
30 outputFileNameExpression = anOutputFileNameExpression;
31 nrFeatures = aNrFeatures;
32 nrNewswireItems = aNrNewswireItems;
36 public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
37 CompositeProducer result = new CompositeProducer();
38 Map values = new HashMap();
42 MirGlobal.localizer().producerTool().initializeGenerationValueSet(values);
44 ModuleContent contentModule = new ModuleContent(DatabaseContent.getInstance());
45 ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
46 ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
48 EntityBrowser topicBrowser = new EntityBrowser(
49 DatabaseTopics.getInstance(),
54 while (topicBrowser.hasNext()) {
55 Entity topic = (Entity) topicBrowser.next();
56 values.put("title", topic.getValue("title"));
57 values.put("filename", topic.getValue("filename"));
58 values.put("main_url", topic.getValue("main_url"));
59 values.put("archiv_url", topic.getValue("archiv_url"));
63 // ML: ok, this is way too low-level for this place:
64 String orderBy = "webdb_create desc";
65 String topicSelection = "exists (select * from content_x_topic where content_id=content.id and topic_id='"+topic.getValue("id")+"')";
66 String featureWhereClause = "is_published='1' and to_article_type='2' and "+topicSelection;
67 String newsWireWhereClause = "is_published='1' and to_article_type='1' and "+topicSelection;
71 // "exists (select * from content_x_topic where content_id=content.id and topic_id="+topic.getValue("id")
72 new StartPageProducer(
75 ParameterExpander.expandExpression(values, outputFileNameExpression),
76 contentModule.getContent(newsWireWhereClause, orderBy, 0,nrNewswireItems),
77 contentModule.getContent(featureWhereClause, orderBy, 0,nrFeatures),
78 topicsModule .getTopicsList(),
79 breakingModule.getBreakingNews()));
87 throw new ProducerFailure("Creating TopicStartPageProducer failed",e);
91 public Iterator verbs() {
92 Vector verbList = new Vector();
96 return verbList.iterator();