EPrints Technical Mailing List Archive

Message: #04966


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[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@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Field A.N.
> Sent: 21 October 2015 09:57
> To: eprints-tech@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/