Timephased Data Generation for Different Work Contours

Aspose.Tasks can generate timephased data for different work contours of an assigned resource. The generated data is obtained using TimeScaleData which takes the project start and finish dates as input parameters.

Timephased Data Generation The following piece of code assigns different types of work contours to an assigned resource and displays its time-phased data.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(TimephasedDataGeneration.class);
 4
 5// Read the source MPP file
 6Project project = new Project(dataDir + "SampleFile.Mpp");
 7
 8// Get the first task of the Project
 9Task task = project.getRootTask().getChildren().getById(1);
10
11// Get the First Resource Assignment of the Project
12ResourceAssignment firstRA = project.getResourceAssignments().toList().get(0);
13
14// Flat contour is default contour
15System.out.println("Flat contour");
16for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
17    System.out.println(td.getStart().toString() + " " + td.getValue());
18}
19
20// Change contour
21firstRA.set(Asn.WORK_CONTOUR, WorkContourType.Turtle);
22System.out.println("Turtle contour");
23for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
24    System.out.println(td.getStart().toString() + " " + td.getValue());
25}
26
27// Change contour
28firstRA.set(Asn.WORK_CONTOUR, WorkContourType.BackLoaded);
29System.out.println("BackLoaded contour");
30for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
31    System.out.println(td.getStart().toString() + " " + td.getValue());
32}
33
34// Change contour
35firstRA.set(Asn.WORK_CONTOUR, WorkContourType.FrontLoaded);
36System.out.println("FrontLoaded contour");
37for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
38    System.out.println(td.getStart().toString() + " " + td.getValue());
39}
40
41// Change contour
42firstRA.set(Asn.WORK_CONTOUR, WorkContourType.Bell);
43System.out.println("Bell contour");
44for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
45    System.out.println(td.getStart().toString() + " " + td.getValue());
46}
47
48// Change contour
49firstRA.set(Asn.WORK_CONTOUR, WorkContourType.EarlyPeak);
50System.out.println("EarlyPeak contour");
51for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
52    System.out.println(td.getStart().toString() + " " + td.getValue());
53}
54
55// Change contour
56firstRA.set(Asn.WORK_CONTOUR, WorkContourType.LatePeak);
57System.out.println("LatePeak contour");
58for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
59    System.out.println(td.getStart().toString() + " " + td.getValue());
60}
61// Change contour
62firstRA.set(Asn.WORK_CONTOUR, WorkContourType.DoublePeak);
63System.out.println("DoublePeak contour");
64for (TimephasedData td : task.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE))) {
65    System.out.println(td.getStart().toString() + " " + td.getValue());
66}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.