ARS-Simple
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
Type 'make' (windows: 'nmake' or 'dmake') to build ARS::Simple.
Type 'make test' to test ARS::Simple before installing.
Type 'make install' to install ARS::Simple.
";
}
exit 0;
sub makeTestConfig
{
my ($server, $user, $password);
my ($i, $u, $p) = ('', $ENV{USERNAME}, '');
if(-e './t/config.cache')
{
do './t/config.cache';
$i = &CCACHE::server;
$u = &CCACHE::user;
$p = &CCACHE::password;
Makefile.PL view on Meta::CPAN
$user = prompt("Remedy user with admin", $u);
if($user eq '') { $user = $u if ($u ne ''); }
$password = prompt("Password", $p);;
if($password eq '') { $password = $p if ($p ne ''); }
open (FD, '>', './t/config.cache') || die "open of './t/config.cache' failed: $!";
print FD "package CCACHE;\n";
print FD "\# enter your remedy server, username and password below.\n\n";
print FD qq{sub server { '$server' ; }\n};
print FD qq{sub user { '$user' ; }\n};
print FD qq{sub password { '$password' ; }\n};
print FD "1;\n";
close(FD);
}
lib/ARS/Simple.pm view on Meta::CPAN
# In a Perl2Exe or PerlApp created executable or PerlCtrl
# generated COM object or the cfg is known to exist
eval {require $cfg};
if ($@ and $@ !~ /Can't locate /) #' <-- syntax higlighter
{
carp "Error in $cfg : $@";
}
}
}
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless($self, $class);
# Run initialisation code
$self->_init(@_);
return $self;
}
sub DESTROY
{
my $self = shift;
if ($self->{ctl})
{
ars_Logoff($self->{ctl});
}
}
sub _check_initialised
{
my $self = shift;
unless ($self->{ctl})
{
$self->_carp("Connected to Remedy ARSystem has not been establised yet.\n");
return;
}
return 1;
}
sub get_list
{
my ($self, $args) = @_; # Expect args keys of 'form', 'query', optionally 'max_returns'
# Check ARSystem initailised
return unless $self->_check_initialised();
# Check required args
unless ($args->{form} && $args->{query})
{
$self->_carp("get_list() requires 'form' and 'query' arguments\n");
lib/ARS/Simple.pm view on Meta::CPAN
for (my $x = 0; $x < $#entries; $x += 2)
{
#Assign the entryId's to the array, stripping the query list values
push @entryIds, $entries[$x];
}
my %results = ( numMatches => scalar(@entryIds), eids => \@entryIds );
return \%results;
}
sub _load_qualifier
{
my ($self, $args) = @_;
my $qual = ars_LoadQualifier($self->{ctl}, $args->{form}, $args->{query});
unless ($qual)
{
$self->_carp("_load_qualifier() Error processing query:\n$ars_errstr\n");
}
return $qual;
}
sub get_data_by_label
{
my ($self, $args) = @_;
my $form = $args->{form};
my $query = $args->{query};
my $lfid_hr = $args->{lfid};
my @fid = values %$lfid_hr;
# Check ARSystem initailised
return unless $self->_check_initialised();
lib/ARS/Simple.pm view on Meta::CPAN
{
$entryList{$eID}{$fid2label{$fid}} = $entryList{$eID}{$fid};
delete $entryList{$eID}{$fid};
}
}
}
return \%entryList;
}
sub get_SQL
{
my ($self, $args) = @_;
# Set the limit
$self->set_max_entries($args->{max_returns});
# Run the SQL through the ARSystem API
my $m = ars_GetListSQL($self->{ctl}, $self->{sql});
# Reset the limit
lib/ARS/Simple.pm view on Meta::CPAN
# "rows" => [ [r1col1, r1col2], [r2col1, r2col2] ... ],
# }
if ($ars_errstr && $ars_errstr ne '')
{
$self->_carp('get_SQL() - ars_GetListSQL error, sql=', $self->{sql}, "\nars_errstr=$ars_errstr\n");
}
return $m;
}
sub set_max_entries
{
my ($self, $max) = @_;
if (defined $max)
{
# Just use the value given
}
elsif ($self->{max_returns})
{
$max = $self->{max_returns};
lib/ARS/Simple.pm view on Meta::CPAN
if (defined $max)
{
unless(ars_SetServerInfo($self->{ctl}, &ARS::AR_SERVER_INFO_MAX_ENTRIES, $max))
{
$self->_carp("set_max_entries() - Could not set the AR_SERVER_INFO_MAX_ENTRIES to $max:\n$ars_errstr\n");
}
}
}
sub _reset_max_entries
{
my $self = shift;
if (defined $self->{reset_limit})
{
$self->set_max_entries($self->{reset_limit});
}
}
sub get_fields
{
my ($self, $form) = @_;
# Check required args
unless ($form)
{
$self->_carp("get_fields() requires the 'form' as a argument\n");
return;
}
my %fids = ars_GetFieldTable($self->{ctl}, $form);
$self->_carp("get_fields() error: $ars_errstr\n") unless (%fids);
return \%fids;
}
sub update_record
{
my ($self, $args) = @_;
my $eID = $args->{eid};
my $form = $args->{form};
my %lvp = %{$args->{lvp}};
# Map lvp to use FID rather than label
foreach my $label (keys %lvp)
{
lib/ARS/Simple.pm view on Meta::CPAN
my $msg = "update_record(eid=$eID, form=$form, ...) failed:\nars_errstr=$ars_errstr\nlvp data was:\n";
foreach my $label (sort keys %{$args->{lvp}})
{
$msg .= sprintf("%30s (%10d) ---> %s\n", $label, $args->{lfid}{$label}, defined($lvp{$args->{lfid}{$label}}) ? $lvp{$args->{lfid}{$label}} : '<undefined>');
}
carp($msg);
}
return $rv;
}
sub get_ctl
{
my $self = shift;
return $self->{ctl};
}
sub _carp
{
my $self = shift;
my $msg = join('', @_);
carp $msg;
$self->{log}->exp($msg) if ($self->{log});
}
sub _init
{
my ($self, $args) = @_;
# Did we have any of the persistant variables passed
my $k = '5Jv@sI9^bl@D*j5H3@:7g4H[2]d%Ks314aNuGeX;';
if ($args->{user})
{
$self->{persistant}{user} = $args->{user};
}
else
t/config.cache view on Meta::CPAN
package CCACHE;
# enter your remedy server, username and password below.
sub server { 'devserver' ; }
sub user { 'greg' ; }
sub password { 'password' ; }
1;
( run in 0.341 second using v1.01-cache-2.11-cpan-a5abf4f5562 )