The problem about summary node roll up automatically

Hi,

Please run the code as below:

FileInputStream fstream = null;

try {
// Create a stream object containing the license file
fstream = new FileInputStream("Aspose.Tasks.lic");
// Instantiate the License class
License license = new License();
// Set the license through the stream object
license.setLicense(fstream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fstream.close();
} catch (IOException e) {
e.printStackTrace();
}
}

Project asProject = new Project("Empty_Project.mpp");

Task taskSummary = asProject.getRootTask().getChildren().add("Summary");
Task taskNode1 = taskSummary.getChildren().add("Node1");
taskNode1.set(Tsk.START, formatter2.parse("06/29/16 08:00:00"));
taskNode1.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
taskNode1.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));
Task taskNode2 = taskSummary.getChildren().add("Node2");
taskNode2.set(Tsk.START, formatter2.parse("06/29/16 08:00:00"));
taskNode2.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
taskNode2.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));

asProject.recalculate();

// Save the Project
asProject.save("output_summary.mpp", SaveFileFormat.MPP);

System.out.println("ok");
}

My question is why the summary node can not roll up automatically?

zhencheng.guo
Best Regards!

Hi Zhencheng,


Thank you for contacting Aspose support again.

You may modify your code before saving project file as MPP as given below.



asProject.recalculate();

GanttChartView view = (GanttChartView) asProject.getDefaultView();

view.setHideRollupBarsWhenSummaryExpanded(false);

view.setRollUpGanttBars(true);

MPPSaveOptions options = new MPPSaveOptions();

options.setWriteViewData(true);

// Save the Project

asProject.save(“output_summary.mpp”, options);


Hi Kashif,


I improved the code as you instructed, but why the Duration of Summary node is 10 days? I think it should be 9 days.

zhencheng.guo
Best Regards!

Hi Zhencheng,


I have executed the code and observed the issue in summary task however it is not according to your feedback. You may please share your output mpp file, created using above code for our analysis. Few issues are already reported where adding child task to parent task directly had some problems.

In the meanwhile you may please give a try to the following sample code and share the feedback.


Project asProject = new Project(“Blank2010.mpp”);


Task taskSummary = asProject.getRootTask().getChildren().add(“Summary”);


Task taskNode1 = asProject.getRootTask().getChildren().add(“Node1”);

taskNode1.outlineIndent();

taskNode1.set(Tsk.START, formatter2.parse(“06/29/16 08:00:00”));

taskNode1.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));

taskNode1.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));


Task taskNode2 = asProject.getRootTask().getChildren().add(“Node2”);

taskNode2.outlineIndent();

taskNode2.set(Tsk.START, formatter2.parse(“06/29/16 08:00:00”));

taskNode2.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));

taskNode2.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));


asProject.recalculate();

GanttChartView view = (GanttChartView) asProject.getDefaultView();// as TaskUsageView;

view.setHideRollupBarsWhenSummaryExpanded(false);

view.setRollUpGanttBars(true);

MPPSaveOptions options = new MPPSaveOptions();

options.setWriteViewData(true);

// Save the Project

asProject.save(“D:/Aspose_DotNetProjects/Tasks/SingleProgram/Tasks_762148/output_summaryB.mpp”, options);

System.out.println(“ok”);


Hi kashif,


I have tried this way, but it will lead to another issue, it will cause something wrong if I link Predecessor to Task.

It can not roll up to summary node, don’t you think this is a defect?

zhencheng.guo
Best Regards!

Hi Zhencheng,


Thank you for pointing out the issue where linking of tasks is not working fine. It is logged under Id: TASKSJAVA-226 for further consideration by the product team. You will be automatically notified once any update is received.

Regarding the earlier issue, you may please share the output file as requested here,

Hi Zhencheng,

We have further investigated the issue and found that Predecessors linking is not respected because of initial project "New Task Creation Mode" state. In this case, it is set to "Manual". So, all added tasks become "manually" scheduled and, therefore, their properties are not recalculated. This behavior can be changed in the following two ways:

1) Change whole project new task creation mode before creating new tasks:

Project asProject = new Project("Empty_Project.mpp");
asProject.set(Prj.NEW_TASKS_ARE_MANUAL, new NullableBool(false)); // Changing project
Task taskSummary = asProject.getRootTask().getChildren().add("Summary");

2) Change IsManual property for already created tasks:

Task taskNode2 = asProject.getRootTask().getChildren().add("Node2");
taskNode2.set(Tsk.IS_MANUAL, new NullableBool(false)); // Changing task
taskNode2.outlineIndent();
taskNode2.set(Tsk.START, formatter2.parse("06/29/16 08:00:00"));
taskNode2.set(Tsk.DURATION, asProject.getDuration(9, TimeUnitType.Day));
taskNode2.set(Tsk.WORK, asProject.getDuration(72, TimeUnitType.Hour));