I want to programmatically create Jazz Source Control User properties using Java API
Richard Good (87●28●61)
| asked Aug 14 '14, 1:51 p.m.
edited Aug 20 '14, 4:52 p.m. by Stephanie Taylor (241●1●5) Hello, I am migrating file revisions into RTC from a differrent change control system. There needs to be a file revision property on each repository file such that we can check it against the files changed for the work items I will also be migrating. I can programmatically extract the necessary property from the metadata in the previous tool, but can see no obvious way of adding this data as a Jazz Source Control User Property automatically. Please help... Cheers, Richard |
3 answers
Geoffrey Clemm (30.1k●3●30●35)
| answered Aug 14 '14, 5:21 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can use the scm command line "set property" command. See:
https://www-01.ibm.com/support/knowledgecenter/SSCP65_4.0.6/com.ibm.team.scm.doc/topics/set_property.html?cp=SSCP65_4.0.6&lang=en Comments Hi Geoff, Thank you for the tip. This would be fine for changing one file, but I will be changing thousands. I was imagining I would have to use the Java API. I want to achieve the following 1) I will have created a Stream and a component manuallly int RTC to start 2) I will have a directory of files replete with the other tools metadata to import 3) I will have a form to take the repository uri, stream name, component name and directory to export 4) On pressing Go on the form I will add all the files in the directory to RTC and add one or more properties pertaining to the previous change control tool at the same time. Can I do all this by piping commands to scm? I am already having to write a java application for migrating work items, some of the code can be reused for this utlity, there looks like there is an scm package in the Java API, can I deliver the files, replete with my properties using this - if so can you point me at an example? It is possible to work from the java docs, but a lot more efficient to massage an example into a new tool. Cheers, Richard
|
Ralph Schoon (63.3k●3●36●46)
| answered Aug 15 '14, 5:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Richard,
If possible, use the SCM commandline as suggested by Geoff. If not, please see https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/ for hints on the Java SCM API. This code should allow you to set user properties. IFileItem fileWorkingCopy = (IFileItem) aFile.getWorkingCopy(); fileWorkingCopy.setContent(storedzipContent); fileWorkingCopy.setUserProperty("MyProperty", "MyValue"); fWorkspace.commit(fChangeSet, Collections .singletonList(fWorkspace.configurationOpFactory() .save(fileWorkingCopy)), fMonitor); Comments Thanks Ralph, thats exactly the kind of example I am after. I will take that and the code in your referenced blog and have a play. However, as you imply I think things might be more resilient/simpler if my application creates a batch file of scm commands, rather than do this with the java api, not absolutely sure the following will work, but looks promising. Anything wrong with the technique/ am I missing something. I'll try the scm thing first and go back to java api if I find it impossible.
API automation is more expensive than using available tools like SM command line. And it is more complex to use. It depends on the situation and if you already run a Java program to export the data.
Hi Ralph, I used your very helpful article on importing work items and attachments to create a method to import work items into RTC in very short order. I couldn't just use the Eclipse Import csv function because the tool we are migrating from uses the rtf format so I needed to attach some fields as files. So its not as if I am unfamiliar with battling with java, what put me off using your uploading archive code is the use of encoding and encryption and need to use bytestreams. I am not sure why this was necessary. I want all files to be uploaded just as they are on the filesystem I don't want to inadvertantly change them on import. Is there not an alternative command to commit a file as is? I imagine scm must work out what to do by looking at the file? Richard, basically encoding is necessary. The RTC Eclipse client will use the specified encoding, the SCM commandline as well. I think the encoding is needed to be able to compare/merge the files. In the SCM commandline, I am not sure where the default encoding comes from. there is a .magic file. Maybe that.
Richard, I've cleaned up your posts. Please reply to answers instead of creating a new one so that others may follow the conversation thread. This will help others that are trying to find an answer.
Richard Good
commented Aug 15 '14, 8:09 a.m.
Fair enough - I just typed in the big open box, not used this forum before ;-) For the java api answer. I don't quite understand how to scroll through each and every file in the workspace to add the metadata. Can someone please explain how to do this? Reason for this is that the SCM method is just incredibly slow even after substantial effort to speed it up it still takes a couple of hours to apply the metadata for 7000 files.
showing 5 of 7
show 2 more comments
|
Still having an issue getting hold of all the files in a sandbox so I can write loads of file propeties using the java API, Need to cast my files to something that resembles an IFileItem so I can add metadata to each - a pointer would be appreciated! Looked at the snippets and a couple of blog articles, missing an obvious trick I expect. Cheers Richard |
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.