ARS-Simple
view release on metacpan or search on metacpan
html/Simple.html view on Meta::CPAN
</dd>
<dt id="ars_debug">ars_debug</dt>
<dd>
<p>Turn on, if true (1), the ARSperl debugging output. Not something you would normally use.</p>
</dd>
<dt id="log">log</dt>
<dd>
<p>Pass a object to use to log erros/information to a log file. The log object is expected to have methods <i>exp</i> and <i>msg</i> as per the File::Log object.</p>
</dd>
</dl>
<p>Sample invocation with ALL parameters:</p>
<pre><code> <span class="keyword">use</span> <span class="variable">ARS::Simple</span><span class="operator">;</span>
<span class="keyword">use</span> <span class="variable">File::Log</span><span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$log</span> <span class="operator">=</span> <span class="variable">File::Log</span><span class="operator">-></span><span class="variable">new</span><span class="operator">();</span>
<span class="keyword">my</span> <span class="variable">$ars</span> <span class="operator">=</span> <span class="variable">ARS::Simple</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span clas...
html/Simple.html view on Meta::CPAN
<span class="operator">...</span>
<span class="operator">}</span><span class="operator">;</span>
</code></pre>
<h2 id="get_fields">get_fields</h2>
<p>get_fields has a required argument, the form you require the field details for. The returned hash reference is the result of a call to ars_GetFieldTable, the keys are the field names and the values are the field ids (fid).</p>
<h2 id="set_max_entries">set_max_entries</h2>
<p>This requires that the 'user' has administrator access. This allows the overriding of the <b>system wide</b> maximum rows returned setting AR_SERVER_INFO_MAX_ENTRIES, setting this to zero (0) will allow unlimited returns.</p>
<p><b>Beware of setting this to a small value, it is system wide and could have a major impact on your system</b></p>
<h1 id="PRIVATE-METHODS">PRIVATE METHODS</h1>
<h2 id="init">_init</h2>
<p>Initialisation for new</p>
<h2 id="load_qualifier">_load_qualifier</h2>
lib/ARS/Simple.pm view on Meta::CPAN
}
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};
lib/ARS/Simple.pm view on Meta::CPAN
{
%entryList = ars_GetListEntryWithFields($self->{ctl}, $form, $qual, 0, \@fid);
}
# Reset the limit
$self->_reset_max_entries();
unless (%entryList)
{
no warnings qw(uninitialized);
if ($ars_errstr)
{
$self->_carp("get_data_by_label() failed.\nError=$ars_errstr\nForm=$form\nQuery=$query\n");
}
else
{
if ($self->{log})
{
$self->{log}->msg(3, "get_data_by_label() no records found.\n");
}
}
return;
}
lib/ARS/Simple.pm view on Meta::CPAN
# Run the SQL through the ARSystem API
my $m = ars_GetListSQL($self->{ctl}, $self->{sql});
# Reset the limit
$self->_reset_max_entries();
# $m = {
# "numMatches" => integer,
# "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)
lib/ARS/Simple.pm view on Meta::CPAN
}
elsif (defined $self->{reset_limit})
{
$max = 0; # Set for unlimited returns if we have a reset limit defined
}
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})
{
lib/ARS/Simple.pm view on Meta::CPAN
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}};
lib/ARS/Simple.pm view on Meta::CPAN
}
else
{
carp("update_record - label '$label' not found in lfid hash");
}
}
my $rv = ars_SetEntry($self->{ctl}, $form, $eID, 0, %lvp);
# Check for errors
unless (defined $rv && $rv == 1)
{
# Update failed
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
lib/ARS/Simple.pm view on Meta::CPAN
## Now connect to Remedy
if ($self->{server} && $user && $pword)
{
my $ctl = ars_Login($self->{server}, $user, $pword);
if ($ctl)
{
$self->{ctl} = $ctl;
}
else
{
croak(__PACKAGE__ . " object initialisation failed.\nFailed to log into Remedy server=" . $self->{server} . " as user '$user' with supplied password: $ars_errstr\n");
}
}
else
{
croak(__PACKAGE__ . " object initialisation failed, server, user and password are required\n");
}
}
# GG test - need to find and store the current value of AR_SERVER_INFO_MAX_ENTRIES
lib/ARS/Simple.pm view on Meta::CPAN
reset_limit => 3000, # max returns back to a suitable maximum of 3000
=item ars_debug
Turn on, if true (1), the ARSperl debugging output.
Not something you would normally use.
=item log
Pass a object to use to log erros/information to a log file.
The log object is expected to have methods I<exp> and I<msg>
as per the File::Log object.
=back
Sample invocation with ALL parameters:
use ARS::Simple;
use File::Log;
my $log = File::Log->new();
lib/ARS/Simple.pm view on Meta::CPAN
...
};
=head2 update_record
Update a record on a form based on the Entry-Id (eid). The
data to update is defined in the lvp (label value pair) hash reference.
The other required argument is the lfid (label FID) hash reference which
is used to map the labels to field Ids (FID).
The method returns true on success and carps on error.
update_record({
eid => $eID, # The Entry-Id/Request-Id to update
form => $form, # The form to update
lvp => \%lvp, # The data to be updated as a label => value hash ref
lfid => \%labelFIDhash # The label FID hash reference
});
=head2 get_SQL
lib/ARS/Simple.pm view on Meta::CPAN
=head2 get_fields
get_fields has a required argument, the form you require the
field details for. The returned hash reference is the result
of a call to ars_GetFieldTable, the keys are the field names
and the values are the field ids (fid).
=head2 set_max_entries
This requires that the 'user' has administrator access. This
allows the overriding of the B<system wide> maximum rows returned
setting AR_SERVER_INFO_MAX_ENTRIES, setting this to zero (0) will
allow unlimited returns.
B<Beware of setting this to a small value, it is system wide and
could have a major impact on your system>
=head1 PRIVATE METHODS
=head2 _init
( run in 1.023 second using v1.01-cache-2.11-cpan-49f99fa48dc )