#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2013 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::Import::ADA::v27;

use strict;

use lib '/app/tools/common/lib';
use Common::Assert;
use Common::UTF8;

use lib '/app/tools/rps/lib';
use RPS::Import::ServiceMap;

use base 'RPS::Import::ADA::v19';

# Similar to v19/v25, but with different column positions
sub _fieldMap {
    {
        labelName   => 'N',
        dateBegin   => 'U',
        productType => 'H',
        albumName   => 'P',
        artistName  => 'E',
        upc         => 'O',
        trackName   => 'F',

        isrc        => 'G',
        price       => 'K',
        units       => 'J',
        countryCode => 'D',
        serviceID   => 'C',
    };
}

sub _unverifiedFieldMap {
    {
        mediaCode    => 'B',
        albumNameAlt => 'F',
        upcAlt       => 'G',
    };
}

sub upc {
    my $self = shift;
    my $type = $self->_getByFieldName('productType');
    my $upc;

    if ( $type =~ /^isrc$/i ) {
        $upc = $self->_getByFieldName('upc');
    } else {
        $upc = $self->_getByFieldName('upcAlt');
    }

    return $self->_normalizeValue($upc);
}

sub albumName {
    my $self = shift;
    my $type = $self->_getByFieldName('productType');
    my $albumName;

    if ( $type =~ /^isrc$/i ) {
        $albumName = $self->_getByFieldName('albumName');
    } else {
        $albumName = $self->_getByFieldName('albumNameAlt');
    }

    return $albumName;
}

###
1;    # Play nicely.
###
