On delivery of changeset, how to retrieve component list under a stream via changeset?
Accepted answer
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
Get the components from the delivered change sets - not all, but only the ones we deliver to
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);
}