templateModelRoot ist now a simplehash with two entries: data and config, bugfix...
authoridfx <idfx>
Sun, 17 Mar 2002 16:55:22 +0000 (16:55 +0000)
committeridfx <idfx>
Sun, 17 Mar 2002 16:55:22 +0000 (16:55 +0000)
source/mir/entity/Entity.java
source/mir/misc/HTMLTemplateProcessor.java
source/mircoders/entity/EntityTopics.java
source/mircoders/module/ModuleComment.java
source/mircoders/module/ModuleTopics.java
source/mircoders/storage/DatabaseContent.java

index 6dd39ac..068d4e2 100755 (executable)
@@ -118,13 +118,13 @@ public class Entity implements TemplateHashModel, TemplateModelRoot
     {
       if (field.equals("webdb_create_formatted"))
       {
-               if (hasValueForField("webdb_create"))
-                       returnValue=StringUtil.dateToReadableDate(getValue("webdb_create"));
+        if (hasValueForField("webdb_create"))
+          returnValue=StringUtil.dateToReadableDate(getValue("webdb_create"));
       }
       else if (field.equals("webdb_lastchange_formatted"))
       {
         if (hasValueForField("webdblast_change"))
-                           returnValue=StringUtil.dateToReadableDate(getValue("webdb_lastchange"));
+          returnValue=StringUtil.dateToReadableDate(getValue("webdb_lastchange"));
       }
       else
         returnValue = (String)theValuesHash.get(field);
@@ -283,10 +283,10 @@ public class Entity implements TemplateHashModel, TemplateModelRoot
 
   public TemplateModel get(java.lang.String key) throws TemplateModelException
   {
-    return new SimpleScalar(getValue(key));
+               return new SimpleScalar(getValue(key));
   }
-
-  public void put(java.lang.String key, TemplateModel model)
+       
+       public void put(java.lang.String key, TemplateModel model)
   {
     // putting should only take place via setValue and is limited to the
     // database fields associated with the entity. no additional freemarker
index 1abaae5..bfa7558 100755 (executable)
@@ -204,27 +204,26 @@ public final class HTMLTemplateProcessor {
        *  date "now" // rk */
       // put standard configuration into tempalteRootmodel
       SimpleHash configHash = new SimpleHash();
-      configHash.put("docroot", new SimpleScalar(producerDocRoot));
-      configHash.put("storageroot", new SimpleScalar(producerStorageRoot));
-      configHash.put("productionhost", new SimpleScalar(productionHost));
-      configHash.put("openaction", new SimpleScalar(openAction));
+      configHash.put("producerDocRoot", new SimpleScalar(producerDocRoot));
+      configHash.put("storageRoot", new SimpleScalar(producerStorageRoot));
+      configHash.put("productionHost", new SimpleScalar(productionHost));
+      configHash.put("openAction", new SimpleScalar(openAction));
       configHash.put("actionRootLogin",new SimpleScalar(actionRoot));
-
-
-      tmr.put("docRoot", new SimpleScalar(docRoot));
-      tmr.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
-      tmr.put("actionRoot", new SimpleScalar(actionRoot+session));
-      tmr.put("openAction", new SimpleScalar(openAction));
-      tmr.put("productionHost", new SimpleScalar(productionHost));
-      tmr.put("videoHost", new SimpleScalar(videoHost));
-      tmr.put("audioHost", new SimpleScalar(audioHost));
-      tmr.put("imageHost", new SimpleScalar(imageHost));
+      configHash.put("docRoot", new SimpleScalar(docRoot));
+      configHash.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
+      configHash.put("actionRoot", new SimpleScalar(actionRoot+session));
+      configHash.put("productionHost", new SimpleScalar(productionHost));
+      configHash.put("videoHost", new SimpleScalar(videoHost));
+      configHash.put("audioHost", new SimpleScalar(audioHost));
+      configHash.put("imageHost", new SimpleScalar(imageHost));
       // this conform to updated freemarker syntax
-      tmr.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
-
-      tmr.put("config", configHash);
-      tmpl.process(tmr, out);
-
+      configHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+                       
+                       SimpleHash outPutHash = new SimpleHash();
+                       outPutHash.put("data",tmr);
+      outPutHash.put("config", configHash);
+                       
+      tmpl.process(outPutHash,out);
     }
 
 
index c7fb5cf..4e3aefa 100755 (executable)
@@ -18,23 +18,13 @@ import mircoders.storage.*;
  */
 
 
-public class EntityTopics extends Entity
-{
+public class EntityTopics extends Entity {
   public EntityTopics(){
          super();
   }
 
-  public EntityTopics(StorageObject theStorage)
-  {
+  public EntityTopics(StorageObject theStorage) {
     this();
     setStorage(theStorage);
   }
-
-  // Dependencies einhalten
-  public void update() throws StorageObjectException{
-    super.update();
-    DatabaseContent dbContent = DatabaseContent.getInstance();
-    dbContent.setUnproduced("to_topic="+getId());
-  }
-
 }
index 169e418..c49448d 100755 (executable)
@@ -48,19 +48,16 @@ public class ModuleComment extends AbstractModule
   /**
    * setValues in the Entity and updates them on the StorageObject
    */
-  public String set(HashMap theValues) throws ModuleException
-  {
+  public String set(HashMap theValues) throws ModuleException {
     try {
       Entity theEntity = theStorage.selectById((String)theValues.get("id"));
       if (theEntity == null)
          throw new ModuleException("No Objekt with id in Database id: " + theValues.get("id"));
+      DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
       theEntity.setValues(theValues);
       theEntity.update();
-      //set content to unproduced
-      DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
       return theEntity.getId();
-    }
-    catch (StorageObjectException e){
+    } catch (StorageObjectException e){
       e.printStackTrace(System.err);
       throw new ModuleException(e.toString());
     }
index ac4f02e..707ce61 100755 (executable)
@@ -16,6 +16,7 @@ import mir.misc.*;
 import mir.storage.*;
 
 import mircoders.storage.*;
+import mircoders.entity.*;
 
 /*
  *  ThemenModule -
@@ -62,5 +63,33 @@ public class ModuleTopics extends AbstractModule
       }
       return returnList;
     }
+       
+       /**
+        * Overrides the AbstractModule.set(),
+        * All dependent ContentEntities are set unproduced.
+        * @param theValues Hash mit Spalte/Wert-Paaren
+        * @return Id des eingefügten Objekts
+        * @exception ModuleException
+        */
+       public String set (HashMap theValues) throws ModuleException {
+               try {
+                       Entity theEntity = theStorage.selectById((String)theValues.get("id"));
+                       if (theEntity == null){
+                               throw new ModuleException("Kein Objekt mit id in Datenbank id: " + theValues.get("id"));
+                       }
+                       theEntity.setValues(theValues);
+                       DatabaseContentToTopics db = DatabaseContentToTopics.getInstance();
+       DatabaseContent dbc = DatabaseContent.getInstance();
+                       EntityList contentList = db.getContent((EntityTopics)theEntity);
+                       for (int i = 0; i < contentList.size(); i++){
+                               dbc.setUnproduced("id="+((EntityContent)contentList.elementAt(i)).getId());
+                       }
+                       theEntity.update();
+                       return theEntity.getId();
+               } catch (StorageObjectException e){
+                       e.printStackTrace(System.err);
+                       throw new ModuleException(e.toString());
+               }
+ }
 
 }
index 624b116..f4301ba 100755 (executable)
@@ -60,11 +60,13 @@ public class DatabaseContent extends Database implements StorageObject {
   {
     Connection con=null;Statement stmt=null;
     String sql = "update content set is_produced='0' where " + where;
+    theLog.printDebugInfo("set unproduced: "+where);
     try {
       con = getPooledCon();
       // should be a preparedStatement because is faster
       stmt = con.createStatement();
       executeUpdate(stmt,sql);
+      theLog.printDebugInfo("set unproduced: "+where);
     }
     catch (Exception e) {_throwStorageObjectException(e, "-- set unproduced failed");}
     finally { freeConnection(con,stmt);}