IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational...

17
IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: [email protected]

Transcript of IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational...

Page 1: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group

®

Perl Modules for OSLC Programming

Max Vohlken

Release Engineer, IBM Rational SoftwareEmail: [email protected]

Page 2: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 2

Agenda

Introduction

What services do the modules provide?

The layout of the modules

Module Overview

RTC Query Example

RTC Work Item Update Example

Sample clients

Runtime requirements

What are the next steps?

Live demo

Page 3: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 3

Introduction

Hello my name is Max Vohlken.

I’m a release engineer for ClearCase and ClearQuest.

My main responsibility is the automation used to build these two products.

My automation tool of choice is Perl.

I’ve been programming in Perl for over 15 years.

Our development organization in the progress of migrating from using ClearQuest for defect tracking to using Rational TeamConcert(RTC).

With ClearQuest we have automation that needed to be re-implemented using RTC. This automation was written in Perl.

In my quest to re-implement this automation I’ve created a set of Perl modules to make interacting with RTC easier.

The modules use OSLC to interact with RTC.

Based on what I learned writing the RTC integration I have also created a similar set of modules for interacting with ClearQuest.

Page 4: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 4

What services do the modules provide?

The goal of the modules is to query and update work items in RTC and change requests in CQ.

The modules are based on an existing REST module called REST::Client. This module provided the standard REST methods of GET, PUT, PATCH, POST, and DELETE that OSLC uses.

The modules implement the authentication scheme needed to access restricted resources in RTC and CQ.– For RTC it implements the form based authentication scheme.

– For CQ it implements basic authentication.

The modules implement the service discovery mechanism as documented by each products OSLC specification to discover the URL to use to execute dynamic queries.

Page 5: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 5

The layout of the modules

After trying to implement these modules for both RTC and CQ I’ve come up with this convention for the different modules. The modules are written using Perl object oriented architecture.

Lyo/OSLC/<product>/<domain>.pm– Class that implements a client for a particular OSLC domain of a product.

Lyo/OSLC/<product>.pm– Class that implements methods that are common to the product and can be shared by the

multiple domains.

Lyo/OSLC.pm– Base class for all OSLC modules. Methods common to all products go here.

Lyo/OSLC/RDF.pm– Class used to convert RDF formatted responses from the OSLC provider into equivalent

Perl data structures. The methods that query the OSLC provider return an object of this type.

Page 6: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 6

The modules

Lyo/OSLC.pm– Methods

• credentials($user, $password)

Lyo/OSLC/RTC.pm– Implements form based authentication

– Methods

• rootservices()

Lyo/OSLC/CQ.pm– Implements basic authentication

– Methods

• rootservices()

Page 7: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 7

The modules

Lyo/OSLC/RDF.pm– Module for dealing with the RDF/XML formatted responses

– Methods

• new ( $rdfxml, [%config] )

• Init ( $rdfxml )

• Add ( $rdfxml)

• QueryResults ( [$resultAR] )

• QueryResultsByTitle ( )

• QueryResultsByIdentifier ( )

• Descriptions ( )

• Links ( )

• Namespaces ( )

• QueryResponse ( )

• UpdateByTitle ( )

• UpdateByIdentifier ( )

• ResolveReferences ( $force )

• InlineRDFReferences ( )

Page 8: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 8

The modules Lyo/OSLC/RTC/CM.pm

– Methods

• serviceProviders ()

• servicesURL ($projectArea)

• services ($projectArea)

• projectAreaContextID ($projectArea)

• queryCapability ($projectArea, $queryCapability)

• queryCapabilityURL ($projectArea, $queryCapability)

• oslcWhere ($projectArea, $queryCapability, $where, $properties)

• workitem ($workItemNumber, $propertiesAR)

• workitemUpdate ($workItemNumber, $newValuesAR, $verbose)

• enumeration ($projectArea, $enum)

• enumerationItem ( $projectArea, $enum, $name )

• workflow ($projectArea, $type, $name, $keyAttr)

• states ($projectArea, $stateType)

• state ( $projectArea, $enum, $name )

• resolutions ($projectArea, $resolutionType)

• resolution ( $projectArea, $resolutionType, $name )

• iterations ()

• iteration ($title)

Page 9: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 9

The modules

Lyo/OSLC/CQ/CM.pm– Methods

• serviceProviders ()

• servicesURL ($userDB)

• services ($userDB)

• projectAreaContextID ($userDB)

• queryCapability ($userDB, $queryCapability)

• queryCapabilityURL ($userDB, $queryCapability)

• oslcWhere ($userDB, $queryCapability, $where, $properties)

• changeRequest ( $changeRequestNumber, $propertiesAR )

• changeRequestUpdate ( $changeRequestNumber, $newValuesAR, $verbose )

Page 10: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 10

RTC Query Example

my $client = Lyo::OSLC::RTC::CM->new;

$client->credentials($opt{'user'}, $opt{'password'});

$client->setBaseURI($opt{'baseuri'});

my $rdfOjbect = $client->oslcWhere(

$opt{'project'}, ‘Change request queries',

$opt{'oslcwhere'}, $opt{'property'}

);

my $arrayRef = $rdfObject->QueryResults();

foreach my $ref (@$arrayRef) {– my $id = $ref->{‘dcterms:identifier’}->{‘content’};

– my $description = $ref->{‘dcterms:description’}->{‘content’};

}

Page 11: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 11

RTC Work Item Update Example

my $client = Lyo::OSLC::RTC::CM->new;

$client->credentials($opt{'user'}, $opt{'password'});

$client->setBaseURI($opt{'baseuri'});

my @updates = (– [‘dcterms:description’ => ‘Updated description’],

– [‘rtc_ext:CustomField1->{rdf:resource}’ => ‘https://rtc.mydomain.com/jazz/oslc/enumerations/_ABCDEFG/Model/Model.literal.l2’],

);

$client->workitemUpdate($opt{'workitem'}, \@updates, 1)

Page 12: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 12

Scripts I’ve written to exercise the modules rtcclient

– Usage: rtcclient [-h]

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> <url>

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> \

– -project <project area> \

– -oslcwhere <simple query> \

– [-property <property> ...]

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> \

– -workitem <work item #> \

– [-property <property> ...] \

– [-update <field>=<value> ...]

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> \

– -project <project area> \

– -enum <enum>

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> \

– -project <project area> \

– -state <state>

– rtcclient -baseuri <RTC jazz url> -user <user> -password <password> \

– -project <project area> \

– -resolution <resolution>

Page 13: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 13

Scripts I’ve written to exercise the modules (continued) cqclient

– Usage: cqclient [-h]

– cqclient -baseuri <CQ oslc url> -user <user> -password <password> <url>

– cqclient -baseuri <CQ oslc url> -user <user> -password <password> \

– -db <CQ user db> \

– -oslcwhere <simple query> \

– [-property <property> ...]

– cqclient -baseuri <CQ oslc url> -user <user> -password <password> \

– -db <CQ user db> \

– -cr <change request #> \

– [-property <property> ...] \

– [-update <field>=<value> ...]

Page 14: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 14

Runtime Requirements

perl or ratlperl

Direct module dependencies– LWP::UserAgent

– URI

– HTTP::Cookies

– Data::Dumper

– XML::Simple (not shipped with ratlperl)

– REST::Client (not shipped with ratlperl)

– All of the other modules these modules depend on.

Page 15: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 15

What are the next steps?

Add the ability to create new change management records

Add a more robust RDF handling library

Open the modules up for contributions from the community

Page 16: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 16

Live Demo myrtcclient -workitem 32271 -prop dcterms:title -prop rtc_ext:PatchBundle

myrtcclient -workitem 32271 -update “dcterms:description=apar for automation testing(3)”

Page 17: IBM Software Group ® Perl Modules for OSLC Programming Max Vohlken Release Engineer, IBM Rational Software Email: mvohlken@us.ibm.com.

IBM Software Group | Rational software IBM

Slide 17

Q & A