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
I think its an api issue.. add() and remove() will use the IBuildDefinitionHandle..
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..
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..
Remove could also be failing for the same reason like contains, unless BuildDefinitionHandleImpl implements the equals and hashcode methods, which I doubt. Can you please try the following snippet for remove?
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
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.Gérard Langevin
Sep 12 '16, 9:46 a.m.