Initial revision
[mir.git] / source / mircoders / producer / ProducerAll.java
diff --git a/source/mircoders/producer/ProducerAll.java b/source/mircoders/producer/ProducerAll.java
new file mode 100755 (executable)
index 0000000..c12e706
--- /dev/null
@@ -0,0 +1,105 @@
+package mircoders.producer;
+
+import java.io.*;
+import java.lang.*;
+import java.util.*;
+
+import freemarker.template.*;
+
+import webdb.misc.*;
+import webdb.storage.*;
+import webdb.module.*;
+import webdb.entity.*;
+
+import mir.module.*;
+import mir.entity.*;
+import mir.storage.*;
+
+
+public class ProducerAll extends Producer{
+
+       private boolean rsync;
+
+       public static void main(String argv[])
+       {
+               try {   new ProducerAll().handle(new PrintWriter(System.out), null, false,false);       }
+               catch(Exception e) { System.err.println(e.toString()); }
+       }
+
+       // handle all
+       public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
+               throws StorageObjectException, ModuleException {
+               printHTML(htmlout, "Producer.All: started");
+
+               long                sessionConnectTime = 0;
+               long                startTime = (new java.util.Date()).getTime();
+               new ProducerImages().handle(htmlout, user, force,sync);
+               new ProducerStartPage().handle(htmlout, user, force,sync);
+               new ProducerContent().handle(htmlout, user, force,sync);
+               new ProducerOpenPosting().handle(htmlout, user, force,sync);
+               new ProducerTopics().handle(htmlout, user, force,sync);
+    new ProducerNavigation().handle(htmlout, user, force,sync);
+
+               // Finish
+               sessionConnectTime = new java.util.Date().getTime() - startTime;
+               logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
+
+               // do we have to rsync the site
+               if (sync==true){
+                       sessionConnectTime = 0;
+                       if (Helper.rsync()!=0){
+                               sessionConnectTime = new java.util.Date().getTime() - startTime;
+                               logHTML(htmlout, "Rsync failed: " + sessionConnectTime + " ms.");
+                       } else {
+                               sessionConnectTime = new java.util.Date().getTime() - startTime;
+                               logHTML(htmlout, "Rsync succeded: " + sessionConnectTime + " ms.");
+                       }
+               }
+       }
+
+       // handle all
+       public void handle2(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
+               throws StorageObjectException, ModuleException {
+               printHTML(htmlout, "Producer.All: started");
+
+               long                sessionConnectTime = 0;
+               long                startTime = (new java.util.Date()).getTime();
+               EntityContent   currentContent;
+               HashMap         currentContentValues;
+
+               //get all new unproduced content-entities
+               String whereClause="is_produced='0' && to_article_type>0";
+               String orderBy="date desc";
+               EntityList entityList = contentModule.getContent(whereClause,orderBy,0,-1,null);
+
+               //get their values
+               while (entityList != null) {
+                       for(int i=0;i<entityList.size();i++) {
+                               currentContent = (EntityContent)entityList.elementAt(i);
+                               currentContentValues = currentContent.getValues();
+                               EntityList topicEntityList = DatabaseContentToTopics.getInstance().getTopics(currentContent);
+                               SimpleHash topicHash = HTMLTemplateProcessor.makeSimpleHash(topicEntityList);
+
+                               try {
+                                       //check if this content item is related to a topic
+                                       if(currentContent.getId().equals(topicHash.get("content_id"))){
+                                               // produce the ToicsList
+                                               new ProducerTopics().handle(htmlout, user, force,sync,topicHash.get("topic_id").toString());
+                                       }
+                               } catch (TemplateModelException e) {
+                                       logHTML(htmlout, e.toString());
+                               }
+                       }
+               }
+
+               new ProducerContent().handle(htmlout, user, force,sync);
+               new ProducerOpenPosting().handle(htmlout, user, force,sync);
+               new ProducerStartPage().handle(htmlout, user, force,sync);
+               new ProducerTopics().handle(htmlout, user, force,sync);
+
+               // Finish
+               sessionConnectTime = new java.util.Date().getTime() - startTime;
+               logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
+       }
+}
+