domain::Task Class Reference

Class to represent a task. More...

#include <task.h>

Inheritance diagram for domain::Task:
Inheritance graph
[legend]
Collaboration diagram for domain::Task:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void setField (const QString &id, const QVariant &value)
QVariant field (const QString &id) const
QMap< QString, QVariant > fields () const
QList< const Reservation * > reservations () const
unsigned nbActiveReservations (ResourceType *type) const
QList< const Invitation * > invitations () const
unsigned nbAcceptedInvitations (UserType *type) const
const Scheduleschedule () const
QString stateString () const
TaskState::SettableState state () const
const Projectproject () const
const Useruser () const
QDateTime earliestEndTime () const
QList< const Task * > subTasks () const
QList< const Task * > superTasks () const
QList< const Task * > allSuperTasks () const
void setState (TaskState::SettableState state)
StateChangeData canHaveAsState (TaskState::SettableState state) const
void setProject (Project *project)
void addSubTask (Task *dependency)
void removeSubTask (Task *dependency)
bool dependsOn (const Task *other) const
bool isAvailable () const
bool requirementsAreFulfilled () const
bool canBeSuccessful () const
TaskTypetaskType () const
void notify ()

Private Member Functions

 Task (TaskType *type, User *user, const Schedule &schedule, TaskState::SettableState state=TaskState::Unfinished, const QList< Task * > &subTasks=QList< Task * >(), const QList< InvitationData > &invitations=QList< InvitationData >(), const QList< ReservationData > &reservations=QList< ReservationData >())
virtual ~Task ()
 Task (const Task &other)
Taskoperator= (const Task &other)
void setState (TaskState *state)
void _setField (const QString &id, const QVariant &value)
void _addReservation (Reservation *reservation)
void _setProject (Project *project)
void _addSubTask (Task *dependency)
QList< Task * > superTasks ()
void addInvitation (Invitation *invitation)
void removeInvitation (Invitation *invitation)
void addReservation (Reservation *reservation)
void removeReservation (Reservation *reservation)
QList< StorableData * > dependentData () const

Private Attributes

TaskPrivate *const d

Friends

class TaskManagerData
class TaskState
class Invitation
class Reservation
class TaskPrivate

Detailed Description

Class to represent a task.

Task objects are responsible for the links with their sub tasks, their project and their user. This class provides the means to update those links as well as changing other information about existing task objects.

A Task can also send out invitations to users and make Resource reservations. These invitations or reservations cannot be changed by this task once they have been created. A Task object has the responibility to create and delete the links with Invitation and Reservation when needed.

Most setters in this class are dependent of the state of this task.

Constructors and destructor are private, creating and deleting tasks is handled by TaskManagerData.

See also:
Invitation
Reservation
TaskState
TaskManagerData::createTask

Definition at line 57 of file task.h.


Constructor & Destructor Documentation

domain::Task::Task ( TaskType type,
domain::User user,
const Schedule schedule,
TaskState::SettableState  state = TaskState::Unfinished,
const QList< Task * > &  subTasks = QList<Task*>(),
const QList< InvitationData > &  invitations = QList<InvitationData>(),
const QList< ReservationData > &  reservations = QList<ReservationData>() 
) [private]

Creates a new task with the given properties.

Parameters:
user The user to be assigned to the task.
schedule The schedule for the task.
state The state for the task.
subTasks All tasks this task should depend on.
invitations The invitations for this task.
reservations The reservations for this task.
Exceptions:
StringException If any of the business rules are violated for the given parameters.

Definition at line 60 of file task.cpp.

domain::Task::~Task (  )  [private, virtual]

Removes the links with this tasks project, user and sub/super tasks. It will also delete all reservations and invitations associated with this task.

Definition at line 111 of file task.cpp.


Member Function Documentation

void domain::Task::addInvitation ( Invitation invitation  )  [private]

Adds the given invitations to this tasks list of invitations.

Exceptions:
InvalidDataException 
  • If the user of the given invitation is the owner of this task
  • If the user of the given invitation has already been invited for this task.
  • If this task does not have a requirement for the user type of the user of the given invitation.
  • If the number of "active" invitations for users with the type of the user of the given invitations exceeds the maximum of the requirement. An invitations is active if its state is either accepted or pending.

Definition at line 411 of file task.cpp.

Here is the call graph for this function:

void domain::Task::addReservation ( Reservation reservation  )  [private]

Adds the given reservation to this tasks list of reservation (if the current state allows so).

Exceptions:
InvalidDataException 
  • If this task does not have a requirement for a resource type of the resource of the given reservation.
  • If the number of reservations made for resources of the type of the resource of the given reservation exceeds the maximum number of reservations of the resource requirement.
  • If the duration of the reservation is short than the duration of this task.
  • If there is no suitable overlap with all of this tasks existing reservations.

Definition at line 162 of file task.cpp.

void domain::Task::addSubTask ( Task dependency  ) 

Adds a task as dependency on which this task depends.

Parameters:
dependency The task to set
Exceptions:
InvalidDataException 
  • If a dependency loop is detected
  • If a violation of Business Rule 1 is detected

Definition at line 386 of file task.cpp.

QList< const Task * > domain::Task::allSuperTasks (  )  const

Returns a list of tasks that (in)directly depend on this task.

Definition at line 563 of file task.cpp.

bool domain::Task::canBeSuccessful (  )  const

Indicates whether this task could possibly have a successful state.

See also:
TaskType::canBeSuccessful(const Task*) const

Definition at line 492 of file task.cpp.

StateChangeData domain::Task::canHaveAsState ( TaskState::SettableState  state  )  const

Checks if the state can be set to the given state.

Returns:
Information on the change that may or may not be possible
See also:
StateChangeData TaskState::SettableState

Definition at line 293 of file task.cpp.

Here is the call graph for this function:

QList< StorableData * > domain::Task::dependentData (  )  const [private, virtual]

A task depends on its reservations and its sent invitations

Reimplemented from domain::StorableData.

Definition at line 581 of file task.cpp.

Here is the call graph for this function:

bool domain::Task::dependsOn ( const Task other  )  const

Checks whether this task depends on the given task.

Parameters:
other The task to be checked
Returns:
true if this task depends on the given task, directly or indirectly
false otherwise

Definition at line 468 of file task.cpp.

QDateTime domain::Task::earliestEndTime (  )  const

Returns the earliest possible end time of this task. This is the start time plus the duration.

Definition at line 538 of file task.cpp.

QVariant domain::Task::field ( const QString &  id  )  const

Returns the value of the field with the given id.

Returns:
The value of the field with the given field if this field exists.
A null QVariant otherwise.

Definition at line 149 of file task.cpp.

QMap< QString, QVariant > domain::Task::fields (  )  const

Returns a map (id->value) of all fields.

Definition at line 157 of file task.cpp.

QList< const Invitation * > domain::Task::invitations (  )  const

Returns a list of all invitations issued from this task.

Definition at line 235 of file task.cpp.

bool domain::Task::isAvailable (  )  const

Checks whether this task is available.

Definition at line 482 of file task.cpp.

unsigned domain::Task::nbAcceptedInvitations ( UserType type  )  const

Returns the number of invitations issued from this task for a user of the given type that have the "accepted" state.

See also:
Invitation::state()

Definition at line 240 of file task.cpp.

Here is the call graph for this function:

unsigned domain::Task::nbActiveReservations ( ResourceType type  )  const

Returns the number of "active" reservations for the given type of resource.

See also:
Reservation::isActive()

Definition at line 222 of file task.cpp.

void domain::Task::notify (  )  [virtual]

This can be used to notify this object when something has happened that could have changed something about this object.

See also:
Clock

Reimplemented from domain::StorableData.

Definition at line 573 of file task.cpp.

const Project * domain::Task::project (  )  const

Returns the project to which this task belongs.

Definition at line 502 of file task.cpp.

void domain::Task::removeInvitation ( Invitation invitation  )  [private]

Removes the given invitation from this task object.

Definition at line 449 of file task.cpp.

void domain::Task::removeReservation ( Reservation reservation  )  [private]

Removes the given reservation from this task object.

Definition at line 212 of file task.cpp.

void domain::Task::removeSubTask ( Task dependency  ) 

Removes a given task from the dependency of this task.

Parameters:
dependency The task to remove

Definition at line 456 of file task.cpp.

bool domain::Task::requirementsAreFulfilled (  )  const

Indicates whether all requirements of this task are fulfilled.

See also:
TaskType::requirementsAreFulfilled(const Task*) const

Definition at line 487 of file task.cpp.

Here is the call graph for this function:

QList< const Reservation * > domain::Task::reservations (  )  const

Returns a list of all reservations made for this task.

See also:
Reservation

Definition at line 217 of file task.cpp.

const Schedule & domain::Task::schedule (  )  const

Returns the schedule of this task.

Definition at line 256 of file task.cpp.

Here is the call graph for this function:

void domain::Task::setField ( const QString &  id,
const QVariant &  value 
)

Sets the field with the given id to the given value.

Parameters:
id The id of the field to set.
value The value for the field.
Exceptions:
InvalidDataException 
  • If there is no field with the given id.
  • If the given value is not valid for the field with the given id.
See also:
Field::isNull() const, Field::isValid(const QVariant&) const

Definition at line 128 of file task.cpp.

void domain::Task::setProject ( Project project  ) 

Sets the project of this task.

Parameters:
project The project to set
Postcondition:
This task is now part of the given project

Definition at line 512 of file task.cpp.

void domain::Task::setState ( TaskState state  )  [private]

Sets the state of this task unconditionally to the given state.

Definition at line 287 of file task.cpp.

void domain::Task::setState ( TaskState::SettableState  state  ) 

Sets the state of this task if this is possible. If the change is possible when some other tasks change their state, their states will be changed.

Exceptions:
InvalidDataException If this task cannot have the given state.
See also:
canHaveAsState(TaskState::SettableState) const

Definition at line 271 of file task.cpp.

TaskState::SettableState domain::Task::state (  )  const

Returns the state of this task.

Definition at line 266 of file task.cpp.

QString domain::Task::stateString (  )  const

Returns a string representation of the state of this task.

Definition at line 261 of file task.cpp.

QList< const Task * > domain::Task::subTasks (  )  const

Returns a list of tasks on which this task depends

Definition at line 533 of file task.cpp.

QList< const Task * > domain::Task::superTasks (  )  const

Returns a list of tasks that directly depend on this task.

Definition at line 558 of file task.cpp.

TaskType * domain::Task::taskType (  )  const

Returns the type of this task.

See also:
TaskType

Definition at line 497 of file task.cpp.

const User * domain::Task::user (  )  const

Returns the user that is assigned to this task.

Definition at line 507 of file task.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator
Generated on Thu May 27 14:20:17 2010 for MopTaskManager by  doxygen 1.6.3