OME::Tasks::DatasetManager - manage user's datasets
use OME::Tasks::DatasetManager;
my $datasetManager=new OME::Tasks::DatasetManager;
The OME::Tasks::DatasetManager provides a list of methods to manage user's dataset
To retrieve an OME::Tasks::DatasetManager to use for managing the dataset, 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 $datasetManager = new OME::Tasks::DatasetManager;
The following methods are available to a "DatasetManager."
$datasetManager->addImages([1,2,5,9], $dataset->id());
$datasetManager->addImages( [1,2,5,9] );
Add images to the current dataset.
Note: The method performs its work on the active dataset ($session->dataset()) if the dataset ID is not specified.
if ($d_manager->belong_or_not($project->id(), $dataset->id())) {
...
} else {
...
}
Check if a given dataset belongs to a given project. Returns successful (1) or unsuccessful (undef) based on the link's existance.
$datasetManager->change(
'New description',
'New Name',
$dataset->id(),
);
$datasetManager->change(
'New description',
'New Name',
);
Change a given dataset's metadata.
Note: The method performs its work on the active dataset ($session->dataset()) if the dataset ID is not specified.
my $dataset_a = $datasetManager->create(
'Great images!',
'These are really nice images!',
$session->User->id(),
$session->User->group()->id(),
$my_project->id(),
[1,4,7,9],
);
my $dataset_b = $datasetManager->create(
'Great images again!',
'These are some more really nice images!',
$session->User->id(),
$session->User->group()->id(),
undef,
[2,5,7,9],
);
Create a new dataset with the given parameters and return the dataset object.
Note: The method adds the dataset to the active project ($session->project()) if the project ID is not specified. You can create an imageless dataset using an empty arrayref.
$datasetManager->delete($dataset->id());
Delete a dataset and update OME session if the dataset is the current dataset. If the user doesn't have another dataset, set the current dataset to undefined, otherwise set the first (arbitrary in the dataset list) dataset to the current dataset.
my $d_count = $datasetManager->getAllDatasetCount();
Gets a count of all the datasets in the database.
my @datasets = $datasetManager->getAllDatasets();
Get all the datasets in the database.
my $i_count1 = $datasetManager->getImageCount($dataset1);
my $i_count2 = $datasetManager->getImageCount($dataset2->id());
Get the image count of a given dataset.
Note: This method allows you to pass either a dataset object or a dataset ID.
my @user_datasets = $datasetManager->getUserDatasets();
my @other_user_datasets = $datasetManager->getUserDatasets(
$other_experimenter
);
Get all the datasets related to an experimenter.
Note: The method uses the Session's experimenter as a filter if none is specified.
my $d_count = $datasetManager->getUserDatasetCount();
my $other_d_count = $datasetManager->getUserDatasetCount(
$other_experimenter
);
Gets a count of all the datasets owner by a user.
Note: The method uses the Session's experimenter as a filter if none is specified.
if ($datasetManager->nameExists('My unique name')) {
...
} else {
...
}
Returns successful (1) or unsuccessful (0) based on the dataset name being in the DB.
my @available_images = $datasetManager->imageNotIn ($datset->id());
Return the images which are not in a given dataset. An optional group ID prefilter is available for those who want to restrict the search to images which are not in the current dataset and are owned by a group to which the user belongs.
my @available_images = $datasetManager->imageNotIn( [
$group_a->id(),
$group_b->id(),
$session->User()->group(),
],
$special_dataset->id(),
);
Note: If the dataset is not specified the current ($session->dataset()) dataset is used in the search.
my $my_images = $datasetManager->listMatching($user->id());
my $our_images = $datasetManager->listMatching(
$session->User()->id(),
[ $group_a->id(), $group_b->id() ],
);
Returns an array reference to the images owned by a given user and/or owned by a set of given groups.
my $dataset = $datasetManager->load(1);
Return a dataset object via its ID.
use constant LOCK => 't';
use constant UNLOCK => 'f';
$projectManager->lockUnlock($dataset->id(), LOCK);
$projectManager->lockUnlock($dataset->id(), UNLOCK);
Lock/Unlock a dataset.
my $new_dataset = $datasetManager->newDataset(
'My new dataset.',
'This is my new dataset.',
$session->User->id(),
$session->User()->group()->id(),
$session->project()->id(),
);
Creates and returns a new dataset.
my $our_other_projects = $datasetManager->notBelongToProject(
[$group_a->id(), $group_b->id()],
$project->id()
);
my $our_other_projects = $datasetManager->notBelongToProject();
Returns a hash reference to the datasets not used by the specified project.
$datasetManager->remove( {
$dataset_a->id() => [$project_y->id(), $project_z->id()],
$dataset_b->id() => [$project_x->id()],
);
Remove dataset(s) from project(s).
Undocumented.
$datasetManager->switch($new_dataset->id());
Switch the current active dataset.
OME::Tasks::DatasetManager->deleteCurrentAnnotation( $dataset );
This tries to get an annotation from getCurrentAnnotation()
If it gets one that belongs to the current user, it will mark it invalid.
my $datasetAnnotation = OME::Tasks::DatasetManager->
getCurrentAnnotation( $dataset );
This will look for the most recent DatasetAnnotation created by the current user that is marked Valid. Failing to that, it will look for the most recent DatasetAnnotation created by anyone that is marked Valid.
If no Valid DatasetAnnotation are found, an undef will be returned.
my $datasetAnnotation = OME::Tasks::DatasetManager->
writeAnnotation( $dataset, $data_hash );
This will write a new DatasetAnnotation attribute. The data_hash should follow the format for factory NewObject calls. e.g. { Content => $content, ... } If the Content is identical to the current annotation, a new DatasetAnnotation attribute will not be created, and the current annotation will be returned.
If this user has a current annotation on this dataset, the other annotation will be marked invalid. If another user has a current annotation on this dataset, the other user's annotation will be left alone.
Note, this method does NOT commit the db transaction.
JMarie Burel (jburel@dundee.ac.uk)