From 5ee7a324a59eab93c91ef33447ae442f36f028e9 Mon Sep 17 00:00:00 2001 From: br1 Date: Fri, 29 Mar 2002 13:46:22 +0000 Subject: [PATCH] fixed a bug that prevented saving when there are no associated articles --- source/mircoders/module/ModuleTopics.java | 146 +++++++++++++++--------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/source/mircoders/module/ModuleTopics.java b/source/mircoders/module/ModuleTopics.java index 707ce616..ea47863e 100755 --- a/source/mircoders/module/ModuleTopics.java +++ b/source/mircoders/module/ModuleTopics.java @@ -1,22 +1,21 @@ package mircoders.module; -import java.io.*; -import java.lang.*; -import java.util.*; -import java.sql.*; -import javax.servlet.*; -import javax.servlet.http.*; +import freemarker.template.SimpleList; +import mir.entity.Entity; +import mir.entity.EntityList; +import mir.misc.Logfile; +import mir.misc.MirConfig; +import mir.module.AbstractModule; +import mir.module.ModuleException; +import mir.storage.StorageObject; +import mir.storage.StorageObjectException; +import mircoders.entity.EntityContent; +import mircoders.entity.EntityTopics; +import mircoders.storage.DatabaseContent; +import mircoders.storage.DatabaseContentToTopics; +import mircoders.storage.DatabaseTopics; -import freemarker.template.*; - -import mir.servlet.*; -import mir.module.*; -import mir.entity.*; -import mir.misc.*; -import mir.storage.*; - -import mircoders.storage.*; -import mircoders.entity.*; +import java.util.HashMap; /* * ThemenModule - @@ -25,71 +24,72 @@ import mircoders.entity.*; * @author RK */ -public class ModuleTopics extends AbstractModule -{ +public class ModuleTopics extends AbstractModule { - static Logfile theLog; + static Logfile theLog; - public ModuleTopics(StorageObject theStorage) { - this.theStorage = theStorage; - if (theLog == null) - theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Themen.Logfile")); - } + public ModuleTopics(StorageObject theStorage) { + this.theStorage = theStorage; + if (theLog == null) + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Themen.Logfile")); + } - public SimpleList getTopicsAsSimpleList() throws ModuleException { - try { - return ((DatabaseTopics)theStorage).getPopupData(); - } catch(StorageObjectException e) { - throw new ModuleException(e.toString()); - } + public SimpleList getTopicsAsSimpleList() throws ModuleException { + try { + return ((DatabaseTopics) theStorage).getPopupData(); + } + catch (StorageObjectException e) { + throw new ModuleException(e.toString()); } + } - /** - * Method getTopicList - * - * @return SimpleList of all Topics sorted by title - * - */ - public EntityList getTopicsList() - { - EntityList returnList=null; - try { - returnList=getByWhereClause("","title",-1); + /** + * Method getTopicList + * + * @return SimpleList of all Topics sorted by title + * + */ + public EntityList getTopicsList() { + EntityList returnList = null; + try { + returnList = getByWhereClause("", "title", -1); + } + catch (Exception e) { + theLog.printWarning("--getTopicsList: topics could not be fetched"); + } + 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")); } - catch (Exception e) - { - theLog.printWarning("--getTopicsList: topics could not be fetched"); + theEntity.setValues(theValues); + DatabaseContentToTopics db = DatabaseContentToTopics.getInstance(); + DatabaseContent dbc = DatabaseContent.getInstance(); + EntityList contentList = db.getContent((EntityTopics) theEntity); + if (contentList!=null) { + for (int i = 0; i < contentList.size(); i++) { + dbc.setUnproduced("id=" + ((EntityContent) contentList.elementAt(i)).getId()); + } } - return returnList; + theEntity.update(); + return theEntity.getId(); + } + catch (StorageObjectException e) { + e.printStackTrace(System.err); + throw new ModuleException(e.toString()); } - - /** - * 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()); - } - } + } } -- 2.11.0