NAME Client.pm

Clearquest client - Provide access to a running Clearquest server

VERSION

Author

Andrew DeFaria <Andrew@DeFaria.com>

Revision

$Revision: 2.8 $

Created

Monday, October 10, 2011 5:02:07 PM PDT

Modified

2013/05/30 15:43:28

SYNOPSIS

Provides an interface to a running Clearquest Server over the network. This means that you can use any Perl you like, not just cqperl, and you don't need to have Clearquest installed locally. In fact you can run from say Linux and talk to the Clearquest Server running on Windows.

DESCRIPTION

The server allows both read and write access to a Clearquest database as defined in cqdservice.conf file. Note the username/password must be of a user who can write to the Clearquest database for write access to succeed.

A hash is passed into to the execute method, which the client should use to talk to the server, that describes relatively simple protocol to tell the server what action to perform. In both the read case and the read/write case a field named id should be defined that has a value of "<record>=<id>" (e.g. "defect=BUGDB00034429").

For the read case the rest of the keys are the names of the fields to retrieve with values that are undef'ed. For read/write, the rest of hash contains name value pairs of fields to set and their values.

Execute returns a status and a hash of name value pairs for the read case and an array of lines for any error messages for the read/write case.

ROUTINES

The following methods are available:

Options

Options are keep in the cq.conf file in the etc directory. They specify the default options listed below. Or you can export the option name to the env(1) to override the defaults in cq.conf. Finally you can programmatically set the options when you call new by passing in a %parms hash. The items below are the key values for the hash.

CQ_SERVER

The CQ Server host to connect to

CQ_PORT

Port number to contact the server at (Default: From cq.conf)

CQ_USERNAME

User name to connect as (Default: From cq.conf)

CQ_PASSWORD

Password for CQ_USERNAME

CQ_DATABASE

Name of database to connect to (Default: From cq.conf)

CQ_DBSET

Database Set name (Default: From cq.conf)

add ($$;@)

Insert a new record into the database

Parameters:

$table

The name of the table to insert into

$values

Hash reference of name/value pairs for the insertion

@ordering

Array containing field names that need to be processed in order.

Returns:

$errmsg

Error message if any

connect (;$$$$)

Connect to the Clearquest database.

Parameters:

$username

Username to use to connect to the database

$password

Password to use to connect to the database

$database

Clearquest database to connect to

$dbset

Database set to connect to

Returns:

$status

1 if successful, 0 otherwise

dbsets ()

Get list of available database sets

Parameters:

nothing

Returns:

@dbsets

List of database sets

delete ($$)

Delete a record from the database

Parameters:

$table

The name of the table

$key

The key of the record to delete

Returns:

$errmsg

Error message if any

find ($;$@)

Find records in the database

Parameters:

$table

The name of the table to search

$condition

SQL condition clause (e.g. "id = 12345")

@fields

List of fields to return

Returns:

($status, @output)

Status code and list of matching records

get ($$@)

Get a record from the database

Parameters:

$table

The name of the table

$key

The key of the record to retrieve

@fields

List of fields to return

Returns:

%record

Hash of field names and values

getDBID ($$@)

Get a record by DBID

Parameters:

$table

Table name

$dbid

The DBID of the record

@fields

List of fields to return

Returns:

%record

Record fields

getDynamicList ($)

Get a dynamic list

Parameters:

$list

Name of the list

Returns:

@list

The dynamic list

getNext ($)

Get next record in a result set

Parameters:

$result

Result set object (unused?)

Returns:

%record

Next record

key ($$)

Get the key for a record

Parameters:

$self

Object reference

Returns:

$key

The key

modify ($$$$;@)

Modify a record in the database

Parameters:

$table

The name of the table

$key

The key of the record to modify

$action

The action to perform (default: Modify)

$values

Hash reference of fields to update

@ordering

Order of fields to process

Returns:

$errmsg

Error message if any

modifyDBID ($$$$;@)

Modify a record by DBID

Parameters:

$table

Table name

$dbid

Record DBID

$action

Action to perform

$values

Values hash ref

@ordering

Field order

Returns:

$errmsg

Error message if any

port ()

Get the port number

Returns:

$port

Port number

new ()

Create a new Clearquest Client object

Parameters:

$class

The class name

%parms

Configuration parameters

Returns:

$self

The new object

shutdown ()

Shutdown the remote server

Parameters:

nothing

Returns:

nothing

CONFIGURATION AND ENVIRONMENT

DEBUG: If set then $debug is set to this level.

VERBOSE: If set then $verbose is set to this level.

TRACE: If set then $trace is set to this level.

DEPENDENCIES

Perl Modules

Carp

File::Basename

FindBin

IO::Socket

Net::hostent

POSIX

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Andrew DeFaria <Andrew@DeFaria.com>.

LICENSE AND COPYRIGHT

Copyright (C) 2007-2026 Andrew DeFaria <Andrew@DeFaria.com>

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone else, you are strictly prohibited from removing any copyright notice from that Modified Version.

Copyright Holder makes no, and expressly disclaims any, representation or warranty, should the Package be used for any purpose. The liability of the Copyright Holder is limited to the maximum extent permitted by law.