Got rid of AbstractEntity.java / deprecated Entity.getValues() and HTMLTemplateProces...
authorrk <rk>
Thu, 24 Jan 2002 22:38:04 +0000 (22:38 +0000)
committerrk <rk>
Thu, 24 Jan 2002 22:38:04 +0000 (22:38 +0000)
28 files changed:
source/mir/entity/AbstractEntity.java [deleted file]
source/mir/entity/Entity.java
source/mir/entity/EntityRelation.java
source/mir/entity/GenericEntity.java
source/mir/misc/HTMLTemplateProcessor.java
source/mir/servlet/ServletModule.java
source/mir/servlet/ServletModuleMonitor.java
source/mir/storage/Database.java
source/mircoders/entity/EntityBreaking.java
source/mircoders/entity/EntityComment.java
source/mircoders/entity/EntityContent.java
source/mircoders/entity/EntityFeature.java
source/mircoders/entity/EntityImages.java
source/mircoders/entity/EntityLinksImcs.java
source/mircoders/entity/EntityMedia.java
source/mircoders/entity/EntityTopics.java
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/entity/EntityUsers.java
source/mircoders/entity/EntityVideo.java
source/mircoders/producer/ProducerAll.java
source/mircoders/producer/ProducerContent.java
source/mircoders/producer/ProducerFeature.java
source/mircoders/producer/ProducerStartPage.java
source/mircoders/producer/ProducerTopics.java
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/servlet/ServletModuleLinksImcs.java
source/mircoders/servlet/ServletModuleUsers.java
source/mircoders/storage/DatabaseLinksImcs.java

diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java
deleted file mode 100755 (executable)
index 632fc39..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * <b>abstrakte Basisklasse der Entity-Klassen</b><p>
- */
-
-
-package  mir.entity;
-
-import java.lang.*;
-import java.io.*;
-import java.util.*;
-import java.sql.*;
-
-import mir.storage.*;
-import mir.misc.*;
-
-/**
- * abstrakte Basisklasse der Entity-Klassen
- *
- * @author RK
- * @version 29.6.1999
- *
- */
-
-public class AbstractEntity implements Entity
-{
-  private boolean             changed;
-  protected HashMap           theValuesHash;   // tablekey / value
-  protected StorageObject     theStorageObject;
-  protected static Logfile    theLog;
-  protected ArrayList         streamedInput=null;
-  private static int instances = 0;
-
-    public AbstractEntity() {
-      theLog = Logfile.getInstance(this.getClass().getName());
-      this.changed = false;
-      instances++;
-      Integer i = new Integer(instances);
-      System.err.println("New abstract entity instance: "+i.toString());
-    }
-
-  /**
-   * Konstruktor
-   */
-  public AbstractEntity (StorageObject StorageObject) {
-    this();
-    setStorage(StorageObject);
-  }
-
-  /*
-   * Setzt das StorageObject der Entity.
-   */
-  public void setStorage (StorageObject storage) {
-    this.theStorageObject = storage;
-  }
-
-  /**
-   * Setzt die Werte der Entity
-   * @param theStringValues
-   */
-
-  public void setValues(HashMap theStringValues)
-  {
-    /** @todo should be synchronized */
-    theValuesHash = new HashMap();
-    String aKey;
-    Set set = theStringValues.keySet();
-    Iterator it = set.iterator();
-    int size = set.size();
-    for (int i = 0; i < size; i++) {
-      aKey = (String)it.next();
-      theValuesHash.put(aKey, (String)theStringValues.get(aKey));
-    }
- }
-
-  /**
-   * Liefert boolschen Wert, ob sich der Inhalt der Entity geändert hat.
-   * @return true wenn ja, sonst false
-   */
-  public boolean changed () {
-    return  changed;
-  }
-
-  /**
-   * Liefert den Primärschluessel der Entity zurueck
-   * @return String Id
-   */
-  public String getId () {
-    return  (String)getValue(theStorageObject.getIdName());
-  }
-
-  /**
-   * Setzt den Primaerschluessel der Entity
-   * @param id
-   */
-  public void setId (String id) {
-    theValuesHash.put(theStorageObject.getIdName(), id);
-      }
-
-  /**
-   * Liefert den Wert für einen Feldnamen zurueck
-   * @param theFieldString
-   * @return Wert für Feld
-   */
-  public String getValue (String theFieldString) {
-    return  (String)theValuesHash.get(theFieldString);
-    }
-
-  /**
-   * Fügt Entity via StorageObject in Datenbank ein.
-   * @return Primary Key der Entity
-   * @exception StorageObjectException
-   */
-  public String insert () throws StorageObjectException {
-    theLog.printDebugInfo("Entity: trying to insert ...");
-    if (theStorageObject != null) {
-      return theStorageObject.insert((Entity)this);
-    }
-    else
-      throw  new StorageObjectException("Kein StorageObject gesetzt!");
-  }
-
-  /**
-   * Aktualisiert Aenderungen an der Entity in der Datenbank
-   * @exception StorageObjectException
-   */
-  public void update () throws StorageObjectException {
-    theStorageObject.update((Entity)this);
-  }
-
-  /**
-   * Setzt den Wert fuer ein Feld
-   * @param theProp
-   * @param theValue
-   * @exception StorageObjectException
-   */
-  public void setValueForProperty (String theProp, String theValue) throws StorageObjectException {
-    this.changed = true;
-    if (isField(theProp))
-      theValuesHash.put(theProp, theValue);
-    else
-      theLog.printWarning("Property not found: " + theProp+theValue);
-
-  }
-
-  /**
-   * Gibt die Feldnamen der Entity als ArrayList zurueck
-   * @return ArrayList mit Feldnamen
-   * @exception StorageObjectException wird geworfen, wenn kein Zugriff auf die Datenbank
-   *    möglich.
-   */
-  public ArrayList getFields () throws StorageObjectException {
-    return  theStorageObject.getFields();
-    }
-
-  /**
-   * Liefert ein int[] mit den Typen der Felder zurueck
-   * @return int[] mit den Feldtypen
-   * @exception StorageObjectException
-   */
-  public int[] getTypes () throws StorageObjectException {
-    return  theStorageObject.getTypes();
-    }
-
-  /**
-   * Liefert ArrayListe mit Feldnamen zurueck.
-   * @return Liste mit Feldnamen
-   * @exception StorageObjectException
-   */
-  public ArrayList getLabels () throws StorageObjectException {
-    return  theStorageObject.getLabels();
-    }
-
-  /**
-   * Liefert eine Hashmap mit allen Werten der Entity zurueck
-   * @return HashMap mit Feldname/Wert
-   */
-    public HashMap getValues() {
-      return theValuesHash;
-    }
-
-    /**
-     *  Liefert einen ArrayList mit allen Datenbankfeldern, die
-     *  als streamedInput ausgelesen werden muessen.
-     *  Waere automatisierbar ueber die types (blob, etc.)
-     *  Bisher manuell anzulegen in der erbenden Klasse
-     */
-
-  public ArrayList streamedInput() {
-    return streamedInput;
-  }
-
-   /* Fragt ab, ob fieldName einem Feld entspricht
-   * @param fieldName
-   * @return true, wennn ja, sonst false
-   * @exception StorageObjectException
-   */
-  public boolean isField (String fieldName) throws StorageObjectException {
-    return  theStorageObject.getFields().contains(fieldName);
-  }
-
-   /** Liefert Anzahl der Instanzen zurück
-   * @return int
-   */
-  public int getInstances() {
-     return instances;
-  }
-  /**
-   * Gibt eine Instanz frei
-   */
-  public void finalize () {
-    instances--;
-    try {
-      super.finalize();
-    } catch (Throwable t) {
-      System.err.println(t.toString());
-    }
-  }
-}
-
index bff5eb2..c6790d7 100755 (executable)
-/*
- * put your module comment here
+/**
+ * Base class the entities are derived from. Provides base functionality of
+ * an entity<p>
  */
 
 
-package mir.entity;
+package  mir.entity;
 
 import java.lang.*;
+import java.io.*;
 import java.util.*;
+import java.sql.*;
+
+import freemarker.template.*;
+
 import mir.storage.*;
+import mir.misc.*;
 
 /**
- * Interface-Definition für Entities
+ * Base Class of Entities
+ * Interfacing TemplateHashModel and TemplateModelRoot to be freemarker compliant
+ *
+ * @author rk
+ * @version 29.6.1999
+ *
  */
 
-public interface Entity {
-
-       /**
-        * Eine Entity muss setStorage implementieren, mit der eine Entity mit einem
-        * StorageObject assoziiert wird.
-        *
-        * @param st
-        */
-       public abstract void setStorage (StorageObject st);
-
-
-
-       /**
-        * Eine Entity muss setValues implementieren, mit der die Werte der Entity gesetzt werden
-        * können.
-        *
-        * @param ht
-        */
-               public abstract void setValues(HashMap ht);
-
-
-
-       /**
-        * Eine Entity muss getValues implementieren, mit der die Werte der Entity
-        * als HashMap zurueckgeliefert werden
-        * @return Werte der Entity
-        */
-               public abstract HashMap getValues();
-
-
-
-       /**
-        * Eine Entity muss getFields implementieren, mit der die Feldnamen der
-        * Entity zurueckgegeben werden.
-        * @return ArrayList der Feldnamen
-        * @exception StorageObjectException
-        */
-       public abstract ArrayList getFields () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getTypes implementieren, mit der die Feldtype der
-        * Entity zurueckgegeben werden.
-        * @return int[] der Feldtypen
-        * @exception StorageObjectException
-        */
-       public abstract int[] getTypes () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getLabels implementieren, mit der die Feldnamen der
-        * Entity zurueckgegeben werden.
-        * @return ArrayList der Feldnamen
-        * @exception StorageObjectException
-        */
-       public abstract ArrayList getLabels () throws StorageObjectException;
-
-
-
-       /**
-        * Eine Entity muss getId implementieren, um den Primaerschuessel der
-        * Entity zurueckgeliefert zu bekommen.
-        *
-        * @return Primary-Key der Entity
-        */
-               public abstract String getId();
-
-
-
-       /**
-        * Eine Entity muss setId implementieren, um den Primaerschuessel der
-        * Entity zu setzen
-        *
-        * @param str
-        */
-               public abstract void setId(String str);
-
-
-       /**
-        * Eine Entity muss getValue implementieren, um den Wert eines
-        * Feldes zurueckzugeben
-        *
-        * @param field
-        * @return Wert von Feld field
-        */
-       public abstract String getValue (String field);
-
-
-
-       /**
-        * Einfügen der Entity in StorageObject
-        *
-        * @return Primary-Key der eingefügten Entity
-        * @exception StorageObjectException
-        */
-       public abstract String insert () throws StorageObjectException;
-
-
-
-       /**
-        * Aktualisieren der Entity via StorageObject
-        * @exception StorageObjectException
-        */
-       public abstract void update () throws StorageObjectException;
-
-
-
-       /**
-        * ArrayListe mit Feldern, die einer Sonderbehandlung bedürfen (blobs)
-        * @return Liste der Feldnamen
-        */
-       public abstract ArrayList streamedInput ();
-
-
-       public abstract void setValueForProperty (String theProp, String theValue) throws StorageObjectException;
+public class Entity implements TemplateHashModel, TemplateModelRoot
+{
+  private boolean             changed;
+  protected HashMap           theValuesHash;   // tablekey / value
+  protected StorageObject     theStorageObject;
+  protected static Logfile    theLog;
+  protected ArrayList         streamedInput=null;
+  private static int instances = 0;
+
+    public Entity() {
+      theLog = Logfile.getInstance(this.getClass().getName());
+      this.changed = false;
+      instances++;
+      Integer i = new Integer(instances);
+      System.err.println("New abstract entity instance: "+i.toString());
+    }
+
+  /**
+   * Konstruktor
+   */
+  public Entity (StorageObject StorageObject) {
+    this();
+    setStorage(StorageObject);
+  }
+
+  /*
+   * Setzt das StorageObject der Entity.
+   */
+  public void setStorage (StorageObject storage) {
+    this.theStorageObject = storage;
+  }
+
+  /**
+   * Setzt die Werte der Entity
+   * @param theStringValues
+   */
+
+  public void setValues(HashMap theStringValues)
+  {
+    /** @todo should be synchronized */
+    theValuesHash = new HashMap();
+    String aKey;
+    Set set = theStringValues.keySet();
+    Iterator it = set.iterator();
+    int size = set.size();
+    for (int i = 0; i < size; i++) {
+      aKey = (String)it.next();
+      theValuesHash.put(aKey, (String)theStringValues.get(aKey));
+    }
+ }
+
+  /**
+   * Liefert boolschen Wert, ob sich der Inhalt der Entity geändert hat.
+   * @return true wenn ja, sonst false
+   */
+  public boolean changed () {
+    return  changed;
+  }
+
+  /**
+   * Liefert den Primärschluessel der Entity zurueck
+   * @return String Id
+   */
+  public String getId () {
+    return  (String)getValue(theStorageObject.getIdName());
+  }
+
+  /**
+   * Setzt den Primaerschluessel der Entity
+   * @param id
+   */
+  public void setId (String id) {
+    theValuesHash.put(theStorageObject.getIdName(), id);
+      }
+
+  /**
+   * Liefert den Wert für einen Feldnamen zurueck
+   * @param theFieldString
+   * @return Wert für Feld
+   */
+  public String getValue (String field) {
+    String returnValue = null;
+    if (field != null)
+    {
+      if (field.equals("webdb_create_formatted"))
+      {
+               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"));
+      }
+      else
+        returnValue = (String)theValuesHash.get(field);
+    }
+    return returnValue;
+  }
+
+
+  public boolean hasValueForField(String field)
+  {
+    if (theValuesHash!=null)
+      return theValuesHash.containsKey(field);
+    return false;
+  }
+
+  /**
+   * Fügt Entity via StorageObject in Datenbank ein.
+   * @return Primary Key der Entity
+   * @exception StorageObjectException
+   */
+  public String insert () throws StorageObjectException {
+    theLog.printDebugInfo("Entity: trying to insert ...");
+    if (theStorageObject != null) {
+      return theStorageObject.insert((Entity)this);
+    }
+    else
+      throw  new StorageObjectException("Kein StorageObject gesetzt!");
+  }
+
+  /**
+   * Aktualisiert Aenderungen an der Entity in der Datenbank
+   * @exception StorageObjectException
+   */
+  public void update () throws StorageObjectException {
+    theStorageObject.update((Entity)this);
+  }
+
+  /**
+   * Setzt den Wert fuer ein Feld
+   * @param theProp
+   * @param theValue
+   * @exception StorageObjectException
+   */
+  public void setValueForProperty (String theProp, String theValue) throws StorageObjectException {
+    this.changed = true;
+    if (isField(theProp))
+      theValuesHash.put(theProp, theValue);
+    else
+      theLog.printWarning("Property not found: " + theProp+theValue);
+
+  }
+
+  /**
+   * Gibt die Feldnamen der Entity als ArrayList zurueck
+   * @return ArrayList mit Feldnamen
+   * @exception StorageObjectException wird geworfen, wenn kein Zugriff auf die Datenbank
+   *    möglich.
+   */
+  public ArrayList getFields () throws StorageObjectException {
+    return  theStorageObject.getFields();
+    }
+
+  /**
+   * Liefert ein int[] mit den Typen der Felder zurueck
+   * @return int[] mit den Feldtypen
+   * @exception StorageObjectException
+   */
+  public int[] getTypes () throws StorageObjectException {
+    return  theStorageObject.getTypes();
+    }
+
+  /**
+   * Liefert ArrayListe mit Feldnamen zurueck.
+   * @return Liste mit Feldnamen
+   * @exception StorageObjectException
+   */
+  public ArrayList getLabels () throws StorageObjectException {
+    return  theStorageObject.getLabels();
+    }
+
+  /**
+   * Liefert eine Hashmap mit allen Werten der Entity zurueck
+   * @return HashMap mit Feldname/Wert
+   *
+   * @deprecated This method is deprecated and will be deleted in the next release.
+   *  AbstractEntity interfaces freemarker.template.TemplateHashModel now and can
+   *  be used in the same way as SimpleHash.
+
+   */
+    public HashMap getValues() {
+      return theValuesHash;
+    }
+
+    /**
+     *  Liefert einen ArrayList mit allen Datenbankfeldern, die
+     *  als streamedInput ausgelesen werden muessen.
+     *  Waere automatisierbar ueber die types (blob, etc.)
+     *  Bisher manuell anzulegen in der erbenden Klasse
+     */
+
+  public ArrayList streamedInput() {
+    return streamedInput;
+  }
+
+   /* Fragt ab, ob fieldName einem Feld entspricht
+   * @param fieldName
+   * @return true, wennn ja, sonst false
+   * @exception StorageObjectException
+   */
+  public boolean isField (String fieldName) throws StorageObjectException {
+    return  theStorageObject.getFields().contains(fieldName);
+  }
+
+   /** Liefert Anzahl der Instanzen zurück
+   * @return int
+   */
+  public int getInstances() {
+     return instances;
+  }
+  /**
+   * Gibt eine Instanz frei
+   */
+  public void finalize () {
+    instances--;
+    try {
+      super.finalize();
+    } catch (Throwable t) {
+      System.err.println(t.toString());
+    }
+  }
+
+
+  // Now implements freemarkers TemplateHashModel
+  // two methods have to be overridden:
+  // 1. public boolean isEmpty() throws TemplateModelException
+  // 2. public TemplateModel get(java.lang.String key) throws TemplateModelException
+
+  public boolean isEmpty() throws TemplateModelException
+  {
+    if (theValuesHash==null || theValuesHash.isEmpty())
+      return true;
+    return false;
+  }
+
+  public TemplateModel get(java.lang.String key) throws TemplateModelException
+  {
+    theLog.printDebugInfo("trying to get: " + key);
+    return new SimpleScalar(getValue(key));
+  }
+
+  public void put(java.lang.String key, TemplateModel model)
+  {
+    // empty for testing
+  }
+
+  public void remove(java.lang.String key)
+  {
+    // empty for testing
+  }
+
+
+  //////////////////////////////////////////////////////////////////////////////////
 
 
 }
 
-
-
-
index 161855d..fa7e065 100755 (executable)
@@ -50,10 +50,10 @@ public class EntityRelation {
    *           null.
    */
 
-  public SimpleHash getOneAsSimpleHash(Entity entity) throws StorageObjectException {
+  public Entity getOneAsSimpleHash(Entity entity) throws StorageObjectException {
     if (type==TO_ONE) {
-        Entity returnEntity = getOne(entity);
-        if (returnEntity!=null) return HTMLTemplateProcessor.makeSimpleHash(returnEntity);
+        Entity returnEntity = (Entity)getOne(entity);
+        if (returnEntity!=null) return returnEntity;
     }
     return null;
   }
@@ -83,7 +83,7 @@ public class EntityRelation {
     }
     else return null;
   }
-  
+
   /**
    *   @return Liefert eine freemarker.template.SimpleList mit den verknuepften
    *           Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
@@ -128,7 +128,7 @@ public class EntityRelation {
     }
     return null;
   }
-  
+
   /**
    *   @return Liefert eine freemarker.template.SimpleList mit den verknuepften
    *           Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
index 12f3d56..a52015b 100755 (executable)
@@ -11,8 +11,8 @@ package mir.entity;
  * @author /rk
  * @version 1.2
  */
-public class GenericEntity extends AbstractEntity
-               implements Entity {}
+public class GenericEntity extends Entity
+                {}
 
 
 
index 56747aa..1e47adc 100755 (executable)
@@ -42,9 +42,12 @@ public final class HTMLTemplateProcessor {
     templateDir = MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
     templateCache = new FileTemplateCache(templateDir);
     templateCache.setLoadingPolicy(templateCache.LOAD_ON_DEMAND);
-    templateCache.startAutoUpdate();
+    // gone in freemarker 1.71
+    // templateCache.startAutoUpdate();
+
     docRoot = MirConfig.getProp("RootUri");
     theLog=Logfile.getInstance("HTMLTemplateProcessor");
+
     //the quick hack is back in effect as it was more broken than ever before
     // -mh
     // sorry: nadir back in town, i have to debug the mirbase.jar in the
@@ -231,7 +234,7 @@ public final class HTMLTemplateProcessor {
     SimpleList  simpleList = new SimpleList();
     if (aList != null) {
       for(int i=0;i<aList.size();i++) {
-        simpleList.add(makeSimpleHash(aList.elementAt(i)));
+        simpleList.add(aList.elementAt(i));
       }
     }
     return simpleList;
@@ -252,7 +255,7 @@ public final class HTMLTemplateProcessor {
     if (aList != null) {
       for (int i=0;i<aList.size();i++) {
          currentEntity = (Entity)aList.elementAt(i);
-         simpleHash.put(currentEntity.getId(), makeSimpleHash(currentEntity));
+         simpleHash.put(currentEntity.getId(), currentEntity);
       }
     }
     return simpleHash;
@@ -263,6 +266,9 @@ public final class HTMLTemplateProcessor {
    *  @param entity ist die Entity
    *  @return SimpleHash mit den entsprechenden freemarker Daten
    *
+   *  @deprecated This method is deprecated and will be deleted in the next release.
+   *  AbstractEntity interfaces freemarker.template.TemplateHashModel now and can
+   *  be used in the same way as SimpleHash.
    */
   public static SimpleHash makeSimpleHash(Entity entity) {
     if (entity != null)
@@ -336,11 +342,17 @@ public final class HTMLTemplateProcessor {
    */
   private static Template getTemplateFor(String templateFilename) throws HTMLParseException
   {
-    if (templateFilename!=null) return templateCache.getTemplate(templateFilename);
-    else {
+    Template returnTemplate = null;
+    if (templateFilename!=null)
+      returnTemplate = templateCache.getTemplate(templateFilename);
+
+
+    if (returnTemplate==null) {
       theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);
       throw new HTMLParseException("Templatefile: "+ templateFilename + " not found.");
     }
+
+    return returnTemplate;
   }
 
   public static void stopAutoUpdate(){
index 2938c65..6e4998b 100755 (executable)
@@ -300,20 +300,6 @@ public abstract class ServletModule {
       throw new ServletModuleException(e.toString());
     }
   }
-  /**
-   * deliver liefert das Template mit dem Filenamen templateFilename
-   * an den HttpServletResponse res aus, nachdem es mit den Daten aus
-   * TemplateModelRoot rtm gemischt wurde
-   *
-   * @param res Http-Response, die vom Dispatcher durchgereicht wird
-   * @param entity Entity, aus der die Daten, die ins Template gemerged werden sollen.
-   * @param tmpl Name des Templates
-   * @exception ServletModuleException
-   */
-  public void deliver(HttpServletRequest req, HttpServletResponse res, Entity ent, String templateFilename)
-    throws ServletModuleException {
-    deliver(req, res,HTMLTemplateProcessor.makeSimpleHash(ent), templateFilename);
-  }
 
   /**
    * deliver liefert das Template mit dem Filenamen templateFilename
index 0a5b387..3bfdd1f 100755 (executable)
@@ -49,7 +49,7 @@ public class ServletModuleMonitor extends ServletModule
     }
   }
   protected int getInstances(){
-    AbstractEntity ent = new AbstractEntity();
+    Entity ent = new Entity();
     return ent.getInstances();
   }
   public String getInstancesInfo(){
index 3c75365..fb0cc8e 100755 (executable)
@@ -563,7 +563,6 @@ public class Database implements StorageObject {
     //cache
     invalidatePopupCache();
     try {
-      HashMap theEntityValues = theEntity.getValues();
       ArrayList streamedInput = theEntity.streamedInput();
       StringBuffer f = new StringBuffer();
       StringBuffer v = new StringBuffer();
@@ -583,8 +582,8 @@ public class Database implements StorageObject {
               aValue = "?";
             }
             else {
-              if (theEntityValues.containsKey(aField)) {
-                aValue = "'" + StringUtil.quote((String)theEntityValues.get(aField))
+              if (theEntity.hasValueForField(aField)) {
+                aValue = "'" + StringUtil.quote((String)theEntity.getValue(aField))
                     + "'";
               }
             }
@@ -612,7 +611,7 @@ public class Database implements StorageObject {
       pstmt = con.prepareStatement(sql);
       if (streamedInput != null) {
         for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString = (String)theEntityValues.get(streamedInput.get(i));
+          String inputString = (String)theEntity.getValue((String)streamedInput.get(i));
           pstmt.setBytes(i + 1, inputString.getBytes());
         }
       }
@@ -649,7 +648,6 @@ public class Database implements StorageObject {
     Connection con = null;
     PreparedStatement pstmt = null;
     ArrayList streamedInput = theEntity.streamedInput();
-    HashMap theEntityValues = theEntity.getValues();
     String id = theEntity.getId();
     String aField;
     StringBuffer fv = new StringBuffer();
@@ -662,14 +660,14 @@ public class Database implements StorageObject {
       // only normal cases
       if (!(aField.equals(thePKeyName) || aField.equals("webdb_create") ||
           aField.equals("webdb_lastchange") || (streamedInput != null && streamedInput.contains(aField)))) {
-        if (theEntityValues.containsKey(aField)) {
+        if (theEntity.hasValueForField(aField)) {
           if (firstField == false) {
             fv.append(", ");
           }
           else {
             firstField = false;
           }
-          fv.append(aField).append("='").append(StringUtil.quote((String)theEntityValues.get(aField))).append("'");
+          fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
         }
       }
     }
@@ -692,7 +690,7 @@ public class Database implements StorageObject {
       pstmt = con.prepareStatement(sql.toString());
       if (streamedInput != null) {
         for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString = (String)theEntityValues.get(streamedInput.get(i));
+          String inputString = theEntity.getValue((String)streamedInput.get(i));
           pstmt.setBytes(i + 1, inputString.getBytes());
         }
       }
index 330e7bb..fbca369 100755 (executable)
@@ -20,7 +20,7 @@ import mir.entity.*;
 import mir.misc.*;
 import mir.storage.*;
 
-public class EntityBreaking extends AbstractEntity implements Entity, TemplateHashModel, TemplateModelRoot
+public class EntityBreaking extends Entity
 {
   private static int instances;
 
@@ -32,44 +32,4 @@ public class EntityBreaking extends AbstractEntity implements Entity, TemplateHa
   }
 
 
-       public HashMap getValues() {
-               HashMap returnHash = super.getValues();
-               String date=null;
-
-               if ((date=(String)returnHash.get("webdb_create"))!=null)
-                       returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
-               return returnHash;
-       }
-
-  // Now implements freemarkers TemplateHashModel
-  // two methods have to be overridden:
-  // 1. public boolean isEmpty() throws TemplateModelException
-  // 2. public TemplateModel get(java.lang.String key) throws TemplateModelException
-
-  public boolean isEmpty() throws TemplateModelException
-  {
-    if (theValuesHash==null || theValuesHash.isEmpty())
-      return true;
-    return false;
-  }
-
-  public TemplateModel get(java.lang.String key) throws TemplateModelException
-  {
-    theLog.printDebugInfo("trying to get: " + key);
-    return new SimpleScalar(getValue(key));
-  }
-
-  public void put(java.lang.String key, TemplateModel model)
-  {
-    // empty for testing
-  }
-
-  public void remove(java.lang.String key)
-  {
-    // empty for testing
-  }
-
-
-  //////////////////////////////////////////////////////////////////////////////////
-
 }
index 1bbe80b..c41b3af 100755 (executable)
@@ -19,7 +19,7 @@ import mir.storage.*;
  */
 
 
-public class EntityComment extends AbstractEntity implements Entity
+public class EntityComment extends Entity
 {
   private static int instances;
 
@@ -34,13 +34,6 @@ public class EntityComment extends AbstractEntity implements Entity
     setStorage(theStorage);
   }
 
-  public HashMap getValues() {
-    HashMap returnHash = super.getValues();
-    String create = (String)returnHash.get("webdb_create");
-    returnHash.put("date",StringUtil.dateToReadableDate(create));
-
-    return returnHash;
-  }
 
   /**
    * overridden method setValues to patch creator_main_url
index 693afd8..b514016 100755 (executable)
@@ -22,7 +22,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityContent extends AbstractEntity implements Entity
+public class EntityContent extends Entity
 {
 
        private static int      instances;
@@ -130,21 +130,20 @@ public class EntityContent extends AbstractEntity implements Entity
        }
 
        /**
-        * overridden method getValues to include formatted date into every
+        * overridden method getValue to include formatted date into every
         * entityContent
         */
 
-       public HashMap getValues() {
-               HashMap returnHash = super.getValues();
-               String date=null;
-
-               if ((date=(String)returnHash.get("date"))!=null)
-                       returnHash.put("date_formatted", StringUtil.webdbDate2readableDate(date));
-               if ((date=(String)returnHash.get("webdb_create"))!=null)
-                       returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
-               if ((date=(String)returnHash.get("webdb_lastchange"))!=null)
-                       returnHash.put("webdb_lastchange_formatted", StringUtil.dateToReadableDate(date));
-               return returnHash;
+       public String getValue(String field)
+  {
+    if (field!=null && field.equals("date_formatted"))
+    {
+               if (hasValueForField("date"))
+       return StringUtil.webdbDate2readableDate(getValue("date"));
+      else return null;
+               }
+    else
+      return super.getValue(field);
        }
 
        /**
index de1f0de..16d422e 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityFeature extends AbstractEntity implements Entity
+public class EntityFeature extends Entity
 {
                private static int instances;
 
index f098b68..d13ac5c 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityImages extends AbstractEntity implements Entity
+public class EntityImages extends Entity
 {
        private static int instances;
 
@@ -71,7 +71,7 @@ public class EntityImages extends AbstractEntity implements Entity
         if (imageType.equals("1"))
             type = 1;
          //end hack
-            
+
                if (uploadData!=null) {
                        Connection con=null;PreparedStatement pstmt=null;
                        try {
index 8c321d5..6b83557 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityLinksImcs extends AbstractEntity implements Entity
+public class EntityLinksImcs extends Entity
 {
   private static int instances;
 
index d43fdec..2d2c503 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityMedia extends AbstractEntity implements Entity
+public class EntityMedia extends Entity
 {
   private static int instances;
 
index 409e301..33ed4c0 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityTopics extends AbstractEntity implements Entity
+public class EntityTopics extends  Entity
 {
   private static int instances;
 
index 554795c..a797b4a 100755 (executable)
@@ -18,7 +18,7 @@ import mircoders.storage.*;
  */
 
 
-public class EntityUploadedMedia extends AbstractEntity implements Entity
+public class EntityUploadedMedia extends Entity
 {
   private static int instances;
 
index 6527123..56f9912 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityUsers extends AbstractEntity implements Entity
+public class EntityUsers extends Entity
 {
                private static int instances;
 
index 2adf427..8f651e4 100755 (executable)
@@ -17,7 +17,7 @@ import mir.storage.*;
  */
 
 
-public class EntityVideo extends AbstractEntity implements Entity
+public class EntityVideo extends Entity
 {
        private static int instances;
 
index b437b27..93eb4f4 100755 (executable)
@@ -65,7 +65,6 @@ public class ProducerAll extends Producer{
                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";
@@ -76,7 +75,6 @@ public class ProducerAll extends Producer{
                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);
 
index c198f82..e9fe8eb 100755 (executable)
@@ -66,7 +66,6 @@ public class ProducerContent extends Producer {
     String              currentMediaId;
     EntityContent       currentContent;
     EntityList          batchEntityList;
-    HashMap             currentContentValues;
     SimpleHash          imageHash = new SimpleHash();
     EntityUsers         userEntity=null;
     Entity              mediaType;
@@ -102,16 +101,13 @@ public class ProducerContent extends Producer {
     while (batchEntityList != null) {
       for(int i=0;i<batchEntityList.size();i++) {
         currentContent = (EntityContent)batchEntityList.elementAt(i);
-        currentContentValues = currentContent.getValues();
-
-        //because of postgres 7.1.* not needed anymore
-        //currentContentValues.put("content_data",currentContent.getContentData());
-        String date = (String)currentContentValues.get("date");
+        HashMap currentContentValues = currentContent.getValues();
+        String date = (String)currentContent.getValue("date");
         String year = date.substring(0,4);
         String month = date.substring(4,6);
 
         htmlFileName =  producerDocRoot
-          + "/" + year + "/" + month + "/" +  currentContentValues.get("id") + ".shtml";
+          + "/" + year + "/" + month + "/" +  currentContent.getValue("id") + ".shtml";
 
         currentContentValues.put("content_data",StringUtil.deleteForbiddenTags((String)currentContentValues.get("content_data")));
         currentContentValues.put("description",StringUtil.deleteForbiddenTags((String)currentContentValues.get("description")));
index a8c54d1..ef9d633 100755 (executable)
@@ -42,7 +42,7 @@ public class ProducerFeature extends ProducerList {
                        EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
                        whereClause += currentTopic.getId();
                        fileDesc = currentTopic.getValue("filename").trim();
-                       setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+                       setAdditional("topic",currentTopic);
 
                        first = false;
                }
index 22939fb..ad8e225 100755 (executable)
@@ -267,6 +267,8 @@ public class ProducerStartPage extends Producer {
               theLog.printError("ProducerList: problem in reflection: "+mediaHandlerName);
             } //end catch
             upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType));
+
+            // he marc, shouldn't this be .equals("1") ?
             if (upMedia.getValue("is_published") == "1") {
               if (mediaHandler.isImage()) {
                 mediaListImages.add(upMediaSimpleHash);
index 6b3d418..e007aad 100755 (executable)
@@ -79,7 +79,7 @@ public class ProducerTopics extends ProducerList {
             whereClause += currentContent.getId();
             whereClauseSpecial += currentContent.getId();
 
-            setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+            setAdditional("topic",currentTopic);
 
             first = false;
           }
@@ -151,7 +151,7 @@ public class ProducerTopics extends ProducerList {
           } //end if currentMediaList != null
           setAdditional("special",specialHash);
         }
-        
+
         //set the list of topics
         setAdditional("topicslist",topicsList);
 
index 9f81ea7..9e1a4d4 100755 (executable)
@@ -158,7 +158,7 @@ public class ServletModuleContent extends ServletModule
       theLog.printError("language-popup could not be fetched.");
     }
     mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList());
-    mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(user));
+    mergeData.put("login_user", user);
     deliver(req, res, mergeData, templateObjektString);
   }
 
@@ -388,7 +388,7 @@ public class ServletModuleContent extends ServletModule
       if ((offsetParam = req.getParameter("offset"))!=null) mergeData.put("offset", offsetParam);
       if ((whereParam = req.getParameter("where"))!=null) mergeData.put("where", whereParam);
       if ((orderParam = req.getParameter("order"))!=null) mergeData.put("order", orderParam);
-      mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(_getUser(req)));
+      mergeData.put("login_user", _getUser(req));
       deliver(req, res, mergeData, templateObjektString);
     } catch (Exception e) {
       throw new ServletModuleException(e.toString());
index 90bc5ce..e59498e 100755 (executable)
@@ -174,7 +174,7 @@ public class ServletModuleLinksImcs extends ServletModule
 
       modelRoot.put("parentlist",HTMLTemplateProcessor.makeSimpleList(parentList));
       modelRoot.put("languagelist",HTMLTemplateProcessor.makeSimpleList(theLanguageList));
-      modelRoot.put("entity", HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam)));
+      modelRoot.put("entity", mainModule.getById(idParam));
       deliver(req, res, modelRoot, templateObjektString);
 
     } catch(ModuleException e) {
index 35fcbb9..0f2457f 100755 (executable)
@@ -50,9 +50,7 @@ public class ServletModuleUsers extends mir.servlet.ServletModule
                String        idParam = req.getParameter("id");
                if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben");
                 try {
-                       //theLog.printInfo("Showing User with id: " + idParam);
-                       SimpleHash mergeData =  HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam));
-                       deliver(req, res, mergeData, templateObjektString);
+                       deliver(req, res, mainModule.getById(idParam), templateObjektString);
                }
                catch (ModuleException e) { throw new ServletModuleException(e.toString());}
        }
@@ -74,8 +72,7 @@ public class ServletModuleUsers extends mir.servlet.ServletModule
                try {
                        HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject());
                        String id = mainModule.add(withValues);
-                       SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(id));
-                       deliver(req, res, mergeData, templateObjektString);
+                       deliver(req, res, mainModule.getById(id), templateObjektString);
                }
                catch (Exception e) { throw new ServletModuleException(e.toString());}
        }
index 63f6c68..6618251 100755 (executable)
@@ -55,7 +55,6 @@ public class DatabaseLinksImcs extends Database
                //cache
                invalidatePopupCache();
                try {
-                       HashMap theEntityValues = theEntity.getValues();
                        ArrayList streamedInput = theEntity.streamedInput();
                        StringBuffer f = new StringBuffer();
                        StringBuffer v = new StringBuffer();
@@ -75,11 +74,11 @@ public class DatabaseLinksImcs extends Database
                                                        aValue = "?";
                                                }
                                                else {
-                                                       if (theEntityValues.containsKey(aField)) {
+                                                       if (theEntity.hasValueForField(aField)) {
                 if (aField.equals("to_parent_id")) {
-                  aValue = StringUtil.quote((String)theEntityValues.get(aField));
+                  aValue = StringUtil.quote((String)theEntity.getValue(aField));
                 } else {
-                                                                 aValue = "'" + StringUtil.quote((String)theEntityValues.get(aField)) + "'";
+                                                                 aValue = "'" + StringUtil.quote((String)theEntity.getValue(aField)) + "'";
                 }
                                                        }
                                                }
@@ -107,7 +106,7 @@ public class DatabaseLinksImcs extends Database
                        pstmt = con.prepareStatement(sql);
                        if (streamedInput != null) {
                                for (int i = 0; i < streamedInput.size(); i++) {
-                                       String inputString = (String)theEntityValues.get(streamedInput.get(i));
+                                       String inputString = (String)theEntity.getValue((String)streamedInput.get(i));
                                        pstmt.setBytes(i + 1, inputString.getBytes());
                                }
                        }
@@ -134,7 +133,6 @@ public class DatabaseLinksImcs extends Database
     Connection con = null;
     PreparedStatement pstmt = null;
     ArrayList streamedInput = theEntity.streamedInput();
-    HashMap theEntityValues = theEntity.getValues();
     String id = theEntity.getId();
     String aField;
     StringBuffer fv = new StringBuffer();
@@ -147,7 +145,7 @@ public class DatabaseLinksImcs extends Database
       // only normal cases
       if (!(aField.equals(thePKeyName) || aField.equals("webdb_create") ||
           aField.equals("webdb_lastchange") || (streamedInput != null && streamedInput.contains(aField)))) {
-        if (theEntityValues.containsKey(aField)) {
+        if (theEntity.hasValueForField(aField)) {
           if (firstField == false) {
             fv.append(", ");
           }
@@ -155,9 +153,9 @@ public class DatabaseLinksImcs extends Database
             firstField = false;
           }
           if (aField.equals("to_parent_id")) {
-            fv.append(aField).append("=").append(StringUtil.quote((String)theEntityValues.get(aField)));
+            fv.append(aField).append("=").append(StringUtil.quote(theEntity.getValue(aField)));
           } else {
-            fv.append(aField).append("='").append(StringUtil.quote((String)theEntityValues.get(aField))).append("'");
+            fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'");
           }
         }
       }
@@ -181,7 +179,7 @@ public class DatabaseLinksImcs extends Database
       pstmt = con.prepareStatement(sql.toString());
       if (streamedInput != null) {
         for (int i = 0; i < streamedInput.size(); i++) {
-          String inputString = (String)theEntityValues.get(streamedInput.get(i));
+          String inputString = (String)theEntity.getValue((String)streamedInput.get(i));
           pstmt.setBytes(i + 1, inputString.getBytes());
         }
       }