organizing imports
[mir.git] / source / mircoders / module / ModuleTopics.java
index ea38e25..901dde5 100755 (executable)
 
 package mircoders.module;
 
-import freemarker.template.SimpleList;
+import java.util.Map;
+
 import mir.entity.Entity;
 import mir.entity.EntityList;
-import mir.misc.Logfile;
-import mir.misc.MirConfig;
+import mir.log.LoggerWrapper;
 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 mir.storage.StorageObjectExc;
+import mir.storage.StorageObjectFailure;
 import mircoders.storage.DatabaseTopics;
-
-import java.util.HashMap;
+import freemarker.template.SimpleList;
 
 /*
  *  ThemenModule -
@@ -57,24 +53,21 @@ import java.util.HashMap;
 
 public class ModuleTopics extends AbstractModule {
 
-  static Logfile theLog;
+  static LoggerWrapper logger = new LoggerWrapper("Module.Topics");
 
   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) {
+    catch (StorageObjectFailure e) {
       throw new ModuleException(e.toString());
     }
   }
 
-
   /**
    *  Method getTopicList
    *
@@ -87,7 +80,7 @@ public class ModuleTopics extends AbstractModule {
       returnList = getByWhereClause("", "title", -1);
     }
     catch (Exception e) {
-      theLog.printWarning("--getTopicsList: topics could not be fetched");
+      logger.warn("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage());
     }
     return returnList;
   }
@@ -96,29 +89,24 @@ public class ModuleTopics extends AbstractModule {
    * Overrides the AbstractModule.set(),
    * All dependent ContentEntities are set unproduced.
    * @param theValues Hash mit Spalte/Wert-Paaren
-   * @return Id des eingefΓΌgten Objekts
+   * @return Id des eingef?gten Objekts
    * @exception ModuleException
    */
-  public String set(HashMap theValues) throws ModuleException {
+  public String set(Map 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"));
+        throw new ModuleException("No topic with id  " + theValues.get("id") + " found");
       }
       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());
-        }
-      }
       theEntity.update();
+
       return theEntity.getId();
     }
-    catch (StorageObjectException e) {
-      e.printStackTrace(System.err);
+    catch (StorageObjectFailure e) {
+      throw new ModuleException(e.toString());
+    }
+    catch (StorageObjectExc e) {
       throw new ModuleException(e.toString());
     }
   }