diff --git a/deploy_checkit_tiff/add_dnx_mappings/README.txt b/deploy_checkit_tiff/add_dnx_mappings/README.txt deleted file mode 100644 index 66b6d9e26a9f85a8544969390c8930c86281dd2c..0000000000000000000000000000000000000000 --- a/deploy_checkit_tiff/add_dnx_mappings/README.txt +++ /dev/null @@ -1,33 +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="Rosetta-Host.Domain.tld" --protocol="https" --ui_port="Port-Number" --user="Rosetta-User" --password="Rosetta-Password" --institution="Institution-Name" --plugin_name="Plugin-Name" --classification_group="Classification-Group" - -* example invocation: -** $# perl -I path/to/perl/modules ./add_dnx_mappings.pl --rosetta_host="sdvrosetta-test.slub-dresden.de" --protocol="https" --ui_port="8443" --user="su-user" --password="Sw0rdF!$h" --institution="SLUB" --plugin_name="SLUBTechnicalMetadataExtractorCheckItTiffPlugin" --classification_group="Image (Mix)" - diff --git a/deploy_checkit_tiff/add_dnx_mappings/add_dnx_mappings.pl b/deploy_checkit_tiff/add_dnx_mappings/add_dnx_mappings.pl deleted file mode 100644 index d1a6df54a8b21722e0de5da1bbae9d62fe633149..0000000000000000000000000000000000000000 --- a/deploy_checkit_tiff/add_dnx_mappings/add_dnx_mappings.pl +++ /dev/null @@ -1,265 +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 "Image (Mix)" - -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 = 'SLUBTechnicalMetadataExtractorCheckItTiffPlugin'; -my $classification_group = 'Image (Mix)'; -my $driver; -my $step; - -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, - "step=i" => \$step, -) 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 %exiftool2dnx = ( - "ICC-header:ColorSpaceData" => "icc.colorspacedata", - "ICC-header:DeviceModel" => "icc.devicemodel", - "ICC-header:PrimaryPlatform" => "icc.primaryplatform", - "ICC-header:ProfileCMMType" => "icc.profilecmmtype", - "ICC-header:ProfileCreator" => "icc.profilecreator", - "ICC-header:ProfileDateTime" => "icc.profiledatetime", - "ICC-header:ProfileVersion" => "icc.profileversion", - "ICC_Profile:CalibrationDateTime" => "icc.profilecalibrationdatetime", - "ICC_Profile:MakeAndModel" => "icc.makeandmodel", - "ICC_Profile:ProfileCopyright" => "icc.profilecopyright", - "ICC_Profile:ProfileDescription" => "icc.profiledescription", - "IFD0:BitsPerSample" => "tiff.bitspersample", # TIFF-Tag 258 BitsPerSample - "IFD0:Compression" => "tiff.compression", # TIFF-Tag 259 Compression - "IFD0:Copyright" => "tiff.copyright", # TIFF-Tag 33432 Copyright - "IFD0:DocumentName" => "tiff.documentname", # TIFF-Tag 269 DocumentName - "ExifIFD:GrayResponseCurve" => "tiff.grayresponsecurve", # TIFF-Tag 291 GrayResponseCurve - "IFD0:GrayResponseUnit" => "tiff.grayresponseunit", # TIFF-Tag 290 GrayResponseUnit - "IFD0:ImageDescription" => "tiff.imagedescription", # TIFF-Tag 270 ImageDescription - "IFD0:ImageHeight" => "image.height", # TIFF-Tag 257 ImageLength - "IFD0:ImageWidth" => "image.width", # TIFF-Tag 256 ImageWidth - "IFD0:Make" => "tiff.make", # TIFF-Tag 271 Make - "IFD0:MaxSampleValue" => "tiff.maxsamplevalue", # TIFF-Tag 281 MaxSampleValue - "IFD0:MinSampleValue" => "tiff.minsamplevalue", # TIFF-Tag 280 MinSampleValue - "IFD0:Model" => "tiff.model", # TIFF-Tag 272 Model - "IFD0:ModifyDate" => "tiff.datetime", # TIFF-Tag 306 DateTime - "IFD0:PageNumber" => "tiff.pagenumber", # TIFF-Tag 297 PageNumber - "IFD0:PhotometricInterpretation" => "tiff.photometricinterpretation", # TIFF-Tag 262 PhotometricInterpretation - "IFD0:PrimaryChromaticities" => "tiff.primarychromaticities", # TIFF-Tag 319 PrimaryChromaticities - "IFD0:SamplesPerPixel" => "tiff.samplesperpixel", # TIFF-Tag 277 SamplesPerPixel - "IFD0:Software" => "tiff.software", # TIFF-Tag 305 Software - "IFD0:WhitePoint" => "tiff.whitepoint", # TIFF-Tag 318 WhitePoint - "IFD0:XResolution" => "image.xresolution", # TIFF-Tag 282 XResolution - "IFD0:YResolution" => "image.yresolution", # TIFF-Tag 283 YResolution -); - -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) { - say "try to join 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 extractors_add_mapping ($dnx_property, $exiftool_property) { - say "try to add extractor mapping"; - # 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"); - $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')]")->click; - $driver->find_element("go", "name")->click; - # add 1 plugin mapping - $driver->find_element("Edit", "link")->click; - $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='$exiftool_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(); -} - -# 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 -if (!defined $step or $step == 3) { - printf colored("Step 3 of 7: add dnx property \n", 'bold green'); - foreach my $exiftool_property (sort keys %exiftool2dnx) { - my $dnx_property = $exiftool2dnx{ $exiftool_property }; - add_dnx_property($dnx_property, "$dnx_property <- Exiftool '$exiftool_property'"); - } -} - -# include dnx property to classification group -if (!defined $step or $step == 4) { - printf colored("Step 4 of 7: join dnx property to classification group \n", 'bold green'); - foreach my $exiftool_property (sort keys %exiftool2dnx) { - my $dnx_property = $exiftool2dnx{ $exiftool_property }; - join_dnx_property_to_classification_group($dnx_property); - } -} - -# add mapping -if (!defined $step or $step == 5) { - printf colored("Step 5 of 7: extractors add mapping \n", 'bold green'); - foreach my $exiftool_property (sort keys %exiftool2dnx) { - my $dnx_property = $exiftool2dnx{ $exiftool_property }; - extractors_add_mapping($dnx_property, $exiftool_property); - } -} - -# 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');