private void associateWithBuildRun( BuildRun buildRun, Collection<ChangeSet> changeSets, Set<PrimaryWorkitem> workitems) { for (ChangeSet changeSet : changeSets) { buildRun.getChangeSets().add(changeSet); for (PrimaryWorkitem workitem : workitems) { if (workitem.isClosed()) { logger.println(MessagesRes.workitemClosedCannotAttachData(workitem.getDisplayID())); continue; } final Collection<BuildRun> completedIn = workitem.getCompletedIn(); final List<BuildRun> toRemove = new ArrayList<BuildRun>(completedIn.size()); changeSet.getPrimaryWorkitems().add(workitem); for (BuildRun otherRun : completedIn) { if (otherRun.getBuildProject().equals(buildRun.getBuildProject())) { toRemove.add(otherRun); } } for (BuildRun buildRunDel : toRemove) { completedIn.remove(buildRunDel); } completedIn.add(buildRun); } } }
private boolean isBuildExist(BuildProject buildProject, BuildInfo info) { BuildRunFilter filter = new BuildRunFilter(); filter.references.add(Long.toString(info.getBuildId())); filter.name.add(getBuildName(info)); filter.buildProjects.add(buildProject); Collection<BuildRun> buildRuns = config.getV1Instance().get().buildRuns(filter); return buildRuns != null && buildRuns.size() != 0; }