Wednesday, September 6, 2006

Making the relationship between OSVD objects

I wasted way too much time trying to figure this out, so I thought I would try to save others from doing the same. OVSD has a webapi available for Java. The api is quite nice. One thing that was not obvious to me at first, but kind of makes sense in the end is how to make relationships between objects. Let's assume you are creating a service call. The service call has a relationship to an assignment which as a relationship to a workgroup. Long templateID = 12345l; // note the lowercase L at the end to designate a LONG. IServicecall sc = ServiceCallHome().openNewServicecall(templateID); The first lesson is that you cannot create the assignment directly. You must call the getAssignment() method on the service call; it creates it for you. IAssignment ia = sc.getAssignment(); The next thing we do is make the relationship to the to-workgroup by calling the the setAssWorkgroup() on the assignment object. ia.setAssWorkgroup(GetServiceDesk1stLineWorkgroup()); The second lesson comes when trying to save changes. In OVSD webapi related objects don't use a save method. Instead they have a transfer() method that does some magic, but is basically the same as a save on a child/related object. ia.transfer(); Finally, call save() on the service call to save all changes to database. sc.save();

4 comments:

LeandroTakeda said...

Hi, nice to meet you first.
I'm Leandro from Brazil.
I had a chance to work with Hp OpenView Service Desk and I would like to construct some tools to work with OVSD.
Do you have maybe any documentation about the WEB-API? Or maybe examples?

Thanks
Leandro Takeda
letakeda@gmail.com

Brent V said...

Hi Leandro,

I don't really have any examples other than the examples or documentation other what comes with the HP OpenView itself.

With that said, if you have the HP OpenView CD you will see there is a doc directory. In there you will find Web_API_pg.pdf. I highly recommend you read this. It explains how the web-api works and what objects are available. There are also java docs in that same directory. They are not very useful in my opinion. They tend to have very useless comments if any comments at all.


As far as examples, I recommend the Api\examples directory on the CD. It has 8 examples. If you get the patches, they also contain an example 9 I believe.

Also, if you have not figured it out already you cannot program against OVSD except with web-api.jar. Be sure to use the one that is the same service pack as what is on your server. All your code will be in Java and will use the objects in the web-api.jar for all communications with OVSD. Also, even though it is called a web-api.jar it really has nothing to do with the web. You can right desktop applications with it just the same.

burrito said...

Hi, I'm finding some of these blog posts very interesting - I wish I'd found a couple of them earlier as I've just spent a few days hacking up a sort-of web service using the web-api.
I'm interested in hearing about how you go about finding which API calls are used for the various custom fields. We have quite a few custom fields, and I have been able to divine most of them from the admin console->custom fields, there are one or two which elude me. Is there a smarter or easier way to find what I want? (I've also looked at some of the database views and tables for clues, and trawled through the javadoc looking at all functions with what looks like an appropriate return type)

regards,
Brett McBride
brett@deakin.edu.au

Brent V said...

Hi Brett,

Sorry for the very long delay in responding. The short answer is you are looking at the right places it sounds like.

Before I figured out where to find all the fields in the admin console, I just went through every field in service call for example. I did this using reflection (for the most part) so it was not so bad. I then set a value I could identify when I looked at the UI.

I use this technique for debugging when I can't figure out why I don't see a value in the UI.

It is not perfect, but it is helpful. Once I figured it all out, I took a screenshot of the UI and then added what the programmatic fields were using a paint program to edit the image. I find that to be very helpful.