for ( int projectId : map.keySet() )
{
int buildDefinitionId = map.get( projectId );
ProjectRunSummary runToDelete = null;
// check if there is an existing current run with that project id and build definition id
for ( ProjectRunSummary currentRun : currentRuns )
{
if ( currentRun.getProjectId() == projectId &&
currentRun.getBuildDefinitionId() == buildDefinitionId )
{
runToDelete = currentRun;
break;
}
}
if ( runToDelete != null )
{
// previous run already finished, but was not removed from the list
// removed it
currentRuns.remove( runToDelete );
}
ProjectRunSummary run = new ProjectRunSummary();
run.setProjectGroupId( projectGroupId );
run.setProjectScmRootId( projectScmRootId );
run.setProjectId( projectId );
run.setBuildDefinitionId( buildDefinitionId );
run.setTriggeredBy( task.getBuildTrigger().getTriggeredBy() );
run.setTrigger( task.getBuildTrigger().getTrigger() );
run.setBuildAgentUrl( buildAgentUrl );
currentRuns.add( run );
}
}
}