Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Jose Marcelo Fascio Absent Member.
Absent Member.
2475 views

How to get all Change Request of a User, in all projects?

Jump to solution

Hi,

Is it possible to somehow get all Change Request items assigned to a given user, for all server projects? And for a specific project (assuming that if it cannot be done for all projects at the same time, I'll have to populate the list project by project)?

I'm a very newbie on SDK, so if you could provide me with some sample code, I'll be much appreciated! 😃

Thanks!

J.Marcelo

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

RE: How to get all Change Request of a User, in all projects?

Jump to solution

No, it's not possible to get ChangeReqests across all projects.

StarTeam follows a container driven architecture.

The server contains projects.

Projects contain views.

Views contain folders.

Folders contain Items, including files, change requests, tasks, etc.

You can query a view for all it's change requests, but bear in mind that a projects can contain multiple views.

so, here's some brute force pseudo-code, based on the com.starteam namespace of the 14.0.3.23 java SDK (the latest public release).

If you aren't on this build, I'd recommend upgrading - you can download it from microfocus supportline.

Server s = new Server("host", port);

s.logon("user", "password");

ChangeRequest.Type crTyp = s.getTypes().CHANGE_REQUEST;

PropertyCollection pc = new PropertyCollection();

pc.add(crType.getProperties().find(ChangeRequest.Type.ResponsibilityProperty.NAME);

for each (Project p in s.getProjects()) {

 for each (View v in p.getViews()) {

    ViewMemberCollection vmc = v.getViewMembers(s.getTypes().CHANGE_REQUEST);

    vmc.getCache().populate(pc);

   ChangeRequest[] cc = (ChangeRequest[])vmc.toArray(new ChangeRequest[0]));

   for each (ChangeRequest cr in cc) {

     // find the cr's assigned to a particular user and do something with them

     if (cr.getResponsibility().getName().equals("the responsible user i want"))

       // do something

   }

  v.close();

 }

}

s.disconnect();

As indicated, this is the brute force or heavy handed approach.

This code will open each project on the server, load all cr's in each view, then release them when done.

(a non-programming equivalent to this would be the use of the command line )

java -jar stcmdex.jar select * from change-request where responsibility = "The responsible user i want" -p "user:password@host:port/projectname/viewname"

possibly driven via a batch script which identifies project names using list-projects & view names using list-views.

A lightweight approach involves using the lightweight listener event interface, register for all events for all projects & views across the server, then wait for events to come over, and process the interesting ones.

This approach typically fits a back office service model, where a constantly running process simply processes lightweight events as they come over, without necessarily loading data on the server or in the client.

Yet another approach is to use the out of the box notification agent service (a StarTeam product) and register for notifications for all projects and views.

>>I'm a very newbie on SDK

I'd suggest rectifying this as quickly as you can. 🙂

There's a trove of information on this forum and the associated wiki pages,

including zipped up javadoc for download, a few samples, the source code of the SDK test suite,

and several SDK topics of interest.

I hope this all helps.

View solution in original post

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: How to get all Change Request of a User, in all projects?

Jump to solution

No, it's not possible to get ChangeReqests across all projects.

StarTeam follows a container driven architecture.

The server contains projects.

Projects contain views.

Views contain folders.

Folders contain Items, including files, change requests, tasks, etc.

You can query a view for all it's change requests, but bear in mind that a projects can contain multiple views.

so, here's some brute force pseudo-code, based on the com.starteam namespace of the 14.0.3.23 java SDK (the latest public release).

If you aren't on this build, I'd recommend upgrading - you can download it from microfocus supportline.

Server s = new Server("host", port);

s.logon("user", "password");

ChangeRequest.Type crTyp = s.getTypes().CHANGE_REQUEST;

PropertyCollection pc = new PropertyCollection();

pc.add(crType.getProperties().find(ChangeRequest.Type.ResponsibilityProperty.NAME);

for each (Project p in s.getProjects()) {

 for each (View v in p.getViews()) {

    ViewMemberCollection vmc = v.getViewMembers(s.getTypes().CHANGE_REQUEST);

    vmc.getCache().populate(pc);

   ChangeRequest[] cc = (ChangeRequest[])vmc.toArray(new ChangeRequest[0]));

   for each (ChangeRequest cr in cc) {

     // find the cr's assigned to a particular user and do something with them

     if (cr.getResponsibility().getName().equals("the responsible user i want"))

       // do something

   }

  v.close();

 }

}

s.disconnect();

As indicated, this is the brute force or heavy handed approach.

This code will open each project on the server, load all cr's in each view, then release them when done.

(a non-programming equivalent to this would be the use of the command line )

java -jar stcmdex.jar select * from change-request where responsibility = "The responsible user i want" -p "user:password@host:port/projectname/viewname"

possibly driven via a batch script which identifies project names using list-projects & view names using list-views.

A lightweight approach involves using the lightweight listener event interface, register for all events for all projects & views across the server, then wait for events to come over, and process the interesting ones.

This approach typically fits a back office service model, where a constantly running process simply processes lightweight events as they come over, without necessarily loading data on the server or in the client.

Yet another approach is to use the out of the box notification agent service (a StarTeam product) and register for notifications for all projects and views.

>>I'm a very newbie on SDK

I'd suggest rectifying this as quickly as you can. 🙂

There's a trove of information on this forum and the associated wiki pages,

including zipped up javadoc for download, a few samples, the source code of the SDK test suite,

and several SDK topics of interest.

I hope this all helps.

View solution in original post

0 Likes
Highlighted
Jose Marcelo Fascio Absent Member.
Absent Member.

RE: How to get all Change Request of a User, in all projects?

Jump to solution

Thank you very much Anil, this all helped me a LOT! 🙂

I'll also try the lightweight approach, using the listener event interface you mentioned.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.