00001 <?php
00002
00012 class SDRResourceCache extends ModelBase {
00014 public static $ATTRIBUTES = array(
00015 'cserdId' => array(
00016 'nullable' => false,
00017 'commit' => SModel2::COMMIT_CHANGED,
00018 'type' => 'int'
00019 ),
00020 'releaseFlag' => array(
00021 'nullable' => false,
00022 'type' => 'int',
00023 'default' => 0
00024 ),
00025 'Url' => array(
00026 'nullable' => false,
00027 'type' => 'string'
00028 ),
00029 'AverageReviewRating' => array(
00030 'type' => 'float',
00031 'default' => null
00032 ),
00033 'ShodorProject' => array(
00034 'type' => 'string',
00035 'default' => null
00036 ),
00037 'Hierarchy' => array(
00038 'type' => 'int',
00039 'default' => null
00040 ),
00041 'liveVersionId' => array(
00042 'commit' => SModel2::COMMIT_FIRST,
00043 'type' => 'int',
00044 'default' => null,
00045 'foreign' => array('table' => 'SDRVersionCache', 'on' => 'versionId', 'object' => 'liveVersion')
00046 ),
00047 'devVersionId' => array(
00048 'commit' => SModel2::COMMIT_FIRST,
00049 'type' => 'int',
00050 'default' => null,
00051 'foreign' => array('table' => 'SDRVersionCache', 'on' => 'versionId', 'object' => 'devVersion')
00052 ),
00053 'pendingVersionId' => array(
00054 'commit' => SModel2::COMMIT_FIRST,
00055 'type' => 'int',
00056 'default' => null,
00057 'foreign' => array('table' => 'SDRVersionCache', 'on' => 'versionId', 'object' => 'pendingVersion')
00058 ),
00059 'created' => array(
00060 'nullable' => false,
00061 'commit' => SModel2::COMMIT_CHANGED,
00062 'type' => 'time',
00063 'default' => ''
00064 ),
00065 'liveVersion' => array(
00066 'commit' => SModel2::COMMIT_FOREIGN,
00067 'type' => 'SDRVersionCache'
00068 ),
00069 'devVersion' => array(
00070 'commit' => SModel2::COMMIT_FOREIGN,
00071 'type' => 'SDRVersionCache'
00072 ),
00073 'pendingVersion' => array(
00074 'commit' => SModel2::COMMIT_FOREIGN,
00075 'type' => 'SDRVersionCache'
00076 )
00077 );
00078
00088 public function __construct($constraints = null, $multi = false) {
00089 parent::__construct();
00090
00091 $this->registerAttributes(self::$ATTRIBUTES);
00092 $this->registerTableName('SDRResourceCache');
00093 $this->registerPrimaryKey('cserdId');
00094
00095 if($constraints !== null)
00096 $this->populate($constraints, $multi);
00097 }
00098
00108 public static function getAttributesStatic() {
00109 return self::$ATTRIBUTES;
00110 }
00111
00117 public static function getTableNameStatic() {
00118 return 'SDRResourceCache';
00119 }
00120
00132 public static function retrieve($constraints = array(), $checkOnly = false) {
00133 $list = self::getList($constraints, array(1), array(), $checkOnly);
00134 if(!$list || count($list) == 0)
00135 return $checkOnly ? false : null;
00136 else if($checkOnly)
00137 return $list > 0;
00138 else
00139 return $list[0];
00140 }
00141
00150 public static function exists($constraints = array()) {
00151 return self::retrieve($constraints, true);
00152 }
00153
00166 public static function retrieveMulti($constraints = array(), $checkOnly = false, $depth = 1) {
00167 $list = self::getListMulti($constraints, array(1), array(), $checkOnly, $depth);
00168 if(!$list || count($list) == 0)
00169 return $checkOnly ? false : null;
00170 else if($checkOnly)
00171 return $list > 0;
00172 else
00173 return $list[0];
00174 }
00175
00184 public static function existsMulti($constraints = array()) {
00185 return self::retrieveMulti($constraints, true);
00186 }
00187
00201 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00202 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'SDRResourceCache', true);
00203 }
00204
00220 public static function getListMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00221 return parent::getListBaseMulti(self::getDBI(), $constraints, $limit, $order, $count,
00222 'SDRResourceCache', true, $depth);
00223 }
00224
00225
00234 public function getParentLiveVersion() {
00235 return SDRVersionCache::retrieve(array('versionId' => $this->liveVersionId));
00236 }
00237
00247 public function getParentLiveVersionMulti($depth = 1) {
00248 return SDRVersionCache::retrieveMulti(array('Base.versionId' => $this->liveVersionId), false, $depth);
00249 }
00250
00259 public function getParentDevVersion() {
00260 return SDRVersionCache::retrieve(array('versionId' => $this->devVersionId));
00261 }
00262
00272 public function getParentDevVersionMulti($depth = 1) {
00273 return SDRVersionCache::retrieveMulti(array('Base.versionId' => $this->devVersionId), false, $depth);
00274 }
00275
00284 public function getParentPendingVersion() {
00285 return SDRVersionCache::retrieve(array('versionId' => $this->pendingVersionId));
00286 }
00287
00297 public function getParentPendingVersionMulti($depth = 1) {
00298 return SDRVersionCache::retrieveMulti(array('Base.versionId' => $this->pendingVersionId), false, $depth);
00299 }
00300 }
00301
00302 ?>