It's all about the answers!

Ask a question

how to get the timecodeId


Li Li (1518) | asked May 29 '16, 10:19 p.m.
Hello,
   How can I get  the corresponding relationship between timecodeId and timecodeName through the URL,just like I can get  the corresponding relationship between the enumerationID of  severity and enumerationName of severity through the URL"https://localhost:9443/ccm/oslc/enumerations/_NK97OTIPEeKNFJMqNw8Q4w/severity"("NK97OTIPEeKNFJMqNw8Q4w" is the ID of the ProjectArea)

Accepted answer


permanent link
Ralph Schoon (63.3k33646) | answered May 30 '16, 2:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 30 '16, 2:40 a.m.
OSLC, all I have is: https://jazz.net/wiki/bin/view/Main/OSLCAccessForTimesheetEntry


In the Java API (in the downloadable code https://rsjazz.wordpress.com/2015/03/31/the-work-item-time-tracking-api/ ):

    /**
     * Get the time code identifier from the name
     *
     * @param timeCodeName
     * @return
     * @throws TeamRepositoryException
     */
    private ITimeCode calculateTimeCode(String timeCodeName)
            throws TeamRepositoryException {
        // Find the time code
        ITimeCode timeCodeToSet = null;
        List<ITimeCode> timeCodes = getWorkItemCommon().getTimeCodes(
                getWorkItem().getProjectArea());
        for (ITimeCode aTimeCode : timeCodes) {
            if (aTimeCode.getTimeCodeLabel().equals(timeCodeName)) {
                timeCodeToSet = aTimeCode;
                break;
            }
        }
        if (timeCodeToSet == null) {
            throw new TeamRepositoryException("Timecode not found: "
                    + timeCodeName);
        }
        return timeCodeToSet;
    }

Li Li selected this answer as the correct answer

One other answer



permanent link
Li Li (1518) | answered Jul 20 '16, 2:58 a.m.
 I try to use OSLC to add timesheet through the following code
public boolean addDairy(String startdate,float spentTime,String timeCode,String timeCodeId,String defectId,String userId){
String url=rtcBaseURL + "/oslc/workitems/"+defectId+"/rtc_cm:timeSheet";//rtcBaseURL is like"https://jazz.com:9443/ccm"
String workItem=rtcBaseURL + "/resource/itemName/com.ibm.team.workitem.WorkItem/" + defectId;
String creator =rtcBaseURL+"/jts/users/"+userId;
String spentTm=new DecimalFormat("#").format(spentTime*3600000);
String jsonComment = "{\"rtc_cm:workItem\":\"" + workItem + "\",\"dc:creator\":\""+creator+"\",\"rtc_cm:startDate\":\""+startdate+"\",\"rtc_cm:timeCode\":\""+timeCode+"\",\"rtc_cm:timeCodeId\":\""+timeCodeId+"\",\"rtc_cm:timeSpent\":\""+spentTm+"\"}";
JSONObject json = (JSONObject) post(url, jsonComment);
return true;
}

I use the code to add timesheet ,howerver it return "HTTP/1.1 405 Method Not Allowed [Server: Apache-Coyote/1.1, Cache-Control: private, max-age=0, must-revalidate, Expires: Wed, 20 Jul 2016 06:48:54 GMT, Content-Length: 0, Date: Wed, 20 Jul 2016 06:48:54 GMT] org.apache.http.conn.BasicManagedEntity@3f4c24"

I have used the same method to add comments´╝îand I want to know if I have the wrong OSLC interface .

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.