It's all about the answers!

Ask a question

How to serch files ChangeSet with the same name under separate parent folders in SCM


Kodac Hasubo (365) | asked Apr 03 '22, 12:36 a.m.
edited Apr 03 '22, 11:38 a.m. by David Lafreniere (4.8k7)
(I am posting a fileto SCM by  EWM SDK or the Plain Java API)

 There are two different folders under the same Stream and the same component. 

Within the two folders, there is a file with the same name. 
I want to search for the ChangeSet of "text.txt" files under the "fileA" folder. 
However, the ChangeSet of "text.txt" under the "fileB" folder is also searched. 
I want to specify the name of the parent folder in the search criteria. 

How can I specify a parent folder name?


Below is the source code to search for changesets.

IChangeSetSearchCriteria searchCriteria = IChangeSetSearchCriteria.FACTORY.newInstance();
searchCriteria.setContext(myStream.getContextHandle());
searchCriteria.setComponent(targetComponentHandle);

if (modifierHandleInCondition != null ) {searchCriteria.setAuthor(modifierHandleInCondition); }
if (searchCondition.fileNameStr != null ) {searchCriteria.setName(searchCondition.fileNameStr); }
List<IChangeSetHandle> changeSetHandleList =  wsm.findChangeSets(searchCriteria, searchItemNumberLimit, progressMonitor);

Accepted answer


permanent link
David Lafreniere (4.8k7) | answered Apr 03 '22, 11:38 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 03 '22, 11:40 a.m.

The IChangeSetSearchCriteria (and IChangeSetPropertiesSearchCriteria [which it also extends]) does not support additional filtering by the parent folder of a modified file.

I would suggest if you can track down the itemID (UUID) of the file (IVersionable) you are trying to find, then instead of using searchCriteria.setName() you would instead use: searchCriteria.setItem(IVersionableHandle value).

.. and here is how you build up the item to pass in:
String fileItemIdString = "TODO"; // This is the UUID / itemId of the file
IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItemHandle(fileItemIdString , null);

Otherwise if you don't track down the itemId (UUID) of the file you are looking for, and are instead just searching by file Name (which could match files in 'any' folder in the component), then for each IChangeSetHandle you get back, you would then need to fetch the full IChangeSets (do this in bulk though), then iterate across the changes  in each change set (represented as IChange objects) (which could be changes to other files and folders) until you find the file with the name you were looking for, then you'd have to calculate the remote file path in order to determine it's the one you want (or if you had the parent folder UUID, you can just check that, which would be faster).. Note: I am saying you'd have to figure out the full remote path (up to the component root), because in your example above, you could get results in which text.txt is in "<component_root>/randomDir/randomDir/fileA/fileA.txt" (and so if you just checked the parent folder name, which would be 'fileA' in this case you may think you found the right file, but it might not be, because the expected parent folder is actually nested in some other unexpected parent folder

Kodac Hasubo selected this answer as the correct answer

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.