From f7e1b07f5072f9da9203b307ad33bea797c032b1 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Mon, 12 Sep 2022 15:16:13 +0200
Subject: [PATCH] - removed dead code (add_mappings unwanted)

---
 deploy_mediaconch/add_dnx_mappings/README.txt |  32 --
 .../add_dnx_mappings/add_dnx_mappings.pl      | 339 ------------------
 2 files changed, 371 deletions(-)
 delete mode 100644 deploy_mediaconch/add_dnx_mappings/README.txt
 delete mode 100644 deploy_mediaconch/add_dnx_mappings/add_dnx_mappings.pl

diff --git a/deploy_mediaconch/add_dnx_mappings/README.txt b/deploy_mediaconch/add_dnx_mappings/README.txt
deleted file mode 100644
index 96ba473..0000000
--- a/deploy_mediaconch/add_dnx_mappings/README.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-How to automatically add Mappings between extracted Technical Metadata and DNX Significant Properties in Rosetta
-================================================================================================================
-
-:lang: en
-:encoding: utf-8
-:author: Jörg Sachse
-
-== Prerequisites
-
-* Desktop environment
-* Perl programming language
-* Selenium Perl module (download at https://metacpan.org/pod/Selenium::Remote::Driver)
-* Chrome browser (download at https://www.google.com/intl/de_de/chrome/)
-* Chrome driver compatible with the installed Chrome browser (download at https://sites.google.com/chromium.org/driver/)
-
-== How to install on Debian 11 (Buster)
-* sudo apt install perl chromium cpanminus unzip
-* cpanm Selenium::Remote::Driver
-* check Chromium version (i.e. "91.x.xxxx.xxx") --> download coresponding 'chromedriver_linux64.zip' from https://sites.google.com/chromium.org/driver/ (Downloads)
-* unzip chromedriver_linux64.zip
-
-== How to build
-
-* You don't have to do anything, just run the script.
-
-== How to run
-
-* general invocation
-** $# perl -I path/to/perl/modules .add_dnx_mappings.pl "Rosetta-Host.Domain.tld" "Rosetta-User" "Rosetta-Password" "Institution-Name" "Portnumber"
-
-* example invocation:
-** $# perl -I ~/perl5/lib/perl5 ./add_dnx_mappings.pl "sdvrosetta-test.slub-dresden.de" "su-user" "Sw0rdF!$h" "SLUB" "8443"
diff --git a/deploy_mediaconch/add_dnx_mappings/add_dnx_mappings.pl b/deploy_mediaconch/add_dnx_mappings/add_dnx_mappings.pl
deleted file mode 100644
index 5a00c80..0000000
--- a/deploy_mediaconch/add_dnx_mappings/add_dnx_mappings.pl
+++ /dev/null
@@ -1,339 +0,0 @@
-#!/usr/bin/env perl
-# adds all dnx properties
-#
-# usage:   perl add_dnx_mappings.pl rosetta-host rosetta-user rosetta-user-password rosetta-institution rosetta-login-port
-# example: perl add_dnx_mappings.pl rosetta.my-archive.domain user1 12345 MYINSTITUTE 8443
-#
-# needs a geckodriver and the Selenium::Remote::Driver module
-# see http://www.seleniumhq.org/
-#
-# tested against Rosetta 7.1 using ChromeDriver 98.0.4758.102 and Chrome 98 in Debian 11
-#
-# ensure, that the plugin is assigned to a classification, for example to "Video"
-
-use strict;
-use warnings;
-use utf8;
-use feature qw(say signatures);
-no warnings qw(experimental::signatures);
-use Selenium::Remote::Driver;
-use Selenium::Chrome;
-use Term::ANSIColor; # colored print
-use Getopt::Long;
-
-
-my $host;
-my $protocol = 'https';
-my $ui_port = "8443";
-my $user;
-my $passwd;
-my $institution;
-my $plugin_name = 'SLUBTechnicalMetadataExtractorMediaConchPlugin';
-my $classification_group = 'Video';
-my $driver;
-
-GetOptions(
-    "rosetta_host=s{1}"         => \$host,
-    "protocol:s{1}"             => \$protocol,
-    "ui_port:s{1}"              => \$ui_port,
-    "user=s{1}"                 => \$user,
-    "password=s{1}"             => \$passwd,
-    "institution=s{1}"          => \$institution,
-    "plugin_name:s{1}"          => \$plugin_name,
-    "classification_group:s{1}" => \$classification_group
-) or die("Error in command line arguments\n");
-die("invalid/missing argument: --rosetta_host")         unless $host;
-die("invalid/missing argument: --protocol")             unless $protocol;
-die("invalid/missing argument: --ui_port")              unless $ui_port;
-die("invalid/missing argument: --user")                 unless $user;
-die("invalid/missing argument: --password")             unless $passwd;
-die("invalid/missing argument: --institution")          unless $institution;
-die("invalid/missing argument: --plugin_name")          unless $plugin_name;
-die("invalid/missing argument: --classification_group") unless $classification_group;
-
-my %mediainfo2dnx = (
-    "mediainfo.track.Audio.BitDepth"                          => "audio.bit_depth",
-    "mediainfo.track.Audio.BitRate"                           => "audio.bit_rate",
-    "mediainfo.track.Audio.BitRate_Mode"                      => "audio.bit_rate_mode",
-    "mediainfo.track.Audio.Channels"                          => "audio.channel_s_",
-    "mediainfo.track.Audio.CodecID"                           => "audio.codec_ID",
-    "mediainfo.track.Audio.Commercial_Name"                   => "audio.commercial_name",
-    "mediainfo.track.Audio.Compression_Mode"                  => "audio.compression_mode",
-    "mediainfo.track.Audio.Default"                           => "audio.default",
-    "mediainfo.track.Audio.Duration"                          => "audio.duration",  # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Audio.encoded_library"                   => "audio.encoded_library",
-    "mediainfo.track.Audio.Forced"                            => "audio.forced",
-    "mediainfo.track.Audio.Format"                            => "audio.format",
-    "mediainfo.track.Audio.Format_Profile"                    => "audio.format_profile",
-    # "mediainfo.track.Audio.Format_Settings_Sign"              => "audio.format_settings_sign",  # not in FL
-    "mediainfo.track.Audio.Format_Settings_Wrapping"          => "audio.format_Settings_Wrapping",
-    "mediainfo.track.Audio.Format_Version"                    => "audio.format_version",
-    "mediainfo.track.Audio.FrameRate"                         => "audio.frame_rate",
-    "mediainfo.track.Audio.ID"                                => "audio.ID",
-    "mediainfo.track.Audio.SamplingRate"                      => "audio.sampling_rate", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Audio.ServiceKind"                       => "audio.service_kind",
-    "mediainfo.track.Audio.StreamSize"                        => "audio.stream_size", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Audio.Title"                             => "audio.title",
-    "mediainfo.track.General.AudioCount"                      => "general.audio_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.General.CodecID"                         => "general.codec_ID",
-    "mediainfo.track.General.CompleteName"                    => "general.complete_name",
-    # "mediainfo.track.General.Description"                     => "general.description",  # not in FL
-    "mediainfo.track.General.Duration"                        => "general.duration",
-    "mediainfo.track.General.Encoded_Application_CompanyName" => "general.encoded_application_company_name",
-    "mediainfo.track.General.Encoded_Application"             => "general.writing_application",
-    "mediainfo.track.General.Encoded_Application_Name"        => "general.encoded_application_name",
-    "mediainfo.track.General.Encoded_Application_Version"     => "general.encoded_application_version",
-    "mediainfo.track.General.Encoded_Date"                    => "general.encoded_date",
-    "mediainfo.track.General.Encoded_Library"                 => "general.writing_library",
-    "mediainfo.track.General.Encoded_Library_Name"            => "general.encoded_library_name",
-    "mediainfo.track.General.Encoded_Library_Version"         => "general.encoded_library_version",
-    "mediainfo.track.General.extra.Attachments"               => "general.extra.attachments",
-    # "mediainfo.track.General.extra.bext_Present"              => "general.extra.bext_present",  # not in FL
-    "mediainfo.track.General.extra.ErrorDetectionType"        => "general.extra.error_detection_type",
-    "mediainfo.track.General.extra.IsTruncated"               => "general.extra.is_truncated",
-    "mediainfo.track.General.FileSize"                        => "general.file_size",
-    "mediainfo.track.General.Format"                          => "general.format",
-    "mediainfo.track.General.Format_Profile"                  => "general.format_profile",
-    "mediainfo.track.General.Format_Settings"                 => "general.format_settings",
-    "mediainfo.track.General.Format_Version"                  => "general.format_version",
-    "mediainfo.track.General.IsStreamable"                    => "general.is_streamable",
-    "mediainfo.track.General.MenuCount"                       => "general.menu_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.General.OtherCount"                      => "general.other_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.General.OverallBitRate"                  => "general.overall_bit_rate",
-    "mediainfo.track.General.OverallBitRateMode"              => "general.overall_bit_rate_mode",
-    "mediainfo.track.General.PackageName"                     => "general.package_name",
-    # "mediainfo.track.General.Producer"                        => "general.producer",  # not in FL
-    "mediainfo.track.General.StreamSize"                      => "general.stream_size", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.General.TextCount"                       => "general.text_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.General.Title"                           => "general.title",
-    "mediainfo.track.General.UniqueID"                        => "general.unique_id",
-    "mediainfo.track.General.VideoCount"                      => "general.video_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Image.BitDepth"                          => "image.bit_depth",
-    "mediainfo.track.Image.ColorSpace"                        => "image.color_space",
-    "mediainfo.track.Image.colour_primaries"                  => "image.color_primaries",
-    "mediainfo.track.Image.Compression_Mode"                  => "image.compression_mode",
-    "mediainfo.track.Image.DisplayAspectRatio"                => "image.display_aspect_ratio",
-    "mediainfo.track.Image.Encoded_Date"                      => "image.encoded_date",
-    "mediainfo.track.Image.Encoded_Library"                   => "image.writing_library",
-    "mediainfo.track.Image.Format"                            => "image.format",
-    "mediainfo.track.Image.Format_Version"                    => "image.format_version",
-    "mediainfo.track.Image.FrameRate"                         => "image.frame_rate",
-    "mediainfo.track.Image.Height"                            => "image.height",
-    "mediainfo.track.Image.StreamSize"                        => "image.stream_size",
-    "mediainfo.track.Image.transfer_characteristics"          => "image.transfer_characteristics",
-    "mediainfo.track.Image.Width"                             => "image.width",
-    "mediainfo.track.Video.BitDepth"                          => "video.bit_depth",
-    "mediainfo.track.Video.BitRate_Mode"                      => "video.bit_rate_mode",
-    "mediainfo.track.Video.BitRate"                           => "video.bit_rate", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Video.BitsPixel_Frame"                   => "video.bits__Pixel_Frame_",
-    "mediainfo.track.Video.ChromaSubsampling"                 => "video.chroma_subsampling",
-    "mediainfo.track.Video.CodecID"                           => "video.codec_ID",
-    "mediainfo.track.Video.ColorSpace"                        => "video.color_space",
-    "mediainfo.track.Video.Compression_Mode"                  => "video.compression_mode",
-    "mediainfo.track.Video.Default"                           => "video.default",
-    "mediainfo.track.Video.DisplayAspectRatio"                => "video.display_aspect_ratio", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Video.Duration"                          => "video.duration", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Video.Encoded_Library"                   => "video.encoded_library",
-    "mediainfo.track.Video.extra.coder_type"                  => "video.extra.coder_type",
-    "mediainfo.track.Video.extra.ErrorDetectionType"          => "video.extra.error_detection_type",
-    "mediainfo.track.Video.extra.MaxSlicesCount"              => "video.extra.max_slices_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Video.extra.OriginalSourceMedium"        => "video.extra.original_source_medium",
-    "mediainfo.track.Video.Forced"                            => "video.forced",
-    "mediainfo.track.Video.Format_Profile"                    => "video.format_profile",
-    "mediainfo.track.Video.Format_Settings_GOP"               => "video.format_settings_GOP",
-    "mediainfo.track.Video.Format_Settings_Wrapping"          => "video.format_Settings_Wrapping",
-    "mediainfo.track.Video.Format_Version"                    => "video.format_version",
-    "mediainfo.track.Video.Format"                            => "video.format",
-    "mediainfo.track.Video.FrameCount"                        => "video.frame_count", # HINT: type NUMBER in Rosetta
-    "mediainfo.track.Video.FrameRate"                         => "video.frame_rate",
-    "mediainfo.track.Video.Height"                            => "video.height",
-    "mediainfo.track.Video.ID"                                => "video.ID",
-    "mediainfo.track.Video.PixelAspectRatioOriginal"          => "video.pixel_aspect_ratio_original",
-    "mediainfo.track.Video.PixelAspectRatio"                  => "video.pixel_aspect_ratio",
-    "mediainfo.track.Video.ScanOrder"                         => "video.scan_order",
-    "mediainfo.track.Video.ScanType"                          => "video.scan_type",
-    "mediainfo.track.Video.Standard"                          => "video.standard",
-    "mediainfo.track.Video.StreamSize"                        => "video.stream_size",
-    "mediainfo.track.Video.TimeCode_FirstFrame"               => "video.time_code_of_first_frame",
-    "mediainfo.track.Video.TimeCode_Source"                   => "video.time_code_source",
-    "mediainfo.track.Video.Title"                             => "video.title",
-    "mediainfo.track.Video.transfer_characteristics"          => "video.transfer_characteristics",
-    "mediainfo.track.Video.Width"                             => "video.width"
-);
-
-sub login {
-    $driver->get("$protocol://$host:${ui_port}/mng?auth=local");
-    my $ele_institute = $driver->find_element("institution", "id");
-    $driver->find_child_element($ele_institute, "./option[\@value='$institution']", "xpath")->click;
-    $driver->find_element("userName", "id")->clear;
-    $driver->find_element("userName", "id")->send_keys($user);
-    $driver->find_element("password", "id")->clear;
-    $driver->find_element("password", "id")->send_keys($passwd);
-    $driver->find_element("login", "id")->click;
-}
-
-sub logout {
-    $driver->get("$protocol://$host:${ui_port}/mng/action/menus.do?first_time_key=com.exlibris.dps.wrk.general.menu");
-    my $ele = $driver->find_element("user", "id")->click;
-    $driver->pause();
-    $ele = $driver->find_element("Logout", "link")->click;
-}
-
-sub _change_to_xxx_format_library {
-    $driver->get("$protocol://$host:${ui_port}/mng/action/menus.do?first_time_key=com.exlibris.dps.wrk.general.menu");
-    $driver->find_element("//a[\@title='Administer the system']", "xpath")->click;
-    $driver->find_element("General Parameters", "link")->click;
-    $driver->find_element("modules_button", "id")->click;
-    $driver->find_element("//li[\@title='format_library']", "xpath")->click;
-    my $tr = $driver->find_element("//tr[starts-with(td,'format_library_is_global')]", "xpath");
-    my $td = $driver->find_child_element($tr, "./td[\@class='form-inline']", "xpath");
-    $driver->find_element("generalParameters_model_parameters_2__value_button", "id")->click;
-    say "click combobox button";
-    return $td;
-}
-
-sub change_to_global_format_library {
-    my $td = _change_to_xxx_format_library();
-    $driver->find_child_element($td, "descendant::li[text()='true']", "xpath")->click;
-    say "select true";
-    $driver->find_element("//button[\@value='Update']", "xpath")->click;
-    say "click update button";
-}
-
-sub change_to_local_format_library {
-    my $td = _change_to_xxx_format_library();
-    $driver->find_child_element($td, "descendant::li[text()='false']", "xpath")->click;
-    say "select false";
-    $driver->find_element("//button[\@value='Update']", "xpath")->click;
-    say "click update button";
-    $driver->pause();
-}
-
-sub add_dnx_property ($dnx_property, $dnx_description) {
-    my $dow = localtime;
-    $driver->get("$protocol://$host:${ui_port}/mng/action/pageAction.page_xml.page_sig_prop_list.xml.do?pageViewMode=Edit&pageBean.currentUserMode=GLOBAL&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryGLOBAL.mngLibraryHeader.SigProps.InnerMenu&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryGLOBAL.mngLibraryHeader.SigProps.InnerMenu&backUrl=");
-    $driver->pause();
-    $driver->find_element("Add Significant Property", "link")->click;
-    $driver->find_element("selectedSigPropname", "id")->clear;
-    $driver->find_element("selectedSigPropname", "id")->send_keys("$dnx_property");
-    $driver->find_element("selectedSigPropdescription", "id")->clear;
-    $driver->find_element("selectedSigPropdescription", "id")->send_keys("$dnx_description (automatically added by ${0}, $dow)");
-    $driver->find_element("SaveSigPropGenDetails", "name")->click;
-}
-
-sub join_dnx_property_to_classification_group ($dnx_property) {
-    $driver->get("$protocol://$host:${ui_port}/mng/action/pageAction.page_xml.page_classification_list.xml.do?pageViewMode=Edit&pageBean.currentUserMode=GLOBAL&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryGLOBAL.mngLibraryHeader.Classifications.InnerMenu&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryGLOBAL.mngLibraryHeader.Classifications.InnerMenu&backUrl=");
-    $driver->pause();
-    $driver->find_element("find0.0", "id")->clear;
-    $driver->find_element("find0.0", "id")->send_keys($classification_group);
-    $driver->find_element("go", "name")->click;
-    $driver->find_element("Edit", "link")->click;
-    $driver->find_element("Related Properties", "link")->click;
-    $driver->find_element("//form[\@id='classificationDetails']//div[\@class='available']//div//input", "xpath")->clear;
-    $driver->find_element("//form[\@id='classificationDetails']//div[\@class='available']//div//input", "xpath")->send_keys($dnx_property);
-    $driver->pause();
-    $driver->find_element("Add all", "link")->click;
-    $driver->find_element("SaveClassificationGenDetails", "name")->click;
-    $driver->pause();
-}
-
-sub add_single_dnx_mapping ($dnx_property, $mediainfo_property) {
-    $driver->find_element("Add Mapping", "link")->click;
-    $driver->find_element("pageBeancurrentMappingextractorProperty_input", "id")->clear;
-    $driver->find_element("pageBeancurrentMappingextractorProperty_button", "id")->click;
-    $driver->pause();
-    $driver->find_element("//li[\@title='$mediainfo_property']", "xpath")->click;
-    $driver->pause();
-    $driver->find_element("pageBeancurrentMappingclassificationProperty_input", "id")->clear;
-    $driver->find_element("pageBeancurrentMappingclassificationProperty_button", "id")->click;
-    $driver->pause();
-    $driver->find_element("//li[\@title='$dnx_property']", "xpath")->click;
-    $driver->pause();
-    $driver->find_element("pageBeancurrentMappingnormalizer_input", "id")->click;
-    $driver->find_element("pageBeancurrentMappingnormalizer_input", "id")->click;
-    $driver->find_element("pageBeancurrentMappingnormalizer_input", "id")->clear;
-    $driver->pause();
-    $driver->find_element("page.buttons.operation", "name")->click;
-    $driver->pause();
-    # cancel (go back) if already mapped
-    if ($driver->find_element_by_xpath("//ul[contains(.,'is already mapped to DNX Property')]")) {
-        $driver->find_element("Cancel", "link_text")->click;
-    }
-}
-
-sub add_dnx_mappings_to_extractor {
-    # go to custom extractor page (local format library)
-    $driver->get("$protocol://$host:${ui_port}/mng/action/pageAction.page_xml.page_extractors_list.xml.do?pageBean.deploymentMode=BUNDLED&pageViewMode=Edit&pageBean.currentUserMode=LOCAL&RenewBean=true&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryLOCAL.mngLibraryHeader.Extractors.InnerMenu&menuKey=com.exlibris.dps.wrk.general.menu.Preservation.AdvancedPreservationActivities.mngLibraryLOCAL.mngLibraryHeader.Extractors.InnerMenu&backUrl=");
-    $driver->pause();
-    $driver->find_element("Custom", "link")->click;
-    # filter by plugin name
-    $driver->find_element("find1.0", "id")->clear;
-    $driver->find_element("find1.0", "id")->send_keys($plugin_name);
-    $driver->find_element("pagesections1widgetList0hdListsearchValue2_button", "id")->click;
-    $driver->find_element("//li[contains(.,'Name')]", "xpath")->click;
-    $driver->find_element("go", "name")->click;
-    # add plugin mappings
-    $driver->find_element("Edit", "link")->click;
-    $driver->find_element("paginationSelect_button", "id")->click;
-    $driver->find_element("//li[contains(.,'20 Records')]", "xpath")->click; # limit displayed records
-    foreach my $mediainfo_property (sort keys %mediainfo2dnx) {
-        my $dnx_property = $mediainfo2dnx{ $mediainfo_property };
-        add_single_dnx_mapping($dnx_property, $mediainfo_property);
-    }
-}
-
-# startup info
-printf colored("Trying to mechanize adding DNX mappings using:
-  rosetta host         = '$host'
-  ui port              = '$ui_port'
-  user                 = '$user'
-  institution          = '$institution'
-  plugin name          = '$plugin_name'
-  classification group = '$classification_group'\n\n", 'bold white');
-
-# startup driver
-$driver = Selenium::Chrome->new();
-$driver->debug_on;
-$driver->set_implicit_wait_timeout(1000);
-$driver->set_timeout('script', 1000);
-
-# Rosetta login
-printf colored("Step 1 of 7: login \n", 'bold green');
-login();
-
-# change to global format library
-printf colored("Step 2 of 7: change to global format library \n", 'bold green');
-change_to_global_format_library();
-
-# add dnx property
-printf colored("Step 3 of 7: add dnx property \n", 'bold green');
-foreach my $mediainfo_property (sort keys %mediainfo2dnx) {
-    my $dnx_property = $mediainfo2dnx{ $mediainfo_property };
-    add_dnx_property($dnx_property, "$dnx_property <- Mediainfo '$mediainfo_property'");
-}
-
-# include dnx property to classification group
-printf colored("Step 4 of 7: join dnx property to classification group \n", 'bold green');
-foreach my $mediainfo_property (sort keys %mediainfo2dnx) {
-    my $dnx_property = $mediainfo2dnx{ $mediainfo_property };
-    join_dnx_property_to_classification_group($dnx_property);
-}
-
-# add mapping
-printf colored("Step 5 of 7: add dnx mappings to extractor \n", 'bold green');
-add_dnx_mappings_to_extractor();
-
-# change to local format library
-printf colored("Step 6 of 7: change to local format library \n", 'bold green');
-change_to_local_format_library();
-
-# logout
-printf colored("Step 7 of 7: logout \n", 'bold green');
-logout();
-
-# stop driver
-$driver->quit();
-$driver->shutdown_binary();
-
-# stop info
-printf colored("Finished! \n", 'bold green');
-- 
GitLab