From 50d223072c642a8e12e0fa99d378426ce2667926 Mon Sep 17 00:00:00 2001 From: idfx Date: Sun, 17 Mar 2002 16:55:22 +0000 Subject: [PATCH] templateModelRoot ist now a simplehash with two entries: data and config, bugfix for bugs: 46, 45 --- source/mir/entity/Entity.java | 12 ++++----- source/mir/misc/HTMLTemplateProcessor.java | 37 +++++++++++++-------------- source/mircoders/entity/EntityTopics.java | 14 ++-------- source/mircoders/module/ModuleComment.java | 9 +++---- source/mircoders/module/ModuleTopics.java | 29 +++++++++++++++++++++ source/mircoders/storage/DatabaseContent.java | 2 ++ 6 files changed, 60 insertions(+), 43 deletions(-) diff --git a/source/mir/entity/Entity.java b/source/mir/entity/Entity.java index 6dd39ac8..068d4e2e 100755 --- a/source/mir/entity/Entity.java +++ b/source/mir/entity/Entity.java @@ -118,13 +118,13 @@ public class Entity implements TemplateHashModel, TemplateModelRoot { if (field.equals("webdb_create_formatted")) { - if (hasValueForField("webdb_create")) - returnValue=StringUtil.dateToReadableDate(getValue("webdb_create")); + if (hasValueForField("webdb_create")) + returnValue=StringUtil.dateToReadableDate(getValue("webdb_create")); } else if (field.equals("webdb_lastchange_formatted")) { if (hasValueForField("webdblast_change")) - returnValue=StringUtil.dateToReadableDate(getValue("webdb_lastchange")); + returnValue=StringUtil.dateToReadableDate(getValue("webdb_lastchange")); } else returnValue = (String)theValuesHash.get(field); @@ -283,10 +283,10 @@ public class Entity implements TemplateHashModel, TemplateModelRoot public TemplateModel get(java.lang.String key) throws TemplateModelException { - return new SimpleScalar(getValue(key)); + return new SimpleScalar(getValue(key)); } - - public void put(java.lang.String key, TemplateModel model) + + public void put(java.lang.String key, TemplateModel model) { // putting should only take place via setValue and is limited to the // database fields associated with the entity. no additional freemarker diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java index 1abaae5d..bfa7558b 100755 --- a/source/mir/misc/HTMLTemplateProcessor.java +++ b/source/mir/misc/HTMLTemplateProcessor.java @@ -204,27 +204,26 @@ public final class HTMLTemplateProcessor { * date "now" // rk */ // put standard configuration into tempalteRootmodel SimpleHash configHash = new SimpleHash(); - configHash.put("docroot", new SimpleScalar(producerDocRoot)); - configHash.put("storageroot", new SimpleScalar(producerStorageRoot)); - configHash.put("productionhost", new SimpleScalar(productionHost)); - configHash.put("openaction", new SimpleScalar(openAction)); + configHash.put("producerDocRoot", new SimpleScalar(producerDocRoot)); + configHash.put("storageRoot", new SimpleScalar(producerStorageRoot)); + configHash.put("productionHost", new SimpleScalar(productionHost)); + configHash.put("openAction", new SimpleScalar(openAction)); configHash.put("actionRootLogin",new SimpleScalar(actionRoot)); - - - tmr.put("docRoot", new SimpleScalar(docRoot)); - tmr.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); - tmr.put("actionRoot", new SimpleScalar(actionRoot+session)); - tmr.put("openAction", new SimpleScalar(openAction)); - tmr.put("productionHost", new SimpleScalar(productionHost)); - tmr.put("videoHost", new SimpleScalar(videoHost)); - tmr.put("audioHost", new SimpleScalar(audioHost)); - tmr.put("imageHost", new SimpleScalar(imageHost)); + configHash.put("docRoot", new SimpleScalar(docRoot)); + configHash.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); + configHash.put("actionRoot", new SimpleScalar(actionRoot+session)); + configHash.put("productionHost", new SimpleScalar(productionHost)); + configHash.put("videoHost", new SimpleScalar(videoHost)); + configHash.put("audioHost", new SimpleScalar(audioHost)); + configHash.put("imageHost", new SimpleScalar(imageHost)); // this conform to updated freemarker syntax - tmr.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() ); - - tmr.put("config", configHash); - tmpl.process(tmr, out); - + configHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() ); + + SimpleHash outPutHash = new SimpleHash(); + outPutHash.put("data",tmr); + outPutHash.put("config", configHash); + + tmpl.process(outPutHash,out); } diff --git a/source/mircoders/entity/EntityTopics.java b/source/mircoders/entity/EntityTopics.java index c7fb5cf4..4e3aefab 100755 --- a/source/mircoders/entity/EntityTopics.java +++ b/source/mircoders/entity/EntityTopics.java @@ -18,23 +18,13 @@ import mircoders.storage.*; */ -public class EntityTopics extends Entity -{ +public class EntityTopics extends Entity { public EntityTopics(){ super(); } - public EntityTopics(StorageObject theStorage) - { + public EntityTopics(StorageObject theStorage) { this(); setStorage(theStorage); } - - // Dependencies einhalten - public void update() throws StorageObjectException{ - super.update(); - DatabaseContent dbContent = DatabaseContent.getInstance(); - dbContent.setUnproduced("to_topic="+getId()); - } - } diff --git a/source/mircoders/module/ModuleComment.java b/source/mircoders/module/ModuleComment.java index 169e4189..c49448d2 100755 --- a/source/mircoders/module/ModuleComment.java +++ b/source/mircoders/module/ModuleComment.java @@ -48,19 +48,16 @@ public class ModuleComment extends AbstractModule /** * setValues in the Entity and updates them on the StorageObject */ - public String set(HashMap theValues) throws ModuleException - { + public String set(HashMap theValues) throws ModuleException { try { Entity theEntity = theStorage.selectById((String)theValues.get("id")); if (theEntity == null) throw new ModuleException("No Objekt with id in Database id: " + theValues.get("id")); + DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media")); theEntity.setValues(theValues); theEntity.update(); - //set content to unproduced - DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media")); return theEntity.getId(); - } - catch (StorageObjectException e){ + } catch (StorageObjectException e){ e.printStackTrace(System.err); throw new ModuleException(e.toString()); } diff --git a/source/mircoders/module/ModuleTopics.java b/source/mircoders/module/ModuleTopics.java index ac4f02ee..707ce616 100755 --- a/source/mircoders/module/ModuleTopics.java +++ b/source/mircoders/module/ModuleTopics.java @@ -16,6 +16,7 @@ import mir.misc.*; import mir.storage.*; import mircoders.storage.*; +import mircoders.entity.*; /* * ThemenModule - @@ -62,5 +63,33 @@ public class ModuleTopics extends AbstractModule } return returnList; } + + /** + * Overrides the AbstractModule.set(), + * All dependent ContentEntities are set unproduced. + * @param theValues Hash mit Spalte/Wert-Paaren + * @return Id des eingefügten Objekts + * @exception ModuleException + */ + public String set (HashMap theValues) throws ModuleException { + try { + Entity theEntity = theStorage.selectById((String)theValues.get("id")); + if (theEntity == null){ + throw new ModuleException("Kein Objekt mit id in Datenbank id: " + theValues.get("id")); + } + theEntity.setValues(theValues); + DatabaseContentToTopics db = DatabaseContentToTopics.getInstance(); + DatabaseContent dbc = DatabaseContent.getInstance(); + EntityList contentList = db.getContent((EntityTopics)theEntity); + for (int i = 0; i < contentList.size(); i++){ + dbc.setUnproduced("id="+((EntityContent)contentList.elementAt(i)).getId()); + } + theEntity.update(); + return theEntity.getId(); + } catch (StorageObjectException e){ + e.printStackTrace(System.err); + throw new ModuleException(e.toString()); + } + } } diff --git a/source/mircoders/storage/DatabaseContent.java b/source/mircoders/storage/DatabaseContent.java index 624b116f..f4301bad 100755 --- a/source/mircoders/storage/DatabaseContent.java +++ b/source/mircoders/storage/DatabaseContent.java @@ -60,11 +60,13 @@ public class DatabaseContent extends Database implements StorageObject { { Connection con=null;Statement stmt=null; String sql = "update content set is_produced='0' where " + where; + theLog.printDebugInfo("set unproduced: "+where); try { con = getPooledCon(); // should be a preparedStatement because is faster stmt = con.createStatement(); executeUpdate(stmt,sql); + theLog.printDebugInfo("set unproduced: "+where); } catch (Exception e) {_throwStorageObjectException(e, "-- set unproduced failed");} finally { freeConnection(con,stmt);} -- 2.11.0