How to fetch component and stream name from a changeset associated to a workitem
5 answers
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
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
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..
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.
There is no code up there. that is a declaration in the plugin.xml. It can only harm the execution of your code if
- The dependency to the package with the service is not declared
- 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.
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();
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
If this question is not related to the one above, please create your own question.
If you don't know what a ClassCast Exception is and how the extension mechanisms work and how you can debug them, start here:
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.
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
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.
Comments
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.
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... ?
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 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.