joniles / mpxj

Primary repository for MPXJ library

Home Page:http://www.mpxj.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SetLag for Primavera Tasks

iMohannad opened this issue · comments

Is there a way to set lags for tasks in Primavira projects? If so, how can I do that?

I can only get lags from successors or predessors using relation class, but I couldn't find a way to setLag for these relations.

(I'm not the maintainer)

You could remove the existing relation and add a new one using the RelationContainer.addPredecessor() method

@iMohannad , @JanecekPetr's suggestion should work.

Based on your request, I'm considering two things. The first would be the ability to initialise the builder classes from another instance of the parent class, for example:

Relation newRelation = Relation.Builder.from(relation)
   .lag(newLag)
   .type(newType)
   .build();

This would just avoid having to populate attributes yourself if you are working with data you already have. The builder just works as it does before and calling the build method creates a new instance of the class. This seems like a non-controversial (and simple) addition, so I'll probably look at adding this.

The second thing is I wondering if it would be worth adding an update mechanism for the various immutable classes in the library. I want to keep things simple (so not too verbose), the syntax I'm considering might look something like this:

m_project.getRelations().update(relation)
   .lag(newLag)
   .type(newType)
   .build();

The update method on the container returns a Relation.Builder which is already populated with the current Relation's attributes. You use the builder methods to change the values you want, and finally calling the build method creates the new instance and informs the container so it can sort things out and replace the existing instance.

I'd be interested in feedback on this suggestion.

For consistency, I've added a from method to all Builder classes. I'll close this issue now, but feel free to add comments on suggested syntax for an "update" mechanism...