Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Setting absences using the Server Side API

 Hi all,

Is there a way to set an absence using the Server Side API? It is surely possible to achieve this using some internal client libraries but it seems that this cannot be done by the Server API  .

I´ve already read this:
https://jazz.net/forum/questions/37634/accessing-the-time-zone-of-usercontributor-of-a-work-item

This:
https://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/

And this:
https://jazz.net/forum/questions/103798/is-there-any-solutions-for-saving-or-getting-users-absence-information-using-api-of-server-side-rtc

And quite a lot more so I would really appreciate your help or guidance.

Thanks in advance,
Francisco R.

0 votes

Comments

I don't know.. as u can manage this from the Web UI  there IS a server side api. but much of the server api is not yet published.

by looking thru the source in the SDK you can get close pretty quickly.
the packaging model here is

client
common
service

client & common go on the client
common and service go on the server.

the classes u want are in the com\ibm\team\apt\api\common\rm package in the com.ibm.team.apt.api.common.jar

com.ibm.team.apt.service.... far contains the com\ibm\team\apt\internal\service\resource\ResourcePlanningService  class
which has a method
public IContributorResourceDetails saveResourceDetails(final IContributorResourceDetails workingCopy)

which seems close to the qst link.

Thanks, Sam. I can now see the classes you mentioned. 

I have another question. Let's see if you can help me. Currently, the absences can only be set by the users with JazzAdmins privileges, but we need users with JazzUsers privileges and specific roles can also set the absences through the Web UI or the Eclipse UI. Do you think this can be achieved with a plugin extension developed using the Server API? 

Unlikely. I haven't found a way around the permissions system. 

Do it with OSLC. Then permission isn't a problem anymore!
But this is also pretty dangerous to avoid the OAuth!

Hmmm, but as far as I know, each contributor should be able to manage it's own absences. Or you wanna have full access?

Yes, each contributor is able to manage its own absences. But we want the behavior that I commented before.

@Jonas, you have to authenticate to use OSLC  too. so, no change

Today Sue's manager Bob cannot manage her absences unless he is JazzAdmin.
if she has an accident or falls ill, Bob must contact someone else (who doesn't need to know any of this)  just to manage this data.

showing 5 of 6 show 1 more comments

Accepted answer

Permanent link
I found a way from AbstractService, to at least get at the data.
You can get the handle for IContributorRecord which is a class that provides all the data, including the details, which include the absences. This might be another way through the server API.
Francisco Rodriguez selected this answer as the correct answer

0 votes

Comments

there is a service..

from com.ibm.team.apt.service.????.jar

     <serviceProvider
           componentId="com.ibm.team.apt.resource"
           implementationClass="com.ibm.team.apt.internal.service.resource.ResourcePlanningService">
        <provides>
           <providedService
                 interface="com.ibm.team.apt.common.resource.IResourcePlanningService">
           </providedService></provides>

Interesting. I wasn't able to find it in the SDK.. Probably because I didnot have the dependent plugin? I dummy.

eh?  sorry,  didn't understand that.

what  I did from yesterday,
the client class is com.ibm.team.apt.internal.client.resource.ResourcePlanningClient:
ths took me to the source in the sdk, where I found the matching service method I listed. 

lack of clarity lead to the stream of notes overnight.

so I looked in the sdk/plugins folder for a similar 'service' jar. and found one.
then I looked in the plugin.xml in that jar, and found a service which pre-reqs a similarly named service.
                <requiredService interface="com.ibm.team.apt.common.resource.IResourcePlanningService"/>

then I looked for the definition of said service. and found the info on my prior post.
which took me back to the same class I had previously found. (service defines class and interface)
(and as it is USED by other services, its pretty sticky, and unlikely to go away)
which when properly connected in my plugin, provides these methods via eclipse
 

What I am saying is: once I create a new plug-in project, added all com.ibm. plugins as dependency and then did a JavaSearch for 'ResourcePlanning', Type, All Occurrences

It found the service class right away. I did not have to dig into any plugin.XML.

When I did that in a project that did NOT have all dependencies, somehow, the class was not found searching the SDK, which led me to believe it would not exist.

Attached a screenshot


k.. my mind doesn't work that way, I can't try to search the catalog for something I 'think' might be there without any clue of the name construct..


That is right, Sam. That service provides some helpful methods.

A general pattern is that client API is called com.ibm.......SomeNameClient and the server API is com.ibm.......SomeNameService

right.. but this only works, as you've noted, if you have all the right dependencies setup.. (if I KNEW what I needed, why was I searching?!)..  sorry, again, my mind has some blockage here..

Ralph,

This service (IResourcePlanningService) and its methods will definitely help me to set absences somehow, but they are useless if the user does not have a JazzAdmins privilege. Do you think it is possible to save the absence with this privilege no matter the current user has JazzUsers role?

Thanks in advance,
Francisco R.

I think Sam's answer should be marked as the accepted one. The question above is now posted in the next link:



Thanks!

showing 5 of 11 show 6 more comments

2 other answers

Permanent link
The only API I am aware of is described here: http://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/

If you look for references to any of the classes used or for "ResourcePlanning" you will notice that there are only references to com.ibm.apt.*.common and com.ibm.apt.*.client and that there is no service (at least I could find) for this.

Common api is for client and server, however, all I was able to find are the resource model classes. No common service.

If you find something, let me know.

@Sam, as far as I know, the WebUI uses the client API.

0 votes

Comments

Hy Ralph,

As I guess from my experience I don't think that the WebUI uses the client API.
Just compare the "ProcessClient" of them to see there's a difference.
Maybe I'm mixing something so don't be mad at me ;)

As I am not completely sure how this works, I could not be mad at you anyway. 8D

However, I am unable to find a service for the scheduled absences - at least in the SDK. All I can see is the client library and the common API. This could well be just a left over from the times this was done in the Eclipse UI. Not sure how the WebUI accesses it. There could be a rest service. This might be a case where someone would have to trace the communication from the browser.

Hey Ralph,

Why don't I get notifications when you comment?
Can I change that?

Jonas,

you should. I am not sure what is going on. I get notifications, but it takes some time.

Now it works again?!?!
Problem solved :D

Hey Ralph,

I've got a plain Widget Class where I described the Methods which fires automatically.
So if you wanna have it (or better improve it), give me your mail.
Then you can upload it to your blog.

Greetings

Jonas,

mail is ralph.schoon@de.ibm.com. Feel free to send it. But I never blog about stuff I don't understand. So I would likely need to look into it first and maybe ask back. I am a HTML/JavaScript dummy.

showing 5 of 7 show 2 more comments

Permanent link
Hy Francisco,

I've found out how you can do it with the ServerSide API.
Hopefully I didn't  meant something different.
But here's my solution:

First you have to require the needed Class:
dojo.require("com.ibm.team.apt.web.client.internal.ResourcePlanningClient");

If you wanna see the class watch it here:
"installs\rtc-sdk\plugins\com.ibm.team.apt.web.client_3.0.800.v20131025_0417\resources\internal"
In RTC 4.0.5
There you can see the different parameters you could use.

So on... you have to set up a serviceResponseHandler.

var serviceObjectSprints = {
          self: this, //This you don't really need. But in this way you could iteract with the viewlet [this.self.test()]
          success: function(page) {
          },
          failure: function (error) {
          }
}
var srh = new ServiceResponseHandler(serviceObjectSprints, "success", "failure");
var args = {
       addedAbsences: { "description": "nameOfAbsence",
                                     "startDate": "ISO String",
                                     "endDate": " 2014-07-24T00:00:00+02:00" //This is an ISO-String
                  },
       contributorId: //The ID of the user you wanna add the absence
};

ResourcePlanningClient.postAbsences(srh, args);

To be honest, I didn't tryed it out.... but this is the key ;)
If it won't work, I gonna try it for you if you want.

0 votes

Comments

Good catch.

This is however a client interface that you are using.

Yeah,
Due to my reverse engineering I just get client interfaces.

I just went to the absences and watched the NET Panel.
This is how I got to my solution ;)

Thank you, Ralph and Jonas. I'm going to try the different approaches posted here and I'll let you know my results. 

@Francisco,

Ou.. . I forgot to mention that I work with.
Javascript and Dojo. So please don't get baffled

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Jul 23 '14, 5:52 p.m.

Question was seen: 4,079 times

Last updated: Jul 25 '14, 3:59 a.m.

Confirmation Cancel Confirm