At last the EntityBatchingProducerNode is working. This will replace the old
[mir.git] / source / mircoders / entity / adapter / ContentAdapterDefinition.java
index 6abca53..d2e390c 100755 (executable)
@@ -25,7 +25,9 @@ public class ContentAdapterDefinition extends EntityAdapterDefinition {
   public ContentAdapterDefinition() {
     super();
 
-    addDateField("date", "date");
+    addDBDateField("creationdate", "webdb_lastchange");
+    addDBDateField("changedate", "webdb_create");
+    addMirDateField("date", "date");
     addCalculatedField("to_topics", new ContentToTopicsField());
     addCalculatedField("to_comments", new ContentToCommentsField());
     try {
@@ -175,146 +177,6 @@ public class ContentAdapterDefinition extends EntityAdapterDefinition {
       return result;
     }
   }
-
-
-/*
-  // @todo this needs to optimized. expensive SQL
-  private SimpleHash getUploadedMediaForNewswire()
-    throws StorageObjectException, TemplateModelException
-  {
-    // fetching/setting the images
-    // return to_media_icons
-    String        tinyIcon = null, iconAlt = null;
-    MirMedia      mediaHandler = null;
-    EntityUploadedMedia uploadedMedia;
-    Entity        mediaType;
-    SimpleHash    returnHash = new SimpleHash();
-
-    EntityList upMediaEntityList =
-                    DatabaseContentToMedia.getInstance().getUploadedMedia(this);
-    if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) {
-
-      for (int n=0; n < upMediaEntityList.size();n++) {
-        uploadedMedia = (EntityUploadedMedia)upMediaEntityList.elementAt(n);
-        mediaType = uploadedMedia.getMediaType();
-        try {
-          mediaHandler = MediaHelper.getHandler( mediaType );
-        } catch (MirMediaException ex) {
-          throw new TemplateModelException(ex.toString());
-        }
-        //the "best" media type to show
-        if (mediaHandler.isVideo()) {
-          tinyIcon = MirConfig.getProp("Producer.Icon.TinyVideo");
-          iconAlt = "Video";
-          break;
-        } else if (mediaHandler.isAudio()) {
-          tinyIcon = MirConfig.getProp("Producer.Icon.TinyAudio");
-          iconAlt = "Audio";
-        } else if (tinyIcon == null && !mediaHandler.isImage()) {
-          tinyIcon = mediaHandler.getTinyIcon();
-          iconAlt = mediaHandler.getIconAlt();
-        }
-
-      }
-      //it only has image(s)
-      if (tinyIcon == null) {
-        tinyIcon = MirConfig.getProp("Producer.Icon.TinyImage");
-        iconAlt = "Image";
-      }
-    // uploadedMedia Entity list is empty.
-    // we only have text
-    } else {
-      tinyIcon = MirConfig.getProp("Producer.Icon.TinyText");
-      iconAlt = "Text";
-    }
-    returnHash.put("tiny_icon", mirconf_imageRoot+"/"+tinyIcon);
-    returnHash.put("icon_alt", iconAlt);
-    return returnHash;
-  }
-*/
-
-
 }
 
 
-//  String mirconf_extLinkName  = MirConfig.getProp("Producer.ExtLinkName");
-//  String mirconf_intLinkName  = MirConfig.getProp("Producer.IntLinkName");
-//  String mirconf_mailLinkName = MirConfig.getProp("Producer.MailLinkName");
-//  String mirconf_imageRoot    = MirConfig.getProp("Producer.ImageRoot");
-
-
-//      if (field.equals("date_formatted"))
-//      {
-//               if (hasValueForField("date"))
-//             returnField = StringUtil.webdbDate2readableDate(getValue("date"));
-//             }
-//      else if (field.equals("description_parsed"))
-//        returnField = getDescriptionParsed();
-//      else if (field.equals("description_sentence"))
-//        returnField = getDescriptionSentence();
-//      else if (field.equals("content_data_parsed"))
-//        returnField = getContentDataParsed();
-
-/*
-      else if (key.equals("to_media_icon")) {
-        try {
-          _entCache.put(key, getUploadedMediaForNewswire());
-          return (TemplateModel)_entCache.get(key);
-        }
-        catch (Exception ex) {
-          theLog.printWarning("-- getUploadedMediaForNewswire: could not fetch data " + ex.toString());
-          throw new TemplateModelException(ex.toString());
-        }
-      }
-*/
-
-/*
-  private boolean hasMedia() throws StorageObjectException
-  {
-    if (_hasMedia == null) {
-      _hasMedia =
-        new Boolean(DatabaseContentToMedia.getInstance().hasMedia(this));
-    }
-    return _hasMedia.booleanValue();
-  }
-
-  //######## @todo all of the following getBlahForContent should have
-  // and optimized version where LIMIT=1 sql for list view.
-  private EntityList getImagesForContent()
-    throws StorageObjectException, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getImages(this);
-    else
-      return null;
-  }
-
-  private EntityList getAudioForContent()
-    throws StorageObjectException, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getAudio(this) ;
-    else
-      return null;
-  }
-
-  private EntityList getVideoForContent()
-    throws StorageObjectException, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getVideo(this) ;
-    else
-      return null;
-  }
-
-  private EntityList getOtherMediaForContent()
-    throws StorageObjectException, TemplateModelException
-  {
-    if (hasMedia())
-      return DatabaseContentToMedia.getInstance().getOther(this);
-    else
-      return null;
-  }
-
-}
-*/
\ No newline at end of file