| Dicop-Server documentation | Contained in the Dicop-Server distribution. |
Dicop::Data::Case - a container to group jobs in the Dicop system
use Dicop::Data::Case; use Dicop::Data::Job; my $case = Dicop::Data::Case->new ( $case_options ); my $job = Dicop::Data::Job->new ( $job_options );
perl5.008001, Exporter, Data::Item
Exports nothing.
Each job belongs to exactly one case. After loading the case number on the job is converted to a reference to the case itself.
For a description of the fields a case has, see doc/Objects.pod.
Return a field of the object as an ASCII string suitable for HTML output:
$object->get_as_string('foo');
Return a field of the object as an hexified string, or as a fallback, as normal string via get_as_string. The hexify happens only for certain special fields, all other are returned as simple strings:
$object->get_as_hex('foo');
Return the value of a specified field of the object:
$object->get('foo');
Change a field's value after checking that the field can be changed (via can_change) and checking the new value. If the new value does not conform to the expected format, it will be silently modifed (f.i. invalid characters might be removed) and then the change will happen:
$object->change('foo','bar'); # will change $object->{foo} to bar
# if foo can be changed
Return true if the field's value can be changed.
die ("Can not change field $field\n") if !$object->can_change($field);
None known yet.
(c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2006
DiCoP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
See http://www.bsi.de/ for more information.
| Dicop-Server documentation | Contained in the Dicop-Server distribution. |
############################################################################# # Dicop/Data/Case.pm -- a container to group jobs in the Dicop system # # (c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2006 # # DiCoP is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License version 2 as published by the Free # Software Foundation. # # See the file LICENSE or L<http://www.bsi.de/> for more information. ############################################################################# package Dicop::Data::Case; use vars qw($VERSION); $VERSION = 0.03; # Current version of this package require 5.008001; # requires this Perl version or later use base qw(Dicop::Item); use strict; sub get_as_hex { # convert data item from internal representation to hex string my ($self,$var) = @_; $self->get_as_string($var); } sub get_as_string { # return a field of yourself as plain string # return "" for non-existing fields my $self = shift; my $key = lc(shift||""); # fake key "jobs": how many jobs do we have? if ($key eq 'jobs') { # get parent (bad, access to internal data structure) my $jobs = $self->{_parent}->{jobs}; my $count = 0; my $id = $self->{id}; foreach my $job (keys %$jobs) { $count++ if $jobs->{$job}->{case}->{id} eq $id; } return $count; } # automatically fill in empty URLs if ($key eq 'url' && $self->{url} eq '') { return $self->{_parent}->_format_string('case_url', $self); } $self->SUPER::get_as_string($key); } 1; __END__ #############################################################################