Welcome to the Jazz Community Forum
RTC Java Api Remove Build Engine from Build Definition

I try to remove BuildEngine from BuildDefinition and it doesn't work!
My code:
String id = someBuildEngineId;
IBuildDefinition buildDefinition = someBuildDefinition;
IBuildEngine be = client.getBuildEngine(id, monitor)
IBuildEngine workingCopy = (IBuildEngine) be.getWorkingCopy();
workingCopy.getSupportedBuildDefinitions().remove(buildDefinition);
client.save(workingCopy, monitor);
If I use following add, it's work fine:
workingCopy.getSupportedBuildDefinitions().add(buildDefinition);
The following code return false:
workingCopy.getSupportedBuildDefinitions().contains(buildDefinition);
I am very confuse...
Someone have an idea?
Thanks in advance.
3 answers

Contains() is a java object list method..
getSupportedBuildDefinitions() returns a list of HANDLES.(IBuildDefinitionHandle). not objects (IBuildDefinition)
but then you asked does this IBuildDefinition (object address, NOT HANDLE), exist in the list of HANDLES..(IBuildDefinitionHandle) and it does not..

String id = someBuildEngineId;
IBuildDefinition buildDefinition = someBuildDefinition;
IBuildEngine be = client.getBuildEngine(id, monitor)
IBuildEngine workingCopy = (IBuildEngine) be.getWorkingCopy();
List buildDefinitionHandles = workingCopy .getSupportedBuildDefinitions();
for (int j = 0; j < buildDefinitionHandles.size(); j++) {
IBuildDefinitionHandle handle = (IBuildDefinitionHandle) buildDefinitionHandles.get(j);
if (buildDefinition .getItemId().getUuidValue().equals(buildDefinitionHandle.getItemId().getUuidValue())) {
workingCopy.getSupportedBuildDefinitions().remove(j);
client.save(workingCopy, monitor);
break;
}
}
Thanks,
Sridevi
Comments
Sridevi Sangaiah
JAZZ DEVELOPER Sep 12 '16, 12:03 a.m.If "workingCopy.getSupportedBuildDefinitions().contains(buildDefinition)" returns false then there is a possibility that the build definition is not supported by the build engine.
Can you please confirm from the UI that when you add a build definition, in your code, it gets added to the build engine and then when you programatically remove the build definition it is not removed?
Thanks,
Sridevi
Gérard Langevin
Sep 12 '16, 9:46 a.m.Hello Sridevi,
Thanks for your quick response. I can confirm from UI that I can add new Build Engine X but I can't remove them.
I use artifact com.ibm.team.build.common:3.1.400.v20130415_0257
Thanks a lot it's very appreciate it.