Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes

Comments

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

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.



3 answers

Permanent link
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..

0 votes


Permanent link
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

0 votes

Comments

I think it could have been done with

workingCopy.getSupportedBuildDefinitions().contains(buildDefinition.getItemHandle());

contains cannot be overridden because the raw java list object is exposed..

add and remove also are raw list methods..


Permanent link

Good morning,

It's work fine!

Thanks you very much for your help, it's very appreciate it.

Have a good day.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 457
× 411
× 234
× 89

Question asked: Sep 08 '16, 11:08 a.m.

Question was seen: 3,500 times

Last updated: Sep 13 '16, 8:10 a.m.

Confirmation Cancel Confirm