Error: sorted array finish date should be greater than or equal to start date

Hello,

I am implementing code to export same data to MPP.

I am getting an error when I try to add assignments to my aspose project, in this line:

ResourceAssignment mppAssignment = mppProject.getResourceAssignments().add(mppTask, mppResource);

The error is this:

Caused by: java.lang.AssertionError: in sorted array finish date should be greater than or equal to start date.
at com.aspose.tasks.private.ai.a.a(Unknown Source)
at com.aspose.tasks.bws.a(Unknown Source)
at com.aspose.tasks.TimephasedDataCollection.a(Unknown Source)
at com.aspose.tasks.dql.a(Unknown Source)
at com.aspose.tasks.cds.c(Unknown Source)
at com.aspose.tasks.cds.a(Unknown Source)
at com.aspose.tasks.ddj.d(Unknown Source)
at com.aspose.tasks.ddj.b(Unknown Source)
at com.aspose.tasks.beb.b(Unknown Source)
at com.aspose.tasks.ddj.f(Unknown Source)
at com.aspose.tasks.ddj.d(Unknown Source)
at com.aspose.tasks.ResourceAssignmentCollection.add(Unknown Source)
at com.aspose.tasks.ResourceAssignmentCollection.add(Unknown Source)

Apparently, the dates for the task are not ok. But, in my data, the tasks start dates are always less or equal than the tasks finish dates!!! Or I am thinking wrong??

I am sending as attachment the MPP that I am exporting WITHOUT THE ASSIGNMENTS. Can you see any bug/problem/whatever with the task dates or anything else? Why can’t I add assignments?
[Note: the error is raised when I try to add the first resource “Ricardo Gonçalves” to the Task Nº5 “Project Management”]

Thx a lot!!
renata

EXPORT-MPP-project-plan.zip (38.9 KB)

@renatadiasilva,

Could you please share the exact running code sample with us that fails while doing so? We are unable to get an idea about what you are trying to export? An elaborate code sample will help us investigate the issue for assisting you further.

Thx for the quick answer!

I am sending my exporter class as attachment:

ProjectPlanExporter.zip (8.3 KB)

But there are a lot of dependencies, so you will not be able to run the code…

Anyway, If you could give me any ideas or sugestions concerning this error, I would apreciate. Since my task dates appear to be ok (start before or equal finish), can you tell me what other dates can be the source of the problem?


I also have tried to use the MPP exported by my code but WITHOUT ASSIGNMENTS, only calendars. tasks and resources (the file that I have sent to you in the first post) as starting template and then I added the assignments.

Surprisingly, that worked!!! So If I cannot solve the initial problem I can use this workaround (export first the calendars, tasks and resources save to MPP, get the bytes, then create a new aspose project using the bytes, then add the assignments and finally save project again to MPP). But this is a very very bad workaround…

Thx again for all the help!

Hi again,

I have done some other tests and I came up with a solution.

I first, add all resources and then all tasks to the aspose project and then at the end use:

Collectos

to iterate through the previsously add tasks and I add the assignments.

But it is still not the best solution, since I am iterating twice through the tasks! What I want is to add the assignments as soos as I add the respective task (the resources are all added at the beginning) and that is not working!

Can you tell me if it is possible to add the asisgnments as soon as we have the resource and the tasks? I guess so, so the problem should be my code…

In the meanwhile, I am trying to make a runnable code to send to you.

Thx again,
renata

@renatadiasilva,

When we open the attached MPP file in MS Outlook, it gives us error about the cyclic tasks and removes the dependency from these before opening. This shows that there is some issue with the task dates in the MPP file as well.

The code sample you shared is a bit lengthy and non-compilable as well at the same time which is making it difficult for us to investigate the issue further. Yes, you can do resource assignments to tasks if you have both tasks and resources available in the project.

It would be better if you could create a separate short runnable sample code for further investigation of this issue at our end. We’ll look into it for assisting you further.

Hi again,

I implemented a runnable code, similar to my “real” code (instead of getting the data from my data base, I have set it directly in the code).

When I run this runnable code, I no longer get the “in sorted array finish date should be greater than or equal to start date” error, but I notice that there are some issues in the MPP exported:

  1. Like you said in you last answer, the MPP file gives error about the cyclic tasks (and removes the dependency from these before opening).
  2. I also notice that all my resources calendars day exceptions are not being set in the MPP file.

Can you please help me understaind what I am doing wrong in my code?? I send as attachment the runnable code, so you can better debug it. The main method is in ExportTest.java, and I also send a few dependencies and the base MPP template.

I hope I fix this, I will be able to also fix my “real” code.

Thx again,
renata

aspose forum.zip (41.6 KB)

@renatadiasilva,

We tried to analyse your sample code but its lengthy and we are not able to investigate it thoroughly as it is still missing some dependencies. We request you to please share a short and to the point code sample that raises the same problem so that we can use it for reproducing it at our end and assist you accordingly. We appreciate your cooperation in this regard.

Hi again,

I am sorry you are right, there were still missing some dependies…

I send now the code after removing those dependies. I have run it as a standalone project in intellij and I am sending now the project folder as attachment. All needd java classes (including main in ExportTest.java) are located in “src/com/test/exportmpp”. The empty template and the license are at the root folder (ExportToMPP).

I hope now you can run the code… It is dificult for me to implement a shorter code that is not working well.

Thanks a lot for you pacience!
renata

ExportToMPP.zip (80.3 KB)

@renatadiasilva,

Thank you for providing the working sample code. I have tested it using latest version Aspose.Tasks for Java 17.8, however could not observe any issue as no exception is raised. Could you please give this code a try with the latest version and share the feedback?

Yes, the exception is no longer raised, but when I open the MPP file (in Project 2010) I get this error:

“There was a problem linking these tasks. You cannot do this because it would create a circular task relationship woth other tasks” (error picture ErrorProject.png (5.1 KB))

Can you help me understand why this error appear? Because I think this can be the cause of the first raised exception “Caused by: java.lang.AssertionError: in sorted array finish date should be greater than or equal to start date.”

Thx a lot (again!)
renata

@renatadiasilva,

Thank you for providing the feedback. I have tested the code using latest version Aspose.Tasks for Java 17.8.0 and output MPP file is tested in MSP 2010. There is no error raised and file opens fine in MSP 2010. This output file is attached here for your reference. Please give a try using latest version and share the feedback.

EXPORT-MPP-project-plan.zip (33.0 KB)