Get process configuration source via API
Hello Everyone,
I was trying below to get the process configuration source -
On the client:
1. Get the client library IProcessClientService.
ITeamRepository#getClientLibrary(IProcessClientService.class)
2. From this, get the client process for the project area in question.
IProcessClientService#getClientProcess(...)
3. Get the config data from the client process.
IClientProcess#getProjectConfigurationData(...)
1. Get the client library IProcessClientService.
ITeamRepository#getClientLibrary(IProcessClientService.class)
2. From this, get the client process for the project area in question.
IProcessClientService#getClientProcess(...)
3. Get the config data from the client process.
IClientProcess#getProjectConfigurationData(...)
Looks like the getProjectConfigurationData method requires a string ID. I tried "com.ibm.team.process". No luck. Any idea what it should be?
Thanks
Sunil
4 answers
Hi Sunil,
This post might get you started: https://jazz.net/forum/questions/7229/modify-teamconfiguration-in-a-projectarea
This post might get you started: https://jazz.net/forum/questions/7229/modify-teamconfiguration-in-a-projectarea
the key string is
found by exported item
com.ibm.team.process.common.ProcessContentKeys.PROCESS_SPECIFICATION_KEY;
see
https://jazz.net/forum/questions/81132/why-is-iprojectareagetprocessdata-finding-multiple-process-xml-source-objects-for-a-project-area-v-40
found by exported item
com.ibm.team.process.common.ProcessContentKeys.PROCESS_SPECIFICATION_KEY;
see
https://jazz.net/forum/questions/81132/why-is-iprojectareagetprocessdata-finding-multiple-process-xml-source-objects-for-a-project-area-v-40
get the icontent object, and then call save
<code>
IProjectArea parentProject = (IProjectArea) (repo
.itemManager().fetchCompleteItem(iparenthandle,
IItemManager.DEFAULT, sPm));
System.out.println("have parent project name = "
+ parentProject.getName());
// get the process data
@SuppressWarnings("unchecked")
Map<String, Object> pd = ip.getProcessData();
//// here is the xml extract
// get the process config content object
IContent processSource = (IContent) pd.get(keyname);
if (processSource != null)
{
System.out.println("have xml source");
saveXMLSource(ip, processSource, icm, sPm);
}
</code>
then save the source
<code>
// save the process source for the project
private static void saveXMLSource(IProjectArea ip, IContent ic,
IContentManager icm, SysoutProgressMonitor sPm)
{
// make an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// get the content of the content object.
try
{
icm.retrieveContent(ic, os, sPm);
// write xml content to file
// project name + data name
FileOutputStream fo = new FileOutputStream(ip.getName() + "."
+ keyname);
// write
fo.write(os.toString().getBytes(), 0, os.toString().length());
// close
fo.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
</code>
<code>
IProjectArea parentProject = (IProjectArea) (repo
.itemManager().fetchCompleteItem(iparenthandle,
IItemManager.DEFAULT, sPm));
System.out.println("have parent project name = "
+ parentProject.getName());
// get the process data
@SuppressWarnings("unchecked")
Map<String, Object> pd = ip.getProcessData();
//// here is the xml extract
// get the process config content object
IContent processSource = (IContent) pd.get(keyname);
if (processSource != null)
{
System.out.println("have xml source");
saveXMLSource(ip, processSource, icm, sPm);
}
</code>
then save the source
<code>
// save the process source for the project
private static void saveXMLSource(IProjectArea ip, IContent ic,
IContentManager icm, SysoutProgressMonitor sPm)
{
// make an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// get the content of the content object.
try
{
icm.retrieveContent(ic, os, sPm);
// write xml content to file
// project name + data name
FileOutputStream fo = new FileOutputStream(ip.getName() + "."
+ keyname);
// write
fo.write(os.toString().getBytes(), 0, os.toString().length());
// close
fo.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
</code>
the Monitor part of the apis is a class object, I made my own to be able to control the output
<code>
import org.eclipse.core.runtime.*;
public class SysoutProgressMonitor implements IProgressMonitor {
}
</code>
then added all the required methods.
the Content Manager is accessible thru the repository object after logon
<code>
// login &
// get the repository object where we are connecting
if ((repo=login(url, userid, password, sPm)) != null )
{
// get the content Manager
IContentManager icm = repo.contentManager();
</code>
<code>
import org.eclipse.core.runtime.*;
public class SysoutProgressMonitor implements IProgressMonitor {
}
</code>
then added all the required methods.
the Content Manager is accessible thru the repository object after logon
<code>
// login &
// get the repository object where we are connecting
if ((repo=login(url, userid, password, sPm)) != null )
{
// get the content Manager
IContentManager icm = repo.contentManager();
</code>