package BookPub::Tracker::Service;

use strict;

#use warnings;

use Data::Dumper;

use lib '/app/tools/common/lib';
use Common::RSDB;
use Common::Consts;
use Common::FormObject;
use Common::Assert;

use lib '/app/tools/bookpub/lib';
use BookPub::DB::Item::Service;

use base 'Common::FormObject';

# I think we're going to want a separate ID space for the BookPublishing world.
#
use constant COURSE_SMART       => 1;
use constant CREATE_SPACE       => 2;
use constant FOLLETT            => 3;
use constant SONY               => 4;
use constant MBS_TEX            => 5;
use constant WEB_CT             => 6;
use constant BOOK_SURGE         => 7;
use constant AMAZON             => 8;
use constant APPLE              => 9;
use constant EBOOK              => 10;
use constant FOLLETT_CAFESCRIBE => 11;
use constant LSI                => 12;
use constant OVERDRIVE          => 13;
use constant MOBIPOCKET         => 14;
use constant AUDIBLE            => 15;
use constant BARNES_NOBLE       => 16;
use constant PLAY_AWAY          => 17;
use constant BBC_AUDIO          => 18;
use constant SCROLL_MOTION      => 19;

#use constant LSI_POD                  => 20; #merged with service id 12
use constant EMUSIC         => 21;
use constant SIMPLY_AUDIO   => 22;
use constant SPOKEN_NETWORK => 23;

# changing service name below to Rakuten Kobo, FB5947
use constant KOBO                     => 24;
use constant FICTIONWISE              => 25;
use constant INGRAM_DIGITAL           => 26;
use constant DNAML                    => 27;
use constant RSFORMAT                 => 28;
use constant MOBCAST                  => 29;
use constant VODAPHONE360             => 30;
use constant BLACKBERRY               => 31;
use constant ORANGEUK                 => 32;
use constant NOKIAOVI                 => 33;
use constant ITUNES                   => 34;
use constant ANDROID_MARKETPLACE      => 35;
use constant ORANGE_FR                => 36;
use constant GOSPOKEN                 => 37;
use constant ORANGE_BOOKSTORE         => 38;
use constant TMOBILE_UK               => 39;
use constant TMOBILE_AT               => 40;
use constant WHSMITH_MOBILE           => 41;
use constant GARDNERS                 => 42;
use constant CHRISTIANBOOK            => 43;
use constant WEREAD4YOU               => 44;
use constant WATERSTONES              => 45;
use constant OLF                      => 46;
use constant FNAC                     => 47;
use constant RANDOMHOUSE              => 48;
use constant BORDERS                  => 49;
use constant BAKERANDTAYLOR           => 50;
use constant VODAFONE_UK              => 51;
use constant GOOGLE                   => 52;
use constant RIPPLE                   => 53;
use constant PREMIERAUDIOBOOKS        => 54;
use constant LEARN_OUT_LOUD           => 55;
use constant KIWITECH                 => 56;
use constant EREADERS                 => 57;
use constant LIBRI                    => 58;
use constant CHRISTIANAUDIO           => 59;
use constant BESTSELLERLIST           => 60;
use constant JONATHAN_BALL            => 61;
use constant SKOOB                    => 62;
use constant UNCUVA                   => 63;
use constant ANOBII                   => 64;
use constant SMARTEBOOK               => 65;
use constant CHEGG                    => 66;
use constant RECORDED_BOOKS           => 67;
use constant DAWSON_BOOKS             => 68;
use constant OREILLY                  => 69;
use constant REDGROUP                 => 70;
use constant FOLLETT_HIGHER_EDUCATION => 71;
use constant KNO                      => 72;
use constant AIDC                     => 73;
use constant AUDIO_SCHOLAR            => 74;
use constant AIDC_AUTHOR              => 75;
use constant AIDC_CONSUMER            => 76;
use constant AIDC_PROMOTIONAL         => 77;
use constant DOCSTOC                  => 78;

# changing service name THREE_M to Bibliotheca, FB 13258
use constant THREE_M           => 79;
use constant EBSCO             => 80;
use constant WHEELERS          => 81;
use constant SCRIBD            => 82;
use constant INSCRIBE_DIGITAL  => 83;
use constant EBRARY            => 84;
use constant GOOGLE_PROMOTIONS => 85;
use constant KOBO_PROMOTIONS   => 86;
use constant BOOKISH           => 87;
use constant EBOOK_COM         => 88;
use constant TUNECORE          => 89;
use constant BLACKSTONE_AUDIO  => 90;

#Name change from txtr to Juke! Entertainment FB13724
use constant TXTR                   => 91;
use constant DIESEL_EBOOKS          => 92;
use constant COPIA                  => 93;
use constant DRAGONMOUNT            => 94;
use constant BOOKSHOUT              => 95;
use constant THE_BOOK_PEOPLE        => 96;
use constant FLIPKART               => 97;
use constant GOOGLE_PLAY            => 98;
use constant ZOLA_BOOKS             => 99;
use constant IGROUP                 => 100;
use constant ZINIO                  => 101;
use constant VITAL_SOURCE           => 102;
use constant FEEDBOOKS              => 103;
use constant BOOKSFREE              => 104;
use constant AMBLINGBOOKS           => 105;
use constant MACKIN                 => 106;
use constant COURSELOAD             => 107;
use constant KOORONG                => 108;
use constant TBS_DIRECT             => 109;
use constant AIDC_DISTRIBUTOR       => 110;
use constant OYSTER                 => 111;
use constant JB_HIFI                => 112;
use constant DOUGLAS_COUNTY_LIBRARY => 113;
use constant ROWMAN_COM_ESALES      => 114;
use constant READBOOKS              => 115;
use constant PUBLISHERS_ROW         => 116;
use constant BOLINDA_DIGITAL        => 117;
use constant DIRECT_EBOOKS          => 118;
use constant MOMENTUM_BOOKS         => 119;
use constant READCLOUD              => 120;
use constant ENTITLE_BOOKS          => 121;
# FINDAWAY_WORLD is now InAudio (RSD-11596)
use constant IN_AUDIO               => 122;
use constant WORD                   => 123;
use constant BLINKBOX               => 124;
use constant NUMILOG                => 125;
use constant HBG                    => 126;
use constant YUZU                   => 127;
use constant SKOOBE                 => 128;
use constant MACQUARIE              => 129;
use constant CALIFA                 => 130;

# VIRDOCS is now REDSHELF
use constant VIRDOCS                      => 131;
use constant PROQUEST                     => 132;
use constant BOOKS_A_MILLION              => 133;
use constant BOOKSOURCE                   => 134;
use constant LIBRIFY                      => 135;
use constant ACX                          => 136;
use constant SLICEBOOKS                   => 137;
use constant CATCH_GROUP                  => 138;
use constant GLOSE                        => 139;
use constant RM_BOOKS                     => 140;
use constant PAN_AUSTRALIA                => 141;
use constant ODILO                        => 142;
use constant KORTEXT                      => 143;
use constant SAFARIBOOKS                  => 144;
use constant TWENTY_FOUR_SYMBOLS          => 145;
use constant INKLING                      => 146;
use constant BOOKTOPIA                    => 147;
use constant PETER_PAL                    => 148;
use constant BITLIT_MEDIA                 => 149;
use constant READWELL                     => 150;
use constant SHAREDBOOK                   => 151;
use constant EPIC                         => 152;
use constant BLLOON                       => 153;
use constant BOOKMATE                     => 154;
use constant ADAMS_BOOK_COMPANY           => 155;
use constant GALE                         => 156;
use constant CREDO                        => 157;
use constant SHAW_DIGITAL                 => 158;
use constant ME_BOOKS_LTD                 => 159;
use constant STORYTEL                     => 160;
use constant WEBASSIGN                    => 161;
use constant INKTERA                      => 162;
use constant UNIZIN                       => 163;
use constant VEARSA                       => 164;
use constant AMIGOS                       => 165;
use constant TRAJECTORY                   => 166;
use constant HUMMINGBIRD_DIGITAL          => 167;
use constant HASTINGS_BKS_AND_RECORDS     => 168;
use constant CAPELLA                      => 169;
use constant GRAND_CANYON_UNIV            => 170;
use constant TEXIDIUM                     => 171;
use constant ED_MAP                       => 172;
use constant SAVANT_LEARNING              => 173;
use constant WESTERN_INTERNATIONAL        => 174;
use constant DEVRY                        => 175;
use constant CEC                          => 176;
use constant ECAMPUS                      => 177;
use constant COPYRIGHT_CLEARANCE          => 178;
use constant INDIANA_UNIVERSITY           => 179;
use constant APUS                         => 180;
use constant ZOVIO                        => 181;
use constant LAUREATE                     => 182;
use constant BLOOMSBURY_COM               => 183;
use constant SNAPPLIFY                    => 184;
use constant EDMC                         => 185;
use constant AMBASSADOR                   => 186;
use constant APOLLO_GROUP                 => 187;
use constant SHELFIE                      => 188;
use constant FAITHLIFE                    => 189;
# changing service name OneClickdigital to W.F. Howes (RSD-2827)
use constant ONECLICKDIGITAL              => 190;
use constant XANEDU                       => 191;
use constant WGU                          => 192;
use constant LIBRARY_IDEAS                => 193;
use constant ALEXI                        => 194;
use constant PERUSALL                     => 195;
use constant CNPEREADING                  => 196;
use constant CORBAN_UNIVERSITY            => 197;
use constant MICROSOFT                    => 198;
use constant KINOKUNIYA                   => 199;
use constant BFC_GB                       => 200;
use constant BFC_US                       => 201;
use constant BARNES_NOBLE_EDUCATION       => 202;
use constant LANGUAGE_WORLD               => 203;
use constant BOKBASEN                     => 204;
use constant ACROBATIQ                    => 205;
use constant NYU                          => 206;
use constant MULTNOMAH_UNIVERSITY         => 207;
use constant WESTMINSTER_LIBRARY          => 208;
use constant PRINCETON_UNIVERSITY         => 209;
use constant DOWNPOUR                     => 210;
use constant WESTERN_THEOLOGICAL_SEMINARY => 211;
use constant VERBA                        => 212;
use constant ALEXANDER_STREET             => 213;
use constant KNOVEL                       => 214;
use constant PRODEVIA_LEARNING            => 215;
use constant PERMA_BOUND                  => 216;
use constant LIX                          => 217;
use constant BOOKPAL                      => 218;
use constant AIDC_TEXTBOOKS               => 219;
use constant MORGAN_LIBRARY               => 220;
use constant ADTALEM_CHAMBERLAIN          => 221;
use constant BOKSALA_STUDENTA             => 222;
use constant BAOBAB_EBOOK_SERVICES        => 223;
use constant PERLEGO                      => 224;
use constant HOOPLA_DIGITAL               => 225;
use constant EBA                          => 226;
use constant AUDIOBOOKSNOW                => 227;
use constant ECONCORDIA                   => 228;
use constant FRANKLIN_UNIVERSITY          => 229;
use constant VIVLIO                       => 230;
use constant CSU_FULLERTON                => 231;
use constant SHANGHAI_BOOK_TRADERS        => 232;
use constant WILLIAM_PERKINS_LIBRARY      => 233;
use constant ALKEM                        => 234;
use constant NEMCC                        => 235;
use constant LIBRIOS                      => 236;
use constant MOFIBO                       => 237;
use constant LEO_DEHON_LIBRARY            => 238;
use constant YOUNGSTOWN_STATE             => 239;
use constant WRIGHT_STATE                 => 240;
use constant CATHOLIC_DISTANCE_UNIVERSITY => 241;
use constant PROQUEST_SUBSCRIPTION        => 242;
use constant BARNES_NOBLE_FIRST_DAY       => 243;
use constant PENN_FOSTER                  => 244;
use constant BOOKWIRE                     => 245;
use constant JUGGERNAUT                   => 246;
use constant LIBRO                        => 247;
use constant DE_MARQUE                    => 248;
use constant WKU                          => 249;
use constant AUDIOBOOK_STORE              => 250;
use constant CLOUDALOUD                   => 251;
use constant COLUMBIA_SOUTHERN_UNIVERSITY => 252;
use constant AIDC_SPECIAL                 => 253;
use constant ONEWORLD_CONTENT             => 254;
use constant ATHABASCA_UNIVERSITY         => 255;
use constant NEXTORY                      => 256;
use constant BOOKBEAT                     => 257;
use constant ZEBRALUTION                  => 258;
use constant RALLY_READER                 => 259;
use constant PEC                          => 260;
use constant IZNEO                        => 261;
use constant OPEN_ROAD_MEDIA              => 262;
use constant BLINKIST                     => 263;
use constant FABLE                        => 264;
use constant BIBLIU                       => 265;
use constant HEKMAN_LIBRARY               => 266;
use constant YOTO                         => 267;
use constant CHAPTER                      => 268;
use constant WILLO_LABS                   => 269;
use constant CAMPUS_EBOOKSTORE            => 270;
use constant XIG_XAG                      => 271;
use constant CHIRP                        => 272;
use constant BOOK_OF_THE_MONTH            => 273;
use constant SPEECHIFY                    => 274;
use constant MARUZEN_YUSHODO              => 275;
use constant CEPIEC                       => 276;
use constant HENI                         => 277;
use constant CAMBRIDGE_BUSINESS_PUBLISHERS => 278;
use constant ALDI                         => 279;
use constant THOUSAND_COOKBOOKS_LTD       => 280;
use constant BOOKSIO                      => 281;
use constant UAGC                         => 282;
use constant UNIVERSITY_OF_MISSISSIPPI    => 283;
use constant SOOMO_LEARNING               => 284;
use constant SPOTIFY                      => 285;
use constant CASALINI                     => 286;
use constant SAXO                         => 287;
use constant BOOKT                        => 288;
use constant PANSING                      => 289;
# changing service name Textbooks.com to MBS Textbook Exchange (RSD-10621)
use constant MBS_TEXTBOOK_EXCHANGE        => 290;
use constant BUKU                         => 291;
use constant SKILLSOFT                    => 292;
# changing service name Bibliotheca to OCLC, RSD-10162
use constant OCLC                         => 293;
use constant BLOOMSBURY_DIRECT_SALES      => 294;
use constant LEGIBLE                      => 295;
use constant LOGIN                        => 296;
use constant HEIMKAUP                     => 297;
use constant OSPREY_WEBSITE               => 298;
use constant BLOOMSBURY_WEBSITE           => 299;
use constant WEILBACH                     => 300;
use constant CLASSOOS                     => 301;
use constant BOOKSHOP                     => 302;
use constant JSTOR_ITHAKA                 => 303;
use constant ONEBOOKSHELF                 => 304;
use constant WARLORD_GAMES                => 305;
use constant BLOOMSBURY_PROFESSIONAL      => 306;
use constant FOOTNOTE                     => 307;
use constant SWINBURNE_ONLINE             => 308;
use constant BOOKERY                      => 309;
use constant BACCAH_IT                    => 310;
use constant BOX_OF_BOOKS                 => 311;
use constant POLYTEKNISK                  => 312;
use constant KEELE_UNIVERSITY             => 313;
use constant EDINBURGH_NAPIER_UNIVERSITY  => 314;
use constant BATH_SPA_UNIVERSITY          => 315;
use constant GROWMORE_GENERAL_TRADING_CO  => 316;
use constant DSM_FIRMENICH                => 317;
use constant BASHEER_GRAPHIC_BOOKS        => 318;
use constant ADDED_INFO_SERVICES          => 319;
use constant VISION_IP_CO                 => 320;
use constant DAR_AL_FAJR_FOR_PUB_AND_DIST => 321;
use constant ALL_PRINTS                   => 322;
use constant PERIPLUS_HOLDINGS            => 323;
use constant RAFBOKIN                     => 324;
use constant CUHK                         => 325;
use constant INTO_MANCHESTER              => 326;
use constant FAHASA                       => 327;
use constant UNIVERSITY_OF_MICHIGAN       => 328;
use constant UNIVERSITY_OF_EDINBURGH      => 329;
use constant ENAMUH                       => 330;
use constant PLAYAWAY                     => 331;
use constant LIBRERIA_SCIENTIFICA                => 332;
use constant BRIGHT                              => 333;
use constant UNISTER_INTERNATIONAL_LIMITED       => 334;
use constant UNIVERSITY_OF_EASTERN_FINLAND       => 335;
use constant EF_LANGUAGE_LEARNING_SOLUTIONS_AG   => 336;
use constant SUP_RETAIL                          => 337;
use constant DK_TODAY                            => 338;
use constant WEBSTER_UNIVERSITY_BOOKSTORE        => 339;
use constant JONATHAN_BALL_PUBLISHERS            => 341;
use constant THE_CAMPUS_BOOK_SHOP                => 342;
use constant R2                                  => 343;
use constant PMS_PUBLISHERS                      => 345;
use constant INDEPENDENT_MONITORING_AUTHORITY    => 346;
use constant DOMINOVIC                           => 347;
use constant MEMMO                               => 348;
use constant NORTHWEST_MISSOURI_STATE_UNIVERSITY => 349;



my %gDefaultServiceNames = (
    AMAZON()             => [ 'Amazon',             'amazon' ],
    APPLE()              => [ 'Apple',              'apple' ],
    COURSE_SMART()       => [ 'CourseSmart',        'coursesmart' ],
    CREATE_SPACE()       => [ 'CreateSpace',        'createspace' ],
    EBOOK()              => [ 'eBooks.com',         'ebooks_com' ],
    FOLLETT()            => [ 'Follett',            'follett' ],
    SONY()               => [ 'Sony',               'sony' ],
    MBS_TEX()            => [ 'MBS',                'mbs' ],
    WEB_CT()             => [ 'WebCT',              'webct' ],
    BOOK_SURGE()         => [ 'BookSurge',          'booksurge' ],
    FOLLETT_CAFESCRIBE() => [ 'Follett-CafeScribe', 'follett_cafescribe' ],
    OVERDRIVE()          => [ 'OverDrive',          'overdrive' ],
    MOBIPOCKET()         => [ 'MobiPocket',         'mobipocket' ],
    AUDIBLE()            => [ 'Audible',            'audible' ],
    BARNES_NOBLE()       => [ 'Barnes & Noble',     'barnes_and_noble' ],
    PLAY_AWAY()          => [ 'PlayAway',           'play_away' ],
    BBC_AUDIO()          => [ 'AudioGo',            'audiogo' ],
    SCROLL_MOTION()      => [ 'ScrollMotion',       'scroll_motion' ],
    LSI()                => [ 'Ingram Digital LSI', 'ingram_digital_lsi' ],
    EMUSIC()             => [ 'eMusic',             'emusic' ],
    SIMPLY_AUDIO()       => [ 'Audiobooks.com',     'audiobooks_com' ],
    SPOKEN_NETWORK()     => [ 'Spoken Network',     'spoken_network' ],

    # name change for this service, FB5947
    KOBO()                => [ 'Rakuten Kobo',        'rakuten_kobo' ],
    FICTIONWISE()         => [ 'Fictionwise',         'fictionwise' ],
    INGRAM_DIGITAL()      => [ 'Ingram MyiLibrary',   'ingram_myilibrary' ],
    DNAML()               => [ 'DNAML',               'dnaml' ],
    RSFORMAT()            => [ 'RoyaltyShare',        'rsformat' ],
    MOBCAST()             => [ 'Blinkbox',            'blinkbox' ],
    VODAPHONE360()        => [ 'Vodafone 360',        'vodafone_360' ],
    BLACKBERRY()          => [ 'BlackBerry',          'blackberry' ],
    ORANGEUK()            => [ 'Orange UK',           'orange_uk' ],
    NOKIAOVI()            => [ 'Nokia OVI',           'nokia_ovi' ],
    ITUNES()              => [ 'iTunes',              'itunes' ],
    ANDROID_MARKETPLACE() => [ 'Android Marketplace', 'android_marketplace' ],
    ORANGE_FR()           => [ 'Orange FR',           'orange_fr' ],
    GOSPOKEN()            => [ 'GoSpoken',            'gospoken' ],
    ORANGE_BOOKSTORE()    => [ 'Orange BookStore',    'ornage_bookstore' ],
    TMOBILE_UK()          => [ 'T-Mobile UK',         'tmobile_uk' ],
    TMOBILE_AT()          => [ 'T-Mobile AT',         'tmobile_at' ],
    WHSMITH_MOBILE()      => [ 'WHSmith Mobile',      'whsmith_mobile' ],
    GARDNERS()            => [ 'Gardners',            'gardners' ],
    CHRISTIANBOOK()       => [ 'Christianbook.com',   'christianbook.com' ],
    WEREAD4YOU()          => [ 'WeRead4You',          'weread4you' ],
    WATERSTONES()         => [ 'Waterstones',         'waterstones' ],
    OLF()                 => [ 'OLF',                 'olf' ],
    FNAC()                => [ 'FNAC',                'fnac' ],
    RANDOMHOUSE()         => [ 'Random House',        'random_house' ],
    BORDERS()             => [ 'Borders',             'borders' ],
    BAKERANDTAYLOR()      => [ 'Baker and Taylor',    'baker_and_taylor' ],
    VODAFONE_UK()         => [ 'Vodafone UK',         'vodafone_uk' ],
    GOOGLE()              => [ 'Google',              'google' ],
    RIPPLE()              => [ 'Ripple',              'ripple' ],
    PREMIERAUDIOBOOKS()   => [ 'Premier Audiobooks',  'premier_audiobooks' ],
    LEARN_OUT_LOUD()      => [ 'Learn Out Loud',      'learn_out_loud' ],
    KIWITECH()            => [ 'KiwiTech',            'kiwitech' ],
    EREADERS()            => [ 'E-READERS',           'ereaders' ],
    LIBRI()               => [ 'Libri',               'libri' ],
    CHRISTIANAUDIO()      => [ 'eChristian',          'echristian' ],
    BESTSELLERLIST()      => [ 'Best Seller List',    'best_seller_list' ],
    JONATHAN_BALL()       => [ 'Jonathan Ball',       'jonathan_ball' ],
    SKOOB()               => [ 'Skoob',               'skoob' ],
    UNCUVA()              => [ 'uncuva',              'uncuva' ],

    #Name change from Anobii to Sainsbury's Entertainment FB7772
    ANOBII()                   => [ q(Sainsbury's Entertainment), 'sainsburys_entertainment' ],
    SMARTEBOOK()               => [ 'SmartEbook',                 'smartebook' ],
    CHEGG()                    => [ 'Chegg',                      'chegg' ],
    RECORDED_BOOKS()           => [ 'Recorded Books',             'recorded_books' ],
    DAWSON_BOOKS()             => [ 'Dawson Books',               'dawson_books' ],
    OREILLY()                  => [ q(O'Reilly),                  'oreilly' ],
    REDGROUP()                 => [ 'REDGroup',                   'redgroup' ],
    FOLLETT_HIGHER_EDUCATION() => [ 'Follett-Higher-Education',   'follett_higher_education' ],

    #Name change from Kno to Intel FB7810
    KNO()               => [ 'Intel',             'intel' ],
    AIDC()              => [ 'AIDC',              'aidc' ],
    AUDIO_SCHOLAR()     => [ 'Audio Scholar',     'audio_scholar' ],
    AIDC_AUTHOR()       => [ 'AIDC Author',       'aidc_author' ],
    AIDC_CONSUMER()     => [ 'AIDC Consumer',     'aidc_consumer' ],
    AIDC_PROMOTIONAL()  => [ 'AIDC Promotional',  'aidc_promotional' ],
    AIDC_TEXTBOOKS()    => [ 'AIDC Textbooks',    'aidc_textbooks' ],
    DOCSTOC()           => [ 'DocStoc',           'docstoc' ],
    THREE_M()           => [ 'Bibliotheca',       'bibliotheca' ],
    EBSCO()             => [ 'EBSCO Publishing',  'ebsco_publishing' ],
    WHEELERS()          => [ 'Wheelers',          'wheelers' ],
    SCRIBD()            => [ 'Scribd',            'scribd' ],
    INSCRIBE_DIGITAL()  => [ 'INscribe Digital',  'inscribe_digital' ],
    EBRARY()            => [ 'ebrary',            'ebrary' ],
    GOOGLE_PROMOTIONS() => [ 'Google Promotions', 'google_promotions' ],
    KOBO_PROMOTIONS()   => [ 'Kobo Promotions',   'kobo_promotions' ],
    BOOKISH()           => [ 'Booki.sh',          'booki.sh' ],
    EBOOK_COM()         => [ 'Ebook.com',         'ebook_com' ],
    TUNECORE()          => [ 'TuneCore',          'tunecore' ],
    BLACKSTONE_AUDIO()  => [ 'Blackstone Audio',  'blackstone_audio' ],

    #Name change from txtr to Juke! Entertainment FB13724
    TXTR()                   => [ 'Juke! Entertainment',    'juke' ],
    DIESEL_EBOOKS()          => [ 'Diesel eBooks',          'diesel_ebooks' ],
    COPIA()                  => [ 'Copia',                  'copia' ],
    DRAGONMOUNT()            => [ 'Dragonmount',            'dragonmount' ],
    BOOKSHOUT()              => [ 'BookShout!',             'bookshout' ],
    THE_BOOK_PEOPLE()        => [ 'The Book People',        'the_book_people' ],
    FLIPKART()               => [ 'Flipkart',               'flipkart' ],
    GOOGLE_PLAY()            => [ 'Google Play',            'google_play' ],
    ZOLA_BOOKS()             => [ 'Zola Books',             'zola_books' ],
    IGROUP()                 => [ 'iGroup',                 'igroup' ],
    ZINIO()                  => [ 'Zinio',                  'zinio' ],
    VITAL_SOURCE()           => [ 'Vital Source',           'vital_source' ],
    FEEDBOOKS()              => [ 'Feedbooks',              'feedbooks' ],
    BOOKSFREE()              => [ 'Booksfree',              'booksfree' ],
    AMBLINGBOOKS()           => [ 'Ambling Books',          'ambling_books' ],
    MACKIN()                 => [ 'Mackin',                 'mackin' ],
    COURSELOAD()             => [ 'Courseload',             'courseload' ],
    KOORONG()                => [ 'Koorong',                'koorong' ],
    TBS_DIRECT()             => [ 'TBS Direct',             'tbs_direct' ],
    AIDC_DISTRIBUTOR()       => [ 'AIDC Distributor',       'aidc_distributor' ],
    OYSTER()                 => [ 'Oyster',                 'oyster' ],
    JB_HIFI()                => [ 'JB Hi-Fi',               'jbhifi' ],
    DOUGLAS_COUNTY_LIBRARY() => [ 'Douglas County Library', 'douglas_county_library' ],
    ROWMAN_COM_ESALES()      => [ 'Rowman.com Esales',      'rowman_com_esales' ],
    READBOOKS()              => [ 'Readbooks',              'readbooks' ],
    PUBLISHERS_ROW()         => [ 'Publishers Row',         'publishers_row' ],
    BOLINDA_DIGITAL()        => [ 'Bolinda Digital',        'bolinda_digital' ],
    DIRECT_EBOOKS()          => [ 'Direct Ebooks',          'direct_ebooks' ],
    MOMENTUM_BOOKS()         => [ 'Momentum Books',         'momentum_books' ],
    READCLOUD()              => [ 'ReadCloud',              'readcloud' ],
    ENTITLE_BOOKS()          => [ 'Entitle Books',          'entitle_books' ],
    # FINDAWAY_WORLD is now InAudio (RSD-11596)
    IN_AUDIO()               => [ 'InAudio',                'in_audio' ],
    WORD()                   => [ 'Word',                   'word' ],
    BLINKBOX()               => [ 'blinkbox',               'blinkbox' ],
    NUMILOG()                => [ 'Numilog',                'numilog' ],
    HBG()                    => [ 'HBG',                    'hbg' ],
    YUZU()                   => [ 'Yuzu',                   'yuzu' ],
    SKOOBE()                 => [ 'Skoobe',                 'skoobe' ],
    MACQUARIE()              => [ 'Macquarie Direct',       'macquarie_direct' ],
    CALIFA()                 => [ 'Califa',                 'califa' ],

    #Name change from Virdocs to RedShelf FB7648
    VIRDOCS()                      => [ 'RedShelf',                         'redshelf' ],
    PROQUEST()                     => [ 'Proquest',                         'proquest' ],
    BOOKS_A_MILLION()              => [ 'Books-A-Million',                  'booksamillion' ],
    BOOKSOURCE()                   => [ 'Booksource',                       'booksource' ],
    LIBRIFY()                      => [ 'Librify',                          'librify' ],
    ACX()                          => [ 'ACX',                              'acx' ],
    SLICEBOOKS()                   => [ 'Slicebooks',                       'slicebooks' ],
    CATCH_GROUP()                  => [ 'Catch Group',                      'catch_group' ],
    GLOSE()                        => [ 'Glose',                            'glose' ],
    RM_BOOKS()                     => [ 'RM Books',                         'rm_books' ],
    PAN_AUSTRALIA()                => [ 'Pan Australia',                    'pan_australia' ],
    ODILO()                        => [ 'Odilo',                            'odilo' ],
    KORTEXT()                      => [ 'Kortext',                          'kortext' ],
    SAFARIBOOKS()                  => [ 'Safari Books',                     'safari_books' ],
    TWENTY_FOUR_SYMBOLS()          => [ '24 Symbols',                       '24_symbols' ],
    INKLING()                      => [ 'Inkling',                          'inkling' ],
    BOOKTOPIA()                    => [ 'Booktopia',                        'booktopia' ],
    PETER_PAL()                    => [ 'Peter Pal',                        'peter_pal' ],
    BITLIT_MEDIA()                 => [ 'BitLit Media',                     'bitlit_media' ],
    READWELL()                     => [ 'Readwell',                         'readwell' ],
    SHAREDBOOK()                   => [ 'SharedBook',                       'sharedbook' ],
    EPIC()                         => [ 'Epic!',                            'epic' ],
    BLLOON()                       => [ 'Blloon',                           'blloon' ],
    BOOKMATE()                     => [ 'Bookmate',                         'bookmate' ],
    ADAMS_BOOK_COMPANY()           => [ 'Adams Book Company',               'adams_book_company' ],
    GALE()                         => [ 'Gale',                             'gale' ],
    CREDO()                        => [ 'Credo',                            'credo' ],
    SHAW_DIGITAL()                 => [ 'Shaw Digital',                     'shaw_digital' ],
    ME_BOOKS_LTD()                 => [ 'Me Books Ltd',                     'me_books' ],
    STORYTEL()                     => [ 'Storytel',                         'storytel' ],
    WEBASSIGN()                    => [ 'WebAssign',                        'webassign' ],
    INKTERA()                      => [ 'Inktera',                          'inktera' ],
    UNIZIN()                       => [ 'Unizin',                           'unizin' ],
    VEARSA()                       => [ 'Vearsa',                           'vearsa' ],
    AMIGOS()                       => [ 'Amigos',                           'amigos' ],
    TRAJECTORY()                   => [ 'Trajectory',                       'trajectory' ],
    HUMMINGBIRD_DIGITAL()          => [ 'Hummingbird Digital Media',        'hummingbird_digital_media' ],
    HASTINGS_BKS_AND_RECORDS()     => [ 'Hastings BKS & Records',           'hastings_bks_and_records' ],
    CAPELLA()                      => [ 'Capella',                          'capella' ],
    GRAND_CANYON_UNIV()            => [ 'Grand Canyon Univ',                'grand_canyon_univ' ],
    TEXIDIUM()                     => [ 'Texidium',                         'texidium' ],
    ED_MAP()                       => [ 'ED Map',                           'ed_map' ],
    SAVANT_LEARNING()              => [ 'Savant Learning Systems',          'savant_learning' ],
    WESTERN_INTERNATIONAL()        => [ 'Western International University', 'western_international' ],
    DEVRY()                        => [ 'DeVry',                            'devry' ],
    CEC()                          => [ 'CEC',                              'cec' ],
    ECAMPUS()                      => [ 'eCampus',                          'ecampus' ],
    COPYRIGHT_CLEARANCE()          => [ 'Copyright Clearance',              'copyright_clearance' ],
    INDIANA_UNIVERSITY()           => [ 'Indiana University',               'indiana_university' ],
    APUS()                         => [ 'APUS',                             'apus' ],
    ZOVIO()                        => [ 'Zovio',                            'zovio' ],
    LAUREATE()                     => [ 'Laureate',                         'laureate' ],
    BLOOMSBURY_COM()               => [ 'Bloomsbury.com',                   'bloomsbury_com' ],
    SNAPPLIFY()                    => [ 'Snapplify',                        'snapplify' ],
    EDMC()                         => [ 'EDMC',                             'edmc' ],
    AMBASSADOR()                   => [ 'Ambassador',                       'ambassador' ],
    APOLLO_GROUP()                 => [ 'Apollo Group',                     'apollo_group' ],
    SHELFIE()                      => [ 'Shelfie',                          'shelfie' ],
    FAITHLIFE()                    => [ 'Faithlife',                        'faithlife' ],
    ONECLICKDIGITAL()              => [ 'W.F. Howes',                       'w_f_howes' ],
    XANEDU()                       => [ 'XanEdu',                           'xanedu' ],
    WGU()                          => [ 'WGU',                              'wgu' ],
    LIBRARY_IDEAS()                => [ 'Library Ideas',                    'library_ideas' ],
    ALEXI()                        => [ 'Alexi',                            'alexi' ],
    PERUSALL()                     => [ 'Perusall',                         'perusall' ],
    CNPEREADING()                  => [ 'CNPeReading',                      'cnpereading' ],
    CORBAN_UNIVERSITY()            => [ 'Corban University',                'corban_university' ],
    MICROSOFT()                    => [ 'Microsoft',                        'microsoft' ],
    KINOKUNIYA()                   => [ 'Kinokuniya',                       'kinokuniya' ],
    BFC_GB()                       => [ 'BFC-GB',                           'bfc_gb' ],
    BFC_US()                       => [ 'BFC-US',                           'bfc_us' ],
    BARNES_NOBLE_EDUCATION()       => [ 'Barnes & Noble Education',         'barnes_and_noble_education' ],
    LANGUAGE_WORLD()               => [ 'Language World',                   'language_world' ],
    BOKBASEN()                     => [ 'Bokbasen',                         'bokbasen' ],
    ACROBATIQ()                    => [ 'Acrobatiq',                        'acrobatiq' ],
    NYU()                          => [ 'NYU',                              'nyu' ],
    MULTNOMAH_UNIVERSITY()         => [ 'Multnomah University',             'multnomah_university' ],
    WESTMINSTER_LIBRARY()          => [ 'Westminster Library',              'westminster_library' ],
    PRINCETON_UNIVERSITY()         => [ 'Princeton University',             'princeton_university' ],
    DOWNPOUR()                     => [ 'Downpour',                         'downpour' ],
    WESTERN_THEOLOGICAL_SEMINARY() => [ 'Western Theological Seminary',     'western_theological_seminary' ],
    VERBA()                        => [ 'Verba',                            'verba' ],
    ALEXANDER_STREET()             => [ 'Alexander Street',                 'alexander_street' ],
    KNOVEL()                       => [ 'Knovel',                           'knovel' ],
    PRODEVIA_LEARNING()            => [ 'Prodevia Learning',                'prodevia_learning' ],
    PERMA_BOUND()                  => [ 'Perma-Bound Books',                'perma_bound_books' ],
    LIX()                          => [ 'Lix',                              'lix' ],
    BOOKPAL()                      => [ 'BookPal',                          'bookpal' ],
    MORGAN_LIBRARY()               => [ 'Morgan Library',                   'morgan_library' ],
    ADTALEM_CHAMBERLAIN()          => [ 'Adtalem-Chamberlain',              'adtalem_chamberlain' ],
    BOKSALA_STUDENTA()             => [ 'Boksala studenta',                 'boksala_studenta' ],
    BAOBAB_EBOOK_SERVICES()        => [ 'Baobab eBook Services',            'baobab_ebook_services' ],
    PERLEGO()                      => [ 'Perlego',                          'perlego' ],
    HOOPLA_DIGITAL()               => [ 'Hoopla Digital',                   'hoopla_digital' ],
    EBA()                          => [ 'EBA',                              'eba' ],
    AUDIOBOOKSNOW()                => [ 'AudiobooksNow.com',                'audiobooksnow' ],
    ECONCORDIA()                   => [ 'eConcordia',                       'econcordia' ],
    FRANKLIN_UNIVERSITY()          => [ 'Franklin University',              'franklin_university' ],
    VIVLIO()                       => [ 'Vivlio',                           'vivlio' ],
    CSU_FULLERTON()                => [ 'CSU Fullerton',                    'csu_fullerton' ],
    SHANGHAI_BOOK_TRADERS()        => [ 'Shanghai Book Traders',            'shanghai_book_traders' ],
    WILLIAM_PERKINS_LIBRARY()      => [ 'William Perkins Library',          'william_perkins_library' ],
    ALKEM()                        => [ 'ALKEM',                            'alkem' ],
    NEMCC()                        => [ 'NEMCC',                            'nemcc' ],
    LIBRIOS()                      => [ 'Librios',                          'librios' ],
    MOFIBO()                       => [ 'Mofibo',                           'mofibo' ],
    LEO_DEHON_LIBRARY()            => [ 'Leo Dehon Library',                'leo_dehon_library' ],
    YOUNGSTOWN_STATE()             => [ 'Youngstown State',                 'youngstown_state' ],
    WRIGHT_STATE()                 => [ 'Wright State',                     'wright_state' ],
    CATHOLIC_DISTANCE_UNIVERSITY() => [ 'Catholic Distance University',     'catholic_distance_university' ],
    PROQUEST_SUBSCRIPTION()        => [ 'ProQuest Subscription',            'proquest_subscription' ],
    BARNES_NOBLE_FIRST_DAY()       => [ 'Barnes & Noble - First Day',       'barnes_and_noble_first_day' ],
    PENN_FOSTER()                  => [ 'Penn Foster',                      'penn_foster' ],
    BOOKWIRE()                     => [ 'Bookwire',                         'bookwire' ],
    JUGGERNAUT()                   => [ 'Juggernaut',                       'juggernaut' ],
    LIBRO()                        => [ 'Libro.fm',                         'libro_fm' ],
    DE_MARQUE()                    => [ 'De Marque',                        'de_marque' ],
    WKU()                          => [ 'WKU',                              'wku' ],
    AUDIOBOOK_STORE()              => [ 'AudiobookStore.com',               'audiobook_store' ],
    CLOUDALOUD()                   => [ 'Cloudaloud',                       'cloudaloud' ],
    COLUMBIA_SOUTHERN_UNIVERSITY() => [ 'Columbia Southern University',     'columbia_southern_university' ],
    AIDC_SPECIAL()                 => [ 'AIDC Special',                     'aidc_special' ],
    ONEWORLD_CONTENT()             => [ '1World Content',                   '1world_content' ],
    ATHABASCA_UNIVERSITY()         => [ 'Athabasca University',             'athabasca_university' ],
    NEXTORY()                      => [ 'Nextory',                          'nextory' ],
    BOOKBEAT()                     => [ 'BookBeat',                         'bookbeat' ],
    ZEBRALUTION()                  => [ 'Zebralution',                      'zebralution' ],
    RALLY_READER()                 => [ 'Rally Reader',                     'rally_reader' ],
    PEC()                          => [ 'PEC',                              'pec' ],
    IZNEO()                        => [ 'Izneo',                            'izneo' ],
    OPEN_ROAD_MEDIA()              => [ 'Open Road Media',                  'open_road_media' ],
    BLINKIST()                     => [ 'Blinkist',                         'blinkist' ],
    FABLE()                        => [ 'Fable',                            'fable' ],
    BIBLIU()                       => [ 'BibliU',                           'bibliu' ],
    HEKMAN_LIBRARY()               => [ 'Hekman Library',                   'hekman_library' ],
    YOTO()                         => [ 'Yoto',                             'yoto' ],
    CHAPTER()                      => [ 'Chapter',                          'chapter' ],
    WILLO_LABS()                   => [ 'Willo Labs',                       'willo_labs' ],
    CAMPUS_EBOOKSTORE()            => [ 'Campus eBookstore',                'campus_ebookstore' ],
    XIG_XAG()                      => [ 'XigXag',                           'xigxag' ],
    CHIRP()                        => [ 'Chirp',                            'chirp' ],
    BOOK_OF_THE_MONTH()            => [ 'Book of the Month',                'book_of_the_month' ],
    SPEECHIFY()                    => [ 'Speechify',                        'speechify' ],
    MARUZEN_YUSHODO()              => [ 'Maruzen-Yushodo Co.,Ltd.',         'maruzen_yushodo_co_ltd' ],
    CEPIEC()                       => [ 'CEPIEC',                           'cepiec' ],
    HENI()                         => [ 'HENI',                             'heni' ],
    CAMBRIDGE_BUSINESS_PUBLISHERS() => [ 'Cambridge Business Publishers',   'cambridge_business_publishers' ],
    ALDI()                         => [ 'Aldi',                             'aldi' ],
    THOUSAND_COOKBOOKS_LTD()       => ['1000 Cookbooks Ltd',                '1000_cookbooks_ltd'],
    BOOKSIO()                      => [ 'BOOKSIO',                          'booksio' ],
    UAGC()                         => [ 'UAGC',                             'uagc' ],
    UNIVERSITY_OF_MISSISSIPPI()    => [ 'University of Mississippi',        'university_of_mississippi' ],
    SOOMO_LEARNING()               => [ 'Soomo Learning',                   'soomo_learning' ],
    SPOTIFY()                      => [ 'Spotify',                          'spotify' ],
    CASALINI()                     => [ 'Casalini',                         'casalini' ],
    SAXO()                         => [ 'Saxo',                             'saxo' ],
    BOOKT()                        => [ 'Bookt',                            'bookt' ],
    PANSING()                      => [ 'Pansing',                          'pansing' ],
    # new service, previously was TEXTBOOKS_COM
    MBS_TEXTBOOK_EXCHANGE()        => [ 'MBS Textbook Exchange',            'mbs_textbook_exchange' ],
    BUKU()                         => [ 'Buku',                             'buku' ],
    SKILLSOFT()                    => [ 'Skillsoft',                        'skillsoft' ],
    # new service, previously was Bibliotheca
    OCLC()                         => [ 'OCLC',                             'oclc' ],
    BLOOMSBURY_DIRECT_SALES()      => [ 'Bloomsbury - Direct Sales',        'bloomsbury_direct_sales' ],
    LEGIBLE()                      => [ 'Legible',                          'legible' ],
    LOGIN()                        => [ 'Login',                            'login' ],
    HEIMKAUP()                     => [ 'Heimkaup',                         'heimkaup' ],
    OSPREY_WEBSITE()               => [ 'Osprey Website',                   'osprey_website' ],
    BLOOMSBURY_WEBSITE()           => [ 'Bloomsbury Website',               'bloomsbury_website' ],
    WEILBACH()                     => [ 'Weilbach',                         'weilbach' ],
    CLASSOOS()                     => [ 'Classoos',                         'classoos' ],
    BOOKSHOP()                     => [ 'Bookshop',                         'bookshop' ],
    JSTOR_ITHAKA()                 => [ 'JSTOR',                            'jstor_ithaka' ],
    ONEBOOKSHELF()                 => [ 'OneBookShelf',                     'onebookshelf' ],
    WARLORD_GAMES()                => [ 'Warlord Games',                    'warlord_games' ],
    BLOOMSBURY_PROFESSIONAL()      => [ 'Bloomsbury Professional',          'bloomsbury_professional' ],
    FOOTNOTE()                     => [ 'Footnote',                         'footnote' ],
    SWINBURNE_ONLINE()             => [ 'Swinburne Online',                 'swinburne_online' ],
    BOOKERY()                      => [ 'Bookery',                          'bookery' ],
    BACCAH_IT()                    => [ 'Baccah IT',                        'baccah_it' ],
    BOX_OF_BOOKS()                 => [ 'Box of Books',                     'box_of_books' ],
    POLYTEKNISK()                  => [ 'Polyteknisk',                      'polyteknisk' ],
    KEELE_UNIVERSITY()             => [ 'Keele University',                 'keele_university' ],
    EDINBURGH_NAPIER_UNIVERSITY()  => [ 'Edinburgh Napier University',      'edinburgh_napier_university' ],
    BATH_SPA_UNIVERSITY()          => [ 'Bath Spa University',              'bath_spa_university' ],
    GROWMORE_GENERAL_TRADING_CO()  => [ 'Growmore General Trading Co',      'growmore_general_trading_co' ],
    DSM_FIRMENICH()                => [ 'Dsm-Firmenich',                    'dsm_firmenich' ],
    BASHEER_GRAPHIC_BOOKS()        => [ 'Basheer Graphic Books',            'basheer_graphic_books' ],
    ADDED_INFO_SERVICES()          => [ 'Added Info Services',              'added_info_services' ],
    VISION_IP_CO()                 => [ 'Vision IP Co LTD',                 'vision_ip_co' ],
    DAR_AL_FAJR_FOR_PUB_AND_DIST() => [ 'Dar Al-Fajr for Publishing & Distribution', 'dar_al_fajr_for_publishing_and_distribution' ],
    ALL_PRINTS()                   => [ 'All Prints LLC',                   'all_prints' ],
    PERIPLUS_HOLDINGS()            => [ 'Periplus Holdings Ltd',            'periplus_holdings' ],
    RAFBOKIN()                     => [ 'Rafbókin',                         'rafbokin' ],
    CUHK()                         => [ 'CUHK',                             'cuhk' ],
    INTO_MANCHESTER()              => [ 'INTO Manchester',                  'into_manchester' ],
    FAHASA()                       => [ 'Fahasa',                           'fahasa' ],
    UNIVERSITY_OF_MICHIGAN()       => [ 'University of Michigan',           'university_of_michigan' ],
    UNIVERSITY_OF_EDINBURGH()      => [ 'University of Edinburgh',          'university_of_edinburgh' ],
    ENAMUH()                       => [ 'Enamuh Ltd',                       'enamuh' ],
    PLAYAWAY()                     => [ 'Playaway',                         'playaway' ],
    LIBRERIA_SCIENTIFICA()                => [ 'Libreria Scientifica',                'libreria_scientifica' ],
    BRIGHT()                              => [ 'Bright',                              'bright' ],
    UNISTER_INTERNATIONAL_LIMITED()       => [ 'Unister International Limited',       'unister_international_limited' ],
    UNIVERSITY_OF_EASTERN_FINLAND()       => [ 'University of Eastern Finland',       'university_of_eastern_finland' ],
    EF_LANGUAGE_LEARNING_SOLUTIONS_AG()   => [ 'EF Language Learning Solutions AG',   'ef_language_learning_solutions_ag' ],
    SUP_RETAIL()                          => [ 'SUP Retail',                          'sup_retail' ],
    DK_TODAY()                            => [ 'D.K Today',                           'd_k_today' ],
    WEBSTER_UNIVERSITY_BOOKSTORE()        => [ 'Webster University Bookstore',        'webster_university_bookstore' ],
    JONATHAN_BALL_PUBLISHERS()            => [ 'Jonathan Ball Publishers',            'jonathan_ball_publishers' ],
    THE_CAMPUS_BOOK_SHOP()                => [ 'The Campus Book Shop',                'the_campus_book_shop' ],
    R2()                                  => [ 'R2',                                  'r2' ],
    PMS_PUBLISHERS()                      => [ 'PMS Publishers',                      'pms_publishers' ],
    INDEPENDENT_MONITORING_AUTHORITY()    => [ 'Independent Monitoring Authority',    'independent_monitoring_authority' ],
    DOMINOVIC()                           => [ 'Dominovic',                           'dominovic' ],
    MEMMO()                               => [ 'Memmo',                               'memmo' ],
    NORTHWEST_MISSOURI_STATE_UNIVERSITY() => [ 'Northwest Missouri State University', 'northwest_missouri_state_university' ],

);

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my %properties;
    if ( $args{dbItem} ) {
        $self->_propertiesFromDBItem( \%properties, $args{dbItem} );
    } elsif ( defined $args{serviceID} ) {
        $self->_propertiesFromDB( \%properties, $args{serviceID} );
    }

    my $rval = $self->_initProperties( \%properties );

    return $rval;
}

sub _propertiesFromDB {
    my ( $self, $hrProperties, $serviceID ) = @_;
    assert($serviceID);

    my $dbItem = BookPub::DB::Item::Service->Lookup( service_id => $serviceID );
    if ($dbItem) {
        $self->_propertiesFromDBItem( $hrProperties, $dbItem );
    }
}

sub _propertiesFromDBItem {
    my ( $self, $hrProperties, $dbItem ) = @_;
    assert($dbItem);

    # Save a reference to the dbItem we used, so we can tell later if this object
    # exists in the database already...
    #
    $self->{_dbItem} = $dbItem;

    $hrProperties->{service_id}          = $dbItem->service_id;
    $hrProperties->{service_name}        = $dbItem->service_name;
    $hrProperties->{service_name_clean}  = $dbItem->service_name_clean;
    $hrProperties->{client_service_name} = $dbItem->client_service_name;

    $hrProperties->{date_created}  = $dbItem->date_created;
    $hrProperties->{date_modified} = $dbItem->date_modified;
}

sub _initProperties {
    my ( $self, $hrProperties ) = @_;

    $self->{ServiceID}         = $hrProperties->{service_id};
    $self->{ServiceName}       = $hrProperties->{service_name};
    $self->{ServiceNameClean}  = $hrProperties->{service_name_clean};
    $self->{ClientServiceName} = $hrProperties->{client_service_name};

    $self->{DateCreated}  = Common::FormObject::Scalar::DateTime->new( value => $hrProperties->{date_created},  readOnly => 1 );
    $self->{DateModified} = Common::FormObject::Scalar::DateTime->new( value => $hrProperties->{date_modified}, readOnly => 1 );
    return $self;
}

# -------------------------------
# Static Methods
# -------------------------------

sub GetAllServiceNames {
    my %services;
    my $allServices = BookPub::DB::Item::Service->GetAll();
    while ( my $service = $allServices->next() ) {
        $services{ $service->service_id } = $service->service_name;
    }
    return \%services;
}

sub GetAllServiceNamesInPeriod {
    my %args     = @_;
    my $periodID = $args{periodID};
    assert( defined($periodID), "periodID is a required parameter" );

    my $allServices = BookPub::DB::Item::Service->GetAllInPeriodSortedByName($periodID);

    return $allServices;
}

sub GetAllServiceIDs {
    my $self = shift;
    return keys(%gDefaultServiceNames);
}

sub GetServiceNameMap {
    my %args     = @_;
    my $field    = $args{clean} ? 1 : 0;
    my %services = ();

    map { $services{ lc( $gDefaultServiceNames{$_}->[$field] ) } = $_ } keys %gDefaultServiceNames;

    return \%services;
}

sub GetServiceIDByName {
    my $serviceName = shift || return;
    my $serviceMap = GetServiceNameMap();

    return $serviceMap->{ lc($serviceName) };
}

#
# AddService
#
# !!! CHANGING THIS INTERFACE.
# !!! NO REASON TO PASS CLIENT_ID.
# Adds an entry in a Client's Service table for a (new) Service.
# Does nothing if there is already an entry for that service_id.
# Uses default service names defined locally.
# TODO - Might want to be able to override the default names.
#
sub AddService {
    my %args       = @_;
    my $service_id = $args{service_id};
    assert( $service_id, "service_id is a required parameter" );

    # Only add if it doesn't already exist...
    #
    return if ( BookPub::DB::Item::Service->Lookup( service_id => $service_id ) );

    # Add an entry into the service table for this service.
    #
    my ( $serviceName, $cleanName );
    my $namesArrayRef = $gDefaultServiceNames{$service_id};
    if ( defined $namesArrayRef ) {
        $serviceName = $$namesArrayRef[0];
        $cleanName   = $$namesArrayRef[1];
    } else {
        $serviceName = "Service $service_id";
        $cleanName   = "service_" . $service_id;
    }
    my $service = BookPub::DB::Item::Service->Create(
        service_id         => $service_id,
        service_name       => $serviceName,
        service_name_clean => $cleanName,
    );
    $service->save();
}

sub GetDefaultServiceName {
    my %args       = @_;
    my $service_id = $args{service_id};
    my $field      = $args{clean} ? 1 : 0;

    return $gDefaultServiceNames{$service_id}->[$field];
}

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