javartcjazz

comparing two baselines in RTC/Jazz with plain java


I try to compare two snapshots from one stream programamtically in plain java...

Step 1: getting my stream (working)

IWorkspaceConnection stream = null;
List<IWorkspaceConnection> list = RtcAdapter.inst().getStreams(); //my library
for (IWorkspaceConnection connection: list){
    if (connection.getName().equalsIgnoreCase("myStreamName") ){
        stream = connection;
        break;
    }
}//now we have found our stream

Step 2: getting base lines (working)

List<IBaselineSet> snapShotList = 
    RtcAdapter.inst().getSnapShotsFromStream(stream);

IBaselineSet snapShot0 = null;
IBaselineSet snapShot1 = null;

for (IBaselineSet snapShot: snapShotList){
    if (snapShot.getName().equalsIgnoreCase("mySnapShotName0") ){
        snapShot0 = snapShot;
    }
    if (snapShot.getName().equalsIgnoreCase("mySnapShotName1") ){
        snapShot1 = snapShot;
    }
}//now we've got also my two snapShots

Step 3: comparing each other (not working)

IUpdateReport report = 
    workspaceManager.compareBaselineSetConfigurations(
        snapShot0, snapShot0, stream.getComponents(), monitor);

my report is empty... --annoying--

report=com.ibm.team.scm.common.internal.dto.impl.UpdateReportImpl@1de5a20 (stateBefore: <unset>, stateAfter: <unset>)

i also tried to get the ChangeHistorySyncReport...

IChangeHistorySyncReport report = 
    workspaceManager.compareBaselineSets(
        snapShot0, snapShot1, componentList(stream), monitor);

also the report is empty...

so how do I create a proper report? or how can I compare two baselines? (what am I doing wrong?

report.getAffectedComponents() returns an empty array, as well does report.getModifiedComponents()

UPDATE as far a s i know now i must inspect the ChangeHistorySyncReport... and when i print my report it says:

com.ibm.team.scm.common.internal.dto.impl.ChangeHistorySyncReportImpl@150f091 (localTime: <unset>, remoteTime: <unset>, compareFlags: <unset>)

this makes my question deeper - how can i set better CompareFlags?


Solution

  • GOD it took me ages....

    but first things first: it was totally right to use the IChangeHistorySyncReport instead of IUpdateReport...

    so what was wrong?

    IWorkspaceConnection stream; //is not null, already instantiated somewhere else
    IBaselineSet bl0 = (IBaselineSet) 
        itemManager.fetchCompleteItem(baseLineHandle0, IItemManager.DEFAULT, monitor);
    IBaselineSet bl1 = (IBaselineSet)
        itemManager.fetchCompleteItem(baseLineHandle1, IItemManager.DEFAULT, monitor);
    IChangeHistorySyncReport report = 
        workspaceManager.compareBaselineSets(bl0, bl1, getComponentHandles(stream), monitor);
    

    a simply code change solves the problem

    //have a close look: 3.rd param is now null!!
    IChangeHistorySyncReport report = 
        workspaceManager.compareBaselineSets(bl0, bl1, null, monitor); 
    

    by the way, there was another tricky part, when i browsed up the report:

    System.out.println("report: "+report );    
    System.out.println("incoming: "+report.incomingChangeSets() );
    
    output:
    report = com.ibm.team.scm.common.internal.dto.impl.ChangeHistorySyncReportImpl@127c1ae (localTime: <unset>, remoteTime: <unset>, compareFlags: <unset>)
    incoming []
    

    looked empty ot first sight - but digging deeper i found out that i simply had to ask for report.outgoingChangeSets() which brings out a great sum of (expected) changes...

    but when i exchange the baseline workspaceManager.compareBaselineSets(bl1, bl0, null, monitor); then

    update:

    enter image description here

    using the compare baseline method i can now provide a full diff on several components!!!