Java Client: Retrieve Process Definition
Hi,
I need to use Java client library to retrieve predefined process definitions. I was able to get the data, but with a strange format, like: Name: %openup_template_1 Description summary: %openup_template_2 I believe it is related to language bundle. How could I get the real message using the current local in my Java code? Thanks! -- YC Li |
5 answers
Jared Burns (4.5k●2●9)
| answered Aug 17 '09, 8:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
On Fri, 14 Aug 2009 17:07:59 +0000, yongchengli wrote:
Hi, Questions about writing code that extends Jazz should be posted to the "jazz.extend" newsgroup. The name and summary that you're seeing are the real values for those fields in the object. If you want to translate those values it is possible through the API, but it requires some work. The translated values of these fields are provided in process attachments named template.messages on the process definition. You can retrieve those attachments, read the IContents from the DB, and parse out the key/value pairs for the name and summary. There is also a non-API way to get at this information, but if you use this technique your code will only work on Jazz Foundation 1.0 (RTC 2.0). In future releases, you'll probably have to rewrite your code. The non- API way is to cast the IProcessDefinition to com.ibm.team.process.internal.common.ProcessDefinition and then call getTranslatedName(String locale) and getTranslatedSummary(String locale). Note that this method will only work for process definitions which have been fetched using the methods on IProcessItemService. If you fetch the definitions using the item manager, this non-API translation information will not be available. -- Jared Burns Jazz Process Team |
I feel like it's better to take the API approach to get the translated values of those fields. However, I have very limited knowledge and experience about the Jazz API and have difficulty figuring out how to do the following:
named template.messages on the process definition. You can retrieve those attachments, read the IContents from the DB, and parse out the key/value pairs for the name and summary. Is there any documentation I can look at to get help? Or could you provide me with some sample code of method invocation to parse out the key/value pairs? Thanks very much! YC Li On Fri, 14 Aug 2009 17:07:59 +0000, yongchengli wrote: Hi, Questions about writing code that extends Jazz should be posted to the "jazz.extend" newsgroup. The name and summary that you're seeing are the real values for those fields in the object. If you want to translate those values it is possible through the API, but it requires some work. The translated values of these fields are provided in process attachments named template.messages on the process definition. You can retrieve those attachments, read the IContents from the DB, and parse out the key/value pairs for the name and summary. There is also a non-API way to get at this information, but if you use this technique your code will only work on Jazz Foundation 1.0 (RTC 2.0). In future releases, you'll probably have to rewrite your code. The non- API way is to cast the IProcessDefinition to com.ibm.team.process.internal.common.ProcessDefinition and then call getTranslatedName(String locale) and getTranslatedSummary(String locale). Note that this method will only work for process definitions which have been fetched using the methods on IProcessItemService. If you fetch the definitions using the item manager, this non-API translation information will not be available. -- Jared Burns Jazz Process Team |
Jared Burns (4.5k●2●9)
| answered Aug 19 '09, 8:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
On Wed, 19 Aug 2009 00:07:55 +0000, yongchengli wrote:
The translated values of these fields are provided in process In the internal implementation, the Process component's client library uses an internal (non-API) service to retrieve the translated name and summary for the process definitions. You should look at how this service is implemented to see how we compute the translated values. The code is in ProcessDefinitionTranslationService.java -- Jared Burns Jazz Process Team |
Jared Burns (4.5k●2●9)
| answered Aug 24 '09, 8:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
On Mon, 24 Aug 2009 15:23:01 +0000, sstephen wrote:
Jared Burnswrote: The ProcessDefinitionTranslationService isn't API. Yongcheng asked for a code sample which shows how to translate the template name and summary, so I suggested looking at the translation service. I meant that you can use it as a reference, not that you should call it. Sorry for the confusion. -- Jared Burns Jazz Process Team |
On Wed, 19 Aug 2009 00:07:55 +0000, yongchengli wrote: The translated values of these fields are provided in process In the internal implementation, the Process component's client library uses an internal (non-API) service to retrieve the translated name and summary for the process definitions. You should look at how this service is implemented to see how we compute the translated values. The code is in ProcessDefinitionTranslationService.java -- Jared Burns Jazz Process Team Jared , thanks for the assistance so far. I attempted to work up a bit of code that used the IProcessDefinitionTranslationService as follows .. but the translationService returned from the client library is null. I'm not sure Yongcheng and I are understanding your recommendation properly. Has this service been retired ?? IProgressMonitor monitor = new NullProgressMonitor(); IProcessItemService itemService= (IProcessItemService) repo.getClientLibrary(IProcessItemService.class); IProcessDefinitionTranslationService translationService= (IProcessDefinitionTranslationService) repo.getClientLibrary(IProcessDefinitionTranslationService.class); IProcessDefinition [] definitions = null; ProcessDefinitionTranslation[] translations = null; try { List dlist = itemService.findAllProcessDefinitions(IProcessClientService.ALL_PROPERTIES, monitor); definitions = (IProcessDefinition[]) dlist.toArray(); translations = translationService.fetchWithTranslations(definitions); for (int i=0;i<translations.length;i++) { ProcessDefinitionTranslation pdt = translations; List transEntries = pdt.getInternalTranslationEntries(); for (Object object : transEntries) { TranslationEntry te = (TranslationEntry) object; System.out.println("Process locale: " + te.getLocale()); System.out.println("Process name: " + te.getName()); System.out.println("Process summary: " + te.getSummary()); } } } |
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.