+ // @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.getTinyIconName();
+ iconAlt = mediaHandler.getIconAltName();
+ }
+
+ }
+ //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;
+ }
+
+ 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;
+ }