+++ /dev/null
-/**
- * <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());
- }
- }
-}
-
-/*
- * 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
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////////
}
-
-
-
* 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;
}
}
else return null;
}
-
+
/**
* @return Liefert eine freemarker.template.SimpleList mit den verknuepften
* Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
}
return null;
}
-
+
/**
* @return Liefert eine freemarker.template.SimpleList mit den verknuepften
* Entities, wenn es sich um eine TO_MANY Liste handelt, ansonsten
* @author /rk
* @version 1.2
*/
-public class GenericEntity extends AbstractEntity
- implements Entity {}
+public class GenericEntity extends Entity
+ {}
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
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;
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;
* @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)
*/
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(){
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
}
}
protected int getInstances(){
- AbstractEntity ent = new AbstractEntity();
+ Entity ent = new Entity();
return ent.getInstances();
}
public String getInstancesInfo(){
//cache
invalidatePopupCache();
try {
- HashMap theEntityValues = theEntity.getValues();
ArrayList streamedInput = theEntity.streamedInput();
StringBuffer f = new StringBuffer();
StringBuffer v = new StringBuffer();
aValue = "?";
}
else {
- if (theEntityValues.containsKey(aField)) {
- aValue = "'" + StringUtil.quote((String)theEntityValues.get(aField))
+ if (theEntity.hasValueForField(aField)) {
+ aValue = "'" + StringUtil.quote((String)theEntity.getValue(aField))
+ "'";
}
}
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());
}
}
Connection con = null;
PreparedStatement pstmt = null;
ArrayList streamedInput = theEntity.streamedInput();
- HashMap theEntityValues = theEntity.getValues();
String id = theEntity.getId();
String aField;
StringBuffer fv = new StringBuffer();
// 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("'");
}
}
}
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());
}
}
import mir.misc.*;
import mir.storage.*;
-public class EntityBreaking extends AbstractEntity implements Entity, TemplateHashModel, TemplateModelRoot
+public class EntityBreaking extends Entity
{
private static int instances;
}
- 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
- }
-
-
- //////////////////////////////////////////////////////////////////////////////////
-
}
*/
-public class EntityComment extends AbstractEntity implements Entity
+public class EntityComment extends Entity
{
private static int instances;
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
*/
-public class EntityContent extends AbstractEntity implements Entity
+public class EntityContent extends Entity
{
private static int instances;
}
/**
- * 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);
}
/**
*/
-public class EntityFeature extends AbstractEntity implements Entity
+public class EntityFeature extends Entity
{
private static int instances;
*/
-public class EntityImages extends AbstractEntity implements Entity
+public class EntityImages extends Entity
{
private static int instances;
if (imageType.equals("1"))
type = 1;
//end hack
-
+
if (uploadData!=null) {
Connection con=null;PreparedStatement pstmt=null;
try {
*/
-public class EntityLinksImcs extends AbstractEntity implements Entity
+public class EntityLinksImcs extends Entity
{
private static int instances;
*/
-public class EntityMedia extends AbstractEntity implements Entity
+public class EntityMedia extends Entity
{
private static int instances;
*/
-public class EntityTopics extends AbstractEntity implements Entity
+public class EntityTopics extends Entity
{
private static int instances;
*/
-public class EntityUploadedMedia extends AbstractEntity implements Entity
+public class EntityUploadedMedia extends Entity
{
private static int instances;
*/
-public class EntityUsers extends AbstractEntity implements Entity
+public class EntityUsers extends Entity
{
private static int instances;
*/
-public class EntityVideo extends AbstractEntity implements Entity
+public class EntityVideo extends Entity
{
private static int instances;
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";
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);
String currentMediaId;
EntityContent currentContent;
EntityList batchEntityList;
- HashMap currentContentValues;
SimpleHash imageHash = new SimpleHash();
EntityUsers userEntity=null;
Entity mediaType;
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")));
EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
whereClause += currentTopic.getId();
fileDesc = currentTopic.getValue("filename").trim();
- setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+ setAdditional("topic",currentTopic);
first = false;
}
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);
whereClause += currentContent.getId();
whereClauseSpecial += currentContent.getId();
- setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+ setAdditional("topic",currentTopic);
first = false;
}
} //end if currentMediaList != null
setAdditional("special",specialHash);
}
-
+
//set the list of topics
setAdditional("topicslist",topicsList);
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);
}
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());
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) {
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());}
}
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());}
}
//cache
invalidatePopupCache();
try {
- HashMap theEntityValues = theEntity.getValues();
ArrayList streamedInput = theEntity.streamedInput();
StringBuffer f = new StringBuffer();
StringBuffer v = new StringBuffer();
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)) + "'";
}
}
}
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());
}
}
Connection con = null;
PreparedStatement pstmt = null;
ArrayList streamedInput = theEntity.streamedInput();
- HashMap theEntityValues = theEntity.getValues();
String id = theEntity.getId();
String aField;
StringBuffer fv = new StringBuffer();
// 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(", ");
}
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("'");
}
}
}
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());
}
}