It's all about the answers!

Ask a question

Setting absences using the Server Side API


Francisco Rodriguez (561328) | asked Jul 23 '14, 5:52 p.m.
 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.


Comments
sam detweiler commented Jul 23 '14, 7:27 p.m.

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.


Francisco Rodriguez commented Jul 23 '14, 8:38 p.m.
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? 


sam detweiler commented Jul 23 '14, 8:45 p.m.

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


Jonas Studer commented Jul 24 '14, 5:35 a.m.

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?


Francisco Rodriguez commented Jul 24 '14, 12:08 p.m.

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


sam detweiler commented Jul 24 '14, 12:30 p.m. | edited Jul 24 '14, 12:30 p.m.

@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
Ralph Schoon (63.1k33646) | answered Jul 24 '14, 5:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

Comments
sam detweiler commented Jul 24 '14, 9:04 a.m.

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>


Ralph Schoon commented Jul 24 '14, 9:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


sam detweiler commented Jul 24 '14, 10:03 a.m. | edited Jul 24 '14, 10:53 a.m.

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
 


Ralph Schoon commented Jul 24 '14, 11:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Jul 24 '14, 11:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Attached a screenshot



sam detweiler commented Jul 24 '14, 11:13 a.m.

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..



Francisco Rodriguez commented Jul 24 '14, 11:36 a.m.

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


Ralph Schoon commented Jul 24 '14, 11:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


sam detweiler commented Jul 24 '14, 11:59 a.m.

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..


Francisco Rodriguez commented Jul 24 '14, 1:22 p.m.
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.

Francisco Rodriguez commented Jul 24 '14, 2:40 p.m.

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
Ralph Schoon (63.1k33646) | answered Jul 24 '14, 3:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 24 '14, 3:53 a.m.
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.

Comments
Jonas Studer commented Jul 24 '14, 4:33 a.m.

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 ;)


Ralph Schoon commented Jul 24 '14, 4:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Jonas Studer commented Jul 24 '14, 5:20 a.m.

Hey Ralph,

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


Ralph Schoon commented Jul 24 '14, 5:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Jonas,

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


Jonas Studer commented Jul 24 '14, 5:47 a.m.

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


Jonas Studer commented Jul 24 '14, 10:58 a.m.

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


Ralph Schoon commented Jul 24 '14, 11:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
Jonas Studer (207917) | answered Jul 24 '14, 5:07 a.m.
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.


Comments
Ralph Schoon commented Jul 24 '14, 5:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Good catch.

This is however a client interface that you are using.


Jonas Studer commented Jul 24 '14, 5:50 a.m.

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 ;)


Francisco Rodriguez commented Jul 24 '14, 11:39 a.m.

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


Jonas Studer commented Jul 25 '14, 3:59 a.m.

@Francisco,

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

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.