PHP Class PKPSubmissionFileDAO, pkp-lib

Inheritance: extends PKPFileDAO
Show file Open project: pkp/pkp-lib Class Usage Examples

Public Properties

Property Type Description
$_delegates a private list of delegates that provide operations for different SubmissionFile implementations.

Public Methods

Method Description
__construct ( ) Constructor
assignRevisionToReviewRound ( $fileId, $revision, $reviewRound ) Assign file to a review round.
baseQueryForFileSelection ( ) : string Return the basic join over all file class tables.
changePubId ( $fileId, $pubIdType, $pubId )
deleteAllPubIds ( $contextId, $pubIdType )
deleteAllRevisionsByAssocId ( $assocType, $assocId, $fileStage = null ) : integer Retrieve all files associated to a certain object.
deleteAllRevisionsById ( $fileId, $fileStage = null, $submissionId = null ) : integer Delete all revisions of a file, optionally restricted to a given file stage.
deleteAllRevisionsByReviewRound ( $reviewRoundId ) Remove all file assignements for the given review round.
deleteAllRevisionsBySubmissionId ( $submissionId, $fileStage = null ) : integer Delete all revisions of all files of a submission, optionally restricted to a given file stage.
deleteLatestRevisionById ( $fileId, $fileStage = null, $submissionId = null ) : integer Delete the latest revision of a submission file by id.
deletePubId ( $fileId, $pubIdType )
deleteReviewRoundAssignment ( $submissionId, $stageId, $fileId, $revision ) Remove a specific file assignment from a review round.
deleteRevision ( $submissionFile ) : integer Delete a specific revision of a submission file.
deleteRevisionById ( $fileId, $revision, $fileStage = null, $submissionId = null ) : integer Delete a specific revision of a submission file by id.
fromRow ( $row, $fileImplementation ) : SubmissionFile Internal function to return a SubmissionFile object from a row.
getAllFileStages ( ) : array Return all file stages.
getAllRevisions ( $fileId, $fileStage = null, $submissionId = null, $rangeInfo = null ) : array | null Retrieve all revisions of a submission file.
getAllRevisionsByAssocId ( $assocType, $assocId, $fileStage = null, $rangeInfo = null ) : array | null Retrieve all files associated to a certain object.
getByBestId ( $fileId, $submissionId ) : SubmissionFile | null Retrieve file by public ID or, failing that, internal file ID and revision; public ID takes precedence.
getByPubId ( $pubIdType, $pubId, $submissionId = null, $contextId = null ) : SubmissionFile | null Retrieve file by public file ID
getBySubmissionId ( $submissionId, $rangeInfo = null ) : array Retrieve all submission files & revisions for a submission.
getDelegateClassNames ( ) : array Return the available delegates mapped by lower case class names.
getFileIdsBySetting ( $settingName, $settingValue, $submissionId = null, $contextId = null ) : array Find file IDs by querying file settings.
getGenreCategoryMapping ( ) : array Return the mapping of genre categories to the lower case class name of file implementation.
getLatestRevision ( $fileId, $fileStage = null, $submissionId = null ) : SubmissionFile | null Retrieve the latest revision of a file.
getLatestRevisionNumber ( $fileId ) : integer | null Retrieve the current revision number for a file.
getLatestRevisions ( $submissionId, $fileStage = null, $rangeInfo = null ) : array | null Retrieve a list of current revisions.
getLatestRevisionsByAssocId ( $assocType, $assocId, $submissionId = null, $fileStage = null, $rangeInfo = null ) : array | null Retrieve the latest revision of all files associated to a certain object.
getLatestRevisionsByReviewRound ( $reviewRound, $fileStage = null ) : array Get the latest revisions of all files that are in the specified review round.
getRevision ( $fileId, $revision, $fileStage = null, $submissionId = null ) : SubmissionFile | null Retrieve a specific revision of a file.
getRevisionsByReviewRound ( $reviewRound, $fileStage = null, $uploaderUserId = null, $uploaderUserGroupId = null ) : array | null Get all file revisions assigned to the given review round.
insertObject ( $submissionFile, $sourceFile, $isUpload = false ) : SubmissionFile Insert a new SubmissionFile.
newDataObjectByGenreId ( $genreId ) : SubmissionFile Construct a new data object corresponding to this DAO.
pubIdExists ( $pubIdType, $pubId, $fileId, $contextId )
setAsLatestRevision ( $revisedFileId, $newFileId, $submissionId, $fileStage ) : SubmissionFile Set the latest revision of a file as the latest revision of another file.
transferOwnership ( $oldUserId, $newUserId ) Transfer the ownership of the submission files of one user to another.
updateObject ( $updatedFile, $previousFileId = null, $previousRevision = null ) : SubmissionFile Update an existing submission file.

Private Methods

Method Description
_buildFileSelectionFilter ( $submissionId, $fileStage, $fileId, $revision, $assocType, $assocId, $stageId, $uploaderUserId, $uploaderUserGroupId, $reviewRoundId ) : array Build an SQL where clause to select submissions based on the given filter information.
_castToDatabase ( $submissionFile ) : SubmissionFile Make sure that a file's implementation corresponds to the way it is saved in the database.
_castToGenre ( $submissionFile ) : SubmissionFile Make sure that the genre of the file and its file implementation are compatible.
_checkAndReturnRevision ( $revisions ) : SubmissionFile Check whether the given array contains exactly zero or one revisions and return it.
_deleteInternally ( $submissionId = null, $fileStage = null, $fileId = null, $revision = null, $assocType = null, $assocId = null, $stageId = null, $uploaderUserId = null, $uploaderUserGroupId = null, $latestOnly = false ) : boolean | integer Private method to delete submission file revisions according to the given filters.
_getDaoDelegate ( $fileImplementation ) : SubmissionFileDAODelegate Return the requested SubmissionFileDAODelegate.
_getDaoDelegateForGenreId ( $genreId ) : SubmissionFileDAODelegate Instantiates an approprate SubmissionFileDAODelegate based on the given genre identifier.
_getDaoDelegateForObject ( $object ) : SubmissionFileDAODelegate Instantiates an appropriate SubmissionFileDAODelegate based on the given SubmissionFile.
_getFileImplementationForGenreId ( $genreId ) : string Map a genre to the corresponding file implementation.
_getInternally ( $submissionId = null, $fileStage = null, $fileId = null, $revision = null, $assocType = null, $assocId = null, $stageId = null, $uploaderUserId = null, $uploaderUserGroupId = null, $reviewRoundId = null, $latestOnly = false, $rangeInfo = null ) : array Private method to retrieve submission file revisions according to the given filters.

Method Details

__construct() public method

Constructor
public __construct ( )

assignRevisionToReviewRound() public method

Assign file to a review round.
public assignRevisionToReviewRound ( $fileId, $revision, $reviewRound )
$fileId int The file to be assigned.
$revision int The revision of the file to be assigned.
$reviewRound ReviewRound

baseQueryForFileSelection() public method

Return the basic join over all file class tables.

changePubId() public method

public changePubId ( $fileId, $pubIdType, $pubId )

deleteAllPubIds() public method

public deleteAllPubIds ( $contextId, $pubIdType )

deleteAllRevisionsByAssocId() public method

Retrieve all files associated to a certain object.
public deleteAllRevisionsByAssocId ( $assocType, $assocId, $fileStage = null ) : integer
$assocType int ASSOC_TYPE_...
$assocId int ID corresponding to specified assocType.
$fileStage int (optional) further restricts the selection to a given file stage.
return integer the number of deleted file revisions.

deleteAllRevisionsById() public method

Delete all revisions of a file, optionally restricted to a given file stage.
public deleteAllRevisionsById ( $fileId, $fileStage = null, $submissionId = null ) : integer
$fileId int File ID.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int (optional) for validation purposes only
return integer the number of deleted file revisions

deleteAllRevisionsByReviewRound() public method

Remove all file assignements for the given review round.
public deleteAllRevisionsByReviewRound ( $reviewRoundId )
$reviewRoundId int The review round ID.

deleteAllRevisionsBySubmissionId() public method

Delete all revisions of all files of a submission, optionally restricted to a given file stage.
public deleteAllRevisionsBySubmissionId ( $submissionId, $fileStage = null ) : integer
$submissionId int Submission ID.
$fileStage int (optional) further restricts the selection to a given file stage.
return integer the number of deleted file revisions

deleteLatestRevisionById() public method

Delete the latest revision of a submission file by id.
public deleteLatestRevisionById ( $fileId, $fileStage = null, $submissionId = null ) : integer
$fileId int File ID.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int (optional) for validation purposes only
return integer the number of deleted file revisions

deletePubId() public method

public deletePubId ( $fileId, $pubIdType )

deleteReviewRoundAssignment() public method

Remove a specific file assignment from a review round.
public deleteReviewRoundAssignment ( $submissionId, $stageId, $fileId, $revision )
$submissionId int The submission id of the file
$stageId int The review round type.
$fileId int The file id.
$revision int The file revision.

deleteRevision() public method

Delete a specific revision of a submission file.
public deleteRevision ( $submissionFile ) : integer
$submissionFile SubmissionFile
return integer the number of deleted file revisions

deleteRevisionById() public method

Delete a specific revision of a submission file by id.
public deleteRevisionById ( $fileId, $revision, $fileStage = null, $submissionId = null ) : integer
$fileId int File ID.
$revision int File revision number.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int (optional) for validation purposes only
return integer the number of deleted file revisions

fromRow() public method

Internal function to return a SubmissionFile object from a row.
public fromRow ( $row, $fileImplementation ) : SubmissionFile
$row array
$fileImplementation string
return SubmissionFile

getAllFileStages() public method

Return all file stages.
public getAllFileStages ( ) : array
return array

getAllRevisions() public method

Retrieve all revisions of a submission file.
public getAllRevisions ( $fileId, $fileStage = null, $submissionId = null, $rangeInfo = null ) : array | null
$fileId int File ID.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int Optional submission ID for validation purposes only
$rangeInfo DBResultRange (optional)
return array | null a list of SubmissionFile instances

getAllRevisionsByAssocId() public method

Retrieve all files associated to a certain object.
public getAllRevisionsByAssocId ( $assocType, $assocId, $fileStage = null, $rangeInfo = null ) : array | null
$assocType int ASSOC_TYPE_...
$assocId int ID corresponding to specified assocType.
$fileStage int (optional) further restricts the selection to a given file stage.
$rangeInfo DBResultRange (optional)
return array | null a list of SubmissionFile instances

getByBestId() public method

Retrieve file by public ID or, failing that, internal file ID and revision; public ID takes precedence.
public getByBestId ( $fileId, $submissionId ) : SubmissionFile | null
$fileId string Either public ID or fileId-revision
$submissionId int
return SubmissionFile | null

getByPubId() public method

Retrieve file by public file ID
public getByPubId ( $pubIdType, $pubId, $submissionId = null, $contextId = null ) : SubmissionFile | null
$pubIdType string One of the NLM pub-id-type values or 'other::something' if not part of the official NLM list (see ).
$pubId string
$submissionId int optional
$contextId int optional
return SubmissionFile | null

getBySubmissionId() public method

Retrieve all submission files & revisions for a submission.
public getBySubmissionId ( $submissionId, $rangeInfo = null ) : array
$submissionId int Submission ID.
$rangeInfo DBResultRange (optional)
return array a list of SubmissionFile instances

getDelegateClassNames() public method

Return the available delegates mapped by lower case class names.
public getDelegateClassNames ( ) : array
return array a list of fully qualified class names indexed by the lower case class name of the file implementation they serve. NB: Be careful to order class names such that they can be called in the given order to delete files without offending foreign key constraints, i.e. place the sub-classes before the super-classes.

getFileIdsBySetting() public method

Find file IDs by querying file settings.
public getFileIdsBySetting ( $settingName, $settingValue, $submissionId = null, $contextId = null ) : array
$settingName string
$settingValue mixed
$submissionId int optional
$contextId int optional
return array The file IDs identified by setting.

getGenreCategoryMapping() public method

Return the mapping of genre categories to the lower case class name of file implementation.
public getGenreCategoryMapping ( ) : array
return array a list of lower case class names of file implementations.

getLatestRevision() public method

Retrieve the latest revision of a file.
public getLatestRevision ( $fileId, $fileStage = null, $submissionId = null ) : SubmissionFile | null
$fileId int File ID.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int (optional) for validation purposes only
return SubmissionFile | null

getLatestRevisionNumber() public method

Retrieve the current revision number for a file.
public getLatestRevisionNumber ( $fileId ) : integer | null
$fileId int File ID.
return integer | null

getLatestRevisions() public method

Retrieve a list of current revisions.
public getLatestRevisions ( $submissionId, $fileStage = null, $rangeInfo = null ) : array | null
$submissionId int Submission ID.
$fileStage int (optional) further restricts the selection to a given file stage.
$rangeInfo DBResultRange (optional)
return array | null a list of SubmissionFile instances

getLatestRevisionsByAssocId() public method

Retrieve the latest revision of all files associated to a certain object.
public getLatestRevisionsByAssocId ( $assocType, $assocId, $submissionId = null, $fileStage = null, $rangeInfo = null ) : array | null
$assocType int ASSOC_TYPE_...
$assocId int ID corresponding to specified assocType.
$fileStage int (optional) further restricts the selection to a given file stage.
$rangeInfo DBResultRange (optional)
return array | null a list of SubmissionFile instances

getLatestRevisionsByReviewRound() public method

Get the latest revisions of all files that are in the specified review round.
public getLatestRevisionsByReviewRound ( $reviewRound, $fileStage = null ) : array
$reviewRound ReviewRound
$fileStage int SUBMISSION_FILE_... (Optional)
return array A list of SubmissionFiles.

getRevision() public method

Retrieve a specific revision of a file.
public getRevision ( $fileId, $revision, $fileStage = null, $submissionId = null ) : SubmissionFile | null
$fileId int File ID.
$revision int File revision number.
$fileStage int (optional) further restricts the selection to a given file stage.
$submissionId int|null (optional) for validation purposes only
return SubmissionFile | null

getRevisionsByReviewRound() public method

Get all file revisions assigned to the given review round.
public getRevisionsByReviewRound ( $reviewRound, $fileStage = null, $uploaderUserId = null, $uploaderUserGroupId = null ) : array | null
$reviewRound ReviewRound
$fileStage int SUBMISSION_FILE_...
$uploaderUserId int Uploader's user ID
$uploaderUserGroupId int Uploader's user group ID
return array | null A list of SubmissionFiles.

insertObject() public method

Insert a new SubmissionFile.
public insertObject ( $submissionFile, $sourceFile, $isUpload = false ) : SubmissionFile
$submissionFile SubmissionFile
$sourceFile string The place where the physical file resides right now or the file name in the case of an upload. The file will be copied to its canonical target location.
$isUpload boolean set to true if the file has just been uploaded.
return SubmissionFile

newDataObjectByGenreId() public method

Construct a new data object corresponding to this DAO.
public newDataObjectByGenreId ( $genreId ) : SubmissionFile
$genreId integer The genre is required to identify the right file implementation.
return SubmissionFile

pubIdExists() public method

public pubIdExists ( $pubIdType, $pubId, $fileId, $contextId )

setAsLatestRevision() public method

Set the latest revision of a file as the latest revision of another file.
public setAsLatestRevision ( $revisedFileId, $newFileId, $submissionId, $fileStage ) : SubmissionFile
$revisedFileId integer the revised file
$newFileId integer the file that will become the latest revision of the revised file.
$submissionId integer the submission id the two files must belong to.
$fileStage integer the file stage the two files must belong to.
return SubmissionFile the new revision or null if something went wrong.

transferOwnership() public method

Transfer the ownership of the submission files of one user to another.
public transferOwnership ( $oldUserId, $newUserId )
$oldUserId int User ID of old user (to be deleted)
$newUserId int User ID of new user (to receive assets belonging to old user)

updateObject() public method

NB: We implement a delete + insert strategy to deal with various casting problems (e.g. file implementation/genre may change, file path may change, etc.).
public updateObject ( $updatedFile, $previousFileId = null, $previousRevision = null ) : SubmissionFile
$updatedFile SubmissionFile
$previousFileId integer The file id before the file was changed. Must only be given if the file id changed so that the previous file can be identified.
$previousRevision integer The revision before the file was changed. Must only be given if the revision changed so that the previous file can be identified.
return SubmissionFile The updated file. This file may be of a different file implementation than the file passed into the method if the genre of the file didn't fit its implementation.

Property Details

$_delegates public property

a private list of delegates that provide operations for different SubmissionFile implementations.
public $_delegates