Skip to content

Commit

Permalink
Merge 27cdb1f into a5bfc37
Browse files Browse the repository at this point in the history
  • Loading branch information
shelleydoljack committed Nov 14, 2018
2 parents a5bfc37 + 27cdb1f commit 5579e41
Show file tree
Hide file tree
Showing 11 changed files with 673 additions and 353 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/modules/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ li {
position: relative;
top: 12px;
}

.no-wrap {
white-space: nowrap;
}
40 changes: 40 additions & 0 deletions app/controllers/packages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def create
@package = Package.new(package_params)
respond_to do |format|
if @package.save
update_special_attributes
format.html { redirect_to @package }
flash[:success] = 'Package was successfully created.'
format.json { render :show, status: :created, location: @package }
Expand All @@ -45,6 +46,7 @@ def create
def update
respond_to do |format|
if @package.update(package_params)
update_special_attributes
format.html { redirect_to @package }
flash[:success] = 'Package was successfully updated.'
format.json { render :show, status: :ok, location: @package }
Expand Down Expand Up @@ -88,4 +90,42 @@ def set_package
def package_params
params.require(:package).permit!
end

def update_special_attributes
make_access_urls_plats(url_config_params) if url_config_params.values.any?
make_match_opts(package_params[:match_opts]) if package_params[:match_opts].present?
make_ftp_file_prefix(package_params[:no_ftp_search]) if package_params[:no_ftp_search].present?
end

def url_config_params
{ url_substring: package_params[:url_substring],
link_text: package_params[:link_text],
provider_name: package_params[:provider_name],
collection_name: package_params[:collection_name],
access_type: package_params[:access_type] }
end

def make_access_urls_plats(url_config_params)
url_settings = ''
url_config_params.values.transpose.each do |x|
url_settings << x.join("\t") + '|'
end
url_settings = url_settings.gsub(/(\t{4}\|)+/, '')
@package.update(access_urls_plats: url_settings)
end

def make_match_opts(match_opts)
options = []
match_opts.each do |opt|
opt = nil if opt.to_i.zero?
options.push(opt)
end
options = options.reject(&:blank?).join(',')
options = nil if options.empty?
@package.update(match_opts: options)
end

def make_ftp_file_prefix(no_ftp_search)
@package.update(ftp_file_prefix: 'NO FTP SEARCH ***') if no_ftp_search == '0'
end
end
18 changes: 10 additions & 8 deletions app/helpers/package_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,41 @@
module PackageHelper
# get user friendly labels for package columns
def package_label(val)
Constants::PACKAGE_COLUMNS.fetch(val, '')
Package::COLUMNS.fetch(val)
end

# get user friendly labels for match_opts
def match_options(opt)
Constants::PACKAGE_MATCH_OPTS.fetch(opt, '')
Package::MATCH_OPTS.fetch(opt)
end

# get user friendly labels for proc_type
def processing_type(type)
Constants::PACKAGE_PROC_TYPE.fetch(type, '')
Package::PROC_TYPE.fetch(type)
end

def marc_encoding_lvl
Constants::PACKAGE_MARC_ENCDG_LVL
Package::MARC_ENCDG_LVL
end

def package_info
%w(package_status package_id package_name vendor_name package_url)
end

def pickup_info
%w(data_pickup_type afs_path put_file_loc ftp_server ftp_user ftp_password ftp_directory ftp_file_prefix)
%w(data_pickup_type afs_path put_file_loc ftp_server ftp_user
ftp_password ftp_directory no_ftp_search ftp_file_prefix)
end

def processing_rules
%w(proc_type match_opts)
end

def processing_info
%w(url_field vendor_id_read access_note update_040 vnd_catcode export_note
export_auth date_cat holding_code encoding_level junktag_file
preprocess_modify_script preprocess_split_script preprocess_put_script)
%w(url_field vendor_id_read access_note access_urls_plats update_040
vnd_catcode export_note export_auth date_cat holding_code encoding_level
junktag_file preprocess_modify_script preprocess_split_script
preprocess_put_script)
end

def package_other
Expand Down
67 changes: 67 additions & 0 deletions app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,76 @@ class Package < ActiveRecord::Base
self.table_name = 'vnd_packages'
self.primary_key = 'record_id'

attr_accessor :url_substring, :link_text, :provider_name, :collection_name, :access_type, :no_ftp_search

validates :record_id, uniqueness: true
validates :package_name, :vendor_name, :data_pickup_type, :package_status, presence: true

COLUMNS = {
'package_status' => 'Package status',
'package_id' => 'Package ID',
'package_name' => 'Package name',
'vendor_name' => 'Vendor name',
'package_url' => 'Documentation URL',
'data_pickup_type' => 'Data pickup type',
'afs_path' => 'AFS directory path',
'put_file_loc' => 'FTP to AFS download directory path',
'ftp_server' => 'FTP server',
'ftp_user' => 'FTP user',
'ftp_password' => 'FTP password',
'ftp_directory' => 'FTP remote directory',
'no_ftp_search' => 'Eloader searches for new files on FTP server',
'ftp_file_prefix' => 'FTP file name pattern (Perl regex)',
'proc_type' => 'Create new record or merge URL',
'match_opts' => 'Fields to match incoming to Symphony records',
'url_field' => 'Symphony URL destination',
'vendor_id_read' => 'Vendor ID field (read)',
'access_note' => 'Add access restriction note',
'access_urls_plats' => 'URL substrings, with associated subfields to be added to 856 if substring found in URL',
'update_040' => 'Create/Update 040 with CSt',
'vnd_catcode' => 'Vendor cataloging code for 040',
'export_note' => 'Export record to OCLC',
'export_auth' => 'Export record to Backstage',
'date_cat' => 'Date cataloged for new records',
'holding_code' => 'Holding code',
'encoding_level' => 'MARC encoding level',
'junktag_file' => 'Custom junktag filename',
'preprocess_modify_script' => 'Full path of preprocess modify script',
'preprocess_split_script' => 'Full path of preprocess split script',
'preprocess_put_script' => 'Full path of preprocess put in AFS script',
'rpt_mail' => 'Extra email addresses for reports',
'comments' => 'Comments'
}.freeze

MATCH_OPTS = {
'020' => '020 (subfield a,z) to Symphony 020 or 776',
'776_isbn' => '776 (subfield z) to Symphony 020 or 776',
'022' => '022 (subfield a,y,z) to Symphony 022 or 776',
'776_issn' => '776 (subfield x) to Symphony 022 or 776',
'024_isbn' => '024 (subfield a,z) to Symphony 020 or 776'
}.freeze

PROC_TYPE = {
'newonly' => 'New only',
'newmerge' => 'Merge or new',
'mergeonly' => 'Merge only',
'ckeymerge' => 'CKEY-URL merge'
}.freeze

MARC_ENCDG_LVL = {
'ASIS' => 'Do not replace',
' ' => '<space character> Full level',
'1' => '1 - Full level, material not examined',
'2' => '2 - Less-than-full level, material not examined',
'3' => '3 - Abbreviated level',
'4' => '4 - Core level',
'5' => '5 - Partial (preliminary) level',
'7' => '7 - Minimal level',
'8' => '8 - Prepublication level',
'u' => 'u - Unknown',
'z' => 'z - Not applicable'
}.freeze

private

def timestamp_attributes_for_create
Expand Down

0 comments on commit 5579e41

Please sign in to comment.