CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- File List
- File Members

ClassificationFactory.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: ClassificationFactory.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2004-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
14 class ClassificationFactory extends ItemFactory {
15
16 # ---- PUBLIC INTERFACE --------------------------------------------------
17
22 function ClassificationFactory($FieldId = NULL)
23 {
24 # set up item factory base class
25 $this->ItemFactory("Classification", "Classifications",
26 "ClassificationId", "ClassificationName", FALSE,
27 ($FieldId ? "FieldId = ".intval($FieldId) : NULL));
28 }
29
35 function GetChildIds($ClassId)
36 {
37 static $DB;
38
39 # retrieve IDs of all children
40 if (!isset($DB)) { $DB = new Database(); }
41 $DB->Query("SELECT ClassificationId FROM Classifications"
42 ." WHERE ParentId = ".intval($ClassId));
43 $ChildIds = $DB->FetchColumn("ClassificationId");
44
45 # for each child
46 $Ids = $ChildIds;
47 foreach ($Ids as $Id)
48 {
49 # retrieve IDs of any children of child
50 $ChildChildIds = $this->GetChildIds($Id);
51
52 # add retrieved IDs to child ID list
53 $ChildIds = array_merge($ChildIds, $ChildChildIds);
54 }
55
56 # return child ID list to caller
57 return $ChildIds;
58 }
59
63 public function RecalculateAllResourceCounts()
64 {
65 # queue a task to recalculate the resource counts for each
66 # classification
67 foreach ($this->GetItemIds() as $Id)
68 {
69 $GLOBALS["AF"]->QueueUniqueTask(
70 array(__CLASS__, "RecalculateResourceCount"),
71 array(intval($Id)),
72 ApplicationFramework::PRIORITY_BACKGROUND,
73 "Recalculate the resource counts for a classification");
74 }
75 }
76
83 public static function RecalculateResourceCount($Id)
84 {
85 $Classification = new Classification($Id);
86
87 # only recalculate the counts if the classification is valid
88 if ($Classification->Status() == Classification::CLASSSTAT_OK)
89 {
90 $Classification->RecalcResourceCount();
91 }
92 }
93
94 # ---- PRIVATE INTERFACE -------------------------------------------------
95
96 }
ClassificationFactory\RecalculateResourceCount
static RecalculateResourceCount($Id)
Callback to recalculate the resource count for a single classification by its ID. ...
Definition: ClassificationFactory.php:83
Database
SQL database abstraction object with smart query caching.
Definition: Axis--Database.php:22
ClassificationFactory\GetChildIds
GetChildIds($ClassId)
Get IDs of all children of specified classification.
Definition: ClassificationFactory.php:35
PHP
PHP
Definition: OAIClient.php:39
ItemFactory\$DB
$DB
Definition: ItemFactory.php:1070
ClassificationFactory\RecalculateAllResourceCounts
RecalculateAllResourceCounts()
Queue tasks to recalculate resource counts for all classifications.
Definition: ClassificationFactory.php:63
ClassificationFactory\ClassificationFactory
ClassificationFactory($FieldId=NULL)
Class constructor.
Definition: ClassificationFactory.php:22
Classification\CLASSSTAT_OK
const CLASSSTAT_OK
Status code indicating operation completed successfully.
Definition: Classification.php:18
ItemFactory
Common factory class for item manipulation.
Definition: ItemFactory.php:17
ClassificationFactory
Factory for producing and manipulating Classification objects.
Definition: ClassificationFactory.php:14
Classification
Metadata type representing hierarchical (&quot;Tree&quot;) controlled vocabulary values.
Definition: Classification.php:13
ItemFactory\GetItemIds
GetItemIds($Condition=NULL, $IncludeTempItems=FALSE, $SortField=NULL, $SortAscending=TRUE)
Return array of item IDs.
Definition: ItemFactory.php:350
ItemFactory\ItemFactory
ItemFactory($ItemClassName, $ItemTableName, $ItemIdFieldName, $ItemNameFieldName=NULL, $OrderOpsAllowed=FALSE, $SqlCondition=NULL)
Class constructor.
Definition: ItemFactory.php:36
ApplicationFramework\PRIORITY_BACKGROUND
const PRIORITY_BACKGROUND
Lowest priority.
Definition: ApplicationFramework.php:2046