It's all about the answers!

Ask a question

In the RTC Java-API, how do I retrieve the "date added" property of a changeset to a workspace?


0
1
Timothy Tan (34) | asked Jul 13 '17, 6:16 a.m.

Given a stream, how do I retrieve the list of changesets as well as the "date added" property for these changesets? I can only find the getLastChangeDate() method in IChangeSet.

Accepted answer


permanent link
Stefan Sauterleute (284) | answered Jul 20 '17, 8:57 a.m.

With the client api you can retrieve the date added with using IWorkspaceConnection class.

Finally you get objects from type IChangeHistoryEntryChange. On this objects you can get the date added with invoke the creationDate() method.

IWorkspaceConnection stream = findWorkspace(repositoryWorkspaceName);
List<IComponentHandle> components = stream .getComponents();

for (IComponentHandle componentHandle : components) {
IChangeHistory changeHistory = stream .changeHistory(componentHandle);

IComponent component = (IComponent) repository.itemManager().fetchCompleteItem(componentHandle,
IItemManager.REFRESH, null);
System.out.println("Component: " + component.getName());
System.out.println("==========================================================");

List<IChangeHistoryEntryChange> historyEntries = changeHistory.recent(monitor);

System.out.println("Comment" + " \t" + "Date Creaded" + " \t" + "Added By" + " \t" + "Date Added");
for (IChangeHistoryEntryChange changeHistoryEntry : historyEntries) {
IChangeSet changeSet = (IChangeSet) repository.itemManager().fetchCompleteItem(
changeHistoryEntry.changeSet(), IItemManager.REFRESH, null);
IContributor user = (IContributor) repository.itemManager().fetchCompleteItem(
changeHistoryEntry.createdBy(), IItemManager.REFRESH, null);

System.out.println(changeSet.getComment() + " \t" + changeSet.getLastChangeDate() + " \t" + user.getName()
+ " \t" + changeHistoryEntry.creationDate());
}
}

Timothy Tan selected this answer as the correct answer

Your answer


Register or to post your answer.