return $self->get_pathid('');
}
+# change the current directory
sub ch_dir
{
my ($self, $pathid) = @_;
$self->{cwdid} = $pathid;
}
+# do a cd ..
sub up_dir
{
my ($self) = @_ ;
}
}
+# return the current PWD
sub pwd
{
my ($self) = @_;
return $self->get_path($self->{cwdid});
}
+# get the Path from a PathId
sub get_path
{
my ($self, $pathid) = @_;
$self->debug("Call with pathid = $pathid");
- my $query =
- "SELECT Path FROM Path WHERE PathId IN (?)";
-
+ my $query = "SELECT Path FROM Path WHERE PathId = ?";
my $sth = $self->dbh_prepare($query);
$sth->execute($pathid);
my $result = $sth->fetchrow_arrayref();
return $result->[0];
}
+# we are working with these jobids
sub set_curjobids
{
my ($self, @jobids) = @_;
# $self->update_brestore_table(@jobids);
}
+# get the PathId from a Path
sub get_pathid
{
my ($self, $dir) = @_;
"SELECT PathId FROM Path WHERE Path = ?";
my $sth = $self->dbh_prepare($query);
$sth->execute($dir);
- my $result = $sth->fetchall_arrayref();
+ my $result = $sth->fetchrow_arrayref();
$sth->finish();
- return join(',', map { $_->[0] } @$result);
+ return $result->[0];
}
sub set_limits
$self->{offset} = $offset || 0;
}
+# fill brestore_xxx tables for speedup
sub update_cache
{
my ($self) = @_;
$self->{dbh}->begin_work();
+ # getting all Jobs to "cache"
my $query = "
SELECT JobId from Job
- WHERE JobId NOT IN (SELECT JobId FROM brestore_knownjobid) AND JobStatus IN ('T', 'f', 'A') ORDER BY JobId";
+ WHERE JobId NOT IN (SELECT JobId FROM brestore_knownjobid)
+ AND Type IN ('B') AND JobStatus IN ('T', 'f', 'A')
+ ORDER BY JobId";
my $jobs = $self->dbh_selectall_arrayref($query);
$self->update_brestore_table(map { $_->[0] } @$jobs);
+ $self->{dbh}->commit();
+ $self->{dbh}->begin_work(); # we can break here
+
print STDERR "Cleaning path visibility\n";
my $nb = $self->dbh_do("
}
}
+# compute the parent directorie
sub parent_dir
{
my ($path) = @_;
}
}
+# list all files in a directory, accross curjobids
sub ls_files
{
my ($self) = @_;
return undef unless ($self->{curjobids});
my $inclause = $self->{curjobids};
- my $inlistpath = $self->{cwdid};
+ my $inpath = $self->{cwdid};
my $query =
"SELECT File.FilenameId, listfiles.id, listfiles.Name, File.LStat, File.JobId
FROM File, Filename
WHERE File.FilenameId = Filename.FilenameId
AND Filename.Name != ''
- AND File.PathId IN ($inlistpath)
+ AND File.PathId = $inpath
AND File.JobId IN ($inclause)
GROUP BY Filename.Name
ORDER BY Filename.Name) AS listfiles
return $result;
}
-
+# list all directories in a directory, accross curjobids
# return ($dirid,$dir_basename,$lstat,$jobid)
sub ls_dirs
{
}
}
+# get jobids that the current user can view (ACL)
sub get_jobids
{
my ($self, @jobid) = @_;
my $args = $bvfs->get_form('pathid', 'filenameid', 'fileid', 'qdate',
'limit', 'offset', 'client');
-if (CGI::param('batch')) {
+if ($action eq 'batch') {
$bvfs->update_cache();
exit 0;
}
-if ($action eq 'list_client') {
- print CGI::header('application/x-javascript');
+# All these functions are returning JSON compatible data
+# for javascript parsing
- my $filter = $bvfs->get_client_filter();
- my $q = "SELECT Name FROM Client $filter";
- my $ret = $bvfs->dbh_selectall_arrayref($q);
+if ($action eq 'list_client') { # list all client [ ['c1'],['c2']..]
+ print CGI::header('application/x-javascript');
- print "[";
- print join(',', map { "['$_->[0]']" } @$ret);
- print "]\n";
- exit 0;
+ my $filter = $bvfs->get_client_filter();
+ my $q = "SELECT Name FROM Client $filter";
+ my $ret = $bvfs->dbh_selectall_arrayref($q);
-} elsif ($action eq 'list_job') {
+ print "[";
+ print join(',', map { "['$_->[0]']" } @$ret);
+ print "]\n";
+ exit 0;
+
+} elsif ($action eq 'list_job') { # list jobs for a client [[jobid,endtime,'desc'],..]
print CGI::header('application/x-javascript');
-
+
my $filter = $bvfs->get_client_filter();
my $query = "
- SELECT Job.EndTime, FileSet.FileSet, Job.Level, Job.JobStatus, Job.JobId
+ SELECT Job.JobId,Job.EndTime, FileSet.FileSet, Job.Level, Job.JobStatus
FROM Job JOIN FileSet USING (FileSetId) JOIN Client USING (ClientId) $filter
WHERE Client.Name = '$args->{client}'
AND Job.Type = 'B'
print "[";
print join(',', map {
- "[$_->[4], '$_->[0]', '$_->[0] $_->[1] $_->[2] ($_->[3]) $_->[4]']"
+ "[$_->[0], '$_->[1]', '$_->[1] $_->[2] $_->[3] ($_->[4]) $_->[0]']"
} @$result);
print "]\n";
exit 0;
}
+# get jobid param and apply user filter
my @jobid = $bvfs->get_jobids(grep { /^\d+(,\d+)*$/ } CGI::param('jobid'));
+# get jobid from date arg
if (!scalar(@jobid) and $args->{qdate} and $args->{client}) {
@jobid = $bvfs->set_job_ids_for_date($args->{client}, $args->{qdate});
}
exit 0;
}
-if (CGI::param('init')) {
+if (CGI::param('init')) { # used when choosing a job
$bvfs->update_brestore_table(@jobid);
}
print "[";
my $dirs = $bvfs->ls_dirs();
- # return ($dirid,$dir_basename,$lstat,$jobid)
+ # return ($dirid,$dir_basename,$lstat,$jobid)
print join(',',
map { "{ 'jobid': '$bvfs->{curjobids}', 'id': '$_->[0]', 'text': '$_->[1]', 'cls':'folder'}" }
my $jobid = join(',', @jobid);
my $fileid = join(',', grep { /^\d+$/ } CGI::param('fileid'));
- # TODO: use client filter
my $q="
SELECT DISTINCT VolumeName, InChanger
FROM File,