changes to playlist so far, made trigger, using position to find clips in new db table.

This commit is contained in:
naomiaro 2010-09-17 16:46:17 -04:00
parent 30adbc2793
commit 1d20c0bc27
5 changed files with 617 additions and 708 deletions

File diff suppressed because it is too large Load Diff

View File

@ -114,6 +114,8 @@ $CC_CONFIG = array(
); );
// Add database table names // Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';
$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents';
$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files'; $CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files';
$CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata'; $CC_CONFIG['mdataTable'] = $CC_CONFIG['tblNamePrefix'].'mdata';
$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access'; $CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access';
@ -127,6 +129,7 @@ $CC_CONFIG['playlogTable'] = $CC_CONFIG['tblNamePrefix'].'playlog';
$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule'; $CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup'; $CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup';
$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id'; $CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id';
$CC_CONFIG['transSequence'] = $CC_CONFIG['transTable'].'_id'; $CC_CONFIG['transSequence'] = $CC_CONFIG['transTable'].'_id';
$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id'; $CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id';

View File

@ -25,6 +25,9 @@ require_once(dirname(__FILE__).'/../GreenBox.php');
require_once(dirname(__FILE__)."/installInit.php"); require_once(dirname(__FILE__)."/installInit.php");
campcaster_db_connect(true); campcaster_db_connect(true);
$sql = "create language 'plpgsql'";
camp_install_query($sql);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Install database tables // Install database tables
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -206,6 +209,75 @@ if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n"; echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n";
} }
if (!camp_db_table_exists($CC_CONFIG['playListTable'])) {
echo " * Creating database table ".$CC_CONFIG['playListTable']."...";
$sql =
"CREATE TABLE ".$CC_CONFIG['playListTable']."
(
id serial NOT NULL,
\"name\" character varying(255) NOT NULL DEFAULT ''::character varying,
state character varying(128) NOT NULL DEFAULT 'empty'::character varying,
currentlyaccessing integer NOT NULL DEFAULT 0,
editedby integer,
mtime timestamp(6) with time zone,
CONSTRAINT cc_playlist_pkey PRIMARY KEY (id),
CONSTRAINT cc_playlist_editedby_fkey FOREIGN KEY (editedby)
REFERENCES cc_subjs (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['playListTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['playListContentsTable'])) {
echo " * Creating database table ".$CC_CONFIG['playListContentsTable']."...";
$sql =
"CREATE TABLE ".$CC_CONFIG['playListContentsTable']."
(
id serial NOT NULL,
playlist_id integer,
file_id integer,
position integer,
cliplength time without time zone DEFAULT '00:00:00.000',
cuein time without time zone DEFAULT '00:00:00.000',
cueout time without time zone DEFAULT '00:00:00.000',
fadein time without time zone DEFAULT '00:00:00.000',
fadeout time without time zone DEFAULT '00:00:00.000',
CONSTRAINT cc_playlistcontents_pkey PRIMARY KEY (id),
CONSTRAINT cc_playlistcontents_playlist_id_fkey FOREIGN KEY (playlist_id)
REFERENCES ".$CC_CONFIG['playListTable']." (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT cc_playlistcontents_file_id_fkey FOREIGN KEY (file_id)
REFERENCES ".$CC_CONFIG['filesTable']." (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
CREATE OR REPLACE FUNCTION calculate_position() RETURNS trigger AS
\$calc_pos\$
BEGIN
IF(TG_OP='INSERT') THEN
UPDATE ".$CC_CONFIG['playListContentsTable']." SET position = (position + 1) WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
END IF;
IF(TG_OP='DELETE') THEN
UPDATE ".$CC_CONFIG['playListContentsTable']." SET position = (position - 1) WHERE (playlist_id = old.playlist_id AND position > old.position);
END IF;
RETURN NULL;
END;
\$calc_pos\$
LANGUAGE 'plpgsql';
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON ".$CC_CONFIG['playListContentsTable']."
FOR EACH ROW EXECUTE PROCEDURE calculate_position();";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['playListContentsTable']."\n";
}
//if (!camp_db_sequence_exists($CC_CONFIG["filesSequence"])) { //if (!camp_db_sequence_exists($CC_CONFIG["filesSequence"])) {
// echo " * Creating database sequence for ".$CC_CONFIG['filesTable']."...\n"; // echo " * Creating database sequence for ".$CC_CONFIG['filesTable']."...\n";
// $CC_DBC->createSequence($CC_CONFIG['filesSequence']); // $CC_DBC->createSequence($CC_CONFIG['filesSequence']);

View File

@ -115,6 +115,26 @@ if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n"; echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
} }
if (camp_db_table_exists($CC_CONFIG['playListTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListTable'];
camp_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListTable']."_id");
} else {
echo " * Skipping: database table ".$CC_CONFIG['playListTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['playListContentsTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListContentsTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListContentsTable'];
camp_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListContentsTable']."_id");
} else {
echo " * Skipping: database table ".$CC_CONFIG['playListContentsTable']."\n";
}
//if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) { //if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) {
// $sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence']; // $sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence'];
// camp_install_query($sql); // camp_install_query($sql);

View File

@ -1,9 +1,17 @@
<?php <?php
require_once 'UnitTests.php'; require_once 'UnitTests.php';
require_once 'PlayListTests.php';
/*
$suite = new PHPUnit_TestSuite("BasicStorTest"); $suite = new PHPUnit_TestSuite("BasicStorTest");
$result = PHPUnit::run($suite); $result = PHPUnit::run($suite);
echo $result->toString();
*/
$suite = new PHPUnit_TestSuite("PlayListTest");
$result = PHPUnit::run($suite);
echo $result->toString(); echo $result->toString();
?> ?>