Class Task
- java.lang.Object
-
- com.aspose.tasks.Task
-
public class Task extends Object implements com.aspose.ms.System.IEquatable<Task>, Cloneable
Represents a task in a project.
<p>The <b>Task</b> is representing a one atomic chuck of work.</p>One can use<b>Task</b>to plan a project by creating tasks and assign appropriate resources onto them. Tasks in a project are organized as a rooted hierarchical tree structure, with a root task and subtrees of children tasks.<p>To build a tree of tasks one can use a specialized collection {@link TaskCollection} by accessing {@code Project.RootTask}({@link Project#getRootTask}/{@link Project#setRootTask(Task)}) property e.g.:</p>Project project = new Project(); // add new tasks Task task1 = project.RootTask.Children.Add(); // a parent task with empty name is added Task childTask1 = task1.Children.Add("Child 1"); childTask1.Set(Tsk.Start, new DateTime(2020, 2, 12, 8, 0, 0)) childTask1.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour)); childTask1.Set(Tsk.Finish, new DateTime(2020, 2, 12, 17, 0, 0)); Task childTask3 = task1.Children.Add("Child 3"); childTask3.Set(Tsk.Start, new DateTime(2020, 2, 13, 8, 0, 0)) childTask3.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour)); childTask3.Set(Tsk.Finish, new DateTime(2020, 2, 13, 17, 0, 0)); Task childTask2 = task1.Children.Add("Child 2", 2); // inserts a task before the childTask3 childTask2.Set(Tsk.Start, new DateTime(2020, 2, 14, 8, 0, 0)) childTask2.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour)); childTask2.Set(Tsk.Finish, new DateTime(2020, 2, 14, 17, 0, 0)); // save project in the one of available formats project.Save("Filled project.xml", SaveFileFormat.MPP);
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectdeepClone()Creates full copy of a task without subtasks.voiddelete()Deletes a task from parent project tasks collection and all its assignments.booleanequals(Task other)Returns a value indicating whether this instance is equal to a specified task.booleanequals(Object obj)Returns a value indicating whether this instance is equal to a specified object.<T> Tget(Key<T,Integer> key)Returns the value to which the property is mapped in this container.ResourceAssignmentCollectiongetAssignments()Gets a collection of resource assignments for this object.TaskBaselineCollectiongetBaselines()Gets the collection of baseline values of the task.TaskCollectiongetChildren()Gets a child task collection of this object.ExtendedAttributeCollectiongetExtendedAttributes()Gets ExtendedAttributeCollection object containing the values of an extended attribute.com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.tasks.IExtendedAttributeParent>getItems()OutlineCodeCollectiongetOutlineCodes()GetsOutlineCodeCollectionobject.ProjectgetParentProject()Gets the parent project of a task.TaskgetParentTask()Gets the parent task of a task.TaskCollectiongetPredecessors()Gets aTaskCollectionobject which contains all predecessors of this Task object.RecurringTaskInfogetRecurringInfo()Gets the instance ofRecurringTaskInfoclass for the task which is a recurring task; if the task is not a recurring one then returns null;SplitPartCollectiongetSplitParts()Gets a SplitPart collection that represents the portions of a task.TaskCollectiongetSuccessors()Gets aTaskCollectionobject which contains all successors of this Task object.TimephasedDataCollectiongetTimephasedData()Gets a TimephasedDataCollection object of this task.TimephasedDataCollectiongetTimephasedData(Date start, Date end)ReturnsTimephasedDataCollectionobject withTimephasedData(getTimephasedData()/setTimephasedData(TimephasedDataCollection)) values within given start and end dates.TimephasedDataCollectiongetTimephasedData(Date start, Date end, int timephasedType)ReturnsTimephasedDataCollectionobject withTimephasedData(getTimephasedData()/setTimephasedData(TimephasedDataCollection)) values within given start and end dates of specified time-phased data type.booleanhasChildren()Gets a value indicating that this task has children.inthashCode()Returns a hash code value for this Task.voidmoveToSibling(int beforeTaskId)Moves the current task at the same Outline Level before a task with the specified Id.voidmoveToSibling(Task beforeTask)Moves the current task at the same Outline Level before the specified task.voidoutlineIndent()Indents a task in the outline.voidoutlineOutdent()Promotes a task in the outline.Iterable<Task>selectAllChildTasks()Recursively collects all child tasks of this task.voidset(Key<Date,Integer> key, Date val)Maps the specified property to the specified value in this container.<T> voidset(Key<T,Integer> key, T val)Maps the specified property to the specified value in this container.voidsetBaselines(TaskBaselineCollection value)Sets the collection of baseline values of the task.voidsetOutlineCodes(OutlineCodeCollection value)SetsOutlineCodeCollectionobject.voidsetTimephasedData(TimephasedDataCollection value)Sets a TimephasedDataCollection object of this task.StringtoString()Returns short string representation of a task.
-
-
-
Method Detail
-
deepClone
public final Object deepClone()
Creates full copy of a task without subtasks.
- Returns:
- Created copy of a task.
-
delete
public final void delete()
Deletes a task from parent project tasks collection and all its assignments.
-
equals
public final boolean equals(Task other)
Returns a value indicating whether this instance is equal to a specified task.
- Parameters:
other- The specified task to compare with this instance.- Returns:
- returns true if the specified task and this instance have equal unique ids.
-
equals
public boolean equals(Object obj)
Returns a value indicating whether this instance is equal to a specified object.
-
get
public final <T> T get(Key<T,Integer> key)
Returns the value to which the property is mapped in this container.
- Parameters:
key- the specified property key.Tskfor getting the property key.T: the type of the mapped value.- Returns:
- the value to which the property is mapped in this container.
-
getAssignments
public final ResourceAssignmentCollection getAssignments()
Gets a collection of resource assignments for this object.
- Returns:
- a collection of resource assignments for this object.
-
getBaselines
public final TaskBaselineCollection getBaselines()
Gets the collection of baseline values of the task.
- Returns:
- the collection of baseline values of the task.
-
setBaselines
public final void setBaselines(TaskBaselineCollection value)
Sets the collection of baseline values of the task.
- Parameters:
value- the collection of baseline values of the task.
-
getChildren
public final TaskCollection getChildren()
Gets a child task collection of this object. TaskCollection object which represents children tasks.
- Returns:
- a child task collection of this object.
-
getExtendedAttributes
public final ExtendedAttributeCollection getExtendedAttributes()
Gets ExtendedAttributeCollection object containing the values of an extended attribute.
Two pieces of data are necessary - a pointer back to the extended attribute table which is specified either by the unique ID or the Field ID, and the value which is specified either with the value, or a pointer back to the value list.- Returns:
- ExtendedAttributeCollection object containing the values of an extended attribute.
-
getItems
public final com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.tasks.IExtendedAttributeParent> getItems()
- Returns:
-
getOutlineCodes
public final OutlineCodeCollection getOutlineCodes()
Gets
OutlineCodeCollectionobject.
Two pieces of data are necessary - a pointer to the outline code table that is specified by the FieldID, and the value that is specified either by the ValueID or ValueGUID pointer to the value list.- Returns:
OutlineCodeCollectionobject.
-
setOutlineCodes
public final void setOutlineCodes(OutlineCodeCollection value)
Sets
OutlineCodeCollectionobject.
Two pieces of data are necessary - a pointer to the outline code table that is specified by the FieldID, and the value that is specified either by the ValueID or ValueGUID pointer to the value list.- Parameters:
value-OutlineCodeCollectionobject.
-
getParentProject
public final Project getParentProject()
Gets the parent project of a task.
Call Project.UpdateReferences to update these properties.- Returns:
- the parent project of a task.
-
getParentTask
public final Task getParentTask()
Gets the parent task of a task.
- Returns:
- the parent task of a task.
-
getPredecessors
public final TaskCollection getPredecessors()
Gets a
TaskCollectionobject which contains all predecessors of this Task object.- Returns:
- Read-only instance of
TaskCollectionclass.
-
getRecurringInfo
public final RecurringTaskInfo getRecurringInfo()
Gets the instance of
RecurringTaskInfoclass for the task which is a recurring task; if the task is not a recurring one then returns null;
The info for the instance ofRecurringTaskInfois present in mpp file format only.- Returns:
- the instance of
RecurringTaskInfoclass for the task which is a recurring task; if the task is not a recurring one then returns null;
-
getSplitParts
public final SplitPartCollection getSplitParts()
Gets a SplitPart collection that represents the portions of a task.
- Returns:
- a SplitPart collection that represents the portions of a task.
-
getSuccessors
public final TaskCollection getSuccessors()
Gets a
TaskCollectionobject which contains all successors of this Task object.- Returns:
- Read-only instance of
TaskCollectionclass.
-
getTimephasedData
public final TimephasedDataCollection getTimephasedData()
Gets a TimephasedDataCollection object of this task. The time phased data block associated with a task.
Reading supported for XML format only.- Returns:
- a TimephasedDataCollection object of this task.
-
setTimephasedData
public final void setTimephasedData(TimephasedDataCollection value)
Sets a TimephasedDataCollection object of this task. The time phased data block associated with a task.
Reading supported for XML format only.- Parameters:
value- a TimephasedDataCollection object of this task.
-
getTimephasedData
public final TimephasedDataCollection getTimephasedData(Date start, Date end, int timephasedType)
Returns
TimephasedDataCollectionobject withTimephasedData(getTimephasedData()/setTimephasedData(TimephasedDataCollection)) values within given start and end dates of specified time-phased data type.- Parameters:
start- The start date for the time phased data.end- The end date for the time phased data.timephasedType- The type of time phased data (TimephasedDataType).- Returns:
- A
TimephasedDataCollectionobject withTimephasedData(getTimephasedData()/setTimephasedData(TimephasedDataCollection)) values within given start and end dates of specified timephased data type.
-
getTimephasedData
public final TimephasedDataCollection getTimephasedData(Date start, Date end)
Returns
TimephasedDataCollectionobject withTimephasedData(getTimephasedData()/setTimephasedData(TimephasedDataCollection)) values within given start and end dates.- Parameters:
start- The start date for the time phased data.end- The end date for the time phased data.- Returns:
- List of
TimephasedDatato be filled in.
-
hasChildren
public final boolean hasChildren()
Gets a value indicating that this task has children.- Returns:
- a value indicating that this task has children.
-
hashCode
public int hashCode()
Returns a hash code value for this Task.
-
moveToSibling
public final void moveToSibling(Task beforeTask)
Moves the current task at the same Outline Level before the specified task. If ParentProject.CalculationMode is None user should invoke Project.Recalculate() after using this method (It will reschedule all project tasks (start/finish dates, sets early/late dates) and calculate the dependent fields such as slacks, work and cost fields, outline levels). If ParentProject.CalculationMode is Manual the method will calculate only task id, outline level and outline numbers automatically. If ParentProject.CalculationMode is Automatic the method reschedules all project's tasks automatically (start/finish dates, sets early/late dates, calculates slacks, work and cost fields, recalculates ids and outline levels).
- Parameters:
beforeTask- Task before which the current task will be inserted.
-
moveToSibling
public final void moveToSibling(int beforeTaskId)
Moves the current task at the same Outline Level before a task with the specified Id. If ParentProject.CalculationMode is None user should invoke Project.Recalculate() after using this method (It will reschedule all project tasks (start/finish dates, sets early/late dates) and calculate the dependent fields such as slacks, work and cost fields, outline levels). If ParentProject.CalculationMode is Manual the method will calculate only task id, outline level and outline numbers automatically. If ParentProject.CalculationMode is Automatic the method reschedules all project's tasks automatically (start/finish dates, sets early/late dates, calculates slacks, work and cost fields, recalculates ids and outline levels).
- Parameters:
beforeTaskId- Id (Tsk.ID) of a task before which the current task will be inserted.
-
outlineIndent
public final void outlineIndent()
Indents a task in the outline.
-
outlineOutdent
public final void outlineOutdent()
Promotes a task in the outline.
-
selectAllChildTasks
public final Iterable<Task> selectAllChildTasks()
Recursively collects all child tasks of this task.
- Returns:
- A list of child tasks of this task.
-
set
public final <T> void set(Key<T,Integer> key, T val)
Maps the specified property to the specified value in this container.
- Parameters:
key- the specified property key.Tskfor getting the property key.val- the value.T: the type of the mapped value.
-
set
public final void set(Key<Date,Integer> key, Date val)
Maps the specified property to the specified value in this container.
- Parameters:
key- the specified property key.Tskfor getting the property key.val- the value.
-
-