+++ /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;
- static {
- theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Entity.Logfile"));
- }
-
- public AbstractEntity() {
- this.changed = false;
- instances++;
- }
-
- /**
- * 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;
- }
-
- protected void throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
- theLog.printError( e.toString() + " Funktion: "+ wo);
- throw new StorageObjectException("Storage Object Exception in entity" +e.toString());
- }
-
- /**
- * 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;
+ static {
+ theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Entity.Logfile"));
+ }
+
+ public Entity() {
+
+ 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.
+ * Entity interfaces freemarker.template.TemplateHashModel now and can
+ * be used in the same way as SimpleHash.
+
+ */
+ public HashMap getValues() {
+ theLog.printWarning("## using deprecated Entity.getValues() - a waste of resources");
+ 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;
+ }
+
+ protected void throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
+ theLog.printError( e.toString() + " Funktion: "+ wo);
+ throw new StorageObjectException("Storage Object Exception in entity" +e.toString());
+ }
+
+ /**
+ * 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
+ {
+ return new SimpleScalar(getValue(key));
+ }
+
+ public void put(java.lang.String key, TemplateModel model)
+ {
+ // putting should only take place via setValue
+ }
+
+ public void remove(java.lang.String key)
+ {
+ // do we need this?
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////////
}
-
-
-
* @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.7.1
+ // templateCache.startAutoUpdate();
+ theLog = Logfile.getInstance(MirConfig.getPropWithHome("HTMLTemplateProcessor.Logfile"));
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
// yeah, from my point too - tob.
//actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");
//actionRoot = docRoot + "/servlet/NadirAktuell";
-
+
actionRoot = docRoot + "/servlet/Mir";
+
openAction = MirConfig.getProp("Producer.OpenAction");
productionHost = MirConfig.getProp("Producer.ProductionHost");
videoHost = MirConfig.getProp("Producer.VideoHost");
/**
* empty private constructor, to avoid instantiation
*/
- private HTMLTemplateProcessor () {}
+ private HTMLTemplateProcessor () { }
// process-methods to merge different datastructures
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. It is not necessary any more to make
+ * a SimpleHash from an Entity
*/
public static SimpleHash makeSimpleHash(Entity entity) {
- if (entity != null)
+ if (entity != null) {
+ theLog.printWarning("## using deprecated makeSimpleHash(entity) - a waste of resources");
return makeSimpleHash(entity.getValues());
+ }
else
return 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(){
/**
+ * This class provides the base functionality for the derived Module-Classes.
+ * These classes should provide methods to make more or less complex actions
+ * on Database and Entity classes. The modules are used by ServletModules.
+ * Future possibility could be access via Applications.
+ *
* Abstrakte Klasse, von denen die Modules die Basisfunktionalität erben.
* Die Moduleschicht dient dazu, Funktionalitaeten zur Verfügung zu stellen,
* die von mehreren ServletModulen verwendet werden.
+ *
*/
+
public class AbstractModule {
protected StorageObject theStorage;
public Entity getById (String id) throws ModuleException {
try {
if (theStorage == null)
- throw new ModuleException("Kein StorageObject gesetzt");
+ throw new ModuleException("No StorageObject set!");
Entity entity = (Entity)theStorage.selectById(id);
if (entity == null)
- throw new ModuleException("Objekt nicht vorhanden: ID=" + id);
+ throw new ModuleException("No object for id = " + id);
else return entity;
}
catch (StorageObjectException e){
/**
+ * Abstract class ServletModule provides the base functionality for servlets.
+ * Deriving a class from ServletModule enables class to insert/edit/update/delete
+ * and list Entity from a Database via mainModule.
+ *
+ *
* Abstrakte Klasse ServletModule stellt die Basisfunktionalitaet der
* abgeleiteten ServletModule zur Verfügung.
*
* 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 rtm beinahalten das freemarker.template.TempalteModelRoot mit den
+ * 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)
+ public void deliver_compressed(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm, String templateFilename)
throws ServletModuleException {
- deliver(req, res,HTMLTemplateProcessor.makeSimpleHash(ent), templateFilename);
+ if (rtm == null) rtm = new SimpleHash();
+ try {
+ PrintWriter out = new LineFilterWriter(res.getWriter());
+ //PrintWriter out = res.getWriter();
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
+ out.close();
+ } catch (HTMLParseException e) {
+ throw new ServletModuleException(e.toString());
+ } catch (IOException e) {
+ throw new ServletModuleException(e.toString());
+ }
}
/**
}
}
protected int getInstances(){
- AbstractEntity ent = new AbstractEntity();
+ Entity ent = new Entity();
return ent.getInstances();
}
public String getInstancesInfo(){
import java.lang.*;
import java.io.*;
import java.util.*;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleHash;
+import freemarker.template.*;
import com.javaexchange.dbConnectionBroker.*;
import mir.storage.StorageObject;
import mir.entity.*;
//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 java.util.*;
import java.sql.*;
+import freemarker.template.*;
+
import mir.entity.*;
import mir.misc.*;
import mir.storage.*;
-public class EntityBreaking extends AbstractEntity implements Entity
+public class EntityBreaking extends Entity
{
private static int instances;
super.finalize();
}
+ /* @deprecated */
+ public HashMap getValues() {
+ return super.getValues();
+ }
- 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;
- }
}
*/
-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
if (!theStringValues.containsKey("is_published")) {
theStringValues.put("is_published","0");
}
-
+
if (theStringValues.containsKey("main_url")){
if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) {
theStringValues.remove("main_url");
theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url")));
}
}
-
+
}
super.setValues(theStringValues);
}
*/
-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;