It's all about the answers!

Ask a question

How to fetch component and stream name from a changeset associated to a workitem


Chandan M B (11314184) | asked Jun 29 '15, 7:55 a.m.
edited Jul 03 '15, 1:23 a.m. by Ralph Schoon (63.6k33647)
Hi,

I need to fetch component name and stream name for a change set associated to a workitem in the follow up action/server side extensions.

Any idea... ?

5 answers



permanent link
Ralph Schoon (63.6k33647) | answered Jun 29 '15, 8:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If this is a SCM delivery participant, you can probably get at the data. Start here: https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/
It is an advisor, but except that it implements the advisor, all the other code is relevant. That at least gives you the right entry point into the SCM API. I don't have more example code. You can find some other code using the SCM API on  https://rsjazz.wordpress.com/ and there is also some code on http://thescmlounge.blogspot.de/ but probably not exactly what you are looking for.


Comments
Chandan M B commented Jun 29 '15, 8:18 a.m. | edited Jun 29 '15, 8:33 a.m.

Hi,
I am using
DeliverOperationData deliverData = (DeliverOperationData) data;
It is breaking my code even though i added scm jar   
 <requiredService interface="com.ibm.team.workitem.common.IAuditableCommon" />
                              <requiredService interface="com.ibm.team.scm.common.IScmService" />   
                          <requiredService interface="com.ibm.team.process.service.IProcessServerService" />       

What could be the issue.
Regards,
Chandan


Ralph Schoon commented Jun 29 '15, 8:37 a.m. | edited Jun 29 '15, 8:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you add a JAR file of the common API to your plugin, you are doing it wrong. The Plugin only declares the dependencies. Follow the Rational Team Concert Extensions Workshop and note that there is no Jar added to the classpath.

You don't provide anything useful in your question either, that could be used to even start helping you..


Chandan M B commented Jun 29 '15, 8:41 a.m.

I corrected it. Added it to dependencies. Please have a look at my code above.
Object data = operation.getOperationData();
DeliverOperationData deliverydata = (DeliverOperationData) data;

On click of save on a workitem, which has changeset associated. It is breaking.


Ralph Schoon commented Jun 29 '15, 9:02 a.m. | edited Jun 29 '15, 9:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There is no code up there. that is a declaration in the plugin.xml. It can only harm the execution of your code if

  1. The dependency to the package with the service is not declared
  2. The service is not a service that needs to be declared that way.

I would really suggest you start providing useful information about the errors you see in your future questions, because it is just only costing time to try squeezing useful information out of them and I don't have the time to do that any more.



Chandan M B commented Jun 29 '15, 9:59 a.m.

I am doing something like this
java.lang.ClassCastException: com.ibm.team.workitem.common.internal.SaveParameter incompatible with com.ibm.team.scm.common.process.DeliverOperationData
if (data instanceof ISaveParameter) {
            saveParameter = (ISaveParameter) data;
            if (saveParameter.getAdditionalSaveParameters().contains(ICreateReviewLinkDefinitions.EXTENSION_ID)) {     return; }
      DeliverOperationData deliverydata = (DeliverOperationData) data;
  List<IChangeSetHandle> changeSetHandles-deliverydata.getChangeSetHandles();


permanent link
Saritha Yadav (134) | answered Jun 29 '15, 10:03 a.m.
Object data1 = operation.getOperationData();
DeliverOperationData deliverydata = (DeliverOperationData) data1;

I have used the above given code snippet, but facing the below given exception. Please suggest.

java.lang.ClassCastException: com.ibm.team.workitem.common.internal.SaveParameter incompatible with com.ibm.team.scm.common.process.DeliverOperationData



Comments
Ralph Schoon commented Jun 29 '15, 10:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If this question is not related to the one above, please create your own question.


Ralph Schoon commented Jun 29 '15, 10:26 a.m. | edited Jun 29 '15, 10:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you don't know what a ClassCast Exception is and how the extension mechanisms work and how you can debug them, start here:

Rational Team Concert Extensions Workshop

This is what Google tells you about the exception: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassCastException.html

Use the debugger and the information below to understand what the data1 object is and how you can use it.

https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/  shows SCM related operations.

Use the debugger to find out what your class really is and the examples above what you should do with it.


permanent link
Saritha Yadav (134) | answered Jun 30 '15, 2:55 a.m.
edited Jun 30 '15, 2:57 a.m.
currently, we have the below given existing method which accepts IParticipantInfoCollector as one of the arguments.

public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException {
       
        System.out.println("Welcome to DXA ALM Server side Plugin");
        Object data = operation.getOperationData();
        ISaveParameter saveParameter = null;
}

but for the DeliverOperationData, one of the argument is mismatching - which is IAdvisorInfoCollector how can we make both the methods compatible? please suggest.

public void run(AdvisableOperation operation,
            IProcessConfigurationElement advisorConfiguration,
            IAdvisorInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException {
        Object operationData = operation.getOperationData();
       
        DeliverOperationData data = (DeliverOperationData) operationData;
    }

Comments
Ralph Schoon commented Jun 30 '15, 3:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

An advisor/pre-condition looks like this:
public class SCMDeliveryAdvisor extends AbstractScmService
        implements IOperationAdvisor {
or this
public class WorkItemSaveAdvisor extends AbstractService implements
        IOperationAdvisor {

a participant/follow up action

public class WorkItemSaveParticipant extends AbstractService implements
        IOperationParticipant {

or

public class SCMDeliveryParticipant extends AbstractScmService implements
        IOperationParticipant {

They get slightly different objects and return different results.


permanent link
Saritha Yadav (134) | answered Jun 30 '15, 4:05 a.m.
How to fetch DeliverOperationData reference inside AbstractService class. Can you please tell me if is there any way to fetch this DeliverOperationData in my user defined class.

Comments
Ralph Schoon commented Jun 30 '15, 4:24 a.m. | edited Jun 30 '15, 4:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There are many examples available. Including the other links in my answers above. Here are more:
https://rsjazz.wordpress.com/?s=advisor
https://rsjazz.wordpress.com/?s=participant

If you are unwilling or unable to read and work through these examples, nobody will be able to help you. I will certainly not write the extension you desire, piecemeal, on this question.

Finally, please note that you will most certainly not be able to find the stream if you use a work item save advisor/participant. Only a SCM change set delivery advisor/participant will be able to access the stream as context the operation is executed in. A changeset can be in many streams. If you don't have the deliver context, there is no correct answer you would be able to determine.

Good luck.


Chandan M B commented Jun 30 '15, 4:48 a.m.

Thanks for the information above.

We are currently using IOperationParticipant to get the attributes of a workitem.
For the changeset details i need to use IOperationAdvisor when i was going through one of your examples.

I think this is the problem me and Saritha are currently facing. We are not able to use IOperationAdvisor since we have already used IOperationParticipant.

How to proceed further now... ?


permanent link
lene borma (11) | answered Dec 03 '19, 12:11 a.m.

 The ClassCastException thrown to indicate that your code has attempted to cast an object to a subclass of which it is not an instance.  Casting only works when the casted object follows an is a relationship to the type you are trying to cast to.


When will be ClassCastException is thrown:

  • When you try to cast an object of Parent class to its Child class type, this exception will be thrown.
  • When you try to cast an object of one class into another class type that has not extended the other class or they don't have any relationship between them.



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.