From 6c4b8be576379a8f3511047cacbf78eae8a2e83f Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 17 Feb 2002 13:18:36 +0000 Subject: [PATCH] changed the way media handling works a little. now much less prone to ClassCastExceptions. There now exists DatabaseAudio, DatabaseVideo, etc.. see dbscripts/create... --- dbscripts/create_pg.sql | 227 +++++++++++++++------ dbscripts/populate_mediatyp.sql | 33 ++- source/mircoders/entity/EntityAudio.java | 140 +++++++++++++ source/mircoders/entity/EntityContent.java | 152 +++++--------- source/mircoders/entity/EntityImages.java | 2 +- source/mircoders/entity/EntityOther.java | 140 +++++++++++++ source/mircoders/entity/EntityUploadedMedia.java | 29 ++- source/mircoders/entity/EntityVideo.java | 2 +- source/mircoders/storage/DatabaseAudio.java | 74 +++++++ .../mircoders/storage/DatabaseContentToMedia.java | 87 +++++++- source/mircoders/storage/DatabaseMedia.java | 9 +- source/mircoders/storage/DatabaseOther.java | 74 +++++++ .../mircoders/storage/DatabaseUploadedMedia.java | 2 +- .../{DatabaseVideos.java => DatabaseVideo.java} | 13 +- templates-dist/producer/content.template | 28 ++- templates-dist/producer/openposting.template | 8 +- templates-dist/producer/startpage.template | 20 +- templates-dist/producer/topiclist.template | 16 +- 18 files changed, 821 insertions(+), 235 deletions(-) create mode 100755 source/mircoders/entity/EntityAudio.java create mode 100755 source/mircoders/entity/EntityOther.java create mode 100755 source/mircoders/storage/DatabaseAudio.java create mode 100755 source/mircoders/storage/DatabaseOther.java rename source/mircoders/storage/{DatabaseVideos.java => DatabaseVideo.java} (79%) diff --git a/dbscripts/create_pg.sql b/dbscripts/create_pg.sql index ffcec457..f53b3280 100755 --- a/dbscripts/create_pg.sql +++ b/dbscripts/create_pg.sql @@ -3,7 +3,7 @@ -- \connect - postgres -- --- TOC Entry ID 2 (OID 28714) +-- TOC Entry ID 2 (OID 19796) -- -- Name: media_id_seq Type: SEQUENCE Owner: postgres -- @@ -11,7 +11,7 @@ CREATE SEQUENCE "media_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 3 (OID 28733) +-- TOC Entry ID 3 (OID 19815) -- -- Name: media_folder_id_seq Type: SEQUENCE Owner: postgres -- @@ -19,7 +19,7 @@ CREATE SEQUENCE "media_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue CREATE SEQUENCE "media_folder_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 5 (OID 28771) +-- TOC Entry ID 4 (OID 19834) -- -- Name: feature_id_seq Type: SEQUENCE Owner: postgres -- @@ -27,7 +27,7 @@ CREATE SEQUENCE "media_folder_id_seq" start 1 increment 1 maxvalue 2147483647 mi CREATE SEQUENCE "feature_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 6 (OID 28790) +-- TOC Entry ID 5 (OID 19853) -- -- Name: topic_id_seq Type: SEQUENCE Owner: postgres -- @@ -35,7 +35,7 @@ CREATE SEQUENCE "feature_id_seq" start 1 increment 1 maxvalue 2147483647 minvalu CREATE SEQUENCE "topic_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 7 (OID 28809) +-- TOC Entry ID 6 (OID 19872) -- -- Name: webdb_users_id_seq Type: SEQUENCE Owner: postgres -- @@ -43,7 +43,7 @@ CREATE SEQUENCE "topic_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue CREATE SEQUENCE "webdb_users_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 8 (OID 28828) +-- TOC Entry ID 7 (OID 19891) -- -- Name: comment_id_seq Type: SEQUENCE Owner: postgres -- @@ -51,7 +51,7 @@ CREATE SEQUENCE "webdb_users_id_seq" start 1 increment 1 maxvalue 2147483647 min CREATE SEQUENCE "comment_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 9 (OID 28847) +-- TOC Entry ID 8 (OID 19910) -- -- Name: breaking_id_seq Type: SEQUENCE Owner: postgres -- @@ -59,7 +59,7 @@ CREATE SEQUENCE "comment_id_seq" start 1 increment 1 maxvalue 2147483647 minvalu CREATE SEQUENCE "breaking_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 10 (OID 28866) +-- TOC Entry ID 9 (OID 19929) -- -- Name: messages_id_seq Type: SEQUENCE Owner: postgres -- @@ -67,7 +67,7 @@ CREATE SEQUENCE "breaking_id_seq" start 1 increment 1 maxvalue 2147483647 minval CREATE SEQUENCE "messages_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 10 (OID 28866) +-- TOC Entry ID 10 (OID 19948) -- -- Name: media_type_id_seq Type: SEQUENCE Owner: postgres -- @@ -75,7 +75,7 @@ CREATE SEQUENCE "messages_id_seq" start 1 increment 1 maxvalue 2147483647 minval CREATE SEQUENCE "media_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 12 (OID 28885) +-- TOC Entry ID 12 (OID 19967) -- -- Name: media_folder Type: TABLE Owner: postgres -- @@ -92,13 +92,13 @@ CREATE TABLE "media_folder" ( ); -- --- TOC Entry ID 13 (OID 28918) +-- TOC Entry ID 13 (OID 20000) -- -- Name: media_type Type: TABLE Owner: postgres -- CREATE TABLE "media_type" ( - "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL, + "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL, "name" character varying(80) NOT NULL, "mime_type" character varying(40) NOT NULL, "classname" character varying(80) NOT NULL, @@ -107,7 +107,7 @@ CREATE TABLE "media_type" ( ); -- --- TOC Entry ID 14 (OID 28932) +-- TOC Entry ID 14 (OID 20016) -- -- Name: img_format Type: TABLE Owner: postgres -- @@ -121,7 +121,7 @@ CREATE TABLE "img_format" ( ); -- --- TOC Entry ID 15 (OID 28946) +-- TOC Entry ID 15 (OID 20030) -- -- Name: img_layout Type: TABLE Owner: postgres -- @@ -132,7 +132,7 @@ CREATE TABLE "img_layout" ( ); -- --- TOC Entry ID 16 (OID 28957) +-- TOC Entry ID 16 (OID 20041) -- -- Name: img_type Type: TABLE Owner: postgres -- @@ -143,7 +143,7 @@ CREATE TABLE "img_type" ( ); -- --- TOC Entry ID 17 (OID 28968) +-- TOC Entry ID 17 (OID 20052) -- -- Name: img_color Type: TABLE Owner: postgres -- @@ -154,7 +154,7 @@ CREATE TABLE "img_color" ( ); -- --- TOC Entry ID 18 (OID 28979) +-- TOC Entry ID 18 (OID 20063) -- -- Name: language Type: TABLE Owner: postgres -- @@ -167,7 +167,7 @@ CREATE TABLE "language" ( ); -- --- TOC Entry ID 19 (OID 28994) +-- TOC Entry ID 19 (OID 20078) -- -- Name: rights Type: TABLE Owner: postgres -- @@ -180,7 +180,7 @@ CREATE TABLE "rights" ( ); -- --- TOC Entry ID 21 (OID 29043) +-- TOC Entry ID 20 (OID 20108) -- -- Name: feature Type: TABLE Owner: postgres -- @@ -196,7 +196,7 @@ CREATE TABLE "feature" ( ); -- --- TOC Entry ID 22 (OID 29078) +-- TOC Entry ID 21 (OID 20143) -- -- Name: webdb_users Type: TABLE Owner: postgres -- @@ -210,7 +210,7 @@ CREATE TABLE "webdb_users" ( ); -- --- TOC Entry ID 23 (OID 29096) +-- TOC Entry ID 22 (OID 20161) -- -- Name: content_x_topic Type: TABLE Owner: postgres -- @@ -221,7 +221,7 @@ CREATE TABLE "content_x_topic" ( ); -- --- TOC Entry ID 24 (OID 29107) +-- TOC Entry ID 23 (OID 20172) -- -- Name: article_type Type: TABLE Owner: postgres -- @@ -232,7 +232,7 @@ CREATE TABLE "article_type" ( ); -- --- TOC Entry ID 25 (OID 29118) +-- TOC Entry ID 24 (OID 20183) -- -- Name: topic Type: TABLE Owner: postgres -- @@ -249,7 +249,7 @@ CREATE TABLE "topic" ( ); -- --- TOC Entry ID 26 (OID 29154) +-- TOC Entry ID 25 (OID 20219) -- -- Name: comment Type: TABLE Owner: postgres -- @@ -268,14 +268,12 @@ CREATE TABLE "comment" ( "to_language" integer DEFAULT '0' NOT NULL, "to_media" integer NOT NULL, "to_comment_status" smallint, - "checksum" integer, + "checksum" integer, Constraint "comment_pkey" Primary Key ("id") ); -CREATE INDEX comment_checksum_index ON comment (checksum); - -- --- TOC Entry ID 27 (OID 29196) +-- TOC Entry ID 26 (OID 20266) -- -- Name: media Type: TABLE Owner: postgres -- @@ -286,7 +284,6 @@ CREATE TABLE "media" ( "subtitle" character varying(30), "edittitle" character varying(30), "date" character(8) NOT NULL, --- "place" character varying(80), "creator" character varying(80), "creator_main_url" character varying(255), "creator_email" character varying(80), @@ -313,13 +310,7 @@ CREATE TABLE "media" ( ); -- --- TOC Entry ID 28 (OID 29257) --- --- Name: images Type: TABLE Owner: postgres --- - --- --- TOC Entry ID 32 (OID 29446) +-- TOC Entry ID 27 (OID 20326) -- -- Name: uploaded_media Type: TABLE Owner: postgres -- @@ -327,8 +318,15 @@ CREATE TABLE "media" ( CREATE TABLE "uploaded_media" ( "icon_is_produced" boolean DEFAULT '0' NOT NULL, "icon_path" character varying(255), - "size" integer -) INHERITS ("media"); + "size" integer +) +INHERITS ("media"); + +-- +-- TOC Entry ID 28 (OID 20392) +-- +-- Name: images Type: TABLE Owner: postgres +-- CREATE TABLE "images" ( "image_data" oid, @@ -346,7 +344,7 @@ CREATE TABLE "images" ( INHERITS ("uploaded_media"); -- --- TOC Entry ID 29 (OID 29338) +-- TOC Entry ID 29 (OID 20474) -- -- Name: content Type: TABLE Owner: postgres -- @@ -356,18 +354,14 @@ CREATE TABLE "content" ( "link_url" character varying(255), "is_html" boolean DEFAULT '0' NOT NULL, "is_stored" boolean DEFAULT '0' NOT NULL, --- "is_mail_sent" boolean DEFAULT '1' NOT NULL, --- "is_digest_sent" boolean DEFAULT '1' NOT NULL, "to_article_type" smallint DEFAULT '0' NOT NULL, "to_content" integer, "checksum" integer ) INHERITS ("media"); -CREATE INDEX content_checksum_index ON content (checksum); - -- --- TOC Entry ID 30 (OID 29418) +-- TOC Entry ID 30 (OID 20549) -- -- Name: breaking Type: TABLE Owner: postgres -- @@ -379,7 +373,7 @@ CREATE TABLE "breaking" ( ); -- --- TOC Entry ID 31 (OID 29431) +-- TOC Entry ID 31 (OID 20562) -- -- Name: messages Type: TABLE Owner: postgres -- @@ -393,7 +387,7 @@ CREATE TABLE "messages" ( ); -- --- TOC Entry ID 33 (OID 30026) +-- TOC Entry ID 32 (OID 20577) -- -- Name: comment_status Type: TABLE Owner: postgres -- @@ -404,7 +398,7 @@ CREATE TABLE "comment_status" ( ); -- --- TOC Entry ID 34 (OID 30064) +-- TOC Entry ID 33 (OID 20588) -- -- Name: content_x_media Type: TABLE Owner: postgres -- @@ -415,7 +409,7 @@ CREATE TABLE "content_x_media" ( ); -- --- TOC Entry ID 11 (OID 32812) +-- TOC Entry ID 11 (OID 20599) -- -- Name: links_imcs_id_seq Type: SEQUENCE Owner: postgres -- @@ -423,7 +417,7 @@ CREATE TABLE "content_x_media" ( CREATE SEQUENCE "links_imcs_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ; -- --- TOC Entry ID 35 (OID 32831) +-- TOC Entry ID 34 (OID 20618) -- -- Name: links_imcs Type: TABLE Owner: postgres -- @@ -439,7 +433,41 @@ CREATE TABLE "links_imcs" ( ); -- --- TOC Entry ID 40 (OID 29078) +-- TOC Entry ID 35 (OID 37215) +-- +-- Name: audio Type: TABLE Owner: postgres +-- + +CREATE TABLE "audio" ( + "audio_data" oid, + "kbits" smallint +) +INHERITS ("uploaded_media"); + +-- +-- TOC Entry ID 36 (OID 37284) +-- +-- Name: video Type: TABLE Owner: postgres +-- + +CREATE TABLE "video" ( + "video_data" oid +) +INHERITS ("uploaded_media"); + +-- +-- TOC Entry ID 37 (OID 45396) +-- +-- Name: other_media Type: TABLE Owner: postgres +-- + +CREATE TABLE "other_media" ( + +) +INHERITS ("uploaded_media"); + +-- +-- TOC Entry ID 40 (OID 20143) -- -- Name: "idx_webdb_user_log_pas_is_admin" Type: INDEX Owner: postgres -- @@ -447,7 +475,7 @@ CREATE TABLE "links_imcs" ( CREATE INDEX "idx_webdb_user_log_pas_is_admin" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops", "is_admin" "bool_ops" ); -- --- TOC Entry ID 44 (OID 29078) +-- TOC Entry ID 41 (OID 20143) -- -- Name: "idx_webdb_user_log_pas" Type: INDEX Owner: postgres -- @@ -455,7 +483,7 @@ CREATE INDEX "idx_webdb_user_log_pas_is_admin" on "webdb_users" using btree ( " CREATE INDEX "idx_webdb_user_log_pas" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops" ); -- --- TOC Entry ID 43 (OID 29096) +-- TOC Entry ID 42 (OID 20161) -- -- Name: "idx_content" Type: INDEX Owner: postgres -- @@ -463,7 +491,7 @@ CREATE INDEX "idx_webdb_user_log_pas" on "webdb_users" using btree ( "login" "v CREATE UNIQUE INDEX "idx_content" on "content_x_topic" using btree ( "content_id" "int4_ops", "topic_id" "int4_ops" ); -- --- TOC Entry ID 45 (OID 29096) +-- TOC Entry ID 43 (OID 20161) -- -- Name: "idx_topic" Type: INDEX Owner: postgres -- @@ -471,7 +499,7 @@ CREATE UNIQUE INDEX "idx_content" on "content_x_topic" using btree ( "content_id CREATE UNIQUE INDEX "idx_topic" on "content_x_topic" using btree ( "topic_id" "int4_ops", "content_id" "int4_ops" ); -- --- TOC Entry ID 46 (OID 29118) +-- TOC Entry ID 44 (OID 20183) -- -- Name: "idx_topic_title" Type: INDEX Owner: postgres -- @@ -479,7 +507,7 @@ CREATE UNIQUE INDEX "idx_topic" on "content_x_topic" using btree ( "topic_id" "i CREATE INDEX "idx_topic_title" on "topic" using btree ( "title" "varchar_ops" ); -- --- TOC Entry ID 51 (OID 29118) +-- TOC Entry ID 45 (OID 20183) -- -- Name: "idx_topic_id" Type: INDEX Owner: postgres -- @@ -487,7 +515,15 @@ CREATE INDEX "idx_topic_title" on "topic" using btree ( "title" "varchar_ops" ) CREATE UNIQUE INDEX "idx_topic_id" on "topic" using btree ( "id" "int4_ops" ); -- --- TOC Entry ID 36 (OID 29154) +-- TOC Entry ID 38 (OID 20219) +-- +-- Name: "comment_checksum_index" Type: INDEX Owner: postgres +-- + +CREATE INDEX "comment_checksum_index" on "comment" using btree ( "checksum" "int4_ops" ); + +-- +-- TOC Entry ID 46 (OID 20219) -- -- Name: "idx_comment_to_media" Type: INDEX Owner: postgres -- @@ -495,7 +531,25 @@ CREATE UNIQUE INDEX "idx_topic_id" on "topic" using btree ( "id" "int4_ops" ); CREATE INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" ); -- --- TOC Entry ID 47 (OID 29257) + +-- +-- TOC Entry ID 59 (OID 20326) +-- +-- Name: "idx_uploaded_media_id" Type: INDEX Owner: postgres +-- + +CREATE UNIQUE INDEX "idx_uploaded_media_id" on "uploaded_media" using btree ( "id" "int4_ops" ); + +-- +-- TOC Entry ID 60 (OID 20326) +-- +-- Name: "idx_uploaded_media_is_published" Type: INDEX Owner: postgres +-- + +CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using btree ( "id" "int4_ops", "is_published" "bool_ops" ); + +-- +-- TOC Entry ID 47 (OID 20392) -- -- Name: "idx_images_is_published__icon_i" Type: INDEX Owner: postgres -- @@ -503,7 +557,7 @@ CREATE INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4 CREATE INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" ); -- --- TOC Entry ID 49 (OID 29257) +-- TOC Entry ID 48 (OID 20392) -- -- Name: "idx_images_id" Type: INDEX Owner: postgres -- @@ -511,7 +565,15 @@ CREATE INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_pu CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" ); -- --- TOC Entry ID 37 (OID 29338) +-- TOC Entry ID 39 (OID 20474) +-- +-- Name: "content_checksum_index" Type: INDEX Owner: postgres +-- + +CREATE INDEX "content_checksum_index" on "content" using btree ( "checksum" "int4_ops" ); + +-- +-- TOC Entry ID 49 (OID 20474) -- -- Name: "idx_content_to_article_type" Type: INDEX Owner: postgres -- @@ -519,7 +581,7 @@ CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" ); CREATE INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" ); -- --- TOC Entry ID 38 (OID 29338) +-- TOC Entry ID 50 (OID 20474) -- -- Name: "idx_content_is_produced" Type: INDEX Owner: postgres -- @@ -527,7 +589,7 @@ CREATE INDEX "idx_content_to_article_type" on "content" using btree ( "to_artic CREATE INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" ); -- --- TOC Entry ID 39 (OID 29338) +-- TOC Entry ID 51 (OID 20474) -- -- Name: "idx_content_is_published__to_ar" Type: INDEX Owner: postgres -- @@ -535,7 +597,7 @@ CREATE INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" CREATE INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" ); -- --- TOC Entry ID 41 (OID 29338) +-- TOC Entry ID 52 (OID 20474) -- -- Name: "idx_content_is_stored" Type: INDEX Owner: postgres -- @@ -543,7 +605,7 @@ CREATE INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_p CREATE INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bool_ops" ); -- --- TOC Entry ID 42 (OID 29338) +-- TOC Entry ID 53 (OID 20474) -- -- Name: "idx_content_is_published__id" Type: INDEX Owner: postgres -- @@ -551,7 +613,7 @@ CREATE INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bo CREATE INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" ); -- --- TOC Entry ID 48 (OID 29338) +-- TOC Entry ID 54 (OID 20474) -- -- Name: "idx_content_is_pub__to_art__to_" Type: INDEX Owner: postgres -- @@ -559,7 +621,7 @@ CREATE INDEX "idx_content_is_published__id" on "content" using btree ( "is_publ CREATE INDEX "idx_content_is_pub__to_art__to_" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops", "id" "int4_ops" ); -- --- TOC Entry ID 50 (OID 29338) +-- TOC Entry ID 55 (OID 20474) -- -- Name: "idx_content_id" Type: INDEX Owner: postgres -- @@ -567,7 +629,7 @@ CREATE INDEX "idx_content_is_pub__to_art__to_" on "content" using btree ( "is_p CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" ); -- --- TOC Entry ID 52 (OID 30064) +-- TOC Entry ID 56 (OID 20588) -- -- Name: "idx_content_media" Type: INDEX Owner: postgres -- @@ -575,11 +637,42 @@ CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" CREATE UNIQUE INDEX "idx_content_media" on "content_x_media" using btree ( "content_id" "int4_ops", "media_id" "int4_ops" ); -- --- TOC Entry ID 53 (OID 30064) +-- TOC Entry ID 57 (OID 20588) -- -- Name: "idx_media_content" Type: INDEX Owner: postgres -- CREATE UNIQUE INDEX "idx_media_content" on "content_x_media" using btree ( "media_id" "int4_ops", "content_id" "int4_ops" ); +-- +-- TOC Entry ID 62 (OID 37215) +-- +-- Name: "idx_audio_is_published_produced" Type: INDEX Owner: postgres +-- + +CREATE INDEX "idx_audio_is_published_produced" on "audio" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" ); + +-- +-- TOC Entry ID 64 (OID 37215) +-- +-- Name: "idx_audio_id" Type: INDEX Owner: postgres +-- + +CREATE UNIQUE INDEX "idx_audio_id" on "audio" using btree ( "id" "int4_ops" ); + +-- +-- TOC Entry ID 65 (OID 37215) +-- +-- Name: "idx_video_id" Type: INDEX Owner: postgres +-- + +CREATE UNIQUE INDEX "idx_video_id" on "audio" using btree ( "id" "int4_ops" ); + +-- +-- TOC Entry ID 63 (OID 37284) +-- +-- Name: "idx_video_is_published_produced" Type: INDEX Owner: postgres +-- + +CREATE INDEX "idx_video_is_published_produced" on "video" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" ); diff --git a/dbscripts/populate_mediatyp.sql b/dbscripts/populate_mediatyp.sql index fe5a71d5..36178328 100755 --- a/dbscripts/populate_mediatyp.sql +++ b/dbscripts/populate_mediatyp.sql @@ -2,7 +2,7 @@ -- Selected TOC Entries: -- -- --- Data for TOC Entry ID 2 (OID 88609) +-- Data for TOC Entry ID 2 (OID 20000) -- -- Name: media_type Type: TABLE DATA Owner: postgres -- @@ -12,27 +12,24 @@ -- Disable triggers UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = 'media_type'; -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (2,'unknown','application/octet-stream','Generic','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (3,'jpg','image/gif','ImagesGif','Images',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (4,'mp3','audio/mp3','Mp3','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (5,'jpg','image/jpeg','ImagesJpeg','Images',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (6,'pdf','application/pdf','Generic','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (7,'mpg','video/mpeg','Video','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (8,'mov','video/quicktime','Video','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (9,'avi','video/x-msvideo','Video','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (10,'ra','audio/vnd.rn-realaudio','RealAudio','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (11,'rm','video/vnd.rn-realvideo','RealVideo','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (12,'ra','audio/x-pn-realaudio','RealAudio','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (13,'mp3','audio/x-mp3','Mp3','UploadedMedia',NULL); -INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (14,'mp3','audio/x-mpeg','Mp3','UploadedMedia',NULL); - - +INSERT INTO "media_type" VALUES (3,'jpg','image/gif','ImagesGif','Images',NULL); +INSERT INTO "media_type" VALUES (5,'jpg','image/jpeg','ImagesJpeg','Images',NULL); +INSERT INTO "media_type" VALUES (4,'mp3','audio/mp3','Mp3','Audio',NULL); +INSERT INTO "media_type" VALUES (13,'mp3','audio/x-mp3','Mp3','Audio',NULL); +INSERT INTO "media_type" VALUES (14,'mp3','audio/x-mpeg','Mp3','Audio',NULL); +INSERT INTO "media_type" VALUES (10,'ra','audio/vnd.rn-realaudio','RealAudio','Audio',NULL); +INSERT INTO "media_type" VALUES (12,'ra','audio/x-pn-realaudio','RealAudio','Audio',NULL); +INSERT INTO "media_type" VALUES (11,'rm','video/vnd.rn-realvideo','RealVideo','Audio',NULL); +INSERT INTO "media_type" VALUES (8,'mov','video/quicktime','Video','Video',NULL); +INSERT INTO "media_type" VALUES (7,'mpg','video/mpeg','Video','Video',NULL); +INSERT INTO "media_type" VALUES (9,'avi','video/x-msvideo','Video','Video',NULL); +INSERT INTO "media_type" VALUES (2,'unknown','application/octet-stream','Generic','Other',NULL); +INSERT INTO "media_type" VALUES (6,'pdf','application/pdf','Generic','Other',NULL); -- Enable triggers - UPDATE pg_class SET reltriggers = (SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid) WHERE relname = 'media_type'; -- --- TOC Entry ID 1 (OID 88557) +-- TOC Entry ID 1 (OID 19948) -- -- Name: media_type_id_seq Type: SEQUENCE SET Owner: -- diff --git a/source/mircoders/entity/EntityAudio.java b/source/mircoders/entity/EntityAudio.java new file mode 100755 index 00000000..8e0f37d5 --- /dev/null +++ b/source/mircoders/entity/EntityAudio.java @@ -0,0 +1,140 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +/* + * kind of hack for postgres non-standard LargeObjects that Poolman + * doesn't know about. see all the casting, LargeObj stuff in getIcon, getAudio + * at some point when postgres has normal BLOB support, this should go. + */ +import org.postgresql.Connection; +import org.postgresql.largeobject.LargeObject; +import org.postgresql.largeobject.LargeObjectManager; + +import mir.entity.*; +import mir.misc.*; +import mir.storage.*; + +/** + * This class handles storage of audio data and meta data + * + * @author mh + * @version 11.11.2000 + */ + + +public class EntityAudio extends EntityUploadedMedia +{ + public EntityAudio() + { + super(); + } + + public EntityAudio(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + // + // methods + + + + public byte[] getAudio() throws StorageObjectException + { + theLog.printDebugInfo("--getaudio started"); + java.sql.Connection con=null;Statement stmt=null; + byte[] img_data=null; + + try { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + LargeObjectManager lom; + java.sql.Connection jCon; + stmt = con.createStatement(); + ResultSet rs = theStorageObject.executeSql(stmt, + "select audio_data from audio where id="+getId()); + jCon = ((com.codestudio.sql.PoolManConnectionHandle)con) + .getNativeConnection(); + lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI(); + if(rs!=null) { + if (rs.next()) { + LargeObject lob = lom.open(rs.getInt(1)); + img_data = lob.read(lob.size()); + lob.close(); + //img_data = rs.getBytes(1); + } + rs.close(); + } + } catch (Exception e) { + e.printStackTrace(); + theLog.printError("EntityAudio -- getAudio failed"+e.toString()); + throwStorageObjectException(e, "EntityAudio -- getAudio failed: "); + } + finally { + try { + con.setAutoCommit(true); + } catch (Exception e) { + e.printStackTrace(); + theLog.printError( + "EntityAudio -- getAudio reseting transaction mode failed" + +e.toString()); + } + theStorageObject.freeConnection(con,stmt); + } + + return img_data; + } + + public void setAudio(byte[] audioData, String audioType) + throws StorageObjectException { + + if (audioData!=null) { + java.sql.Connection con=null;PreparedStatement pstmt=null; + try { + + theLog.printDebugInfo("settaudio :: making internal representation of audio"); + theLog.printDebugInfo("settaudio :: made internal representation of audio"); + theLog.printDebugInfo("settaudio :: getAudio"); + + if ( audioData!=null) { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + theLog.printDebugInfo("settaudio :: trying to insert audio"); + + // setting values + pstmt.setBytes(1, audioData); + String sql="update content set is_produced='0' where to_media="+getId(); + pstmt = con.prepareStatement(sql); + pstmt.executeUpdate(); + } + } + catch (Exception e) {throwStorageObjectException(e, "settaudio :: setAudio gescheitert: ");} + finally { + try { if (con!=null) con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,pstmt); } + } + } + + public void update() throws StorageObjectException { + super.update(); + try { + theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId()); + } catch (SQLException e) { + throwStorageObjectException(e, "EntityAudio :: update :: failed!! "); + } + } + + public void setValues(HashMap theStringValues) + { + if (theStringValues != null) { + if (!theStringValues.containsKey("is_published")) + theStringValues.put("is_published","0"); + } + super.setValues(theStringValues); + } + +} diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java index 28707fe3..047f6bf3 100755 --- a/source/mircoders/entity/EntityContent.java +++ b/source/mircoders/entity/EntityContent.java @@ -164,46 +164,48 @@ public class EntityContent extends Entity throw new TemplateModelException(ex.toString()); } } - if (key.equals("to_media_content")) { + if (key.equals("to_media_images")) { try { - /** @todo why this loggin to System.err and not - * theLog.printDebugInfo() ? / rk */ - System.err.println("ASKED FOR MEDIA"); - SimpleList t = getUploadedMediaForContent(); - //SimpleHash o = t.next(); - - if (t == null) { - System.err.println("NULL -- LIST "+this.getId()); - } else { - SimpleHash o = (SimpleHash)t.next(); - System.err.println("SCALAR: "+o.get("url")); - } - - t.rewind(); - //return getUploadedMediaForContent(); - return t; + return getImagesForContent(); } catch (Exception ex) { - System.err.println("ASKED EXCE"); - theLog.printWarning("-- getUploadedMediaForContent: could not fetch data " + ex.toString()); + theLog.printWarning("-- getImagesForContent: could not fetch data " + ex.toString()); throw new TemplateModelException(ex.toString()); } } - else if (key.equals("to_media_icon")) { + if (key.equals("to_media_audio")) { try { - return getUploadedMediaForNewswire(); + return getAudioForContent(); } catch (Exception ex) { - theLog.printWarning("-- getUploadedMediaForNewswire: could not fetch data " + ex.toString()); + theLog.printWarning("-- getAudioForContent: could not fetch data " + ex.toString()); + throw new TemplateModelException(ex.toString()); + } + } + if (key.equals("to_media_video")) { + try { + return getVideoForContent(); + } + catch (Exception ex) { + theLog.printWarning("-- getVideoForContent: could not fetch data " + ex.toString()); throw new TemplateModelException(ex.toString()); } } - else if (key.equals("to_media_list")) { + if (key.equals("to_media_other")) { try { - return getUploadedMediaForList(); + return getOtherMediaForContent(); } catch (Exception ex) { - theLog.printWarning("-- getUploadedMediaForList: could not fetch data " + ex.toString()); + theLog.printWarning("-- getOtherMediaForContent: could not fetch data " + ex.toString()); + throw new TemplateModelException(ex.toString()); + } + } + else if (key.equals("to_media_icon")) { + try { + return getUploadedMediaForNewswire(); + } + catch (Exception ex) { + theLog.printWarning("-- getUploadedMediaForNewswire: could not fetch data " + ex.toString()); throw new TemplateModelException(ex.toString()); } } @@ -283,6 +285,7 @@ public class EntityContent extends Entity return ((DatabaseContent)theStorageObject).getComments(this); } + // @todo this needs to optimized. expensive SQL private SimpleHash getUploadedMediaForNewswire() throws StorageObjectException, TemplateModelException { @@ -290,8 +293,7 @@ public class EntityContent extends Entity // return to_media_icons String tinyIcon = null, iconAlt = null; MirMedia mediaHandler = null; - Database mediaStorage; - EntityMedia uploadedMedia; + EntityUploadedMedia uploadedMedia; Entity mediaType; SimpleHash returnHash = new SimpleHash(); @@ -300,15 +302,10 @@ public class EntityContent extends Entity if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) { for (int n=0; n < upMediaEntityList.size();n++) { - uploadedMedia = (EntityMedia)upMediaEntityList.elementAt(n); + uploadedMedia = (EntityUploadedMedia)upMediaEntityList.elementAt(n); mediaType = uploadedMedia.getMediaType(); try { - // ############### TODO: merge these and the getURL call into one - // getURL helper call that just takes the Entity as a parameter - // along with media_type mediaHandler = MediaHelper.getHandler( mediaType ); - mediaStorage = MediaHelper.getStorage( mediaType, - "mircoders.storage.Database"); } catch (MirMediaException ex) { throw new TemplateModelException(ex.toString()); } @@ -330,94 +327,45 @@ public class EntityContent extends Entity 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 SimpleHash getUploadedMediaForList() + //######## @todo all of the following getBlahForContent should have + // and optimized version where LIMIT=1 sql for list view. + private SimpleList getImagesForContent() throws StorageObjectException, TemplateModelException { - SimpleHash returnHash = new SimpleHash(); - //media to content - EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(this); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaListAudio = new SimpleList(); - SimpleList mediaListImages = new SimpleList(); - SimpleList mediaListVideo = new SimpleList(); - SimpleList mediaListOther = new SimpleList(); - Entity upMedia; - Entity mediaType; - SimpleHash upMediaSimpleHash; - MirMedia mediaHandler=null; - Database mediaStorage=null; - - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - //upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - - try { - // ############### TODO: merge these and the getURL call into one - // getURL helper call that just takes the Entity as a parameter - // along with media_type - mediaHandler = MediaHelper.getHandler( mediaType ); - mediaStorage = MediaHelper.getStorage( mediaType, - "mircoders.storage.Database"); - } catch (MirMediaException ex) { - throw new TemplateModelException(ex.toString()); - } + return HTMLTemplateProcessor.makeSimpleList( + DatabaseContentToMedia.getInstance().getImages(this) ); + } - // ################ TODO: see getUploadedMediaForContent - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - - // putting media in the apropriate list container - if (upMedia.getValue("is_published").equals("1")) { - if (mediaHandler.isImage()) { - //mediaListImages.add(upMediaSimpleHash); - mediaListImages.add(upMedia); - } else if (mediaHandler.isAudio()) { - //mediaListAudio.add(upMediaSimpleHash); - mediaListAudio.add(upMedia); - } else if (mediaHandler.isVideo()) { - //mediaListVideo.add(upMediaSimpleHash); - mediaListVideo.add(upMedia); - } else { - //mediaListOther.add(upMediaSimpleHash); - mediaListOther.add(upMedia); - } - } //end if is_published - } //end for - returnHash.put("media_audio", mediaListAudio); - returnHash.put("media_images", mediaListImages); - returnHash.put("media_video", mediaListVideo); - returnHash.put("media_other", mediaListOther); - } //end if currentMediaList != null - return returnHash; - } + private SimpleList getAudioForContent() + throws StorageObjectException, TemplateModelException + { + return HTMLTemplateProcessor.makeSimpleList( + DatabaseContentToMedia.getInstance().getAudio(this) ); + } - private SimpleList getUploadedMediaForContent() + private SimpleList getVideoForContent() throws StorageObjectException, TemplateModelException { - /** @todo all logic related to uploaded media should be moved - * to EntityUploadedMedia, selection should just take place - * on published media! .. will fix it later / rk - * - * ok i moved it... let's see what happens... - * - * */ + return HTMLTemplateProcessor.makeSimpleList( + DatabaseContentToMedia.getInstance().getVideo(this) ); + } + private SimpleList getOtherMediaForContent() + throws StorageObjectException, TemplateModelException + { return HTMLTemplateProcessor.makeSimpleList( - DatabaseContentToMedia.getInstance().getUploadedMedia(this) ); + DatabaseContentToMedia.getInstance().getOther(this) ); } } diff --git a/source/mircoders/entity/EntityImages.java b/source/mircoders/entity/EntityImages.java index ac7159ca..5a8b83c5 100755 --- a/source/mircoders/entity/EntityImages.java +++ b/source/mircoders/entity/EntityImages.java @@ -26,7 +26,7 @@ import mir.storage.*; */ -public class EntityImages extends Entity +public class EntityImages extends EntityUploadedMedia { public EntityImages() { diff --git a/source/mircoders/entity/EntityOther.java b/source/mircoders/entity/EntityOther.java new file mode 100755 index 00000000..6cd505a3 --- /dev/null +++ b/source/mircoders/entity/EntityOther.java @@ -0,0 +1,140 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +/* + * kind of hack for postgres non-standard LargeObjects that Poolman + * doesn't know about. see all the casting, LargeObj stuff in getIcon, getOther + * at some point when postgres has normal BLOB support, this should go. + */ +import org.postgresql.Connection; +import org.postgresql.largeobject.LargeObject; +import org.postgresql.largeobject.LargeObjectManager; + +import mir.entity.*; +import mir.misc.*; +import mir.storage.*; + +/** + * This class handles storage of other data and meta data + * + * @author mh + * @version 11.11.2000 + */ + + +public class EntityOther extends EntityUploadedMedia +{ + public EntityOther() + { + super(); + } + + public EntityOther(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + // + // methods + + + + public byte[] getOther() throws StorageObjectException + { + theLog.printDebugInfo("--getother started"); + java.sql.Connection con=null;Statement stmt=null; + byte[] img_data=null; + + try { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + LargeObjectManager lom; + java.sql.Connection jCon; + stmt = con.createStatement(); + ResultSet rs = theStorageObject.executeSql(stmt, + "select other_data from other where id="+getId()); + jCon = ((com.codestudio.sql.PoolManConnectionHandle)con) + .getNativeConnection(); + lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI(); + if(rs!=null) { + if (rs.next()) { + LargeObject lob = lom.open(rs.getInt(1)); + img_data = lob.read(lob.size()); + lob.close(); + //img_data = rs.getBytes(1); + } + rs.close(); + } + } catch (Exception e) { + e.printStackTrace(); + theLog.printError("EntityOther -- getOther failed"+e.toString()); + throwStorageObjectException(e, "EntityOther -- getOther failed: "); + } + finally { + try { + con.setAutoCommit(true); + } catch (Exception e) { + e.printStackTrace(); + theLog.printError( + "EntityOther -- getOther reseting transaction mode failed" + +e.toString()); + } + theStorageObject.freeConnection(con,stmt); + } + + return img_data; + } + + public void setOther(byte[] otherData, String otherType) + throws StorageObjectException { + + if (otherData!=null) { + java.sql.Connection con=null;PreparedStatement pstmt=null; + try { + + theLog.printDebugInfo("settother :: making internal representation of other"); + theLog.printDebugInfo("settother :: made internal representation of other"); + theLog.printDebugInfo("settother :: getOther"); + + if ( otherData!=null) { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + theLog.printDebugInfo("settother :: trying to insert other"); + + // setting values + pstmt.setBytes(1, otherData); + String sql="update content set is_produced='0' where to_media="+getId(); + pstmt = con.prepareStatement(sql); + pstmt.executeUpdate(); + } + } + catch (Exception e) {throwStorageObjectException(e, "settother :: setOther gescheitert: ");} + finally { + try { if (con!=null) con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,pstmt); } + } + } + + public void update() throws StorageObjectException { + super.update(); + try { + theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId()); + } catch (SQLException e) { + throwStorageObjectException(e, "EntityOther :: update :: failed!! "); + } + } + + public void setValues(HashMap theStringValues) + { + if (theStringValues != null) { + if (!theStringValues.containsKey("is_published")) + theStringValues.put("is_published","0"); + } + super.setValues(theStringValues); + } + +} diff --git a/source/mircoders/entity/EntityUploadedMedia.java b/source/mircoders/entity/EntityUploadedMedia.java index f36b0ddc..05675f74 100755 --- a/source/mircoders/entity/EntityUploadedMedia.java +++ b/source/mircoders/entity/EntityUploadedMedia.java @@ -53,7 +53,7 @@ public class EntityUploadedMedia extends Entity public Entity getMediaType() throws StorageObjectException { Entity ent = null; try { - ent = ((DatabaseUploadedMedia)theStorageObject).getMediaType(this); + ent = DatabaseUploadedMedia.getInstance().getMediaType(this); } catch (StorageObjectException e) { throwStorageObjectException(e, "get MediaType failed -- "); } @@ -64,9 +64,15 @@ public class EntityUploadedMedia extends Entity { String returnValue=null; + if (key == null ) + theLog.printError("GOD DAMN!-> null"); + + if (key!=null) { if (key.equals("url")) returnValue=getUrl(); + else if (key.equals("list")) + returnValue=getListView(); else returnValue=super.getValue(key); } @@ -81,16 +87,31 @@ public class EntityUploadedMedia extends Entity private String getUrl() { MirMedia mediaHandler=null; - Database mediaStorage=null; Entity mediaType=null; try { mediaType = getMediaType(); mediaHandler = MediaHelper.getHandler( mediaType ); - mediaStorage = MediaHelper.getStorage( mediaType, "mircoders.storage.Database"); return mediaHandler.getURL(this, mediaType); } catch (Exception ex) { - theLog.printWarning("-- getUrl: could not fetch data " + ex.toString()); + theLog.printWarning("-- getUrl: could not fetch data " + + this.getClass().toString()+" "+ ex.toString()); + } + return null; + } + + private String getListView() + { + MirMedia mediaHandler=null; + Entity mediaType=null; + + try { + mediaType = getMediaType(); + mediaHandler = MediaHelper.getHandler( mediaType ); + return mediaHandler.getListView(this, mediaType); + } catch (Exception ex) { + theLog.printWarning("-- getUrl: could not fetch data " + + this.getClass().toString()+" "+ ex.toString()); } return null; } diff --git a/source/mircoders/entity/EntityVideo.java b/source/mircoders/entity/EntityVideo.java index a72ab3ae..b250b76b 100755 --- a/source/mircoders/entity/EntityVideo.java +++ b/source/mircoders/entity/EntityVideo.java @@ -17,7 +17,7 @@ import mir.storage.*; */ -public class EntityVideo extends Entity +public class EntityVideo extends EntityUploadedMedia { public EntityVideo() diff --git a/source/mircoders/storage/DatabaseAudio.java b/source/mircoders/storage/DatabaseAudio.java new file mode 100755 index 00000000..4b4fd1bd --- /dev/null +++ b/source/mircoders/storage/DatabaseAudio.java @@ -0,0 +1,74 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import mir.storage.*; +import mir.entity.*; +import mir.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseAudio extends Database implements StorageObject{ + + private static DatabaseAudio instance; + private static SimpleList publisherPopupData; + + public static DatabaseAudio getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseAudio(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseAudio() throws StorageObjectException + { + super(); + this.hasTimestamp = true; + this.theTable="audio"; + this.theCoreTable="media"; + try { + this.theEntityClass = Class.forName("mircoders.entity.EntityAudio"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() throws StorageObjectException { + return getPopupData("title",true); + } + + public void update(Entity theEntity) throws StorageObjectException + { + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + + super.update(theEntity); + } + + + public String insert(Entity theEntity) throws StorageObjectException + { + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + return super.insert(theEntity); + } + + // initialisierungen aus den statischen Tabellen + +} diff --git a/source/mircoders/storage/DatabaseContentToMedia.java b/source/mircoders/storage/DatabaseContentToMedia.java index 5a420104..1015e6c0 100755 --- a/source/mircoders/storage/DatabaseContentToMedia.java +++ b/source/mircoders/storage/DatabaseContentToMedia.java @@ -64,6 +64,52 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } /** + * get all the audio belonging to a content entity + * + */ + public EntityList getAudio(EntityContent content) + throws StorageObjectException { + EntityList returnList=null; + if (content != null) { + // get all to_topic from media_x_topic + String id = content.getId(); + //this is not supported by mysql + String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")"; + + try { + returnList = DatabaseAudio.getInstance().selectByWhereClause(subselect,-1); + } catch (Exception e) { + theLog.printDebugInfo("-- get audio failed " + e.toString()); + throw new StorageObjectException("-- get audio failed " + e.toString()); + } + } + return returnList; + } + + /** + * get all the video belonging to a content entity + * + */ + public EntityList getVideo(EntityContent content) + throws StorageObjectException { + EntityList returnList=null; + if (content != null) { + // get all to_topic from media_x_topic + String id = content.getId(); + //this is not supported by mysql + String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")"; + + try { + returnList = DatabaseVideo.getInstance().selectByWhereClause(subselect,-1); + } catch (Exception e) { + theLog.printDebugInfo("-- get video failed " + e.toString()); + throw new StorageObjectException("-- get video failed " + e.toString()); + } + } + return returnList; + } + + /** * get all the images belonging to a content entity * */ @@ -88,7 +134,37 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ /** - * get all the uploaded Media belonging to a content entity + * get all the uploaded/other Media belonging to a content entity + * + */ + public EntityList getOther(EntityContent content) + throws StorageObjectException + { + /** @todo this should only fetch published media / rk */ + + EntityList returnList=null; + if (content != null) { + // get all to_topic from media_x_topic + String id = content.getId(); + //this is not supported by mysql + String subselect = "id in (select media_id from " + theTable + + " where content_id=" + id+")"; + + try { + returnList = DatabaseOther.getInstance().selectByWhereClause(subselect, + "id"); + } catch (Exception e) { + e.printStackTrace(); + theLog.printDebugInfo("-- get Other failed " + e.toString()); + throw new StorageObjectException("-- get Other failed " + + e.toString()); + } + } + return returnList; + } + + /** + * get all the uploaded/other Media belonging to a content entity * */ public EntityList getUploadedMedia(EntityContent content) @@ -101,14 +177,17 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ // get all to_topic from media_x_topic String id = content.getId(); //this is not supported by mysql - String subselect = "id in (select media_id from " + theTable + " where content_id=" + id+")"; + String subselect = "id in (select media_id from " + theTable + + " where content_id=" + id+")"; try { - returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,"id"); + returnList = DatabaseUploadedMedia.getInstance().selectByWhereClause(subselect, + "id"); } catch (Exception e) { e.printStackTrace(); theLog.printDebugInfo("-- get uploadedMedia failed " + e.toString()); - throw new StorageObjectException("-- get uploadedMedia failed " + e.toString()); + throw new StorageObjectException("-- get uploadedMedia failed " + + e.toString()); } } return returnList; diff --git a/source/mircoders/storage/DatabaseMedia.java b/source/mircoders/storage/DatabaseMedia.java index 6d1cf6b0..de0e2945 100755 --- a/source/mircoders/storage/DatabaseMedia.java +++ b/source/mircoders/storage/DatabaseMedia.java @@ -35,8 +35,9 @@ public class DatabaseMedia extends Database implements StorageObject{ super(); //this.cache = new DatabaseCache(100); this.hasTimestamp = false; - this.theTable="media*"; - relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE); + this.theTable="media"; + relationMediaType = new EntityRelation("to_media_type", "id", + DatabaseMediaType.getInstance(), EntityRelation.TO_ONE); try { this.theEntityClass = Class.forName("mircoders.entity.EntityMedia"); } @@ -58,8 +59,8 @@ public class DatabaseMedia extends Database implements StorageObject{ type = relationMediaType.getOne(ent); } catch (StorageObjectException e) { - theLog.printError("DatabaseUploadedMedia :: failed to get media_type"); - throw new StorageObjectException("DatabaseUploadedMedia :"+e.toString()); + theLog.printError("DatabaseMedia :: failed to get media_type"); + throw new StorageObjectException("DatabaseMedia :"+e.toString()); } return type; } diff --git a/source/mircoders/storage/DatabaseOther.java b/source/mircoders/storage/DatabaseOther.java new file mode 100755 index 00000000..e8001751 --- /dev/null +++ b/source/mircoders/storage/DatabaseOther.java @@ -0,0 +1,74 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import mir.storage.*; +import mir.entity.*; +import mir.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseOther extends Database implements StorageObject{ + + private static DatabaseOther instance; + private static SimpleList publisherPopupData; + + public static DatabaseOther getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseOther(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseOther() throws StorageObjectException + { + super(); + this.hasTimestamp = true; + this.theTable="other_media"; + this.theCoreTable="media"; + try { + this.theEntityClass = Class.forName("mircoders.entity.EntityOther"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() throws StorageObjectException { + return getPopupData("title",true); + } + + public void update(Entity theEntity) throws StorageObjectException + { + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + + super.update(theEntity); + } + + + public String insert(Entity theEntity) throws StorageObjectException + { + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + return super.insert(theEntity); + } + + // initialisierungen aus den statischen Tabellen + +} diff --git a/source/mircoders/storage/DatabaseUploadedMedia.java b/source/mircoders/storage/DatabaseUploadedMedia.java index 428edc44..822fb622 100755 --- a/source/mircoders/storage/DatabaseUploadedMedia.java +++ b/source/mircoders/storage/DatabaseUploadedMedia.java @@ -51,7 +51,7 @@ public class DatabaseUploadedMedia extends Database implements StorageObject { /** - * returns the comments that belong to the article (via entityrelation) + * returns the media_type that belongs to the media item (via entityrelation) * where db-flag is_published is true */ public Entity getMediaType(Entity ent) throws StorageObjectException { diff --git a/source/mircoders/storage/DatabaseVideos.java b/source/mircoders/storage/DatabaseVideo.java similarity index 79% rename from source/mircoders/storage/DatabaseVideos.java rename to source/mircoders/storage/DatabaseVideo.java index a53c2c2f..14101ea0 100755 --- a/source/mircoders/storage/DatabaseVideos.java +++ b/source/mircoders/storage/DatabaseVideo.java @@ -17,25 +17,25 @@ import mir.misc.*; * */ -public class DatabaseVideos extends Database implements StorageObject{ +public class DatabaseVideo extends Database implements StorageObject{ - private static DatabaseVideos instance; + private static DatabaseVideo instance; private static SimpleList publisherPopupData; - public static DatabaseVideos getInstance() throws StorageObjectException + public static DatabaseVideo getInstance() throws StorageObjectException { if (instance == null) { - instance = new DatabaseVideos(); + instance = new DatabaseVideo(); instance.myselfDatabase = instance; } return instance; } - private DatabaseVideos() throws StorageObjectException + private DatabaseVideo() throws StorageObjectException { super(); this.hasTimestamp = true; - this.theTable="videos"; + this.theTable="video"; this.theCoreTable="media"; try { this.theEntityClass = Class.forName("mircoders.entity.EntityVideo"); @@ -61,7 +61,6 @@ public class DatabaseVideos extends Database implements StorageObject{ public String insert(Entity theEntity) throws StorageObjectException { - theEntity.setValueForProperty("to_media_type","3"); String date = theEntity.getValue("date"); if (date==null){ date = StringUtil.date2webdbDate(new GregorianCalendar()); diff --git a/templates-dist/producer/content.template b/templates-dist/producer/content.template index 5627136a..a7654b3e 100755 --- a/templates-dist/producer/content.template +++ b/templates-dist/producer/content.template @@ -59,11 +59,31 @@

${creator}, ${webdb_create_formatted}

${description} - -

- + ${to_media_audio[0]["url"]} + +

AU + ${media["url"]} +

+ + +

V + + ${media["url"]} + +

+
+ +

O + + ${media["url"]} + +

+
+ +

I + ${media["url"]} - +

diff --git a/templates-dist/producer/openposting.template b/templates-dist/producer/openposting.template index a3592551..45735b5b 100755 --- a/templates-dist/producer/openposting.template +++ b/templates-dist/producer/openposting.template @@ -59,17 +59,17 @@

${i.creator}, ${i.webdb_create_formatted}

- ${i.to_media_audio[0]["url"]} + ${i.to_media_audio[0]["list"]} - ${i.to_media_video[0]["url"]} + ${i.to_media_video[0]["list"]} - ${i.to_media_other[0]["url"]} + ${i.to_media_other[0]["list"]}

- ${i.to_media_images[0]["url"]} + ${i.to_media_images[0]["list"]} ${i.description}

[read]

diff --git a/templates-dist/producer/startpage.template b/templates-dist/producer/startpage.template index 3a44bb0b..d5f4bc75 100755 --- a/templates-dist/producer/startpage.template +++ b/templates-dist/producer/startpage.template @@ -58,17 +58,17 @@

${s.creator}, ${s.webdb_create_formatted}

- ${s.to_media_audio[0]["url"]} + ${s.to_media_audio[0]["list"]} - ${s.to_media_video[0]["url"]} + ${s.to_media_video[0]["list"]} - ${s.to_media_other[0]["url"]} + ${s.to_media_other[0]["list"]}

- ${s.to_media_images[0]["url"]} + ${s.to_media_images[0]["list"]} ${s.description}

[read]

@@ -87,17 +87,17 @@

${i.creator}, ${i.webdb_create_formatted}

- ${i.to_media_audio[0]["url"]} + ${i.to_media_audio[0]["list"]} - ${i.to_media_video[0]["url"]} + ${i.to_media_video[0]["list"]} - ${i.to_media_other[0]["url"]} + ${i.to_media_other[0]["list"]}

- ${i.to_media_images[0]["url"]} + ${i.to_media_images[0]["list"]} ${i.description}

[read]

@@ -121,8 +121,8 @@

- ${n.icon_alt} + ${n.to_media_icon["icon_alt"]} ${n.title}
${n.webdb_create_formatted}

diff --git a/templates-dist/producer/topiclist.template b/templates-dist/producer/topiclist.template index 04ab03cf..1b75e662 100755 --- a/templates-dist/producer/topiclist.template +++ b/templates-dist/producer/topiclist.template @@ -59,17 +59,17 @@

${special.creator}, ${special.webdb_create_formatted}

- ${special.to_media_audio[0]["url"]} + ${special.to_media_audio[0]["list"]} - ${special.to_media_video[0]["url"]} + ${special.to_media_video[0]["list"]} - ${special.to_media_other[0]["url"]} + ${special.to_media_other[0]["list"]}

- ${special.to_media_images[0]["url"]} + ${special.to_media_images[0]["list"]} ${special.description}

[read]

@@ -87,17 +87,17 @@

${i.creator}, ${i.webdb_create_formatted}

- ${i.to_media_audio[0]["url"]} + ${i.to_media_audio[0]["list"]} - ${i.to_media_video[0]["url"]} + ${i.to_media_video[0]["list"]} - ${i.to_media_other[0]["url"]} + ${i.to_media_other[0]["list"]}

- ${i.to_media_images[0]["url"]} + ${i.to_media_images[0]["list"]} ${i.description}

[read]

-- 2.11.0