It's all about the answers!

Ask a question

On delivery of changeset, how to retrieve component list under a stream via changeset?


0
1
Sudaraazhi Arivalagan (441829) | asked Jul 15 '15, 1:35 a.m.
edited Jul 15 '15, 3:03 a.m. by Ralph Schoon (63.5k33646)

Hi Ralph,

Kindly help on how to retrieve list of components under a specific stream from a ChangeSet..[on server side]

Thanks in advance.

Accepted answer


permanent link
Ralph Schoon (63.5k33646) | answered Jul 15 '15, 3:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 15 '15, 3:54 a.m.
Mind your tagging, this is likely "extending" and not administration.

In an SCM delivery advisor like https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/

The following approaches can be done, as far as I can tell from looking at com.ibm.team.filesystem.service.internal.process.StreamComponentsPermissionAdvisor.class - the class that I found by looking at references of the extension point in said advisor.

Get the components from the destination stream - all components referenced by the stream
		Object operationData = operation.getOperationData();
		if (!(operationData instanceof DeliverOperationData)) {
			return;
		}

		DeliverOperationData data = (DeliverOperationData) operationData;
		IWorkspace destination = data.getDestWorkspace();
		IScmService scmService = this.getScmService();
		IComponentHandle[] componentHandles = scmService
				.getComponentsForWorkspace(destination, null);
		IComponent[] components = (IComponent[]) this
				.getRepositoryItemServiceForScm().fetchItems(componentHandles,
						IRepositoryItemService.COMPLETE);


Get the components from the delivered change sets - not all, but only the ones we deliver to
		Object operationData = operation.getOperationData();
		if (!(operationData instanceof DeliverOperationData)) {
			return;
		}

		DeliverOperationData data = (DeliverOperationData) operationData;
		
		List changeSets = data.getChangeSetHandles();
		IRepositoryItemService itemService = getService(IRepositoryItemService.class);
		IChangeSetHandle[] changeSetHandles = changeSets
				.toArray(new IChangeSetHandle[changeSets.size()]);
		IItem[] items = itemService.fetchItems(changeSetHandles,
				IRepositoryItemService.COMPLETE);
		Collection componentList = new ArrayList();
		HashMap componentHandlesList = new HashMap();
		for (IItem item : items) {
			IChangeSet changeSet = (IChangeSet) item;
			IComponentHandle component = changeSet.getComponent();
			componentList.add(component);
		}



Sudaraazhi Arivalagan selected this answer as the correct answer

Comments
Sudaraazhi Arivalagan commented Jul 15 '15, 3:56 a.m.

Hi Ralph,

I was wondering how to get this from last two days.

Grateful to you !! for a favor

I am sure caring about Tagging from next time.

Thanks again.


Ralph Schoon commented Jul 15 '15, 4:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please keep in mind that I did not test the code, there might be things to check.


Sudaraazhi Arivalagan commented Jul 15 '15, 5:04 a.m.

Ok Sure. Thanks.

Your answer


Register or 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.