SDRService Class Reference

Provide input/ouput service for the SDR metadata database. More...

Inheritance diagram for SDRService:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 getProjects ()
 INSERT BRIEF DESCRIPTION HERE.
 getProjectsForResource ($cserdId)
 Get an array of SDRProjects (collections) bound to a resource.
 init ()
 Initialize the SDRService and create the database interface.

Static Public Member Functions

static addMetadataEditor ($prm, $projectName='CSERD', $cserdId=null, $versionId=null)
 Get the xml for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.
static approve ($version, $agent, $state=SDRVersion::STATE_LIVE)
 Make this metadata version the approved version for its resource Id.
static buildMetadataForm ($cserdId=null, $projectName, $versionId=null)
 Get the xml for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.
static buildMetadataFormObject ($cserdId=null, $projectName, $versionId=null)
 Get the XForms object for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.
static cserdIdExists ($id)
 Check to see whether a resource with a given ID exists in SDR.
static fieldsForProject ($project)
 INSERT BRIEF DESCRIPTION HERE.
static findResourcesByIdentifier ($identifier, $limit=null)
 INSERT BRIEF DESCRIPTION HERE.
static getCserdIdForURL ($url)
 Get the resource id (CSERD id) of an item given its URL.
static getDBI ()
 Get the DBI2 (database interface) object for SDR.
static getLastModifiedVersion ($identifier)
 Get the last SDRVersion for a cserdId.
static getMetadata ($identifier, $versionId=null)
 Get metadata for a given CSERD Id.
static getResource ($identifier)
 Get an SDRResource object based on a cserdId.
static getURLForCserdId ($id)
 Get the URL of an item given its resource id (CSERD id).
static getVersion ($identifier, $state=SDRVersion::STATE_LIVE)
 Get the live (or dev) SDRVersion for a cserdId.
static identifierToCserdId ($cserdId)
 Convert identifier (either URL or ID) to a resource Id. Return null if not found.
static identifierToURL ($cserdId)
 Convert identifier (either URL or ID) to a URL. Return null if not found.
static reject ($version, $agent)
 Reject this metadata version (move it to a rejected state).
static submit ($cserdId, $metadata, $agent, $comment, $projectName=null)
 Submit a new metadata version for a cserdId (id or URL). If the cserdId does not exist, create that resource now.
static updateReleaseFlag ($cserdId, $value, $agent)
 Update the release flag for a resource.
static URLExists ($url)
 Check to see whether a resource with a given URL exists in SDR.
static valuesForField ($field)
 INSERT BRIEF DESCRIPTION HERE.
static versionsForResource ($cserdId)
 INSERT BRIEF DESCRIPTION HERE.

Private Member Functions

 addProjectToResource ($project, $cserdId)
 INSERT BRIEF DESCRIPTION HERE.

Static Private Member Functions

static getCSERDProject ()
 INSERT BRIEF DESCRIPTION HERE.
static newResource ($cserdId, $url, $projects)
 INSERT BRIEF DESCRIPTION HERE.
static nextCserdId ()
 INSERT BRIEF DESCRIPTION HERE.
static resolveProjects ($projects=null)
 INSERT BRIEF DESCRIPTION HERE.
static resolveResource ($cserdId, $url, $projects)
 INSERT BRIEF DESCRIPTION HERE.


Detailed Description

Provide input/ouput service for the SDR metadata database.

Definition at line 6 of file SDRService.php5.


Member Function Documentation

static SDRService::addMetadataEditor ( prm,
projectName = 'CSERD',
cserdId = null,
versionId = null 
) [static]

Get the xml for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.

Parameters:
$prm [PageRender2]: The instance of PageRender where this editor will be displayed.
$cserdId [int]: The id for this item if it already exists.
$projectName [string]: The name of the project the form you want to build is for (different fields for different projects).
Returns:
cserdId on success, -1 on failure

Build the xform

Definition at line 862 of file SDRService.php5.

References SDRAgent::agentFromCSERDUser().

SDRService::addProjectToResource ( project,
cserdId 
) [private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Parameters:
$project [TYPE]: DESCRIPTION
$cserdId [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 337 of file SDRService.php5.

static SDRService::approve ( version,
agent,
state = SDRVersion::STATE_LIVE 
) [static]

Make this metadata version the approved version for its resource Id.

Parameters:
$version [SDRVersion]: The version to approve
$agent [SDRAgent]: The agent performing this action.
$state [string]: The state this version should become.
Returns:
[bool]: True on success, false on error.

For internal use only.

  • Start a DB transaction
  • Find any versions for this cserdId with state live and set them to history
  • Set this version's state to 'live'
  • Set the modified agent ID and modified timestamp
  • Commit object & transaction

Definition at line 404 of file SDRService.php5.

References SDRVersion::getList(), and SDRServiceCache::updateResourceVersionCaches().

static SDRService::buildMetadataForm ( cserdId = null,
projectName,
versionId = null 
) [static]

Get the xml for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.

Parameters:
$cserdId [int]: The id for this item if it already exists.
$projectName [string]: The name of the project the form you want to build is for (different fields for different projects).
Returns:
[String] a string of XML for an XForm containing all the appropriate metadata fields

Definition at line 948 of file SDRService.php5.

static SDRService::buildMetadataFormObject ( cserdId = null,
projectName,
versionId = null 
) [static]

Get the XForms object for an xform that conatins all the fields associated with the given project. If a value is passed in for CSERD id, the form will be prefilled with metadata from the existing resource.

Parameters:
$cserdId [int]: The id for this item if it already exists.
$projectName [string]: The name of the project the form you want to build is for (different fields for different projects).
Returns:
[Form] an XForm object containing all the appropriate metadata fields

Definition at line 972 of file SDRService.php5.

References getMetadata(), and SErrorManager::setError().

static SDRService::cserdIdExists ( id  )  [static]

Check to see whether a resource with a given ID exists in SDR.

Parameters:
$id [string]: The ResourceId (CSERD id) in question
Returns:
[bool]: True if the resource exists, false if not

Definition at line 747 of file SDRService.php5.

Referenced by SDR::resourceIdExists().

static SDRService::fieldsForProject ( project  )  [static]

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$project [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 650 of file SDRService.php5.

static SDRService::findResourcesByIdentifier ( identifier,
limit = null 
) [static]

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$identifier [TYPE]: DESCRIPTION
$limit [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 788 of file SDRService.php5.

static SDRService::getCserdIdForURL ( url  )  [static]

Get the resource id (CSERD id) of an item given its URL.

Parameters:
$url [string]: The URL of the item
Returns:
[mixed]: The resource id of the item if it exists; false if it is not found

Definition at line 709 of file SDRService.php5.

Referenced by TSDObject::getCWISID(), and SDR::getResourceIdForURL().

static SDRService::getCSERDProject (  )  [static, private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 203 of file SDRService.php5.

References SDRProject::getList().

static SDRService::getLastModifiedVersion ( identifier  )  [static]

Get the last SDRVersion for a cserdId.

Parameters:
$identifier [mixed]: Catalog ID number or URL
Returns:
[SDRVersion]: The current approved version object of the metadata (which includes its submission information), null if not found, or false on error

Definition at line 564 of file SDRService.php5.

References SDRVersion::getList().

static SDRService::getMetadata ( identifier,
versionId = null 
) [static]

Get metadata for a given CSERD Id.

Parameters:
$identifier [mixed]: Catalog ID number or URL
Returns:
[SDRMetadataObj]: The metadata; null if none is live/found

For internal use only.

  • Find the resource based on the cserd ID
  • Find the version of metadata for that resource with a 'live' state
    • if no live state version is found, return null
  • Build an SDRMetadataObj representing the metadata; return it

Definition at line 546 of file SDRService.php5.

Referenced by buildMetadataFormObject().

SDRService::getProjects (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 384 of file SDRService.php5.

References SDRProject::getList().

SDRService::getProjectsForResource ( cserdId  ) 

Get an array of SDRProjects (collections) bound to a resource.

Parameters:
$cserdId [mixed]: id number or URL for a resource
Returns:
[array]: An array of SDRProject objects

Definition at line 363 of file SDRService.php5.

References SDRResourceProject::getList().

static SDRService::getResource ( identifier  )  [static]

Get an SDRResource object based on a cserdId.

Parameters:
$identifier [mixed]: Catalog ID number or URL
Returns:
[SDRResource]: The resource for this ID, null if not found, or false on error.

Definition at line 627 of file SDRService.php5.

References SObject::hasError().

Referenced by SDRServiceCache::updateResourceCache(), and SDRServiceCache::updateResourceCacheHelper().

static SDRService::getURLForCserdId ( id  )  [static]

Get the URL of an item given its resource id (CSERD id).

Parameters:
$id [int]: The resource id of the item
Returns:
[mixed]: The URL of the item if it exists; false if it is not found

Definition at line 726 of file SDRService.php5.

Referenced by SDR::getURLForResourceId(), and identifierToURL().

static SDRService::getVersion ( identifier,
state = SDRVersion::STATE_LIVE 
) [static]

Get the live (or dev) SDRVersion for a cserdId.

Parameters:
$identifier [mixed]: Catalog ID number or URL
$state [mixed]: String or array containing possible states
Returns:
[SDRVersion]: The current approved version object of the metadata (which includes its submission information), null if not found, or false on error

Definition at line 589 of file SDRService.php5.

References SDRVersion::getList().

Referenced by SDRServiceCache::updateResourceCache().

static SDRService::identifierToCserdId ( cserdId  )  [static]

Convert identifier (either URL or ID) to a resource Id. Return null if not found.

Parameters:
$cserdId [mixed]: The URL or ID of the item
Returns:
[int]: The id number (cserdId) of the item

Definition at line 695 of file SDRService.php5.

static SDRService::newResource ( cserdId,
url,
projects 
) [static, private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Parameters:
$cserdId [TYPE]: DESCRIPTION
$url [TYPE]: DESCRIPTION
$projects [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 277 of file SDRService.php5.

static SDRService::nextCserdId (  )  [static, private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 830 of file SDRService.php5.

static SDRService::reject ( version,
agent 
) [static]

Reject this metadata version (move it to a rejected state).

Parameters:
$version [SDRVersion]: The version to reject
$agent [SDRAgent]: The agent performing this action.
Returns:
[bool]: True on success, false on error.

For internal use only.

  • Start a new DB transaction
  • Set this version's state to 'rejected'
  • Set the modified agent ID and modified timestamp
  • Commit

Definition at line 477 of file SDRService.php5.

References SDRServiceCache::updateResourceVersionCaches().

static SDRService::resolveProjects ( projects = null  )  [static, private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Parameters:
$projects [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 160 of file SDRService.php5.

References SDRProject::getList().

static SDRService::resolveResource ( cserdId,
url,
projects 
) [static, private]

INSERT BRIEF DESCRIPTION HERE.

For internal use only.

INSERT FULL DESCRIPTION HERE

Parameters:
$cserdId [TYPE]: DESCRIPTION
$url [TYPE]: DESCRIPTION
$projects [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 236 of file SDRService.php5.

static SDRService::submit ( cserdId,
metadata,
agent,
comment,
projectName = null 
) [static]

Submit a new metadata version for a cserdId (id or URL). If the cserdId does not exist, create that resource now.

Parameters:
$cserdId [mixed]: Catalog ID number or URL
$metadata [SDRMetadataObj]: The metadata record
$agent [SDRAgent]: The agent performing this action.
$comment [string]: A comment about why this metadata was submitted.
$project [string]: project to submit to (will become the primary project for new items)
Returns:
[SDRVersion]; The version created by this submission. False if error.

For internal use only.

  • Start a DB transaction
  • Check to see if the cserdId exists. If it does not exist, create it.
    • Make sure there is a URL for any newly created cserdIds. We don't want blank URLs.
  • Create an SDRVersion object
    • Set the created & modified agent ids to be the passed agent
    • Set the comment to be the passed comment
    • State should be pending by default
    • Commit it
  • Foreach attribute on the $metadata object
    • attempt to find a corresponding SDRField
    • attempt to find a corresponding SDRValue (look in one the specific value tables based on the field type)
    • if the field is not found, fail
    • if the value is not found, create and commit it (via the SDRValue object)
    • Create and commit an SDRVersionFieldValue link between the Field, Value, and Version
  • Commit the DB transaction

Definition at line 60 of file SDRService.php5.

References SDRVersion::createVersion(), SDRField::findOrAddField(), SDRProjectField::findOrAddProjectField(), SDRValue::findOrAddValue(), SDRProject::getList(), SDRServiceCache::updateResourceCacheHelper(), and SDRServiceCache::updateValueCache().

static SDRService::updateReleaseFlag ( cserdId,
value,
agent 
) [static]

Update the release flag for a resource.

Parameters:
$cserdId [mixed]: Catalog ID number or URL
$value [mixed]: 1/true (for release) or 0/false (for not released)
$agent [SDRAgent]: The agent performing the action
Returns:
[bool]: True on success; false on failure

Definition at line 505 of file SDRService.php5.

References SDRServiceCache::updateResourceCacheHelper().

static SDRService::URLExists ( url  )  [static]

Check to see whether a resource with a given URL exists in SDR.

Parameters:
$url [string]: The URL in question
Returns:
[bool]: True if the resource exists, false if not

Definition at line 769 of file SDRService.php5.

Referenced by SDR::URLExists().

static SDRService::valuesForField ( field  )  [static]

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$field [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 662 of file SDRService.php5.

static SDRService::versionsForResource ( cserdId  )  [static]

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$cserdId [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

Definition at line 674 of file SDRService.php5.


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:06:07 2010 for Common by  doxygen 1.5.6