It's all about the answers!

Ask a question

Java Client: Retrieve Process Definition


Yongcheng Li (311110) | asked Aug 14 '09, 1:00 p.m.
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



permanent link
Jared Burns (4.5k29) | 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,

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

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

permanent link
Yongcheng Li (311110) | answered Aug 18 '09, 7:59 p.m.
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:

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.


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,

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

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

permanent link
Jared Burns (4.5k29) | 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
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.

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?

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

permanent link
Jared Burns (4.5k29) | 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:
On Wed, 19 Aug 2009 00:07:55 +0000, yongchengli wrote:
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.

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?

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

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

permanent link
Stephen Schmidt (1142) | answered Aug 24 '09, 11:17 a.m.
On Wed, 19 Aug 2009 00:07:55 +0000, yongchengli wrote:
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.

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?

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


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.