Javascript surprise my every day…the last week (inspired by the OSLC Post from Stephane) I played around with OSLC together with Javascript. I expected obstacles and thought that OSLC is dedicated to Java. Oh boy, I was wrong!
Compare the “getCatalog” function below with the Java OSCL examples available at htttp://jazz.net…
Attached is an example with Javascript. For the sake of simplicity I keep the source simple, next time I will use the module pattern to isolate my external Javascript (I promise!)
function getCatalog() {
$.ajax({
url: '/ccm/rootservices',
type: 'GET',
accepts: 'application/rdf+xml',
success: function(data) {
//convert the XML Document to a XML String
var xmlString = (new XMLSerializer()).serializeToString(data);
// Search for the cmServiceProviders element and append the resource value
$(data).find('cmServiceProviders').each(function(){
$('#spa').append($(this).attr("rdf:resource"));
});
}
});
return true;
}
The complete download code is here. It is an Open Social Widget, unzip it to your extensions directory as described in the last Post.
As an additional bonus I include also an D3 extension. In the following video you see an OSLC access to the service.xml of a RTC Project Area. The RDF/XML content is displayed as a D3 Forced Graph.
From my point of view the D3 Graph looks better then the related RDF/XML below.
<?xml version="1.0" encoding="UTF-8"?><oslc_cm:ServiceDescriptor xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" rdf:about="https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/services.xml" xmlns:dc="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/"> <dc:title>Automated Meter Reader - CCM</dc:title> <dc:description>IBM Rational Team Concert OSLC CM Service Description for Project 'Automated Meter Reader - CCM'</dc:description> <dc:contributor> <dc:title>IBM Rational Team Concert Work Items</dc:title> <dc:identifier>com.ibm.team.workitem</dc:identifier> <oslc_cm:icon>https://ssejtsserver:9443/ccm/web/com.ibm.team.rtc.web/ui/graphics/UICustomizations/RationalTeamConcert.ico</oslc_cm:icon> </dc:contributor> <oslc_cm:changeRequests oslc_cm:version="1.0"> <oslc_cm:home> <dc:title>Work Items Home</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/web/projects/Automated%20Meter%20Reader%20-%20CCM#action=com.ibm.team.workitem.viewWelcome</oslc_cm:url> </oslc_cm:home> <oslc_cm:factory oslc_cm:default="true" calm:id="defect"> <dc:title>Location for creation of Defect change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/defect</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="change_request"> <dc:title>Location for creation of Change Request change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/change_request</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="task"> <dc:title>Location for creation of Task change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/task</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="enhancement"> <dc:title>Location for creation of Enhancement change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/enhancement</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="com.ibm.team.workitem.workItemType.risk"> <dc:title>Location for creation of Risk change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/com.ibm.team.workitem.workItemType.risk</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="planItem"> <dc:title>Location for creation of Use Case change requests </dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems/usecase</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory> <dc:title>Location for creation of change requests</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems</oslc_cm:url> </oslc_cm:factory> <oslc_cm:factory calm:id="drafts"> <dc:title>Location for creation of draft change requests</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/drafts/workitems</oslc_cm:url> </oslc_cm:factory> <oslc_cm:simpleQuery> <dc:title>Change request queries</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/workitems</oslc_cm:url> </oslc_cm:simpleQuery> <oslc_cm:creationDialog oslc_cm:default="true" calm:id="defect" oslc_cm:hintWidth="680px" oslc_cm:hintHeight="505px"> <dc:title>New Defect</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/modules/com.ibm.team.workitem.WICreationDialog?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=defect</oslc_cm:url> </oslc_cm:creationDialog> <oslc_cm:creationDialog calm:id="planItem" oslc_cm:hintWidth="680px" oslc_cm:hintHeight="545px"> <dc:title>New Plan Item</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/modules/com.ibm.team.workitem.WICreationDialog?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=usecase</oslc_cm:url> </oslc_cm:creationDialog> <oslc_cm:creationDialog calm:id="task" oslc_cm:hintWidth="680px" oslc_cm:hintHeight="505px"> <dc:title>New Task</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/modules/com.ibm.team.workitem.WICreationDialog?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=task</oslc_cm:url> </oslc_cm:creationDialog> <oslc_cm:creationDialog calm:id="requirementChangeRequest" oslc_cm:hintWidth="680px" oslc_cm:hintHeight="505px"> <dc:title>New Requirement Change Request</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/oslc/contexts/_6ngdX3FXEeKPYMdrWKualg/modules/com.ibm.team.workitem.WICreationDialog?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=defect</oslc_cm:url> </oslc_cm:creationDialog> <oslc_cm:selectionDialog oslc_cm:default="true" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="460px"> <dc:title>Select Change Request</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.workitem.WIPicker?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true</oslc_cm:url> </oslc_cm:selectionDialog> <oslc_cm:selectionDialog calm:id="defect" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="460px"> <dc:title>Select Defect</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.workitem.WIPicker?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=defect</oslc_cm:url> </oslc_cm:selectionDialog> <oslc_cm:selectionDialog calm:id="planItem" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="460px"> <dc:title>Select Plan Item</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.workitem.WIPicker?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=usecase</oslc_cm:url> </oslc_cm:selectionDialog> <oslc_cm:selectionDialog calm:id="task" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="460px"> <dc:title>Select Task</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.workitem.WIPicker?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=task</oslc_cm:url> </oslc_cm:selectionDialog> <oslc_cm:selectionDialog calm:id="requirementChangeRequest" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="460px"> <dc:title>Requirement Change Request</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.workitem.WIPicker?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true&dc%3Atype=defect</oslc_cm:url> </oslc_cm:selectionDialog> <calm:filter calm:id="openItems"> <dc:title>Open Change Requests Filter</dc:title> <calm:url>https://ssejtsserver:9443/ccm/oslc/calm-filter/_6ngdX3FXEeKPYMdrWKualg/openItems</calm:url> </calm:filter> <calm:filter calm:id="resolvedItems"> <dc:title>Resolved Change Requests Filter</dc:title> <calm:url>https://ssejtsserver:9443/ccm/oslc/calm-filter/_6ngdX3FXEeKPYMdrWKualg/resolvedItems</calm:url> </calm:filter> <calm:filter calm:id="readyForTesting"> <dc:title>Ready for Testing Change Requests Filter</dc:title> <calm:url>https://ssejtsserver:9443/ccm/oslc/calm-filter/_6ngdX3FXEeKPYMdrWKualg/readyForTesting</calm:url> </calm:filter> <calm:module calm:id="embedded-cm"> <dc:title>Embeddable Work Item Web Module</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/web/com.ibm.team.workitem.web/ui/internal/module/WorkItemGadget.xml?projectAreaItemId=_6ngdX3FXEeKPYMdrWKualg</oslc_cm:url> </calm:module> <calm:rpc calm:id="home"> <dc:title>Work Items Home</dc:title> <calm:rpcService>OSLC_requestAction</calm:rpcService> <calm:rpcArg>action=com.ibm.team.workitem.viewWelcome</calm:rpcArg> </calm:rpc> <calm:rpc calm:id="defect"> <dc:title>Create Defect</dc:title> <calm:rpcService>OSLC_requestAction</calm:rpcService> <calm:rpcArg>action=com.ibm.team.workitem.newWorkItem&type=defect</calm:rpcArg> </calm:rpc> <calm:rpc calm:id="task"> <dc:title>Create Task</dc:title> <calm:rpcService>OSLC_requestAction</calm:rpcService> <calm:rpcArg>action=com.ibm.team.workitem.newWorkItem&type=task</calm:rpcArg> </calm:rpc> <calm:rpc calm:id="query-page"> <dc:title>Queries</dc:title> <calm:rpcService>OSLC_requestAction</calm:rpcService> <calm:rpcArg>action=com.ibm.team.workitem.viewQueries</calm:rpcArg> </calm:rpc> </oslc_cm:changeRequests> <oslc_cm:plans oslc_cm:version="1.0"> <oslc_cm:home> <dc:title>Plans Home</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/web/projects/Automated%20Meter%20Reader%20-%20CCM#action=com.ibm.team.apt.welcome</oslc_cm:url> </oslc_cm:home> <oslc_cm:selectionDialog oslc_cm:default="true" oslc_cm:hintWidth="550px" oslc_cm:hintHeight="360px"> <dc:title>Plan</dc:title> <oslc_cm:url>https://ssejtsserver:9443/ccm/_ajax-modules/com.ibm.team.apt.PlanSelectionDialog?projectAreaId=_6ngdX3FXEeKPYMdrWKualg&showLoginLink=true</oslc_cm:url> </oslc_cm:selectionDialog> </oslc_cm:plans> </oslc_cm:ServiceDescriptor>
#1 by tommywu on 28/08/2014 - 12:02
Hi Steven :
I failed to load the D3 graph on my RTC dashboard. I change to my project area UUID in the displayForceGraph.js and put the extracted folder under server. But when i click “display service.xml graph, it show nothing. Do u need D3 library manually from local or what’s wrong with my steps ?
#2 by rtcpractise on 31/01/2015 - 06:58
Hi Tommy,
could you use Chrome and open the Dev. Tools from Chrome. If something is wrong than you should see it at the console.
BTW, sorry for the late answer.
Steve