[EP-tech] Re: Data object validation; $for_archive
John Salter
J.Salter at leeds.ac.uk
Fri Oct 23 12:00:56 BST 2015
Hi,
Looking deeper into this, I have discovered that there is a trigger 'EP_TRIGGER_VALIDATE' which is defined in perl_lib/EPrints/Const.pm, but not actually called anywhere*.
I think that the best way forward for this would be to create this trigger, and use that to call {dataobj}_validate routines.
In digging around with this, I have discovered some other redundant code (e.g. references to workflow_staff) that I'll make a pull request to remove.
*There is also EP_TRIGGER_VALIDATE_FIELD that is used in perl_lib/EPrints/MetaField.pm.
Cheers,
John
PS Sorry to hear you're leaving - see you in the JISC arena sometime!
-----Original Message-----
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Field A.N.
Sent: 21 October 2015 11:01
To: eprints-tech at ecs.soton.ac.uk
Subject: [EP-tech] Re: Data object validation; $for_archive
I'm not certain that eprint_validate would stop staff from depositing (happy to be corrected on this).
The only thing I can think of while jumping up and down on the problem in my head for five minutes is to modify the allow_move_archive function in the EPrints::Move screen plugin.
sub allow_move_archive
{
my( $self ) = @_;
#hook to control moving to archive
my $repo = $self->repository;
if
(
$repo->can_call('local_allow_move_archive')
&& ( $repo->call('local_allow_move_archive',$repo, $self->{processor}->{eprint}) == 0 )
)
{
return 0;
}
return 0 unless $self->could_obtain_eprint_lock;
return $self->allow( "eprint/move_archive" );
}
Then in a cfg.d file:
$c->{local_allow_move_archive} = sub
{
my ($repo, $eprint) = @_;
if (
$eprint->value('type') eq 'thesis'
&& !$eprint->is_set('magic_field')
)
{
return 0;
}
return 1;
}
If you prefer, you could subclass the plugin instead, to avoid modifying the core file. Run your checks and call the superclass allow_move_archive. Then use plugins.pl to switch your new one in.
--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services
+44 (0)23 8059 8814
On 21 Oct 2015, at 10:38, John Salter wrote:
> OK - that makes me think it's not actually doing anything :o\
>
> What I'm trying to achieve is to stop something being made live when a set of conditions are not met.
> The conditions are set in the eprint_validate (and/or document_validate) routine, and (would, if it worked) check the 'for_archive' flag to provide a level of editorial control.
> In the specific case, a thesis needs some faculty/department sign off. The student MUST be able to submit it (inbox->buffer), but the editor MUST NOT be able to make it live until the appropriate fields are complete.
>
> Cheers,
> John
>
> -----Original Message-----
> From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Field A.N.
> Sent: 21 October 2015 09:57
> To: eprints-tech at ecs.soton.ac.uk
> Subject: [EP-tech] Re: Data object validation; $for_archive
>
>
> I spent 15 minutes trying to track it through the code, and met with little success, I'm afraid.
>
> https://github.com/eprints/eprints/blob/de3b8d19f310efdbd993d07e9dfd57a15e103354/perl_lib/EPrints/Plugin/Screen/EPrint/Deposit.pm#L88
>
> ...implies that it's set on the screen processor, but I couldn't find anywhere where it's actually set.
>
>
> One cheeky alternative: you could check eprint_status and if it's in the buffer, you can guess it's going to be live soon.
>
> --
> Adam Field
> Business Relationship Manager and Community Lead
> EPrints Services
> +44 (0)23 8059 8814
>
>
>
>
>
> On 20 Oct 2015, at 17:37, John Salter wrote:
>
>> Hi,
>> I'm trying to work out how the '$for_archive' flag works when validating EPrints (I suspect it doesn’t, but am hoping to be proved wrong. I want to use this feature).
>>
>> Starting here: https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/DataObj.pm#L2046-L2047
>> The 'validate' method on a dataobject can take a '$for_archive' flag.
>> This *should* be set as true when the item is about to be moved into the live archive.
>>
>> It is referenced in many places - passed method-to-method, but as far as I can tell, this value is not set anywhere (and therefore is never true).
>> https://github.com/eprints/eprints/search?q=for_archive
>>
>> Can anyone help me trace it through the EPrints code, and confirm that it is or isn't used (especially at the point where an EPrint is made live)?
>>
>> The comments https://github.com/eprints/eprints/blob/3.3/lib/defaultcfg/cfg.d/eprint_validate.pl#L13-L14
>> refer to 'comments at the start of the validation section'.
>> I think these were carried over from Eprints2 days when all the validation routines were in one place: http://www.eprints.org/files/eprints2/eprints-2.2/defaultcfg/ArchiveValidateConfig.pm
>>
>> # $for_archive is a boolean flag (1 or 0) it is set to 0 when the
>> # item is being validated as a submission and to 1 when the item is
>> # being validated for submission to the actual archive. This allows
>> # a stricter validation for editors than for submitters. A useful
>> # example would be that a deposit may have one of several format of
>> # documents but the editor must ensure that it has a PDF before it
>> # can be submitted into the main archive. If it doesn't have a PDF
>> # file, then the editor will have to generate one.
>>
>> Also in Eprints2, this is where the 'for_archive' gets set:
>> http://www.eprints.org/files/eprints2/eprints-2.2/perl_lib/EPrints/SubmissionForm.pm, Line 129
>>
>> Cheers,
>> John
>>
>> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive: http://www.eprints.org/tech.php/
>> *** EPrints community wiki: http://wiki.eprints.org/
>> *** EPrints developers Forum: http://forum.eprints.org/
>
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/
More information about the Eprints-tech
mailing list