All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 99f4893e authored by Leigh B Stoller's avatar Leigh B Stoller

Add methods to get the dataset/lease project object.

parent c2ba461d
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
class Dataset class Dataset
{ {
var $dataset; var $dataset;
var $project;
# #
# Constructor by lookup on unique index. # Constructor by lookup on unique index.
...@@ -48,6 +49,8 @@ class Dataset ...@@ -48,6 +49,8 @@ class Dataset
return; return;
} }
$this->dataset = mysql_fetch_array($query_result); $this->dataset = mysql_fetch_array($query_result);
# Load lazily;
$this->project = null;
} }
# Hmm, how does one cause an error in a php constructor? # Hmm, how does one cause an error in a php constructor?
...@@ -218,6 +221,19 @@ class Dataset ...@@ -218,6 +221,19 @@ class Dataset
"where idx='$idx'"); "where idx='$idx'");
return $webtask; return $webtask;
} }
function Project() {
$pid = $this->pid();
if ($this->project)
return $this->project;
$this->project = Project::Lookup($pid);
if (! $this->project) {
TBERROR("Could not lookup project $pid!", 1);
}
return $this->project;
}
} }
?> ?>
...@@ -29,6 +29,7 @@ class Lease ...@@ -29,6 +29,7 @@ class Lease
{ {
var $lease; var $lease;
var $attributes; var $attributes;
var $project;
# #
# Constructor by lookup on unique index. # Constructor by lookup on unique index.
...@@ -73,6 +74,8 @@ class Lease ...@@ -73,6 +74,8 @@ class Lease
$attrs[$key] = $val; $attrs[$key] = $val;
} }
$this->attributes = $attrs; $this->attributes = $attrs;
# Load lazily;
$this->project = null;
} }
# Hmm, how does one cause an error in a php constructor? # Hmm, how does one cause an error in a php constructor?
...@@ -257,6 +260,19 @@ class Lease ...@@ -257,6 +260,19 @@ class Lease
function grantCommand($webtask) { function grantCommand($webtask) {
return "webgrantlease "; return "webgrantlease ";
} }
function Project() {
$pid = $this->pid();
if ($this->project)
return $this->project;
$this->project = Project::Lookup($pid);
if (! $this->project) {
TBERROR("Could not lookup project $pid!", 1);
}
return $this->project;
}
} }
# #
...@@ -265,6 +281,7 @@ class Lease ...@@ -265,6 +281,7 @@ class Lease
class ImageDataset class ImageDataset
{ {
var $image; var $image;
var $project;
# #
# Constructor by lookup on unique index. # Constructor by lookup on unique index.
...@@ -276,6 +293,8 @@ class ImageDataset ...@@ -276,6 +293,8 @@ class ImageDataset
return; return;
} }
$this->image = $image; $this->image = $image;
# Load lazily;
$this->project = null;
} }
# Hmm, how does one cause an error in a php constructor? # Hmm, how does one cause an error in a php constructor?
...@@ -320,6 +339,7 @@ class ImageDataset ...@@ -320,6 +339,7 @@ class ImageDataset
function locked() { return $this->image->locked(); } function locked() { return $this->image->locked(); }
function locker_pid() { return $this->image->locker_pid(); } function locker_pid() { return $this->image->locker_pid(); }
function islocal() { return 1; } function islocal() { return 1; }
function updated() { return $this->image->updated(); }
# #
# Convert to mebi. # Convert to mebi.
...@@ -451,6 +471,18 @@ class ImageDataset ...@@ -451,6 +471,18 @@ class ImageDataset
function grantCommand($webtask) { function grantCommand($webtask) {
return "webgrantimage "; return "webgrantimage ";
} }
function Project() {
$pid = $this->pid();
if ($this->project)
return $this->project;
$this->project = Project::Lookup($pid);
if (! $this->project) {
TBERROR("Could not lookup project $pid!", 1);
}
return $this->project;
}
} }
?> ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment