NAME

OME::Tasks::ProjectManager - manage user's projects

Back to Top


SYNOPSIS

        use OME::Tasks::ProjectManager;
        my $projectManager = new OME::Tasks::ProjectManager($session);

Back to Top


DESCRIPTION

The OME::Tasks::ProjectManager provides a list of methods to manage user's projects

Back to Top


OBTAINING A PROJECTMANAGER

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;

Back to Top


METHODS (ALPHABETICAL ORDER)

The following methods are available to a "ProjectManager."

add ($datasetID,$projectID)

        $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());

addDatasets ($array_ref,$projectID)

        $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());

change ($description,$name,$projectID)

        $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).

create ($hash_ref)

        $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().

delete ($id)

        $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.

getAllProjectCount ()

        my $p_count = $projectManager->getAllProjectCount();
        Gets a count of all the projects in the database.

getAllProjects ()

        my @projects = $projectManager->getAllProjects();
        Get all the projects in the database.

getAllProjectsLimit ($limit, $offset)

        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.

getDatasetCount ($project/$project_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.

getUserProjectCount ($experimenter)

        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.

getUserProjects ($experimenter)

        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.

getUserProjectsLimit ([$experimenter], $limit, $offset)

        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.

nameExists ($name)

        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.

listMatching ($userID,$array_ref)

        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.

load ($projectID)

        my $project_a = $projectManager->load( 1 );
        my $project_b = $projectManager->load( 2 );

Returns a project object.

removeDatasets ($hash_ref)

        $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)

switch ($id,$bool)

        $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.

Back to Top


AUTHOR

JMarie Burel (jburel@dundee.ac.uk)

Back to Top


SEE ALSO

OME::Project, OME::DBObject, OME::Factory, OME::SetDB,

Back to Top