diff --git a/cfg/cfg.d/z_example_reports.pl.off b/cfg/cfg.d/z_example_reports.pl.off index 2b15edc..79699f4 100644 --- a/cfg/cfg.d/z_example_reports.pl.off +++ b/cfg/cfg.d/z_example_reports.pl.off @@ -3,5 +3,40 @@ $c->{plugins}{"Screen::Report::Example"}{params}{disable} = 0; $c->{plugins}{"Screen::Report::Example::Articles"}{params}{disable} = 0; $c->{plugins}{"Screen::Report::Example::ConferenceItems"}{params}{disable} = 0; -#$c->{plugins}{"Export::Report::CSV::ROS"}{params}{disable} = 0; +$c->{plugins}{"Export::Report::CSV::Example"}{params}{disable} = 0; +my @example_fields = ( + { + target => "EPrint ID", + source => "eprint.eprintid", + validate => "required", + }, + { + target => "Title", + # just to demonstrate getting data via a sub {} + source => sub { + my( $plugin, $objects ) = @_; + + my $eprint = $objects->{eprint}; + return $eprint->value( 'title' ); + }, + validate => sub { + my( $plugin, $objects, $problems ) = @_; + + my $eprint = $objects->{eprint}; + + if( $eprint->value( 'title' ) =~ /the/i ) + { + push @$problems, "Problems detected!!"; + } + } + }, +); + +$c->{reports}->{"example-articles"}->{fields} = [ map { $_->{target} } @example_fields ]; +$c->{reports}->{"example-articles"}->{mappings} = { map { $_->{target} => $_->{source} } @example_fields }; +$c->{reports}->{"example-articles"}->{validate} = { map { $_->{target} => $_->{validate} } @example_fields }; + +$c->{reports}->{"example-conf-items"}->{fields} = [ map { $_->{target} } @example_fields ]; +$c->{reports}->{"example-conf-items"}->{mappings} = { map { $_->{target} => $_->{source} } @example_fields }; +$c->{reports}->{"example-conf-items"}->{validate} = { map { $_->{target} => $_->{validate} } @example_fields }; diff --git a/lib/lang/en/phrases/reports.xml b/lib/lang/en/phrases/reports.xml index 376979c..8859a88 100644 --- a/lib/lang/en/phrases/reports.xml +++ b/lib/lang/en/phrases/reports.xml @@ -7,5 +7,9 @@ Reports No available reports + +Example +Articles +Conference Items diff --git a/lib/plugins/EPrints/Plugin/Export/Report/CSV/Example.pm b/lib/plugins/EPrints/Plugin/Export/Report/CSV/Example.pm new file mode 100644 index 0000000..1be8ca8 --- /dev/null +++ b/lib/plugins/EPrints/Plugin/Export/Report/CSV/Example.pm @@ -0,0 +1,21 @@ +package EPrints::Plugin::Export::Report::CSV::Example; + +use EPrints::Plugin::Export::Report::CSV; +our @ISA = ( "EPrints::Plugin::Export::Report::CSV" ); + +use strict; + +sub new +{ + my( $class, %params ) = @_; + + my $self = $class->SUPER::new( %params ); + + $self->{name} = "Example CSV"; + $self->{accept} = [ 'report/example-articles', 'report/example-conf-items' ]; + $self->{advertise} = 1; + return $self; +} + + +1; diff --git a/lib/plugins/EPrints/Plugin/Screen/Report/Example.pm b/lib/plugins/EPrints/Plugin/Screen/Report/Example.pm index a669439..895a19f 100644 --- a/lib/plugins/EPrints/Plugin/Screen/Report/Example.pm +++ b/lib/plugins/EPrints/Plugin/Screen/Report/Example.pm @@ -94,33 +94,4 @@ sub get_related_objects return $objects; } -# All outputs entered on the Books, Journals or Conferences worksheets must have at least one of the following unique identifiers: ISBN, ISSN, DOI, UKPMC -sub validate_dataobj -{ - my( $plugin, $dataobj ) = @_; - - my @problems; - - # random decision to decide if a data-obj is valid or not - - # of course on a "real" report, you would need to set-up proper validation rules, perhaps defined by some national agencies such as HEFCE, RCUK, ... - - if( int( rand( 100 ) ) % 2 == 0 ) - { - push @problems, "Problems detected!!"; - } - - push @problems, $plugin->SUPER::validate_dataobj( $dataobj ); - - return @problems; -} - -sub report_fields_order -{ - my( $plugin, $dataobj ) = @_; - - return $plugin->SUPER::report_fields_order( $dataobj ); -} - - 1;