OME::Tasks::ProjectManager - manage user's projects
use OME::Tasks::ProjectManager;
my $projectManager = new OME::Tasks::ProjectManager($session);
The OME::Tasks::ProjectManager provides a list of methods to manage user's projects
To retrieve an OME::Tasks::ProjectManager to use for managing the project, the user must log in to OME. This is done via the OME::SessionManager class. Logging in via OME::SessionManager yields an OME::Session object.
my $manager = OME::SessionManager->new();
my $session = $manager->createSession($username,$password);
my $projectManager = new OME::Tasks::ProjectManager;
The following methods are available to a "ProjectManager."
$projectManager->add($dataset->id(), $project->id());
$projectManager->add($dataset->id());
Adds the "Dataset" by reference of its ID to the "Project" by reference of its ID.
Note: The project ID is optional and if it is not defined the dataset is added to the current, active project ($session->Project());
$projectManager->addDatasets([1,2,3], $project->id());
$projectManager->addDatasets([1,2,3]);
Adds the "Datasets" provided by the array reference by reference of their ID to the "Project" by reference of its ID.
Note: The project ID is optional and if it is not defined the dataset is added to the current, active project ($session->Project());
$projectManager->change(
"My new description",
"My new name",
$project->id(),
);
$projectManager->change(
"My new description",
"My new name",
);
Changes the "Project's" name and/or description by reference of its ID (or the current, active project if unspecified).
$projectManager->create( {
name => 'My New Project',
description => 'A great new idea!',
owner_id => $session->User()->ID(),
});
Create a new project and update the OME session.
Note: This method is purely a macro for OME::Factory->newObject().
$projectManager->delete($project->id());
Delete a project and update OME session if the project is the current project.
Note: If the user doesn't have another project, the current active project and dataset are set to undefined. Otherwise the first arbitrary project and/or dataset are set to active.
my $p_count = $projectManager->getAllProjectCount();
Gets a count of all the projects in the database.
my @projects = $projectManager->getAllProjects();
Get all the projects in the database.
my $p_count = $projectManager->getAllProjectCount();
my @projects1 = $projectManager->getAllProjectsLimit($p_count / 2);
my @projects2 = $projectManager->getAllProjectsLimit(
$p_count / 2, $p_count - 100
);
Retrieves a list of projects from the database using the LIMIT and OFFSET parameters to the query.
Note: The fields are ordered by their ID.
my $d_count1 = $projectManager->getDatasetCount($project1);
my $d_count2 = $projectManager->getDatasetCount($project2->id());
Get the dataset count of a given project.
Note: This method allows you to pass either a project object or a project ID.
my $user_p_count = $projectManager->getUserProjectCount();
my $other_p_count = $projectManager->getUserProjects(
$other_experimenter
);
Get a count of all the projects owned by a given user.
Note: By default this method uses the Session's experimenter as a filter.
my @user_projects = $projectManager->getUserProjects();
my @other_user_projects = $projectManager->getUserProjects(
$other_experimenter
);
Get all the projects owned by a given user.
Note: By default this method uses the Session's experimenter as a filter.
my $p_count = $projectManager->getAllProjectCount();
my @projects1 = $projectManager->getUserProjectsLimit($p_count / 2);
my @projects2 = $projectManager->getUserProjectsLimit(
$p_count / 2, $p_count - 100
);
my @projects3 = $projectManager->getUserProjectsLimit(
$experimenter, $p_count / 2, $p_count - 100
);
Retrieves a list of projects from the database using the LIMIT and OFFSET parameters to the query for a given user.
Note: By default this method uses the Session's experimenter as a filter. In addition, the fields are ordered by ID.
if ($projectManager->nameExists("A really good project name") {
...
} else {
...
}
Check if a given project name already exists in the database.
Returns successful (1) or unsuccessful (0) in matching.
my $projects = $projectManager->listMatching();
foreach (@$projects) {
...
}
Returns a list of all the project objects in the database.
my $user_projects = $projectManager->listMatching(
$session->User()->id(),
);
foreach (@$user_projects) {
...
}
Returns a list of all the project objects in the database owned by the specified user ID.
my $related_projects = $projectManager->listMatching(
$session->User()->id(),
[ $ome_group_a->id(), $ome_group_b->id(), $ome_group_c->id() ],
);
foreach (@$related_projects) {
...
}
Returns a list of all the project objects in the database owned by the specified user ID or owned by one of the groups specified.
my $project_a = $projectManager->load( 1 );
my $project_b = $projectManager->load( 2 );
Returns a project object.
$projectManager->removeDatasets({
$project1->id() => [1, 5, 10, 9],
$project2->id() => [$dataset1, $dataset2],
});
Project removal method which accepts a hash reference keyed by project ID and containing an array reference of dataset objects or dataset ID's. Results a session->commitTransaction.
Returns 1 on success and undef on failure, this is an *all or nothing method* (either every remove is successful or the entire task fails)
$projectManager->switch(1, 1);
Switches the current active project. If the boolean switch is active other checking will be done on the session in order to preserve dataset integrity.
JMarie Burel (jburel@dundee.ac.uk)