* TODO: Must be done by build definition
*/
public List<ChangeSet> getChangesSinceLastSuccess( int projectId, int buildResultId )
throws ContinuumException
{
BuildResult previousBuildResult = null;
try
{
previousBuildResult = buildResultDao.getPreviousBuildResultInSuccess( projectId, buildResultId );
}
catch ( ContinuumStoreException e )
{
//No previous build in success, Nothing to do
}
long startTime = previousBuildResult == null ? 0 : previousBuildResult.getStartTime();
ArrayList<BuildResult> buildResults = new ArrayList<BuildResult>(
buildResultDao.getBuildResultsForProjectWithDetails( projectId, startTime, buildResultId ) );
Collections.reverse( buildResults );
Iterator<BuildResult> buildResultsIterator = buildResults.iterator();
boolean stop = false;
//TODO: Shouldn't be used now with the previous call of buildResultDao.getBuildResultsForProjectWithDetails
while ( !stop )
{
if ( buildResultsIterator.hasNext() )
{
BuildResult buildResult = buildResultsIterator.next();
if ( buildResult.getId() == buildResultId )
{
stop = true;
}
}
else
{
stop = true;
}
}
if ( !buildResultsIterator.hasNext() )
{
return null;
}
BuildResult buildResult = buildResultsIterator.next();
List<ChangeSet> changes = null;
while ( buildResult.getState() != ContinuumProjectState.OK )
{
if ( changes == null )
{
changes = new ArrayList<ChangeSet>();
}
ScmResult scmResult = buildResult.getScmResult();
if ( scmResult != null )
{
changes.addAll( scmResult.getChanges() );
}