App-PhotoDB

 view release on metacpan or  search on metacpan

lib/App/PhotoDB/funcs.pm  view on Meta::CPAN

use Exporter qw(import);
use Config::IniHash;
use YAML;
use Image::ExifTool;
use Term::ReadLine;
use Term::ReadLine::Perl;
use File::Basename;
use Time::Piece;
use Text::TabularDisplay;

our @EXPORT_OK = qw(prompt db updaterecord deleterecord newrecord notimplemented nocommand nosubcommand listchoices lookupval lookuplist today validate ini printlist round pad lookupcol thin resolvenegid chooseneg annotatefilm keyword parselensmodel ...

=head2 prompt

Prompt the user for an arbitrary value. Has various options for data validation and customisation of the prompt.
If the provided input fails validation, or if a blank string is given when required=1 then the prompt is repeated.

=head4 Usage

    my $camera = &prompt({prompt=>'What model is the camera?', required=>1, default=>$$defaults{model}, type=>'text'});

lib/App/PhotoDB/funcs.pm  view on Meta::CPAN

		return $string . ' ' x $pad;
	} elsif ($pad = 0) {
		# No pad required, just return the original
		return $string;
	} else {
		# If the input is longer than the target, truncate it
		return substr($string, 0, $totallength);
	}
}

=head2 resolvenegid

Get a negative ID either from the neg ID or the film/frame ID

=head4 Usage

    my $negID = &resolvenegid({db=>$db, string=>'10/4'});

=head4 Arguments

=item * C<$db> DB handle

=item * C<$string> String to represent a negative ID, either as an integer or in film/frame format, e.g. C<834> or C<10/4>

=head4 Returns

Integer negative ID

=cut

sub resolvenegid {
	my $href = shift;
	my $db = $href->{db};
	my $string = $href->{string};
	if ($string =~ m/^\d+$/) {
		# All digits - already a NegID
		return $string;
	} elsif ($string =~ m/^(\d+)\/([a-z0-9]+)$/i) {
		# 999/99A - a film/frame ID
		my $film_id = $1;
		my $frame = $2;

migrations/002-functions.sql  view on Meta::CPAN

SET @saved_cs_results     = @@character_set_results ;
SET @saved_col_connection = @@collation_connection ;
SET character_set_client  = utf8 ;
SET character_set_results = utf8 ;
SET collation_connection  = utf8_general_ci ;
SET @saved_sql_mode       = @@sql_mode ;
SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' ;
CREATE FUNCTION `lookupneg`(p_film_id int, p_frame varchar(5)) RETURNS int(11)
    DETERMINISTIC
BEGIN
	declare negid int;
    select negative_id into negid
    from NEGATIVE
    where film_id = p_film_id
		and frame = p_frame collate utf8mb4_general_ci;
RETURN negid;
END ;;
SET sql_mode              = @saved_sql_mode ;
SET character_set_client  = @saved_cs_client ;
SET character_set_results = @saved_cs_results ;
SET collation_connection  = @saved_col_connection ;
SET @saved_cs_client      = @@character_set_client ;
SET @saved_cs_results     = @@character_set_results ;
SET @saved_col_connection = @@collation_connection ;
SET character_set_client  = utf8 ;
SET character_set_results = utf8 ;



( run in 1.125 second using v1.01-cache-2.11-cpan-5735350b133 )