|
From: <jas...@us...> - 2002-10-20 13:45:15
|
Update of /cvsroot/genex/genex-server/G2G/mason
In directory usw-pr-cvs1:/tmp/cvs-serv12920/G2G/mason
Added Files:
array-design.html.in bioassay.html.in data-loader.html.in
group-maint.html.in
Log Message:
new workspace Mason apps
--- NEW FILE: array-design.html.in ---
<h1 align="center"><% $name %></h1>
<form action="<% $action %>"
method="post" enctype="multipart/form-data">
<div align="center">
% if ($submit) {
<h2><% $data %></h2>
% } else {
<h2>Read Group</h2>
<p>Choose the <b>read group</b> that will be givne to create
the array design files that you load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Read Group</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"read_group",
array_ref=>\@groups &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Write Group</h2>
<p>Choose the <b>write group</b> that will be givne to create
the array design files that you load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Write Group</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"write_group",
array_ref=>\@groups &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Files to Load</h2>
<p>Choose the array files that you wish to load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Data Files</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-select.mason, name=>"data_files",
array_ref=>\@data_files &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<input type="submit" name="submit" value="Load Data" size="33">
<& comps/hiddenlist.mason, name=>'debug', value=>$debug &>
<hr noshade size=5>
% }
</div>
</form>
<%args>
$debug => 0
$submit => ''
$data_files => []
$read_group => ''
$write_group => ''
</%args>
<%attr>
action=>'%%GENEX_WORKSPACE_URL%%/array-design.html'
name=>'GeneX DB Array Design Loader Page'
path=>'%%GENEX_WORKSPACE_URL%%/array-design.html'
</%attr>
<%once>
use Bio::Genex;
use Bio::Genex::Connect;
use Bio::Genex::GroupSec;
use Bio::Genex::ArrayDesign;
</%once>
<%init>;
my $name = $m->current_comp->attr('name');
my $path = $m->current_comp->attr('path');
my $action = $m->current_comp->attr('action');
my $session = Bio::Genex::HTMLUtils::get_session_cookie($r);
my $dbh = Bio::Genex::Connect->new(USER=>$session->{username},
PASSWORD=>$session->{password},
DBNAME=>$session->{dbname},
);
$dbh->assert_table_defined('GroupSec');
$dbh->assert_table_defined('ArrayDesign');
my @groups;
my @data_files;
my $data = '';
if ($submit) {
my @files;
if (ref $data_files) {
@files = @{$data_files};
} else {
@files = ($data_files);
}
my $cmd = '%%GENEX_BIN_DIR%%/array-design-insert.pl';
my @args = ("--user=$session->{username}",
"--password=$session->{password}",
"--dbname=$session->{dbname}",
"--ro_group=$read_group",
"--rw_group=$write_group",
);
my @pks;
foreach my $file (@files) {
my @params = ("--file=$file");
my $command = join(' ', $cmd, @args, @params);
my $pk = `$command`;
die $! if $?;
push(@pks,$pk);
}
$data = "@pks";
} else {
my @gs_dbs = Bio::Genex::GroupSec->get_all_objects($dbh);
foreach my $gs_db (@gs_dbs) {
push(@groups,[$gs_db->name,$gs_db->name]);
}
my @files = glob('%%GENEX_UPLOAD_DIR%%/*.xml');
foreach my $name (@files) {
my $short_name = $name;
$short_name =~ s|.*/||;
push(@data_files,[$name,$short_name]);
}
}
</%init>
--- NEW FILE: bioassay.html.in ---
<h1 align="center"><% $name %></h1>
<form action="<% $action %>"
method="post" enctype="multipart/form-data">
<div align="center">
<h2>BioAssays in DB</h2>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>BioAssays</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-select.mason, name=>"bioassays",
array_ref=>\@bioassays &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<input type="submit" name="submit" value="Load Data" size="33">
<& comps/hiddenlist.mason, name=>'debug', value=>$debug &>
<hr noshade size=5>
</div>
</form>
<%args>
$debug => 0
$submit => ''
$data_files => []
$read_group => ''
$write_group => ''
</%args>
<%attr>
action=>'%%GENEX_WORKSPACE_URL%%/array-design.html'
name=>'GeneX DB Array Design Loader Page'
path=>'%%GENEX_WORKSPACE_URL%%/array-design.html'
</%attr>
<%once>
use Bio::Genex;
use Bio::Genex::Connect;
use Bio::Genex::GroupSec;
use Bio::Genex::MeasuredBioAssay;
</%once>
<%init>;
my $name = $m->current_comp->attr('name');
my $path = $m->current_comp->attr('path');
my $action = $m->current_comp->attr('action');
my $session = Bio::Genex::HTMLUtils::get_session_cookie($r);
my $dbh = Bio::Genex::Connect->new(USER=>$session->{username},
PASSWORD=>$session->{password},
DBNAME=>$session->{dbname},
);
$dbh->assert_table_defined('MeasuredBioAssay');
my @bioassays;
my @data_files;
my $data = '';
my @mba_dbs = Bio::Genex::MeasuredBioAssay->get_all_objects($dbh);
foreach my $mba_db (@mba_dbs) {
push(@bioassays,[$mba_db->mba_pk,$mba_db->name]);
}
</%init>
--- NEW FILE: data-loader.html.in ---
<h1 align="center"><% $name %></h1>
<form action="<% $action %>"
method="post" enctype="multipart/form-data">
<div align="center">
% if ($submit) {
<h2><% $data %></h2>
% } else {
<h2>Read Group</h2>
<p>Choose the <b>read group</b> that will be givne to create
the array design files that you load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Read Group</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"read_group",
array_ref=>\@groups &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Write Group</h2>
<p>Choose the <b>write group</b> that will be givne to create
the array design files that you load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Write Group</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"write_group",
array_ref=>\@groups &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Array Designs</h2>
<p>Choose the Array Design file from the DB from which the
arrays you wish to load have been created.</p>
<table bgcolor="#FFFFFF" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Array Designs</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"ad_pk",
array_ref=>\@array_designs &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Experiment Sets</h2>
<p>Choose the ExperimentSet to which you wish to add the
arrays.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Experiment Sets</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"es_pk",
array_ref=>\@experiment_sets &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Feature Extraction Software</h2>
<p>Choose the feature extraction software package that was
used to create the array files that you wish to load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Feature Extraction Software</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-drop-down.mason, name=>"fe_sw_pk",
array_ref=>\@feature_extractions &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<h2>Files to Load</h2>
<p>Choose the array files that you wish to load.</p>
<table bgcolor="#D8E4F7" border="1" cols="1">
<thead bgcolor="#FFD78F">
<tr>
<th>Data Files</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<& comps/query-select.mason, name=>"data_files",
array_ref=>\@data_files &>
</td>
</tr>
</tbody>
</table>
<hr noshade size=5>
<input type="submit" name="submit" value="Load Data" size="33">
<& comps/hiddenlist.mason, name=>'debug', value=>$debug &>
<hr noshade size=5>
% }
</div>
</form>
<%args>
$debug => 0
$submit => ''
$data_files => []
$read_group => ''
$write_group => ''
$es_pk => ''
$ad_pk => ''
$fe_sw_pk => ''
</%args>
<%attr>
action=>'%%GENEX_WORKSPACE_URL%%/data-loader.html'
name=>'GeneX DB Data Loader Page'
path=>'%%GENEX_WORKSPACE_URL%%/data-loader.html'
</%attr>
<%once>
use Bio::Genex;
use Bio::Genex::Connect;
use Bio::Genex::ArrayDesign;
use Bio::Genex::ExperimentSet;
use Bio::Genex::FeatureExtractionSoftware;
</%once>
<%init>
my $name = $m->current_comp->attr('name');
my $path = $m->current_comp->attr('path');
my $action = $m->current_comp->attr('action');
my $session = Bio::Genex::HTMLUtils::get_session_cookie($r);
my $dbh = Bio::Genex::Connect->new(USER=>$session->{username},
PASSWORD=>$session->{password},
DBNAME=>$session->{dbname},
);
$dbh->assert_table_defined('ExperimentSet');
$dbh->assert_table_defined('ArrayDesign');
$dbh->assert_table_defined('FeatureExtractionSoftware');
my @groups;
my @data_files;
my @feature_extractions;
my @experiment_sets;
my @array_designs;
my $data = '';
if ($submit) {
my @files;
if (ref $data_files) {
@files = @{$data_files};
} else {
@files = ($data_files);
}
my $cmd = '%%GENEX_BIN_DIR%%/mbad-insert.pl';
my @args = ("--user=$session->{username}",
"--password=$session->{password}",
"--dbname=$session->{dbname}",
"--ro_group=$read_group",
"--rw_group=$write_group",
"--es_pk=$es_pk",
"--ad_pk=$ad_pk",
# "--fe_sw_pk=$fe_sw_pk",
"--fe_sw_pk=3",
);
my @pks;
foreach my $file (@files) {
my @params = ($file);
my $command = join(' ', $cmd, @args, @params);
my $pk = `$command`;
die $! if $?;
push(@pks,$pk);
}
$data = "@pks";
} else {
my @gs_dbs = Bio::Genex::GroupSec->get_all_objects($dbh);
foreach my $gs_db (@gs_dbs) {
push(@groups,[$gs_db->name,$gs_db->name]);
}
my @ad_dbs = Bio::Genex::ArrayDesign->get_all_objects($dbh);
foreach my $ad_db (@ad_dbs) {
push(@array_designs,[$ad_db->ad_pk,$ad_db->name]);
}
my @exp_dbs = Bio::Genex::ExperimentSet->get_all_objects($dbh);
foreach my $exp_db (@exp_dbs) {
push(@experiment_sets,[$exp_db->es_pk,$exp_db->name]);
}
my @fe_dbs = Bio::Genex::FeatureExtractionSoftware->get_all_objects($dbh);
foreach my $fe_db (@fe_dbs) {
push(@feature_extractions,[$fe_db->fesw_pk,$fe_db->name . ':' . $fe_db->version]);
}
my @files = glob('%%GENEX_UPLOAD_DIR%%/*.txt');
foreach my $name (@files) {
my $short_name = $name;
$short_name =~ s|.*/||;
push(@data_files,[$name,$short_name]);
}
}
</%init>
--- NEW FILE: group-maint.html.in ---
% if (($response_page eq "NEW")) {
<center>
<h1>Group Member Assicoation Modification</h1>
<form action="<% $action %>"><br></br>
<br></br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; margin-left: auto; margin-right: auto;"
title="Select the group to work with"
summary="Choose Group">
<tbody>
<tr>
<td valign="top">Which Group would you like to add or
remove members?<br></br>
</td>
<td valign="top">
<& comps/query-drop-down.mason, name=>"groupname",
array_ref=>\@groupnames &>
<td valign="top">
</tr>
</tbody>
</table>
<br></br>
<br></br>
<input name="submitted" type="hidden" value="true"></input>
<input type="submit" name="submit" value="Modify This Group"></input>
<br></br>
</form>
</center>
% } else { # session is initialized
<center>
<h1>Group Member Assicoation Modification</h1>
<form action="<% $action %>"><br></br>
<input type="hidden" name="groupname" value="<% $groupname %>"></input>
<input type="hidden" name="modified" value=1></input>
% if ($response_page eq "DONE"){
<div style="text-align: center;">
<h1>Genex User-associations Updated</h1>
% }
<br></br>
% if ($response_page eq "BadGroup"){
<h3><font color="red">You chose an invalid group to
associate this user with</font>
</h3>
% }
<b>Check/Uncheck the Users you wish to be associated with/dissociated from this group.</b>
<table cellpadding="5" cellspacing="2" border="0"
style="text-align: left; margin-left: auto; margin-right: auto;"
title="Enter the following information for your group"
summary="information about the group">
<caption>
<br></br>
</caption>
<tbody>
<tr>
<td valign="top">Group <i><% $groupname %></i><br></br>
currently has the following members, shown here: <br></br>
</td>
<td valign="top">
<& comps/query-checkboxes.mason,
name=>"new_affiliations",
hash_ref=>\%affiliations &>
</td>
</tr>
</tbody>
</table>
<br></br>
<input name="submitted" type="hidden" value="true"></input>
<input type="submit" name="submit" value="Modify This Group"></input>
</div>
</form>
</center>
% }
<%attr>
action=>'%%GENEX_WORKSPACE_URL%%/user_group_add.html'
name=>'Associate Genex User With Group'
path=>'%%GENEX_WORKSPACE_URL%%/user_group_add.html'
</%attr>
<%args>
$groupname => ""
$submitted => ""
$modified => 0
$debug => 0
$new_affiliations => []
</%args>
<%once>;
use Bio::Genex;
use Bio::Genex::Connect;
use Bio::Genex::GroupSec;
use Bio::Genex::UserSec;
use Bio::Genex::GroupLink;
use Bio::Genex::HTMLUtils;
</%once>
<%init>;
my $name = $m->current_comp->attr('name');
my $path = $m->current_comp->attr('path');
my $action = $m->current_comp->attr('action');
my $session = Bio::Genex::HTMLUtils::get_session_cookie($r);
my $dbh = Bio::Genex::Connect->new(USER=>$session->{username},
PASSWORD=>$session->{password},
DBNAME=>$session->{dbname},
);
$dbh->assert_table_defined('UserSec');
$dbh->assert_table_defined('GroupSec');
$dbh->assert_table_defined('GroupLink');
my $response_page;
my %affiliations;
# get list of all valid users and groups for various purposes
my @groupnames; # holds the names of all groups that exist
my %users;
my %groups;
my @allgroups = Bio::Genex::GroupSec->get_all_objects($dbh); #returns objects
my %my_groups = map {$_->groupname=>1}
Bio::Genex::GroupLink->get_all_objects($dbh,
column=>'username',
value=>$session->{username}
);
foreach (@allgroups){
push(@groupnames, [$_->name,$_->name])
if $my_groups{$_->rw_groupname};
$groups{$_->name} = $_;
}
my $entered;
if ($submitted ne "true") { # this is a fresh load of the page
$response_page="NEW";
} elsif ($groupname && !(grep { $_->[0] eq $groupname } @groupnames)) {
$response_page="BadGroup";
} else {
my @old_users = map {$_->username}
Bio::Genex::GroupLink->get_all_objects($dbh,
column=>'groupname',
value=>$groupname
);
my @allusers = Bio::Genex::UserSec->get_all_objects($dbh);
%users = map {$_->username=>$_} @allusers;
%affiliations = map {$_->username=>0} @allusers;
foreach my $groupname (@old_users) {
$affiliations{$groupname}++;
}
if ($modified) {
# Bug in mason, a single checkbox comes back as a string
# not as an array ref with a single string
my %new_affiliations;
if (ref $new_affiliations) {
%new_affiliations = map {$_=>1} @{$new_affiliations};
} else {
%new_affiliations = ($new_affiliations=>1);
}
foreach my $username (keys %new_affiliations){
next if $affiliations{$username};
$entered = "yes";
my $gl_db = Bio::Genex::GroupLink->new(groupname_obj=>$groups{$groupname},
username_obj=>$users{$username},
);
$gl_db->insert_db($dbh);
}
foreach my $username (@old_users){
next if exists $new_affiliations{$username};
$dbh->do("DELETE FROM GroupLink
WHERE username='$username' AND groupname='$groupname'");
$affiliations{$username} = 0;
}
$response_page="DONE";
}
}
</%init>
|