From 703a8e58562f7e25a0e565ded1fbee71ccfa156d Mon Sep 17 00:00:00 2001 From: Jonas L Date: Mon, 4 Jul 2022 22:09:14 +0200 Subject: [PATCH] chore: remove cloud storage remainings (#1934) --- .../migrations/0034_3_0_0_alpha_13_8.py | 39 + .../legacy/migrations/__init__.py | 2 +- .../legacy/migrations/sql/schema.sql | 20 - api/libretime_api/storage/models/__init__.py | 1 - .../storage/models/cloud_file.py | 17 - api/libretime_api/storage/router.py | 3 +- .../storage/serializers/__init__.py | 1 - .../storage/serializers/cloud_file.py | 9 - api/libretime_api/storage/views/__init__.py | 1 - api/libretime_api/storage/views/cloud_file.py | 10 - api/schema.yml | 183 --- legacy/application/airtime-boot.php | 3 - .../cloud_storage/FileStorageBackend.php | 30 - .../cloud_storage/ProxyStorageBackend.php | 54 - .../cloud_storage/StorageBackend.php | 60 - .../configs/classmap-airtime-conf.php | 7 - .../controllers/LibraryController.php | 4 - .../controllers/PreferenceController.php | 15 - legacy/application/models/StoredFile.php | 22 +- legacy/application/models/airtime/CcFiles.php | 22 +- .../application/models/airtime/CloudFile.php | 90 -- .../models/airtime/CloudFilePeer.php | 12 - .../models/airtime/CloudFileQuery.php | 12 - .../models/airtime/map/CcFilesTableMap.php | 1 - .../models/airtime/map/CloudFileTableMap.php | 72 -- .../models/airtime/om/BaseCcFiles.php | 285 ----- .../models/airtime/om/BaseCcFilesPeer.php | 3 - .../models/airtime/om/BaseCcFilesQuery.php | 78 -- .../models/airtime/om/BaseCloudFile.php | 1071 ----------------- .../models/airtime/om/BaseCloudFilePeer.php | 1008 ---------------- .../models/airtime/om/BaseCloudFileQuery.php | 470 -------- legacy/build/schema.xml | 13 - legacy/tests/application/bootstrap.php | 3 - 33 files changed, 50 insertions(+), 3571 deletions(-) create mode 100644 api/libretime_api/legacy/migrations/0034_3_0_0_alpha_13_8.py delete mode 100644 api/libretime_api/storage/models/cloud_file.py delete mode 100644 api/libretime_api/storage/serializers/cloud_file.py delete mode 100644 api/libretime_api/storage/views/cloud_file.py delete mode 100644 legacy/application/cloud_storage/FileStorageBackend.php delete mode 100644 legacy/application/cloud_storage/ProxyStorageBackend.php delete mode 100644 legacy/application/cloud_storage/StorageBackend.php delete mode 100644 legacy/application/models/airtime/CloudFile.php delete mode 100644 legacy/application/models/airtime/CloudFilePeer.php delete mode 100644 legacy/application/models/airtime/CloudFileQuery.php delete mode 100644 legacy/application/models/airtime/map/CloudFileTableMap.php delete mode 100644 legacy/application/models/airtime/om/BaseCloudFile.php delete mode 100644 legacy/application/models/airtime/om/BaseCloudFilePeer.php delete mode 100644 legacy/application/models/airtime/om/BaseCloudFileQuery.php diff --git a/api/libretime_api/legacy/migrations/0034_3_0_0_alpha_13_8.py b/api/libretime_api/legacy/migrations/0034_3_0_0_alpha_13_8.py new file mode 100644 index 000000000..ad25d7ae5 --- /dev/null +++ b/api/libretime_api/legacy/migrations/0034_3_0_0_alpha_13_8.py @@ -0,0 +1,39 @@ +# pylint: disable=invalid-name + +from django.db import migrations + +from ._migrations import legacy_migration_factory + +UP = """ +DROP TABLE IF EXISTS "cloud_file" CASCADE; +""" + +DOWN = """ +CREATE TABLE "cloud_file" +( + "id" serial NOT NULL, + "storage_backend" VARCHAR(512) NOT NULL, + "resource_id" TEXT NOT NULL, + "cc_file_id" INTEGER, + PRIMARY KEY ("id") +); + +ALTER TABLE "cloud_file" ADD CONSTRAINT "cloud_file_FK_1" + FOREIGN KEY ("cc_file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; +""" + + +class Migration(migrations.Migration): + dependencies = [ + ("legacy", "0033_3_0_0_alpha_13_7"), + ] + operations = [ + migrations.RunPython( + code=legacy_migration_factory( + target="3.0.0-alpha.13.8", + sql=UP, + ) + ) + ] diff --git a/api/libretime_api/legacy/migrations/__init__.py b/api/libretime_api/legacy/migrations/__init__.py index 3000100bb..443bd1911 100644 --- a/api/libretime_api/legacy/migrations/__init__.py +++ b/api/libretime_api/legacy/migrations/__init__.py @@ -1 +1 @@ -LEGACY_SCHEMA_VERSION = "3.0.0-alpha.13.7" +LEGACY_SCHEMA_VERSION = "3.0.0-alpha.13.8" diff --git a/api/libretime_api/legacy/migrations/sql/schema.sql b/api/libretime_api/legacy/migrations/sql/schema.sql index 2440e01db..659140348 100644 --- a/api/libretime_api/legacy/migrations/sql/schema.sql +++ b/api/libretime_api/legacy/migrations/sql/schema.sql @@ -100,21 +100,6 @@ CREATE TABLE "cc_track_types" CONSTRAINT "cc_track_types_code_idx" UNIQUE ("code") ); ------------------------------------------------------------------------ --- cloud_file ------------------------------------------------------------------------ - -DROP TABLE IF EXISTS "cloud_file" CASCADE; - -CREATE TABLE "cloud_file" -( - "id" serial NOT NULL, - "storage_backend" VARCHAR(512) NOT NULL, - "resource_id" TEXT NOT NULL, - "cc_file_id" INTEGER, - PRIMARY KEY ("id") -); - ----------------------------------------------------------------------- -- cc_show ----------------------------------------------------------------------- @@ -735,11 +720,6 @@ ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_editedby_fkey" FOREIGN KEY ("editedby") REFERENCES "cc_subjs" ("id"); -ALTER TABLE "cloud_file" ADD CONSTRAINT "cloud_file_FK_1" - FOREIGN KEY ("cc_file_id") - REFERENCES "cc_files" ("id") - ON DELETE CASCADE; - ALTER TABLE "cc_show" ADD CONSTRAINT "cc_playlist_autoplaylist_fkey" FOREIGN KEY ("autoplaylist_id") REFERENCES "cc_playlist" ("id") diff --git a/api/libretime_api/storage/models/__init__.py b/api/libretime_api/storage/models/__init__.py index fa9af85e7..04d331f2e 100644 --- a/api/libretime_api/storage/models/__init__.py +++ b/api/libretime_api/storage/models/__init__.py @@ -1,3 +1,2 @@ -from .cloud_file import CloudFile from .file import File from .library import Library diff --git a/api/libretime_api/storage/models/cloud_file.py b/api/libretime_api/storage/models/cloud_file.py deleted file mode 100644 index 9570e172b..000000000 --- a/api/libretime_api/storage/models/cloud_file.py +++ /dev/null @@ -1,17 +0,0 @@ -from django.db import models - - -class CloudFile(models.Model): - storage_backend = models.CharField(max_length=512) - resource_id = models.TextField() - filename = models.ForeignKey( - "storage.File", - on_delete=models.DO_NOTHING, - blank=True, - null=True, - db_column="cc_file_id", - ) - - class Meta: - managed = False - db_table = "cloud_file" diff --git a/api/libretime_api/storage/router.py b/api/libretime_api/storage/router.py index 6cca258c8..6ec5b2cbe 100644 --- a/api/libretime_api/storage/router.py +++ b/api/libretime_api/storage/router.py @@ -1,8 +1,7 @@ from rest_framework import routers -from .views import CloudFileViewSet, FileViewSet, LibraryViewSet +from .views import FileViewSet, LibraryViewSet router = routers.DefaultRouter() router.register("files", FileViewSet) -router.register("cloud-files", CloudFileViewSet) router.register("libraries", LibraryViewSet) diff --git a/api/libretime_api/storage/serializers/__init__.py b/api/libretime_api/storage/serializers/__init__.py index 52ab3212e..1a84a42b7 100644 --- a/api/libretime_api/storage/serializers/__init__.py +++ b/api/libretime_api/storage/serializers/__init__.py @@ -1,3 +1,2 @@ -from .cloud_file import CloudFileSerializer from .file import FileSerializer from .library import LibrarySerializer diff --git a/api/libretime_api/storage/serializers/cloud_file.py b/api/libretime_api/storage/serializers/cloud_file.py deleted file mode 100644 index 1832e47e0..000000000 --- a/api/libretime_api/storage/serializers/cloud_file.py +++ /dev/null @@ -1,9 +0,0 @@ -from rest_framework import serializers - -from ..models import CloudFile - - -class CloudFileSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = CloudFile - fields = "__all__" diff --git a/api/libretime_api/storage/views/__init__.py b/api/libretime_api/storage/views/__init__.py index 28f64238d..362dda1d4 100644 --- a/api/libretime_api/storage/views/__init__.py +++ b/api/libretime_api/storage/views/__init__.py @@ -1,3 +1,2 @@ -from .cloud_file import CloudFileViewSet from .file import FileViewSet from .library import LibraryViewSet diff --git a/api/libretime_api/storage/views/cloud_file.py b/api/libretime_api/storage/views/cloud_file.py deleted file mode 100644 index cf4a30d49..000000000 --- a/api/libretime_api/storage/views/cloud_file.py +++ /dev/null @@ -1,10 +0,0 @@ -from rest_framework import viewsets - -from ..models import CloudFile -from ..serializers import CloudFileSerializer - - -class CloudFileViewSet(viewsets.ModelViewSet): - queryset = CloudFile.objects.all() - serializer_class = CloudFileSerializer - model_permission_name = "cloudfile" diff --git a/api/schema.yml b/api/schema.yml index a53b74f5e..f90a27eef 100644 --- a/api/schema.yml +++ b/api/schema.yml @@ -151,153 +151,6 @@ paths: responses: "204": description: No response body - /api/v2/cloud-files/: - get: - operationId: cloud_files_list - tags: - - cloud-files - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "200": - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/CloudFile" - description: "" - post: - operationId: cloud_files_create - tags: - - cloud-files - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - application/x-www-form-urlencoded: - schema: - $ref: "#/components/schemas/CloudFile" - multipart/form-data: - schema: - $ref: "#/components/schemas/CloudFile" - required: true - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "201": - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - description: "" - /api/v2/cloud-files/{id}/: - get: - operationId: cloud_files_retrieve - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this cloud file. - required: true - tags: - - cloud-files - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - description: "" - put: - operationId: cloud_files_update - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this cloud file. - required: true - tags: - - cloud-files - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - application/x-www-form-urlencoded: - schema: - $ref: "#/components/schemas/CloudFile" - multipart/form-data: - schema: - $ref: "#/components/schemas/CloudFile" - required: true - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - description: "" - patch: - operationId: cloud_files_partial_update - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this cloud file. - required: true - tags: - - cloud-files - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/PatchedCloudFile" - application/x-www-form-urlencoded: - schema: - $ref: "#/components/schemas/PatchedCloudFile" - multipart/form-data: - schema: - $ref: "#/components/schemas/PatchedCloudFile" - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CloudFile" - description: "" - delete: - operationId: cloud_files_destroy - parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this cloud file. - required: true - tags: - - cloud-files - security: - - cookieAuth: [] - - basicAuth: [] - responses: - "204": - description: No response body /api/v2/countries/: get: operationId: countries_list @@ -5791,26 +5644,6 @@ components: - status - task_id - track_reference - CloudFile: - type: object - properties: - item_url: - type: string - format: uri - readOnly: true - storage_backend: - type: string - maxLength: 512 - resource_id: - type: string - filename: - type: string - format: uri - nullable: true - required: - - item_url - - resource_id - - storage_backend Country: type: object properties: @@ -6238,22 +6071,6 @@ components: track_reference: type: string format: uri - PatchedCloudFile: - type: object - properties: - item_url: - type: string - format: uri - readOnly: true - storage_backend: - type: string - maxLength: 512 - resource_id: - type: string - filename: - type: string - format: uri - nullable: true PatchedCountry: type: object properties: diff --git a/legacy/application/airtime-boot.php b/legacy/application/airtime-boot.php index 6e1b8abc8..7bdbc13d4 100644 --- a/legacy/application/airtime-boot.php +++ b/legacy/application/airtime-boot.php @@ -49,9 +49,6 @@ set_include_path(APPLICATION_PATH . '/controllers/plugins' . PATH_SEPARATOR . ge // Services. set_include_path(APPLICATION_PATH . '/services' . PATH_SEPARATOR . get_include_path()); -// cloud storage directory -set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path()); - // Upgrade directory set_include_path(APPLICATION_PATH . '/upgrade' . PATH_SEPARATOR . get_include_path()); diff --git a/legacy/application/cloud_storage/FileStorageBackend.php b/legacy/application/cloud_storage/FileStorageBackend.php deleted file mode 100644 index a70838a27..000000000 --- a/legacy/application/cloud_storage/FileStorageBackend.php +++ /dev/null @@ -1,30 +0,0 @@ -storageBackend = new FileStorageBackend(); - } else { - $this->storageBackend = new $storageBackend($CC_CONFIG[$storageBackend]); - } - } - - public function getAbsoluteFilePath($resourceId) - { - return $this->storageBackend->getAbsoluteFilePath($resourceId); - } - - public function getDownloadURLs($resourceId, $contentDispositionFilename) - { - return $this->storageBackend->getDownloadURLs($resourceId, $contentDispositionFilename); - } - - public function deletePhysicalFile($resourceId) - { - $this->storageBackend->deletePhysicalFile($resourceId); - } - - public function deleteAllCloudFileObjects() - { - $this->storageBackend->deleteAllCloudFileObjects(); - } - - public function getFilePrefix() - { - return $this->storageBackend->getFilePrefix(); - } -} diff --git a/legacy/application/cloud_storage/StorageBackend.php b/legacy/application/cloud_storage/StorageBackend.php deleted file mode 100644 index 4b5e5f62e..000000000 --- a/legacy/application/cloud_storage/StorageBackend.php +++ /dev/null @@ -1,60 +0,0 @@ -bucket; - } - - protected function setBucket($bucket) - { - $this->bucket = $bucket; - } - - protected function getAccessKey() - { - return $this->accessKey; - } - - protected function setAccessKey($accessKey) - { - $this->accessKey = $accessKey; - } - - protected function getSecretKey() - { - return $this->secretKey; - } - - protected function setSecretKey($secretKey) - { - $this->secretKey = $secretKey; - } -} diff --git a/legacy/application/configs/classmap-airtime-conf.php b/legacy/application/configs/classmap-airtime-conf.php index 4a90ddaab..1eae737b3 100644 --- a/legacy/application/configs/classmap-airtime-conf.php +++ b/legacy/application/configs/classmap-airtime-conf.php @@ -95,9 +95,6 @@ return [ 'BaseCeleryTasks' => 'airtime/om/BaseCeleryTasks.php', 'BaseCeleryTasksPeer' => 'airtime/om/BaseCeleryTasksPeer.php', 'BaseCeleryTasksQuery' => 'airtime/om/BaseCeleryTasksQuery.php', - 'BaseCloudFile' => 'airtime/om/BaseCloudFile.php', - 'BaseCloudFilePeer' => 'airtime/om/BaseCloudFilePeer.php', - 'BaseCloudFileQuery' => 'airtime/om/BaseCloudFileQuery.php', 'BaseImportedPodcast' => 'airtime/om/BaseImportedPodcast.php', 'BaseImportedPodcastPeer' => 'airtime/om/BaseImportedPodcastPeer.php', 'BaseImportedPodcastQuery' => 'airtime/om/BaseImportedPodcastQuery.php', @@ -237,10 +234,6 @@ return [ 'CeleryTasksPeer' => 'airtime/CeleryTasksPeer.php', 'CeleryTasksQuery' => 'airtime/CeleryTasksQuery.php', 'CeleryTasksTableMap' => 'airtime/map/CeleryTasksTableMap.php', - 'CloudFile' => 'airtime/CloudFile.php', - 'CloudFilePeer' => 'airtime/CloudFilePeer.php', - 'CloudFileQuery' => 'airtime/CloudFileQuery.php', - 'CloudFileTableMap' => 'airtime/map/CloudFileTableMap.php', 'ImportedPodcast' => 'airtime/ImportedPodcast.php', 'ImportedPodcastPeer' => 'airtime/ImportedPodcastPeer.php', 'ImportedPodcastQuery' => 'airtime/ImportedPodcastQuery.php', diff --git a/legacy/application/controllers/LibraryController.php b/legacy/application/controllers/LibraryController.php index 44da3bba2..e92f8144e 100644 --- a/legacy/application/controllers/LibraryController.php +++ b/legacy/application/controllers/LibraryController.php @@ -122,10 +122,6 @@ class LibraryController extends Zend_Controller_Action // $menu["publish"] = array("name"=> _("Publish..."), "url" => $baseUrl."library/publish/id/{$id}"); } - // It's important that we always return the parent id (cc_files id) - // and not the cloud_file id (if applicable) for track download. - // Our application logic (StoredFile.php) will determine if the track - // is a cloud_file and handle it appropriately. $url = $baseUrl . "api/get-media/file/{$id}/download/true"; $menu['download'] = ['name' => _('Download'), 'icon' => 'download', 'url' => $url]; } elseif ($type === 'playlist' || $type === 'block') { diff --git a/legacy/application/controllers/PreferenceController.php b/legacy/application/controllers/PreferenceController.php index 5b9f73e82..40b254da2 100644 --- a/legacy/application/controllers/PreferenceController.php +++ b/legacy/application/controllers/PreferenceController.php @@ -465,7 +465,6 @@ class PreferenceController extends Zend_Controller_Action } $this->deleteFutureScheduleItems(); - $this->deleteCloudFiles(); $this->deleteStoredFiles(); $this->getResponse() @@ -499,20 +498,6 @@ class PreferenceController extends Zend_Controller_Action } } - private function deleteCloudFiles() - { - try { - $CC_CONFIG = Config::getConfig(); - - foreach ($CC_CONFIG['supportedStorageBackends'] as $storageBackend) { - $proxyStorageBackend = new ProxyStorageBackend($storageBackend); - $proxyStorageBackend->deleteAllCloudFileObjects(); - } - } catch (Exception $e) { - Logging::info($e->getMessage()); - } - } - private function deleteStoredFiles() { // Delete all files from the database diff --git a/legacy/application/models/StoredFile.php b/legacy/application/models/StoredFile.php index 0eefb4e81..be31817a2 100644 --- a/legacy/application/models/StoredFile.php +++ b/legacy/application/models/StoredFile.php @@ -385,7 +385,7 @@ SQL; } /** - * Deletes the physical file from the local file system or from the cloud. + * Deletes the physical file from the local file system. * * @param mixed $quiet */ @@ -412,7 +412,6 @@ SQL; } // Delete the physical file from either the local stor directory - // or from the cloud if ($this->_file->getDbImportStatus() == CcFiles::IMPORT_STATUS_SUCCESS) { try { $this->_file->deletePhysicalFile(); @@ -433,7 +432,7 @@ SQL; // the file getting deleted self::updateBlockAndPlaylistLength($this->_file->getDbId()); - // delete the file record from cc_files (and cloud_file, if applicable) + // delete the file record from cc_files $this->_file->delete(); } @@ -616,16 +615,7 @@ SQL; throw new Exception('Could not recall file with id: ' . $p_id); } - // Attempt to get the cloud file object and return it. If no cloud - // file object is found then we are dealing with a regular stored - // object so return that - $cloudFile = CloudFileQuery::create()->findOneByCcFileId($p_id); - - if (is_null($cloudFile)) { - return self::createWithFile($storedFile, $con); - } - - return self::createWithFile($cloudFile, $con); + return self::createWithFile($storedFile, $con); } throw new Exception('No arguments passed to RecallById'); @@ -681,13 +671,15 @@ SQL; public static function getLibraryColumns() { - return ['id', 'track_title', 'artist_name', 'album_title', + return [ + 'id', 'track_title', 'artist_name', 'album_title', 'genre', 'length', 'year', 'utime', 'mtime', 'ftype', 'track_number', 'mood', 'bpm', 'composer', 'info_url', 'bit_rate', 'sample_rate', 'isrc_number', 'encoded_by', 'label', 'copyright', 'mime', 'language', 'filepath', 'owner_id', 'conductor', 'replay_gain', 'lptime', 'is_playlist', 'is_scheduled', - 'cuein', 'cueout', 'description', 'artwork', 'track_type', ]; + 'cuein', 'cueout', 'description', 'artwork', 'track_type', + ]; } public static function searchLibraryFiles($datatables) diff --git a/legacy/application/models/airtime/CcFiles.php b/legacy/application/models/airtime/CcFiles.php index 19a1a271e..6c80fc5d2 100644 --- a/legacy/application/models/airtime/CcFiles.php +++ b/legacy/application/models/airtime/CcFiles.php @@ -205,25 +205,7 @@ class CcFiles extends BaseCcFiles try { self::validateFileArray($fileArray); - if ($file && isset($fileArray['resource_id'])) { - $file->fromArray($fileArray, BasePeer::TYPE_FIELDNAME); - - // store the original filename - $file->setDbFilepath($fileArray['filename']); - - $fileSizeBytes = $fileArray['filesize']; - if (!isset($fileSizeBytes) || $fileSizeBytes === false) { - throw new LibreTimeFileNotFoundException("Invalid filesize for {$fileId}"); - } - - $cloudFile = new CloudFile(); - $cloudFile->setStorageBackend($fileArray['storage_backend']); - $cloudFile->setResourceId($fileArray['resource_id']); - $cloudFile->setCcFiles($file); - $cloudFile->save(); - - Application_Model_Preference::updateDiskUsage($fileSizeBytes); - } elseif ($file) { + if ($file) { $file->fromArray($fileArray, BasePeer::TYPE_FIELDNAME); // Our RESTful API takes "full_path" as a field, which we then split and translate to match @@ -265,7 +247,7 @@ class CcFiles extends BaseCcFiles return CcFiles::sanitizeResponse($file); } - /** Delete a file from the database and disk (or cloud). + /** Delete a file from the database and disk. * @param $id The file ID * * @throws DeleteScheduledFileException diff --git a/legacy/application/models/airtime/CloudFile.php b/legacy/application/models/airtime/CloudFile.php deleted file mode 100644 index 64de1aa28..000000000 --- a/legacy/application/models/airtime/CloudFile.php +++ /dev/null @@ -1,90 +0,0 @@ -proxyStorageBackend == null) { - $this->proxyStorageBackend = new ProxyStorageBackend($this->getStorageBackend()); - } - - return $this->proxyStorageBackend->getDownloadURLs($this->getResourceId(), $this->getFilename()); - } - - /** - * Returns a url to the file's object on Amazon S3. - */ - public function getAbsoluteFilePath() - { - if ($this->proxyStorageBackend == null) { - $this->proxyStorageBackend = new ProxyStorageBackend($this->getStorageBackend()); - } - - return $this->proxyStorageBackend->getAbsoluteFilePath($this->getResourceId()); - } - - public function getFilename() - { - $filename = $this->getDbFilepath(); - $info = pathinfo($filename); - - // Add the correct file extension based on the MIME type, for files that were uploaded with the wrong extension. - $mime = $this->getDbMime(); - $extension = FileDataHelper::getFileExtensionFromMime($mime); - - return $info['filename'] . $extension; - } - - /** - * Checks if the file is a regular file that can be previewed and downloaded. - */ - public function isValidPhysicalFile() - { - // We don't need to check if the cloud file is a valid file because - // before it is imported the Analyzer runs it through Liquidsoap - // to check its playability. If Liquidsoap can't play the file it - // does not get imported into the Airtime library. - return true; - } - - /** - * Deletes the file from cloud storage. - */ - public function deletePhysicalFile() - { - if ($this->proxyStorageBackend == null) { - $this->proxyStorageBackend = new ProxyStorageBackend($this->getStorageBackend()); - } - $this->proxyStorageBackend->deletePhysicalFile($this->getResourceId()); - } - - /** - * Deletes the cc_file and cloud_file entries from the database. - */ - public function delete(PropelPDO $con = null) - { - CcFilesQuery::create()->findPk($this->getCcFileId())->delete(); - parent::delete(); - } -} diff --git a/legacy/application/models/airtime/CloudFilePeer.php b/legacy/application/models/airtime/CloudFilePeer.php deleted file mode 100644 index 6cb845957..000000000 --- a/legacy/application/models/airtime/CloudFilePeer.php +++ /dev/null @@ -1,12 +0,0 @@ -addRelation('FkOwner', 'CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); $this->addRelation('CcSubjsRelatedByDbEditedby', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); - $this->addRelation('CloudFile', 'CloudFile', RelationMap::ONE_TO_MANY, array('id' => 'cc_file_id', ), 'CASCADE', null, 'CloudFiles'); $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcShowInstancess'); $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcPlaylistcontentss'); $this->addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcBlockcontentss'); diff --git a/legacy/application/models/airtime/map/CloudFileTableMap.php b/legacy/application/models/airtime/map/CloudFileTableMap.php deleted file mode 100644 index 5f9702bf2..000000000 --- a/legacy/application/models/airtime/map/CloudFileTableMap.php +++ /dev/null @@ -1,72 +0,0 @@ -setName('cloud_file'); - $this->setPhpName('CloudFile'); - $this->setClassname('CloudFile'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cloud_file_id_seq'); - // columns - $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('storage_backend', 'StorageBackend', 'VARCHAR', true, 512, null); - $this->addColumn('resource_id', 'ResourceId', 'LONGVARCHAR', true, null, null); - $this->addForeignKey('cc_file_id', 'CcFileId', 'INTEGER', 'cc_files', 'id', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('cc_file_id' => 'id', ), 'CASCADE', null); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'delegate' => array ( - 'to' => 'cc_files', -), - ); - } // getBehaviors() - -} // CloudFileTableMap diff --git a/legacy/application/models/airtime/om/BaseCcFiles.php b/legacy/application/models/airtime/om/BaseCcFiles.php index ba2647ba9..bc7d045d0 100644 --- a/legacy/application/models/airtime/om/BaseCcFiles.php +++ b/legacy/application/models/airtime/om/BaseCcFiles.php @@ -462,12 +462,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent */ protected $aCcSubjsRelatedByDbEditedby; - /** - * @var PropelObjectCollection|CloudFile[] Collection to store aggregation of CloudFile objects. - */ - protected $collCloudFiles; - protected $collCloudFilesPartial; - /** * @var PropelObjectCollection|CcShowInstances[] Collection to store aggregation of CcShowInstances objects. */ @@ -530,12 +524,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent */ protected $alreadyInClearAllReferencesDeep = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $cloudFilesScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -3154,8 +3142,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->aFkOwner = null; $this->aCcSubjsRelatedByDbEditedby = null; - $this->collCloudFiles = null; - $this->collCcShowInstancess = null; $this->collCcPlaylistcontentss = null; @@ -3313,23 +3299,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->resetModified(); } - if ($this->cloudFilesScheduledForDeletion !== null) { - if (!$this->cloudFilesScheduledForDeletion->isEmpty()) { - CloudFileQuery::create() - ->filterByPrimaryKeys($this->cloudFilesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->cloudFilesScheduledForDeletion = null; - } - } - - if ($this->collCloudFiles !== null) { - foreach ($this->collCloudFiles as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->ccShowInstancessScheduledForDeletion !== null) { if (!$this->ccShowInstancessScheduledForDeletion->isEmpty()) { CcShowInstancesQuery::create() @@ -4014,14 +3983,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } - if ($this->collCloudFiles !== null) { - foreach ($this->collCloudFiles as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collCcShowInstancess !== null) { foreach ($this->collCcShowInstancess as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -4427,9 +4388,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent if (null !== $this->aCcSubjsRelatedByDbEditedby) { $result['CcSubjsRelatedByDbEditedby'] = $this->aCcSubjsRelatedByDbEditedby->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->collCloudFiles) { - $result['CloudFiles'] = $this->collCloudFiles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCcShowInstancess) { $result['CcShowInstancess'] = $this->collCcShowInstancess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -4998,12 +4956,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getCloudFiles() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCloudFile($relObj->copy($deepCopy)); - } - } - foreach ($this->getCcShowInstancess() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCcShowInstances($relObj->copy($deepCopy)); @@ -5211,9 +5163,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('CloudFile' == $relationName) { - $this->initCloudFiles(); - } if ('CcShowInstances' == $relationName) { $this->initCcShowInstancess(); } @@ -5237,231 +5186,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } } - /** - * Clears out the collCloudFiles collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return CcFiles The current object (for fluent API support) - * @see addCloudFiles() - */ - public function clearCloudFiles() - { - $this->collCloudFiles = null; // important to set this to null since that means it is uninitialized - $this->collCloudFilesPartial = null; - - return $this; - } - - /** - * reset is the collCloudFiles collection loaded partially - * - * @return void - */ - public function resetPartialCloudFiles($v = true) - { - $this->collCloudFilesPartial = $v; - } - - /** - * Initializes the collCloudFiles collection. - * - * By default this just sets the collCloudFiles collection to an empty array (like clearcollCloudFiles()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCloudFiles($overrideExisting = true) - { - if (null !== $this->collCloudFiles && !$overrideExisting) { - return; - } - $this->collCloudFiles = new PropelObjectCollection(); - $this->collCloudFiles->setModel('CloudFile'); - } - - /** - * Gets an array of CloudFile objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this CcFiles is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CloudFile[] List of CloudFile objects - * @throws PropelException - */ - public function getCloudFiles($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCloudFilesPartial && !$this->isNew(); - if (null === $this->collCloudFiles || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCloudFiles) { - // return empty collection - $this->initCloudFiles(); - } else { - $collCloudFiles = CloudFileQuery::create(null, $criteria) - ->filterByCcFiles($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCloudFilesPartial && count($collCloudFiles)) { - $this->initCloudFiles(false); - - foreach ($collCloudFiles as $obj) { - if (false == $this->collCloudFiles->contains($obj)) { - $this->collCloudFiles->append($obj); - } - } - - $this->collCloudFilesPartial = true; - } - - $collCloudFiles->getInternalIterator()->rewind(); - - return $collCloudFiles; - } - - if ($partial && $this->collCloudFiles) { - foreach ($this->collCloudFiles as $obj) { - if ($obj->isNew()) { - $collCloudFiles[] = $obj; - } - } - } - - $this->collCloudFiles = $collCloudFiles; - $this->collCloudFilesPartial = false; - } - } - - return $this->collCloudFiles; - } - - /** - * Sets a collection of CloudFile objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $cloudFiles A Propel collection. - * @param PropelPDO $con Optional connection object - * @return CcFiles The current object (for fluent API support) - */ - public function setCloudFiles(PropelCollection $cloudFiles, PropelPDO $con = null) - { - $cloudFilesToDelete = $this->getCloudFiles(new Criteria(), $con)->diff($cloudFiles); - - - $this->cloudFilesScheduledForDeletion = $cloudFilesToDelete; - - foreach ($cloudFilesToDelete as $cloudFileRemoved) { - $cloudFileRemoved->setCcFiles(null); - } - - $this->collCloudFiles = null; - foreach ($cloudFiles as $cloudFile) { - $this->addCloudFile($cloudFile); - } - - $this->collCloudFiles = $cloudFiles; - $this->collCloudFilesPartial = false; - - return $this; - } - - /** - * Returns the number of related CloudFile objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CloudFile objects. - * @throws PropelException - */ - public function countCloudFiles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCloudFilesPartial && !$this->isNew(); - if (null === $this->collCloudFiles || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCloudFiles) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getCloudFiles()); - } - $query = CloudFileQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCcFiles($this) - ->count($con); - } - - return count($this->collCloudFiles); - } - - /** - * Method called to associate a CloudFile object to this object - * through the CloudFile foreign key attribute. - * - * @param CloudFile $l CloudFile - * @return CcFiles The current object (for fluent API support) - */ - public function addCloudFile(CloudFile $l) - { - if ($this->collCloudFiles === null) { - $this->initCloudFiles(); - $this->collCloudFilesPartial = true; - } - - if (!in_array($l, $this->collCloudFiles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCloudFile($l); - - if ($this->cloudFilesScheduledForDeletion and $this->cloudFilesScheduledForDeletion->contains($l)) { - $this->cloudFilesScheduledForDeletion->remove($this->cloudFilesScheduledForDeletion->search($l)); - } - } - - return $this; - } - - /** - * @param CloudFile $cloudFile The cloudFile object to add. - */ - protected function doAddCloudFile($cloudFile) - { - $this->collCloudFiles[]= $cloudFile; - $cloudFile->setCcFiles($this); - } - - /** - * @param CloudFile $cloudFile The cloudFile object to remove. - * @return CcFiles The current object (for fluent API support) - */ - public function removeCloudFile($cloudFile) - { - if ($this->getCloudFiles()->contains($cloudFile)) { - $this->collCloudFiles->remove($this->collCloudFiles->search($cloudFile)); - if (null === $this->cloudFilesScheduledForDeletion) { - $this->cloudFilesScheduledForDeletion = clone $this->collCloudFiles; - $this->cloudFilesScheduledForDeletion->clear(); - } - $this->cloudFilesScheduledForDeletion[]= $cloudFile; - $cloudFile->setCcFiles(null); - } - - return $this; - } - /** * Clears out the collCcShowInstancess collection * @@ -7358,11 +7082,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; - if ($this->collCloudFiles) { - foreach ($this->collCloudFiles as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collCcShowInstancess) { foreach ($this->collCcShowInstancess as $o) { $o->clearAllReferences($deep); @@ -7408,10 +7127,6 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collCloudFiles instanceof PropelCollection) { - $this->collCloudFiles->clearIterator(); - } - $this->collCloudFiles = null; if ($this->collCcShowInstancess instanceof PropelCollection) { $this->collCcShowInstancess->clearIterator(); } diff --git a/legacy/application/models/airtime/om/BaseCcFilesPeer.php b/legacy/application/models/airtime/om/BaseCcFilesPeer.php index ec6b1aa9c..0d42f6185 100644 --- a/legacy/application/models/airtime/om/BaseCcFilesPeer.php +++ b/legacy/application/models/airtime/om/BaseCcFilesPeer.php @@ -690,9 +690,6 @@ abstract class BaseCcFilesPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in CloudFilePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CloudFilePeer::clearInstancePool(); // Invalidate objects in CcShowInstancesPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CcShowInstancesPeer::clearInstancePool(); diff --git a/legacy/application/models/airtime/om/BaseCcFilesQuery.php b/legacy/application/models/airtime/om/BaseCcFilesQuery.php index 2b5c1bc76..2497a5e45 100644 --- a/legacy/application/models/airtime/om/BaseCcFilesQuery.php +++ b/legacy/application/models/airtime/om/BaseCcFilesQuery.php @@ -156,10 +156,6 @@ * @method CcFilesQuery rightJoinCcSubjsRelatedByDbEditedby($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcSubjsRelatedByDbEditedby relation * @method CcFilesQuery innerJoinCcSubjsRelatedByDbEditedby($relationAlias = null) Adds a INNER JOIN clause to the query using the CcSubjsRelatedByDbEditedby relation * - * @method CcFilesQuery leftJoinCloudFile($relationAlias = null) Adds a LEFT JOIN clause to the query using the CloudFile relation - * @method CcFilesQuery rightJoinCloudFile($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CloudFile relation - * @method CcFilesQuery innerJoinCloudFile($relationAlias = null) Adds a INNER JOIN clause to the query using the CloudFile relation - * * @method CcFilesQuery leftJoinCcShowInstances($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcShowInstances relation * @method CcFilesQuery rightJoinCcShowInstances($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcShowInstances relation * @method CcFilesQuery innerJoinCcShowInstances($relationAlias = null) Adds a INNER JOIN clause to the query using the CcShowInstances relation @@ -2839,80 +2835,6 @@ abstract class BaseCcFilesQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CcSubjsRelatedByDbEditedby', 'CcSubjsQuery'); } - /** - * Filter the query by a related CloudFile object - * - * @param CloudFile|PropelObjectCollection $cloudFile the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCloudFile($cloudFile, $comparison = null) - { - if ($cloudFile instanceof CloudFile) { - return $this - ->addUsingAlias(CcFilesPeer::ID, $cloudFile->getCcFileId(), $comparison); - } elseif ($cloudFile instanceof PropelObjectCollection) { - return $this - ->useCloudFileQuery() - ->filterByPrimaryKeys($cloudFile->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCloudFile() only accepts arguments of type CloudFile or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CloudFile relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function joinCloudFile($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CloudFile'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CloudFile'); - } - - return $this; - } - - /** - * Use the CloudFile relation CloudFile object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CloudFileQuery A secondary query class using the current class as primary query - */ - public function useCloudFileQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCloudFile($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CloudFile', 'CloudFileQuery'); - } - /** * Filter the query by a related CcShowInstances object * diff --git a/legacy/application/models/airtime/om/BaseCloudFile.php b/legacy/application/models/airtime/om/BaseCloudFile.php deleted file mode 100644 index 07f85730e..000000000 --- a/legacy/application/models/airtime/om/BaseCloudFile.php +++ /dev/null @@ -1,1071 +0,0 @@ -id; - } - - /** - * Get the [storage_backend] column value. - * - * @return string - */ - public function getStorageBackend() - { - - return $this->storage_backend; - } - - /** - * Get the [resource_id] column value. - * - * @return string - */ - public function getResourceId() - { - - return $this->resource_id; - } - - /** - * Get the [cc_file_id] column value. - * - * @return int - */ - public function getCcFileId() - { - - return $this->cc_file_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CloudFile The current object (for fluent API support) - */ - public function setDbId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CloudFilePeer::ID; - } - - - return $this; - } // setDbId() - - /** - * Set the value of [storage_backend] column. - * - * @param string $v new value - * @return CloudFile The current object (for fluent API support) - */ - public function setStorageBackend($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->storage_backend !== $v) { - $this->storage_backend = $v; - $this->modifiedColumns[] = CloudFilePeer::STORAGE_BACKEND; - } - - - return $this; - } // setStorageBackend() - - /** - * Set the value of [resource_id] column. - * - * @param string $v new value - * @return CloudFile The current object (for fluent API support) - */ - public function setResourceId($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->resource_id !== $v) { - $this->resource_id = $v; - $this->modifiedColumns[] = CloudFilePeer::RESOURCE_ID; - } - - - return $this; - } // setResourceId() - - /** - * Set the value of [cc_file_id] column. - * - * @param int $v new value - * @return CloudFile The current object (for fluent API support) - */ - public function setCcFileId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->cc_file_id !== $v) { - $this->cc_file_id = $v; - $this->modifiedColumns[] = CloudFilePeer::CC_FILE_ID; - } - - if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { - $this->aCcFiles = null; - } - - - return $this; - } // setCcFileId() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which resultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->storage_backend = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resource_id = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->cc_file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - - return $startcol + 4; // 4 = CloudFilePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CloudFile object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCcFiles !== null && $this->cc_file_id !== $this->aCcFiles->getDbId()) { - $this->aCcFiles = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CloudFilePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCcFiles = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CloudFileQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - } else { - $ret = $ret && $this->preUpdate($con); - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CloudFilePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { - $affectedRows += $this->aCcFiles->save($con); - } - $this->setCcFiles($this->aCcFiles); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CloudFilePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CloudFilePeer::ID . ')'); - } - if (null === $this->id) { - try { - $stmt = $con->query("SELECT nextval('cloud_file_id_seq')"); - $row = $stmt->fetch(PDO::FETCH_NUM); - $this->id = $row[0]; - } catch (Exception $e) { - throw new PropelException('Unable to get sequence id.', $e); - } - } - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CloudFilePeer::ID)) { - $modifiedColumns[':p' . $index++] = '"id"'; - } - if ($this->isColumnModified(CloudFilePeer::STORAGE_BACKEND)) { - $modifiedColumns[':p' . $index++] = '"storage_backend"'; - } - if ($this->isColumnModified(CloudFilePeer::RESOURCE_ID)) { - $modifiedColumns[':p' . $index++] = '"resource_id"'; - } - if ($this->isColumnModified(CloudFilePeer::CC_FILE_ID)) { - $modifiedColumns[':p' . $index++] = '"cc_file_id"'; - } - - $sql = sprintf( - 'INSERT INTO "cloud_file" (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '"id"': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '"storage_backend"': - $stmt->bindValue($identifier, $this->storage_backend, PDO::PARAM_STR); - break; - case '"resource_id"': - $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_STR); - break; - case '"cc_file_id"': - $stmt->bindValue($identifier, $this->cc_file_id, PDO::PARAM_INT); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggregated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - - if (($retval = CloudFilePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CloudFilePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getDbId(); - break; - case 1: - return $this->getStorageBackend(); - break; - case 2: - return $this->getResourceId(); - break; - case 3: - return $this->getCcFileId(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['CloudFile'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CloudFile'][$this->getPrimaryKey()] = true; - $keys = CloudFilePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getStorageBackend(), - $keys[2] => $this->getResourceId(), - $keys[3] => $this->getCcFileId(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CloudFilePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setDbId($value); - break; - case 1: - $this->setStorageBackend($value); - break; - case 2: - $this->setResourceId($value); - break; - case 3: - $this->setCcFileId($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CloudFilePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setStorageBackend($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCcFileId($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CloudFilePeer::DATABASE_NAME); - - if ($this->isColumnModified(CloudFilePeer::ID)) $criteria->add(CloudFilePeer::ID, $this->id); - if ($this->isColumnModified(CloudFilePeer::STORAGE_BACKEND)) $criteria->add(CloudFilePeer::STORAGE_BACKEND, $this->storage_backend); - if ($this->isColumnModified(CloudFilePeer::RESOURCE_ID)) $criteria->add(CloudFilePeer::RESOURCE_ID, $this->resource_id); - if ($this->isColumnModified(CloudFilePeer::CC_FILE_ID)) $criteria->add(CloudFilePeer::CC_FILE_ID, $this->cc_file_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CloudFilePeer::DATABASE_NAME); - $criteria->add(CloudFilePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getDbId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setDbId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getDbId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of CloudFile (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setStorageBackend($this->getStorageBackend()); - $copyObj->setResourceId($this->getResourceId()); - $copyObj->setCcFileId($this->getCcFileId()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CloudFile Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CloudFilePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CloudFilePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CloudFile The current object (for fluent API support) - * @throws PropelException - */ - public function setCcFiles(CcFiles $v = null) - { - if ($v === null) { - $this->setCcFileId(NULL); - } else { - $this->setCcFileId($v->getDbId()); - } - - $this->aCcFiles = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcFiles object, it will not be re-added. - if ($v !== null) { - $v->addCloudFile($this); - } - - - return $this; - } - - - /** - * Get the associated CcFiles object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CcFiles The associated CcFiles object. - * @throws PropelException - */ - public function getCcFiles(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCcFiles === null && ($this->cc_file_id !== null) && $doQuery) { - $this->aCcFiles = CcFilesQuery::create()->findPk($this->cc_file_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCcFiles->addCloudFiles($this); - */ - } - - return $this->aCcFiles; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->storage_backend = null; - $this->resource_id = null; - $this->cc_file_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCcFiles instanceof Persistent) { - $this->aCcFiles->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCcFiles = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CloudFilePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - /** - * Catches calls to virtual methods - */ - public function __call($name, $params) - { - - // delegate behavior - - if (is_callable(array('CcFiles', $name))) { - if (!$delegate = $this->getCcFiles()) { - $delegate = new CcFiles(); - $this->setCcFiles($delegate); - } - - return call_user_func_array(array($delegate, $name), $params); - } - - return parent::__call($name, $params); - } - -} diff --git a/legacy/application/models/airtime/om/BaseCloudFilePeer.php b/legacy/application/models/airtime/om/BaseCloudFilePeer.php deleted file mode 100644 index 40e4c486a..000000000 --- a/legacy/application/models/airtime/om/BaseCloudFilePeer.php +++ /dev/null @@ -1,1008 +0,0 @@ - array ('DbId', 'StorageBackend', 'ResourceId', 'CcFileId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'storageBackend', 'resourceId', 'ccFileId', ), - BasePeer::TYPE_COLNAME => array (CloudFilePeer::ID, CloudFilePeer::STORAGE_BACKEND, CloudFilePeer::RESOURCE_ID, CloudFilePeer::CC_FILE_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STORAGE_BACKEND', 'RESOURCE_ID', 'CC_FILE_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'storage_backend', 'resource_id', 'cc_file_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CloudFilePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'StorageBackend' => 1, 'ResourceId' => 2, 'CcFileId' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'storageBackend' => 1, 'resourceId' => 2, 'ccFileId' => 3, ), - BasePeer::TYPE_COLNAME => array (CloudFilePeer::ID => 0, CloudFilePeer::STORAGE_BACKEND => 1, CloudFilePeer::RESOURCE_ID => 2, CloudFilePeer::CC_FILE_ID => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STORAGE_BACKEND' => 1, 'RESOURCE_ID' => 2, 'CC_FILE_ID' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'storage_backend' => 1, 'resource_id' => 2, 'cc_file_id' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CloudFilePeer::getFieldNames($toType); - $key = isset(CloudFilePeer::$fieldKeys[$fromType][$name]) ? CloudFilePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CloudFilePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CloudFilePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CloudFilePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CloudFilePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CloudFilePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CloudFilePeer::ID); - $criteria->addSelectColumn(CloudFilePeer::STORAGE_BACKEND); - $criteria->addSelectColumn(CloudFilePeer::RESOURCE_ID); - $criteria->addSelectColumn(CloudFilePeer::CC_FILE_ID); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.storage_backend'); - $criteria->addSelectColumn($alias . '.resource_id'); - $criteria->addSelectColumn($alias . '.cc_file_id'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CloudFilePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CloudFilePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return CloudFile - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CloudFilePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CloudFilePeer::populateObjects(CloudFilePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CloudFilePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param CloudFile $obj A CloudFile object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getDbId(); - } // if key === null - CloudFilePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A CloudFile object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CloudFile) { - $key = (string) $value->getDbId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CloudFile object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CloudFilePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return CloudFile Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CloudFilePeer::$instances[$key])) { - return CloudFilePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) { - foreach (CloudFilePeer::$instances as $instance) { - $instance->clearAllReferences(true); - } - } - CloudFilePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to cloud_file - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CloudFilePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CloudFilePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CloudFilePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CloudFilePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (CloudFile object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CloudFilePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CloudFilePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CloudFilePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CloudFilePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CloudFilePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related CcFiles table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CloudFilePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CloudFilePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CloudFilePeer::CC_FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of CloudFile objects pre-filled with their CcFiles objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CloudFile objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - } - - CloudFilePeer::addSelectColumns($criteria); - $startcol = CloudFilePeer::NUM_HYDRATE_COLUMNS; - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CloudFilePeer::CC_FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CloudFilePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CloudFilePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CloudFilePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CloudFilePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcFilesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcFilesPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcFilesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CloudFile) to $obj2 (CcFiles) - $obj2->addCloudFile($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CloudFilePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CloudFilePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CloudFilePeer::CC_FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of CloudFile objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CloudFile objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - } - - CloudFilePeer::addSelectColumns($criteria); - $startcol2 = CloudFilePeer::NUM_HYDRATE_COLUMNS; - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CloudFilePeer::CC_FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CloudFilePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CloudFilePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CloudFilePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CloudFilePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcFiles rows - - $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcFilesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcFilesPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcFilesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CloudFile) to the collection in $obj2 (CcFiles) - $obj2->addCloudFile($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CloudFilePeer::DATABASE_NAME)->getTable(CloudFilePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCloudFilePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCloudFilePeer::TABLE_NAME)) { - $dbMap->addTableObject(new \CloudFileTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CloudFilePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CloudFile or Criteria object. - * - * @param mixed $values Criteria or CloudFile object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CloudFile object - } - - if ($criteria->containsKey(CloudFilePeer::ID) && $criteria->keyContainsValue(CloudFilePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CloudFilePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a CloudFile or Criteria object. - * - * @param mixed $values Criteria or CloudFile object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CloudFilePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CloudFilePeer::ID); - $value = $criteria->remove(CloudFilePeer::ID); - if ($value) { - $selectCriteria->add(CloudFilePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CloudFilePeer::TABLE_NAME); - } - - } else { // $values is CloudFile object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the cloud_file table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CloudFilePeer::TABLE_NAME, $con, CloudFilePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CloudFilePeer::clearInstancePool(); - CloudFilePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CloudFile or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CloudFile object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CloudFilePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CloudFile) { // it's a model object - // invalidate the cache for this single object - CloudFilePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CloudFilePeer::DATABASE_NAME); - $criteria->add(CloudFilePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CloudFilePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CloudFilePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CloudFilePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CloudFile object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param CloudFile $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CloudFilePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CloudFilePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CloudFilePeer::DATABASE_NAME, CloudFilePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CloudFile - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CloudFilePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CloudFilePeer::DATABASE_NAME); - $criteria->add(CloudFilePeer::ID, $pk); - - $v = CloudFilePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return CloudFile[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CloudFilePeer::DATABASE_NAME); - $criteria->add(CloudFilePeer::ID, $pks, Criteria::IN); - $objs = CloudFilePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCloudFilePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCloudFilePeer::buildTableMap(); diff --git a/legacy/application/models/airtime/om/BaseCloudFileQuery.php b/legacy/application/models/airtime/om/BaseCloudFileQuery.php deleted file mode 100644 index e57ff2797..000000000 --- a/legacy/application/models/airtime/om/BaseCloudFileQuery.php +++ /dev/null @@ -1,470 +0,0 @@ -mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return CloudFile|CloudFile[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CloudFilePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CloudFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CloudFile A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneByDbId($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CloudFile A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT "id", "storage_backend", "resource_id", "cc_file_id" FROM "cloud_file" WHERE "id" = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CloudFile(); - $obj->hydrate($row); - CloudFilePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CloudFile|CloudFile[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|CloudFile[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CloudFilePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CloudFilePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterByDbId(1234); // WHERE id = 1234 - * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 - * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $dbId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByDbId($dbId = null, $comparison = null) - { - if (is_array($dbId)) { - $useMinMax = false; - if (isset($dbId['min'])) { - $this->addUsingAlias(CloudFilePeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbId['max'])) { - $this->addUsingAlias(CloudFilePeer::ID, $dbId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CloudFilePeer::ID, $dbId, $comparison); - } - - /** - * Filter the query on the storage_backend column - * - * Example usage: - * - * $query->filterByStorageBackend('fooValue'); // WHERE storage_backend = 'fooValue' - * $query->filterByStorageBackend('%fooValue%'); // WHERE storage_backend LIKE '%fooValue%' - * - * - * @param string $storageBackend The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByStorageBackend($storageBackend = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($storageBackend)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $storageBackend)) { - $storageBackend = str_replace('*', '%', $storageBackend); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CloudFilePeer::STORAGE_BACKEND, $storageBackend, $comparison); - } - - /** - * Filter the query on the resource_id column - * - * Example usage: - * - * $query->filterByResourceId('fooValue'); // WHERE resource_id = 'fooValue' - * $query->filterByResourceId('%fooValue%'); // WHERE resource_id LIKE '%fooValue%' - * - * - * @param string $resourceId The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByResourceId($resourceId = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($resourceId)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $resourceId)) { - $resourceId = str_replace('*', '%', $resourceId); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CloudFilePeer::RESOURCE_ID, $resourceId, $comparison); - } - - /** - * Filter the query on the cc_file_id column - * - * Example usage: - * - * $query->filterByCcFileId(1234); // WHERE cc_file_id = 1234 - * $query->filterByCcFileId(array(12, 34)); // WHERE cc_file_id IN (12, 34) - * $query->filterByCcFileId(array('min' => 12)); // WHERE cc_file_id >= 12 - * $query->filterByCcFileId(array('max' => 12)); // WHERE cc_file_id <= 12 - * - * - * @see filterByCcFiles() - * - * @param mixed $ccFileId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function filterByCcFileId($ccFileId = null, $comparison = null) - { - if (is_array($ccFileId)) { - $useMinMax = false; - if (isset($ccFileId['min'])) { - $this->addUsingAlias(CloudFilePeer::CC_FILE_ID, $ccFileId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($ccFileId['max'])) { - $this->addUsingAlias(CloudFilePeer::CC_FILE_ID, $ccFileId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CloudFilePeer::CC_FILE_ID, $ccFileId, $comparison); - } - - /** - * Filter the query by a related CcFiles object - * - * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CloudFileQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - if ($ccFiles instanceof CcFiles) { - return $this - ->addUsingAlias(CloudFilePeer::CC_FILE_ID, $ccFiles->getDbId(), $comparison); - } elseif ($ccFiles instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CloudFilePeer::CC_FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); - } else { - throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CcFiles relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function joinCcFiles($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcFiles'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CcFiles'); - } - - return $this; - } - - /** - * Use the CcFiles relation CcFiles object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcFilesQuery A secondary query class using the current class as primary query - */ - public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcFiles($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery'); - } - - /** - * Exclude object from result - * - * @param CloudFile $cloudFile Object to remove from the list of results - * - * @return CloudFileQuery The current query, for fluid interface - */ - public function prune($cloudFile = null) - { - if ($cloudFile) { - $this->addUsingAlias(CloudFilePeer::ID, $cloudFile->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } - -} diff --git a/legacy/build/schema.xml b/legacy/build/schema.xml index 197038fca..c694f085d 100644 --- a/legacy/build/schema.xml +++ b/legacy/build/schema.xml @@ -96,19 +96,6 @@ - - - - - - - - - - - - -
diff --git a/legacy/tests/application/bootstrap.php b/legacy/tests/application/bootstrap.php index d1a4c9963..78d22af90 100644 --- a/legacy/tests/application/bootstrap.php +++ b/legacy/tests/application/bootstrap.php @@ -59,9 +59,6 @@ set_include_path(APPLICATION_PATH . '/../tests/application/testdata' . PATH_SEPA // helper functions set_include_path(APPLICATION_PATH . '/../tests/application/helpers' . PATH_SEPARATOR . get_include_path()); -// cloud storage files -set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path()); - require_once 'jooola/propel1/runtime/lib/Propel.php'; Propel::init('../application/configs/airtime-conf-production.php');