Class: Bplmodels::ModsDescMetadata
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Bplmodels::ModsDescMetadata
- Defined in:
- app/models/bplmodels/mods_desc_metadata.rb
Constant Summary collapse
- MODS_NS =
'http://www.loc.gov/mods/v3'- MODS_SCHEMA =
'http://www.loc.gov/standards/mods/v3/mods-3-5.xsd'- MODS_PARAMS =
{ "version" => "3.5", "xmlns:xlink" => "http://www.w3.org/1999/xlink", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", #"xmlns" => MODS_NS, "xsi:schemaLocation" => "#{MODS_NS} #{MODS_SCHEMA}", "xmlns:mods" => "http://www.loc.gov/mods/v3" }
Class Method Summary collapse
-
.default_attributes ⇒ Object
include Hydra::Datastream::CommonModsIndexMethods MODS XML constants.
-
.xml_template ⇒ Object
define_template :name do |xml| xml.name { xml.namePart xml.role { xml.roleTerm(:authority => “marcrelator”, :type => “text”) } } end.
Instance Method Summary collapse
- #insert_abstract(abstract = nil) ⇒ Object
- #insert_access_links(preview = nil, primary = nil) ⇒ Object
- #insert_classification(value = nil, edition = nil, authority = nil, display_label = nil) ⇒ Object
- #insert_date(date_type, dateStarted = nil, dateEnding = nil, dateQualifier = nil, dateOther = nil, keydate = nil) ⇒ Object
- #insert_date_copyright(dateStarted = nil, dateEnding = nil, dateQualifier = nil) ⇒ Object
- #insert_date_issued(dateStarted = nil, dateEnding = nil, dateQualifier = nil) ⇒ Object
-
#insert_digital_origin(digital_origin = nil) ⇒ Object
def insert_physical_description(media_type=nil, digital_origin=nil, media_type2=nil, note=nil).
- #insert_edition(edition = nil) ⇒ Object
- #insert_extent(extent = nil) ⇒ Object
- #insert_genre(value = nil, value_uri = nil, authority = nil, display_label = 'specific') ⇒ Object
- #insert_geonames(geonames_id) ⇒ Object
- #insert_host(nonSort = nil, main_title = nil, identifier = nil, args = {}) ⇒ Object
- #insert_identifier(identifier = nil, type = nil, display_label = nil, invalid = nil) ⇒ Object
- #insert_issuance(issuance = nil) ⇒ Object
- #insert_language(value = nil, code = 'eng') ⇒ Object
-
#insert_location_url(url = nil, access = nil, usage = nil) ⇒ Object
def insert_location_url(url=nil, access=nil, usage=nil) location_index = self.mods(0).item_location.count.
- #insert_mcgreevy ⇒ Object
- #insert_media_type(media_type = nil) ⇒ Object
- #insert_name(name = nil, type = nil, authority = nil, value_uri = nil, role = nil, role_uri = nil, date = nil, args = {}) ⇒ Object
- #insert_new_node(term) ⇒ Object
- #insert_note(note = nil, noteQualifier = nil) ⇒ Object
-
#insert_oai_date(date) ⇒ Object
test = [“test1”, “test2”] test.each do |k| define_method “current_#kk.underscore” do puts k.underscore end end.
- #insert_oai_date_copyright(date) ⇒ Object
- #insert_oai_date_issued(date) ⇒ Object
- #insert_origin_event(event_type) ⇒ Object
- #insert_origin_frequency(frequency, authority) ⇒ Object
- #insert_physical_location(location = nil, sublocation = nil, shelf_locator = nil, location_type = nil) ⇒ Object
- #insert_physical_note(note = nil) ⇒ Object
- #insert_publisher(publisher = nil, place = nil) ⇒ Object
- #insert_record_information(record_content_source, record_content_authority = nil) ⇒ Object
- #insert_related_item(value = nil, qualifier = nil) ⇒ Object
- #insert_related_item_url(value = nil) ⇒ Object
- #insert_related_item_xref(value = nil) ⇒ Object
- #insert_rights(value = nil, type = nil, displayLabel = nil) ⇒ Object
- #insert_series(series) ⇒ Object
- #insert_subject_cartographic(coordinates = nil, scale = nil, projection = nil) ⇒ Object
- #insert_subject_date_fix_me(date_start, date_end) ⇒ Object
- #insert_subject_geographic(geographic = nil, valueURI = nil, authority = nil, coordinates = nil) ⇒ Object
- #insert_subject_name(name = nil, type = nil, authority = nil, valueURI = nil, date = nil) ⇒ Object
- #insert_subject_scale(scale = nil, projection = nil) ⇒ Object
- #insert_subject_temporal(date) ⇒ Object
-
#insert_subject_title(main_title = nil, authority = nil, valueURI = nil, type = nil) ⇒ Object
usage=nil, supplied=nil, subtitle=nil, language=nil, type=nil, authority=nil, authorityURI=nil, valueURI=nil.
- #insert_subject_topic(topic = nil, valueURI = nil, authority = nil) ⇒ Object
- #insert_table_of_contents(text_value, url = nil) ⇒ Object
- #insert_target_audience(value = nil, authority = nil, display_label = nil) ⇒ Object
- #insert_tgn(tgn_id) ⇒ Object
-
#insert_title(nonSort = nil, main_title = nil, usage = nil, supplied = nil, type = nil, subtitle = nil, language = nil, display_label = nil, part_number = nil, part_name = nil, args = {}) ⇒ Object
usage=nil, supplied=nil, subtitle=nil, language=nil, type=nil, authority=nil, authorityURI=nil, valueURI=nil.
- #insert_type_of_resource(value = nil, manuscript = nil) ⇒ Object
-
#prefix(path = nil) ⇒ Object
Required for Active Fedora 9.
- #related_item_xref(index) ⇒ Object
- #remove_access_links(index) ⇒ Object
- #remove_extent(index) ⇒ Object
- #remove_genre(index) ⇒ Object
- #remove_host(index) ⇒ Object
- #remove_identifier(index) ⇒ Object
- #remove_language(index) ⇒ Object
- #remove_mcgreevy(index) ⇒ Object
- #remove_name(index) ⇒ Object
- #remove_node(term, index) ⇒ Object
- #remove_note(index) ⇒ Object
- #remove_physical_description(index) ⇒ Object
- #remove_physical_location(index) ⇒ Object
- #remove_publisher(index) ⇒ Object
- #remove_related_item(index) ⇒ Object
- #remove_subject_cartographic(index) ⇒ Object
- #remove_subject_geographic(index) ⇒ Object
- #remove_subject_topic(index) ⇒ Object
- #remove_table_of_contents(index) ⇒ Object
- #remove_title(index) ⇒ Object
- #remove_type_of_resource(index) ⇒ Object
- #to_xml(xml = nil) ⇒ Object
Class Method Details
.default_attributes ⇒ Object
include Hydra::Datastream::CommonModsIndexMethods MODS XML constants.
9 10 11 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 9 def self.default_attributes super.merge(:mimeType => 'application/xml') end |
.xml_template ⇒ Object
define_template :name do |xml|
xml.name {
xml.namePart
xml.role {
xml.roleTerm(:authority => "marcrelator", :type => "text")
}
}
end
define_template :relatedItem do |xml|
xml. {
xml.titleInfo {
xml.title
}
xml.location {
xml.url
}
}
end
define_template :related_citation do |xml|
xml.note(:type => "citation/reference")
end
616 617 618 619 620 621 622 623 624 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 616 def self.xml_template builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml| xml.mods(MODS_PARAMS) { xml.parent.namespace = xml.parent.namespace_definitions.find{|ns|ns.prefix=="mods"} } end return builder.doc end |
Instance Method Details
#insert_abstract(abstract = nil) ⇒ Object
1638 1639 1640 1641 1642 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1638 def insert_abstract(abstract=nil) abstract_index = self.mods(0).abstract.count self.mods(0).abstract(abstract_index, abstract) unless abstract.blank? end |
#insert_access_links(preview = nil, primary = nil) ⇒ Object
816 817 818 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 816 def insert_access_links(preview=nil, primary=nil) add_child_node(ng_xml.root, :access_links, preview, primary) end |
#insert_classification(value = nil, edition = nil, authority = nil, display_label = nil) ⇒ Object
1884 1885 1886 1887 1888 1889 1890 1891 1892 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1884 def insert_classification(value=nil, edition=nil, =nil, display_label=nil) classification_index = self.mods(0).classification.count if value.present? self.mods(0).classification(classification_index, value) self.mods(0).classification(classification_index).edition = edition unless edition.blank? self.mods(0).classification(classification_index). = unless .blank? self.mods(0).classification(classification_index).displayLabel = display_label unless display_label.blank? end end |
#insert_date(date_type, dateStarted = nil, dateEnding = nil, dateQualifier = nil, dateOther = nil, keydate = nil) ⇒ Object
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1258 def insert_date(date_type, dateStarted=nil, dateEnding=nil, dateQualifier=nil, dateOther=nil, keydate=nil) #begin #date_index = self.mods(0).date.count date_index = 0 #This is horrid. Can't use count as other elements use origin_info at the same depth.... if keydate.blank? keydate = true if (self.mods(0).date.dates_created.key_date.blank? and self.mods(0).date.dates_issued.key_date.blank? and self.mods(0).date.dates_copyright.key_date.blank? and self.mods(0).date.date_other.key_date.blank?) keydate ||= false end date_type = 'dates_created' if date_type == 'dateCreated' date_type = 'dates_copyright' if date_type == 'copyrightDate' date_type = 'dates_issued' if date_type == 'dateIssued' date_type = 'date_other' if date_type == 'dateOther' date_type_with_equal = date_type + '=' #Range case - broken...fixme ... under same mods:originInfo ? if dateStarted.present? and dateEnding.present? self.mods(0).date(date_index).send(date_type.to_sym, 0).point = 'start' self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf' self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank? self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false self.mods(0).date(date_index).send(date_type.to_sym, 1).point = 'end' self.mods(0).date(date_index).send(date_type.to_sym, 1).encoding = 'w3cdtf' self.mods(0).date(date_index).send(date_type.to_sym, 1).qualifier = dateQualifier unless dateQualifier.blank? #Hackish way to set the node values.... self.mods(0).date(date_index).send(date_type_with_equal.to_sym, [dateStarted, dateEnding]) elsif dateStarted.present? self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf' self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank? self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateStarted) elsif dateOther.present? self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateOther) end end |
#insert_date_copyright(dateStarted = nil, dateEnding = nil, dateQualifier = nil) ⇒ Object
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1459 def insert_date_copyright(dateStarted=nil, dateEnding=nil, dateQualifier=nil) #begin if self.find_by_terms(:origin_info) != nil && self.find_by_terms(:origin_info).slice(0) != nil add_child_node(self.find_by_terms(:origin_info).slice(0), :date_copyright_partial, dateStarted, dateEnding, dateQualifier) else add_child_node(ng_xml.root, :date_copyright, dateStarted, dateEnding, dateQualifier) end end |
#insert_date_issued(dateStarted = nil, dateEnding = nil, dateQualifier = nil) ⇒ Object
1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1372 def insert_date_issued(dateStarted=nil, dateEnding=nil, dateQualifier=nil) #begin if self.find_by_terms(:origin_info) != nil && self.find_by_terms(:origin_info).slice(0) != nil add_child_node(self.find_by_terms(:origin_info).slice(0), :date_issued_partial, dateStarted, dateEnding, dateQualifier) else add_child_node(ng_xml.root, :date_issued, dateStarted, dateEnding, dateQualifier) end #rescue OM::XML::Terminology::BadPointerError #add_child_node(ng_xml.root, :date, dateStarted, dateEnding, dateQualifier, dateOther) #end end |
#insert_digital_origin(digital_origin = nil) ⇒ Object
def insert_physical_description(media_type=nil, digital_origin=nil, media_type2=nil, note=nil)
667 668 669 670 671 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 667 def insert_digital_origin(digital_origin=nil) physical_description_index = 0 origin_index = self.mods(0).physical_description(physical_description_index).digital_origin.count self.mods(0).physical_description(physical_description_index).digital_origin(origin_index, digital_origin) unless digital_origin.blank? end |
#insert_edition(edition = nil) ⇒ Object
756 757 758 759 760 761 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 756 def insert_edition(edition=nil) origin_index = 0 edition_index = self.mods(0).origin_info(origin_index).edition.count self.mods(0).origin_info(origin_index).edition(edition_index, edition) unless edition.blank? end |
#insert_extent(extent = nil) ⇒ Object
1494 1495 1496 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1494 def insert_extent(extent=nil) self.mods(0).physical_description(0).extent(0, extent) unless extent.blank? end |
#insert_genre(value = nil, value_uri = nil, authority = nil, display_label = 'specific') ⇒ Object
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 764 def insert_genre(value=nil, value_uri=nil, =nil, display_label='specific') #Prevent duplicates if value.present? && !self.mods(0).genre.any?{ |genre| genre == value} genre_index = self.mods(0).genre.count self.mods(0).genre(genre_index, value) unless value.blank? self.mods(0).genre(genre_index). = unless .blank? if == 'gmgpc' || == 'lctgm' self.mods(0).genre(genre_index). = 'http://id.loc.gov/vocabulary/graphicMaterials' elsif == 'lcsh' self.mods(0).genre(genre_index). = 'http://id.loc.gov/authorities/subjects' elsif == 'aat' self.mods(0).genre(genre_index). = 'http://vocab.getty.edu/aat' end if value_uri.present? && value_uri.match(/^http/).blank? if == 'marcgt' value_uri = value_url elsif == 'aat' value_uri = 'http://vocab.getty.edu/aat/' + value_uri elsif == 'gmgpc' || == 'lctgm' value_uri = 'http://id.loc.gov/vocabulary/graphicMaterials/' + value_uri end end self.mods(0).genre(genre_index).valueURI = value_uri unless value_uri.blank? self.mods(0).genre(genre_index).displayLabel = display_label unless display_label.blank? end end |
#insert_geonames(geonames_id) ⇒ Object
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 824 def insert_geonames(geonames_id) puts 'Geonames ID is: ' + geonames_id #Duplicate Geonames value? if self.subject.valueURI.include?(geonames_id) return false end api_result = Geomash::Geonames.get_geonames_data(geonames_id) puts 'API Result is: ' + api_result.to_s subject_index = self.mods(0).subject.count self.mods(0).subject(subject_index). = "geonames" self.mods(0).subject(subject_index).valueURI = "http://sws.geonames.org/#{geonames_id}" self.mods(0).subject(subject_index). = 'http://sws.geonames.org' self.mods(0).subject(subject_index).geographic = api_result[:hier_geo].values[-1] #Insert Coordinates if api_result[:coords] != nil self.mods(0).subject(subject_index).cartographics.coordinates = api_result[:coords][:latitude] + "," + api_result[:coords][:longitude] end end |
#insert_host(nonSort = nil, main_title = nil, identifier = nil, args = {}) ⇒ Object
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1755 def insert_host(nonSort=nil, main_title=nil, identifier=nil, args={}) = self.mods(0)..count self.mods(0).().type = 'host' unless main_title.blank? && identifier.blank? self.mods(0).().title_info(0).nonSort = nonSort unless nonSort.blank? self.mods(0).().title_info(0).title = main_title unless main_title.blank? self.mods(0).().identifier = identifier unless identifier.blank? args.each do |key, value| self.mods(0).().send(key, Bplmodels::DatastreamInputFuncs.utf8Encode(value)) unless value.blank? end end |
#insert_identifier(identifier = nil, type = nil, display_label = nil, invalid = nil) ⇒ Object
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1869 def insert_identifier(identifier=nil, type=nil, display_label=nil, invalid=nil) identifier_index = self.mods(0).identifier.count if identifier.present? self.mods(0).identifier(identifier_index, identifier) unless identifier.blank? self.mods(0).identifier(identifier_index).type_at = type unless type.blank? self.mods(0).identifier(identifier_index).displayLabel = display_label unless display_label.blank? self.mods(0).identifier(identifier_index).invalid = 'yes' if (invalid.present? && invalid == 'yes') end end |
#insert_issuance(issuance = nil) ⇒ Object
749 750 751 752 753 754 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 749 def insert_issuance(issuance=nil) origin_index = 0 issuance_index = self.mods(0).origin_info(origin_index).issuance.count self.mods(0).origin_info(origin_index).issuance(issuance_index, issuance) unless issuance.blank? end |
#insert_language(value = nil, code = 'eng') ⇒ Object
699 700 701 702 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 699 def insert_language(value=nil, code='eng') code = "http://id.loc.gov/vocabulary/iso639-2/#{code}" unless code.include?('http') add_child_node(ng_xml.root, :language, value, code) end |
#insert_location_url(url = nil, access = nil, usage = nil) ⇒ Object
def insert_location_url(url=nil, access=nil, usage=nil)
location_index = self.mods(0).item_location.count
self.mods(0).item_location(location_index).url = url unless url.blank?
self.mods(0).item_location(location_index).url(0).usage = usage unless usage.blank?
self.mods(0).item_location(location_index).url(0).access = access unless access.blank?
end
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1852 def insert_location_url(url=nil, access=nil, usage=nil) location_index = self.mods(0).item_location.count for index in 0..self.mods(0).item_location.count-1 if self.mods(0).item_location(index).url.present? location_index = index end end url_index = self.mods(0).item_location(location_index).url.count self.mods(0).item_location(location_index).url(url_index, url) unless url.blank? self.mods(0).item_location(location_index).url(url_index).usage = usage unless usage.blank? self.mods(0).item_location(location_index).url(url_index).access = access unless access.blank? end |
#insert_mcgreevy ⇒ Object
1912 1913 1914 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1912 def insert_mcgreevy add_child_node(ng_xml.root, :mcgreevy) end |
#insert_media_type(media_type = nil) ⇒ Object
683 684 685 686 687 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 683 def insert_media_type(media_type=nil) physical_description_index = 0 media_type_index = self.mods(0).physical_description(physical_description_index).internet_media_type.count self.mods(0).physical_description(physical_description_index).internet_media_type(media_type_index, media_type) unless media_type.blank? || self.mods(0).physical_description(physical_description_index).internet_media_type.include?(media_type) end |
#insert_name(name = nil, type = nil, authority = nil, value_uri = nil, role = nil, role_uri = nil, date = nil, args = {}) ⇒ Object
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1038 def insert_name(name=nil, type=nil, =nil, value_uri=nil, role=nil, role_uri=nil, date=nil, args={}) name_index = self.mods(0).name.count self.mods(0).name(name_index).type = type unless type.blank? self.mods(0).name(name_index). = unless .blank? self.mods(0).name(name_index).valueURI = value_uri unless value_uri.blank? if role.present? role_split = role.split('{|}') #new split var - see Arnold ticket role_uri = '{|}{|}{|}{|}{|}' if role_uri.nil? #Very hackish... role_uri_split = role_uri.split('{|}') #new split var - see Arnold ticket role_split.each_with_index do |single_role, role_index| self.mods(0).name(name_index).role(role_index).text = single_role unless single_role.blank? self.mods(0).name(name_index).role(role_index).text.valueURI = role_uri_split[role_index] unless role_uri_split[role_index].blank? end end if( == 'naf') self.mods(0).name(name_index). = 'http://id.loc.gov/authorities/names' end if type == 'corporate' name_array = Bplmodels::DatastreamInputFuncs.corpNamePartSplitter(name) name_array.each_with_index do |name_value, array_pos| self.mods(0).name(name_index).namePart(array_pos, name_value) end elsif type=='personal' && date.blank? name_hash = Bplmodels::DatastreamInputFuncs.persNamePartSplitter(name) self.mods(0).name(name_index).namePart = name_hash[:namePart] self.mods(0).name(name_index).date = name_hash[:datePart] unless name_hash[:datePart].blank? elsif date.present? self.mods(0).name(name_index).namePart = name self.mods(0).name(name_index).date = date else self.mods(0).name(name_index).namePart = name end args.each do |key, value| self.mods(0).name(name_index).send(key, Bplmodels::DatastreamInputFuncs.utf8Encode(value)) unless value.blank? end end |
#insert_new_node(term) ⇒ Object
1929 1930 1931 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1929 def insert_new_node(term) add_child_node(ng_xml.root, term) end |
#insert_note(note = nil, noteQualifier = nil) ⇒ Object
1502 1503 1504 1505 1506 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1502 def insert_note(note=nil, noteQualifier=nil) note_index = self.mods(0).note.count self.mods(0).note(note_index, note) unless note.blank? self.mods(0).note(note_index).type_at = noteQualifier unless noteQualifier.blank? end |
#insert_oai_date(date) ⇒ Object
test = [“test1”, “test2”] test.each do |k| define_method “current_#Bplmodels::ModsDescMetadata.kk.underscore” do puts k.underscore end end
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1094 def insert_oai_date(date) #converted = Bplmodels::DatastreamInputFuncs.convert_to_mods_date(date) converted = BplEnrich::Dates.standardize(date) #date_index = self.date.length date_index = 0 dup_found = false #Prevent duplicate entries... Using a flag as keep the potential note? (self.mods(0).date(date_index).dates_created.length-1).times do |index| if converted.has_key?(:single_date) if self.mods(0).date(date_index).dates_created(index).point.blank? && self.mods(0).date(date_index).dates_created(index).first == converted[:single_date] dup_found = true end elsif converted.has_key?(:date_range) if self.mods(0).date(date_index).dates_created(index).point == 'start' && self.mods(0).date(date_index).dates_created(index).first == converted[:date_range][:start] if self.mods(0).date(date_index).dates_created(index+1).point == 'end' && self.mods(0).date(date_index).dates_created(index+1).first == converted[:date_range][:end] dup_found = true end end end end if !dup_found if converted.has_key?(:single_date) && !self.date.dates_created.include?(converted[:single_date]) date_created_index = self.date(date_index).dates_created.length self.date(date_index).dates_created(date_created_index, converted[:single_date]) self.date(date_index).dates_created(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_created(date_created_index).key_date = 'yes' end if converted.has_key?(:date_qualifier) self.date(date_index).dates_created(date_created_index).qualifier = converted[:date_qualifier] end elsif converted.has_key?(:date_range) date_created_index = self.date(date_index).dates_created.length self.date(date_index).dates_created(date_created_index, converted[:date_range][:start]) self.date(date_index).dates_created(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_created(date_created_index).key_date = 'yes' end self.date(date_index).dates_created(date_created_index).point = 'start' self.date(date_index).dates_created(date_created_index).qualifier = converted[:date_qualifier] date_created_index = self.date(date_index).dates_created.length self.date(date_index).dates_created(date_created_index, converted[:date_range][:end]) self.date(date_index).dates_created(date_created_index).encoding = 'w3cdtf' self.date(date_index).dates_created(date_created_index).point = 'end' self.date(date_index).dates_created(date_created_index).qualifier = converted[:date_qualifier] end end self.insert_note(converted[:date_note],"date") unless !converted.has_key?(:date_note) end |
#insert_oai_date_copyright(date) ⇒ Object
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1154 def insert_oai_date_copyright(date) #converted = Bplmodels::DatastreamInputFuncs.convert_to_mods_date(date) converted = BplEnrich::Dates.standardize(date) #date_index = self.date.length date_index = 0 dup_found = false #Prevent duplicate entries... Using a flag as keep the potential note? (self.mods(0).date(date_index).dates_copyright.length-1).times do |index| if converted.has_key?(:single_date) if self.mods(0).date(date_index).dates_copyright(index).point.blank? && self.mods(0).date(date_index).dates_copyright(index).first == converted[:single_date] dup_found = true end elsif converted.has_key?(:date_range) if self.mods(0).date(date_index).dates_copyright(index).point == 'start' && self.mods(0).date(date_index).dates_copyright(index).first == converted[:date_range][:start] if self.mods(0).date(date_index).dates_copyright(index+1).point == 'end' && self.mods(0).date(date_index).dates_copyright(index+1).first == converted[:date_range][:end] dup_found = true end end end end if !dup_found if converted.has_key?(:single_date) && !self.date.dates_copyright.include?(converted[:single_date]) date_created_index = self.date(date_index).dates_copyright.length self.date(date_index).dates_copyright(date_created_index, converted[:single_date]) self.date(date_index).dates_copyright(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_copyright(date_created_index).key_date = 'yes' end if converted.has_key?(:date_qualifier) self.date(date_index).dates_copyright(date_created_index).qualifier = converted[:date_qualifier] end elsif converted.has_key?(:date_range) date_created_index = self.date(date_index).dates_copyright.length self.date(date_index).dates_copyright(date_created_index, converted[:date_range][:start]) self.date(date_index).dates_copyright(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_copyright(date_created_index).key_date = 'yes' end self.date(date_index).dates_copyright(date_created_index).point = 'start' self.date(date_index).dates_copyright(date_created_index).qualifier = converted[:date_qualifier] date_created_index = self.date(date_index).dates_copyright.length self.date(date_index).dates_copyright(date_created_index, converted[:date_range][:end]) self.date(date_index).dates_copyright(date_created_index).encoding = 'w3cdtf' self.date(date_index).dates_copyright(date_created_index).point = 'end' self.date(date_index).dates_copyright(date_created_index).qualifier = converted[:date_qualifier] end end self.insert_note(converted[:date_note],"date") unless !converted.has_key?(:date_note) end |
#insert_oai_date_issued(date) ⇒ Object
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1214 def insert_oai_date_issued(date) #converted = Bplmodels::DatastreamInputFuncs.convert_to_mods_date(date) converted = BplEnrich::Dates.standardize(date) #date_index = self.date.length date_index = 0 if converted.has_key?(:single_date) date_created_index = self.date(date_index).dates_issued.length self.date(date_index).dates_issued(date_created_index, converted[:single_date]) self.date(date_index).dates_issued(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_issued(date_created_index).key_date = 'yes' end if converted.has_key?(:date_qualifier) self.date(date_index).dates_issued(date_created_index).qualifier = converted[:date_qualifier] end elsif converted.has_key?(:date_range) date_created_index = self.date(date_index).dates_issued.length self.date(date_index).dates_issued(date_created_index, converted[:date_range][:start]) self.date(date_index).dates_issued(date_created_index).encoding = 'w3cdtf' if date_created_index == 0 self.date(date_index).dates_issued(date_created_index).key_date = 'yes' end self.date(date_index).dates_issued(date_created_index).point = 'start' self.date(date_index).dates_issued(date_created_index).qualifier = converted[:date_qualifier] date_created_index = self.date(date_index).dates_issued.length self.date(date_index).dates_issued(date_created_index, converted[:date_range][:end]) self.date(date_index).dates_issued(date_created_index).encoding = 'w3cdtf' self.date(date_index).dates_issued(date_created_index).point = 'end' self.date(date_index).dates_issued(date_created_index).qualifier = converted[:date_qualifier] end self.insert_note(converted[:date_note],"date") unless !converted.has_key?(:date_note) end |
#insert_origin_event(event_type) ⇒ Object
853 854 855 856 857 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 853 def insert_origin_event(event_type) #Currently only supporting one elements... origin_index = 0 self.mods(0).origin_info(origin_index).event_type = event_type unless event_type.blank? end |
#insert_origin_frequency(frequency, authority) ⇒ Object
859 860 861 862 863 864 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 859 def insert_origin_frequency(frequency, ) #Currently only supporting one elements... origin_index = 0 self.mods(0).origin_info(origin_index).frequency = frequency unless frequency.blank? self.mods(0).origin_info(origin_index).frequency. = unless .blank? end |
#insert_physical_location(location = nil, sublocation = nil, shelf_locator = nil, location_type = nil) ⇒ Object
1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1823 def insert_physical_location(location=nil, sublocation=nil,shelf_locator=nil, location_type=nil) #Create a new tag unless there is a non-url tag already... location_index = self.mods(0).item_location.count for index in 0..self.mods(0).item_location.count-1 if self.mods(0).item_location(index).url.blank? location_index = index end end physical_location_index = 0 self.mods(0).item_location(location_index).physical_location(physical_location_index, location) unless location.blank? self.mods(0).item_location(location_index).physical_location(physical_location_index).type = location_type unless location.blank? self.mods(0).item_location(location_index).holding_simple(0).copy_information(0).sub_location = sublocation unless sublocation.blank? self.mods(0).item_location(location_index).holding_simple(0).copy_information(0).shelf_locator = shelf_locator unless shelf_locator.blank? end |
#insert_physical_note(note = nil) ⇒ Object
673 674 675 676 677 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 673 def insert_physical_note(note=nil) physical_description_index = 0 note_index = self.mods(0).physical_description(physical_description_index).note.count self.mods(0).physical_description(physical_description_index).note(note_index, note) unless note.blank? end |
#insert_publisher(publisher = nil, place = nil) ⇒ Object
736 737 738 739 740 741 742 743 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 736 def insert_publisher(publisher=nil, place=nil) origin_index = 0 publisher_index = self.mods(0).origin_info(origin_index).publisher.count place_index = self.mods(0).origin_info(origin_index).place.count self.mods(0).origin_info(origin_index).publisher(publisher_index, publisher) unless publisher.blank? self.mods(0).origin_info(origin_index).place(place_index).place_term = place unless place.blank? end |
#insert_record_information(record_content_source, record_content_authority = nil) ⇒ Object
1921 1922 1923 1924 1925 1926 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1921 def insert_record_information(record_content_source, =nil) self.mods(0).record_info(0).record_content_source = record_content_source unless record_content_source.blank? self.mods(0).record_info(0).record_content_source(0). = unless .blank? self.mods(0).record_info(0).record_origin = 'human prepared' self.mods(0).record_info(0).language_of_cataloging(0).language_term = 'English' end |
#insert_related_item(value = nil, qualifier = nil) ⇒ Object
1787 1788 1789 1790 1791 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1787 def (value=nil, qualifier=nil) if value != nil && value.length > 0 add_child_node(ng_xml.root, :related_item, value, qualifier) end end |
#insert_related_item_url(value = nil) ⇒ Object
1813 1814 1815 1816 1817 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1813 def (value=nil) = self.mods(0)..count self.mods(0).().location(0).url = value unless value.blank? end |
#insert_related_item_xref(value = nil) ⇒ Object
1802 1803 1804 1805 1806 1807 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1802 def (value=nil) puts 'told to insert related item xref' if value != nil && value.length > 0 add_child_node(ng_xml.root, :related_item_xref, value) end end |
#insert_rights(value = nil, type = nil, displayLabel = nil) ⇒ Object
709 710 711 712 713 714 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 709 def insert_rights(value=nil, type=nil, displayLabel=nil) access_index = self.mods(0).accessCondition.count self.mods(0).accessCondition(access_index, value) unless value.blank? self.mods(0).accessCondition(access_index).type_at = type unless type.blank? self.mods(0).accessCondition(access_index).displayLabel = displayLabel unless displayLabel.blank? end |
#insert_series(series) ⇒ Object
1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1560 def insert_series(series) if series.present? top_level_insert_position = self.mods(0)..length 0.upto self.mods(0)..length-1 do |pos| if self.mods(0).(pos).type == ['series'] top_level_insert_position = pos end end if self.mods(0).(top_level_insert_position).blank? self.mods(0).(top_level_insert_position).type = 'series' self.mods(0).(top_level_insert_position).title_info.title = series elsif self.mods(0).(top_level_insert_position).(0).blank? self.mods(0).(top_level_insert_position).(0).type = 'series' self.mods(0).(top_level_insert_position).(0).title_info.title = series elsif self.mods(0).(top_level_insert_position).(0).(0).blank? self.mods(0).(top_level_insert_position).(0).(0).type = 'series' self.mods(0).(top_level_insert_position).(0).(0).title_info.title = series elsif self.mods(0).(top_level_insert_position).(0).(0).(0).blank? self.mods(0).(top_level_insert_position).(0).(0).(0).type = 'series' self.mods(0).(top_level_insert_position).(0).(0).(0).title_info.title = series elsif self.mods(0).(top_level_insert_position).(0).(0).(0).(0).blank? self.mods(0).(top_level_insert_position).(0).(0).(0).(0).type = 'series' self.mods(0).(top_level_insert_position).(0).(0).(0).(0).title_info.title = series end end end |
#insert_subject_cartographic(coordinates = nil, scale = nil, projection = nil) ⇒ Object
1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1704 def insert_subject_cartographic(coordinates=nil, scale=nil, projection=nil) subject_index = self.mods(0).subject.count if coordinates.split(' ').length >= 3 coordinates.scan(/([NSWE])([\d\.]+) *([NSWE])([\d\.]+) *([NSWE])([\d\.]+) *([NSWE])([\d\.]+)/).map do |dir1,deg1,dir2,deg2,dir3,deg3,dir4,deg4| deg1 = Float(deg1) deg2 = Float(deg2) deg3 = Float(deg3) deg4 = Float(deg4) deg1 = deg1 * -1 if dir1 == 'S' || dir1 == 'W' deg2 = deg2 * -1 if dir2 == 'S' || dir2 == 'W' deg3 = deg3 * -1 if dir3 == 'S' || dir3 == 'W' deg4 = deg4 * -1 if dir4 == 'S' || dir4 == 'W' if deg1 == deg2 && deg3 == deg4 self.mods(0).subject(subject_index).cartographics(0).coordinates = deg3.to_s + ',' + deg1.to_s else self.mods(0).subject(subject_index).cartographics(0).coordinates = deg1.to_s + ' ' + deg4.to_s + ' ' + deg2.to_s + ' ' + deg3.to_s end end else #Remove spaces around the comma coordinates = coordinates.gsub(/ *, */, ',') self.mods(0).subject(subject_index).cartographics(0).coordinates = coordinates unless coordinates.blank? end #FIXME: self.mods(0).subject(subject_index).cartographics(0).scale = scale unless scale.blank? #FIXME: self.mods(0).subject(subject_index).cartographics(0).projection = projection unless projection.blank? end |
#insert_subject_date_fix_me(date_start, date_end) ⇒ Object
1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1626 def insert_subject_date_fix_me(date_start, date_end) subject_index = self.mods(0).subject.count temporal_index = self.mods(0).subject(subject_index).temporal.length self.mods(0).subject(subject_index).temporal(temporal_index, date_start) unless date_start.blank? self.mods(0).subject(subject_index).temporal(temporal_index).point = 'start' unless date_start.blank? temporal_index = self.mods(0).subject(subject_index).temporal.length self.mods(0).subject(subject_index).temporal(temporal_index, date_end) unless date_end.blank? self.mods(0).subject(subject_index).temporal(temporal_index).point = 'end' unless date_end.blank? end |
#insert_subject_geographic(geographic = nil, valueURI = nil, authority = nil, coordinates = nil) ⇒ Object
1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1681 def insert_subject_geographic(geographic=nil, valueURI=nil, =nil, coordinates=nil) if geographic.present? && !self.mods(0).subject.geographic.any? {|geo| geo==geographic} subject_index = self.mods(0).subject.count self.mods(0).subject(subject_index).geographic = geographic unless geographic.blank? self.mods(0).subject(subject_index).valueURI = valueURI unless valueURI.blank? self.mods(0).subject(subject_index). = unless .blank? if == 'lctgm' self.mods(0).subject(subject_index). = 'http://id.loc.gov/vocabulary/graphicMaterials' elsif == 'lcsh' self.mods(0).subject(subject_index). = 'http://id.loc.gov/authorities/subjects' end self.mods(0).subject(subject_index).cartographics(0).coordinates = coordinates unless coordinates.blank? end end |
#insert_subject_name(name = nil, type = nil, authority = nil, valueURI = nil, date = nil) ⇒ Object
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1644 def insert_subject_name(name=nil, type=nil, =nil, valueURI=nil, date=nil) subject_index = self.mods(0).subject.count if name.is_a?String self.mods(0).subject(subject_index).name(0).name_part_actual(0, name) #Date self.mods(0).subject(subject_index).name(0).name_part_actual(1, date) unless date.blank? self.mods(0).subject(subject_index).name(0).name_part_actual(1).type = 'date' unless date.blank? elsif name.is_a?Array name.each_with_index do |name_part, index| self.mods(0).subject(subject_index).name(0).name_part_actual(index, Bplmodels::DatastreamInputFuncs.utf8Encode(name_part)) end end self.mods(0).subject(subject_index).name(0). = unless .blank? self.mods(0).subject(subject_index).name(0). = 'http://id.loc.gov/authorities/names' if == 'naf' self.mods(0).subject(subject_index).name(0).value_uri = valueURI unless valueURI.blank? self.mods(0).subject(subject_index).name(0).type = type unless type.blank? end |
#insert_subject_scale(scale = nil, projection = nil) ⇒ Object
1735 1736 1737 1738 1739 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1735 def insert_subject_scale(scale=nil, projection=nil) subject_index = self.mods(0).subject.count self.mods(0).subject(subject_index).cartographics(0).scale = scale unless scale.blank? self.mods(0).subject(subject_index).cartographics(0).projection = projection unless projection.blank? end |
#insert_subject_temporal(date) ⇒ Object
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1591 def insert_subject_temporal(date) #converted = Bplmodels::DatastreamInputFuncs.convert_to_mods_date(date) duplicate = false converted = BplEnrich::Dates.standardize(date) subject_index = self.mods(0).subject.count if converted.has_key?(:single_date) #Check for duplicates (0..self.mods(0).subject.length-1).each do |index| if self.mods(0).subject(index).temporal == [converted[:single_date]] duplicate = true end end temporal_index = self.mods(0).subject(subject_index).temporal.length self.mods(0).subject(subject_index).temporal(temporal_index, converted[:single_date]) unless converted[:single_date].blank? || duplicate elsif converted.has_key?(:date_range) #Check for duplicates, FIXME: Is there case this doesn't work? (0..self.mods(0).subject.length-1).each do |index| if self.mods(0).subject(index).temporal == [converted[:date_range][:start], converted[:date_range][:end]] duplicate = true end end temporal_index = self.mods(0).subject(subject_index).temporal.length self.mods(0).subject(subject_index).temporal(temporal_index, converted[:date_range][:start]) unless converted[:date_range][:start].blank? || duplicate self.mods(0).subject(subject_index).temporal(temporal_index).point = 'start' unless converted[:date_range][:start].blank? || duplicate temporal_index = self.mods(0).subject(subject_index).temporal.length self.mods(0).subject(subject_index).temporal(temporal_index, converted[:date_range][:end]) unless converted[:date_range][:end].blank? || duplicate self.mods(0).subject(subject_index).temporal(temporal_index).point = 'end' unless converted[:date_range][:end].blank? || duplicate end end |
#insert_subject_title(main_title = nil, authority = nil, valueURI = nil, type = nil) ⇒ Object
usage=nil, supplied=nil, subtitle=nil, language=nil, type=nil, authority=nil, authorityURI=nil, valueURI=nil
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1513 def insert_subject_title(main_title=nil, =nil, valueURI=nil, type=nil) if main_title.present? subject_index = self.mods(0).subject.count sorted_title = Bplmodels::DatastreamInputFuncs.getProperTitle(main_title) title = sorted_title[1] nonSort = sorted_title[0] self.mods(0).subject(subject_index).title_info(0).nonSort = nonSort unless nonSort.blank? self.mods(0).subject(subject_index).title_info(0).main_title = title unless title.blank? self.mods(0).subject(subject_index).title_info(0).type = type unless type.blank? self.mods(0).subject(subject_index).title_info(0). = unless .blank? if == 'lctgm' self.mods(0).subject(subject_index).title_info(0). = 'http://id.loc.gov/vocabulary/graphicMaterials' elsif == 'lcsh' self.mods(0).subject(subject_index).title_info(0). = 'http://id.loc.gov/authorities/subjects' elsif == 'naf' self.mods(0).subject(subject_index).title_info(0). = 'http://id.loc.gov/authorities/names' end self.mods(0).subject(subject_index).title_info(0).valueURI = valueURI unless valueURI.blank? end end |
#insert_subject_topic(topic = nil, valueURI = nil, authority = nil) ⇒ Object
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1539 def insert_subject_topic(topic=nil, valueURI=nil, =nil) if topic.present? && !self.mods(0).subject.topic.any?{ |top| top == topic } subject_index = self.mods(0).subject.count self.mods(0).subject(subject_index).topic = topic unless topic.blank? self.mods(0).subject(subject_index).valueURI = valueURI unless valueURI.blank? self.mods(0).subject(subject_index). = unless .blank? if == 'lctgm' self.mods(0).subject(subject_index). = 'http://id.loc.gov/vocabulary/graphicMaterials' elsif == 'lcsh' self.mods(0).subject(subject_index). = 'http://id.loc.gov/authorities/subjects' elsif == 'aat' self.mods(0).subject(subject_index). = 'http://vocab.getty.edu/aat/' end end end |
#insert_table_of_contents(text_value, url = nil) ⇒ Object
1745 1746 1747 1748 1749 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1745 def insert_table_of_contents(text_value, url=nil) contents_index = self.mods(0).table_of_contents.count self.mods(0).table_of_contents(contents_index, text_value) unless text_value.blank? self.mods(0).table_of_contents(contents_index).href = url unless url.blank? end |
#insert_target_audience(value = nil, authority = nil, display_label = nil) ⇒ Object
716 717 718 719 720 721 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 716 def insert_target_audience(value=nil, =nil, display_label=nil) audience_index = self.mods(0).target_audience.count self.mods(0).target_audience(audience_index, value) unless value.blank? self.mods(0).target_audience(audience_index). = unless .blank? self.mods(0).target_audience(audience_index).display_label = display_label unless display_label.blank? end |
#insert_tgn(tgn_id) ⇒ Object
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 866 def insert_tgn(tgn_id) puts 'TGN ID is: ' + tgn_id #Duplicate TGN value? if self.subject.valueURI.include?(tgn_id) return false end api_result = Geomash::TGN.get_tgn_data(tgn_id) puts 'API Result is: ' + api_result.to_s #FIXME: Only works for hier_geo places.... #Get rid of less specific matches... city level information should trump state level information. if api_result[:hier_geo].present? if api_result[:hier_geo][:city].present? && self.subject.hierarchical_geographic.present? self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).hierarchical_geographic(0).city.blank? && self.mods(0).subject(subject_index).hierarchical_geographic(0).state == [api_result[:hier_geo][:state]] #Check to not remove non-hier geo cases... as actually more specific than just a state if self.mods(0).subject(subject_index).geographic(0).blank? self.mods(0).subject(subject_index, nil) end end end end #Exit if same city match self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).hierarchical_geographic(0).city == [api_result[:hier_geo][:city]] #Case of more specific in non_hier_geo... if self.mods(0).subject(subject_index).geographic(0).blank? && api_result[:non_hier_geo].present? self.mods(0).subject(subject_index, nil) else return false end end end end #Exit check if trying to insert same state twice with no city elsif api_result[:hier_geo][:city].blank? && api_result[:hier_geo][:state].present? && self.subject.hierarchical_geographic.present? self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).hierarchical_geographic(0).state == [api_result[:hier_geo][:state]] #Case of more specific in non_hier_geo... if self.mods(0).subject(subject_index).geographic(0).blank? && api_result[:non_hier_geo].present? self.mods(0).subject(subject_index, nil) else return false end end end end #Exit check if trying to insert the same area... elsif api_result[:hier_geo][:city].blank? && api_result[:hier_geo][:area].present? && self.subject.hierarchical_geographic.present? self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).hierarchical_geographic(0).area == [api_result[:hier_geo][:area]] #Case of more specific in non_hier_geo... if self.mods(0).subject(subject_index).geographic(0).blank? && api_result[:non_hier_geo].present? self.mods(0).subject(subject_index, nil) else return false end end end end #Finally exit if inserting the same country... elsif api_result[:hier_geo][:city].blank? && api_result[:hier_geo][:state].blank? && api_result[:hier_geo][:area].blank? && api_result[:hier_geo][:country].present? && self.subject.hierarchical_geographic.present? self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).hierarchical_geographic(0).country == [api_result[:hier_geo][:country]] #Case of more specific in non_hier_geo... if self.mods(0).subject(subject_index).geographic(0).blank? && api_result[:non_hier_geo].present? self.mods(0).subject(subject_index, nil) else return false end end end end end end if api_result[:non_hier_geo].present? #Exit if same place match currently.... self.mods(0).subject.each_with_index do |ignored, subject_index| if self.mods(0).subject(subject_index). == ['tgn'] if self.mods(0).subject(subject_index).geographic == [api_result[:non_hier_geo][:value]] return false end end end end subject_index = self.mods(0).subject.count self.mods(0).subject(subject_index). = "tgn" self.mods(0).subject(subject_index).valueURI = "http://vocab.getty.edu/tgn/#{tgn_id}" self.mods(0).subject(subject_index). = 'http://vocab.getty.edu/tgn/' #Insert geographic text if api_result[:non_hier_geo].present? self.mods(0).subject(subject_index).geographic = api_result[:non_hier_geo][:value] self.mods(0).subject(subject_index).geographic.display_label = api_result[:non_hier_geo][:qualifier] unless api_result[:non_hier_geo][:qualifier].blank? end #Insert hierarchicalGeographic text if api_result[:hier_geo] != nil api_result[:hier_geo].keys.reverse.each do |key| key_with_equal = key.to_s + "=" self.mods(0).subject(subject_index).hierarchical_geographic.send(key_with_equal.to_sym, Bplmodels::DatastreamInputFuncs.utf8Encode(api_result[:hier_geo][key])) end end #Insert Coordinates if api_result[:coords] != nil self.mods(0).subject(subject_index).cartographics.coordinates = api_result[:coords][:latitude] + "," + api_result[:coords][:longitude] end end |
#insert_title(nonSort = nil, main_title = nil, usage = nil, supplied = nil, type = nil, subtitle = nil, language = nil, display_label = nil, part_number = nil, part_name = nil, args = {}) ⇒ Object
usage=nil, supplied=nil, subtitle=nil, language=nil, type=nil, authority=nil, authorityURI=nil, valueURI=nil
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 989 def insert_title(nonSort=nil, main_title=nil, usage=nil, supplied=nil, type=nil, subtitle=nil, language=nil, display_label=nil, part_number=nil, part_name=nil, args={}) title_index = self.mods(0).title_info.count self.mods(0).title_info(title_index).nonSort = nonSort unless nonSort.blank? self.mods(0).title_info(title_index).main_title = main_title unless main_title.blank? self.mods(0).title_info(title_index).usage = usage unless usage.blank? self.mods(0).title_info(title_index).supplied = 'yes' unless supplied.blank? || supplied == 'no' self.mods(0).title_info(title_index).type = type unless type.blank? #Need to update previous titles to be translated now as well.... if type == 'translated' && usage == 'primary' 0.upto title_index-1 do |pos| if self.mods(0).title_info(pos).usage[0] == 'primary' self.mods(0).title_info(pos).type = type end end #Currently only main title has a blank type.... may want to pass this instead eventually if that changes. elsif type.blank? self.mods(0).title_info(title_index).display_label = 'primary_display' end self.mods(0).title_info(title_index).subtitle = subtitle unless subtitle.blank? self.mods(0).title_info(title_index).language = language unless language.blank? self.mods(0).title_info(title_index).display_label = display_label unless display_label.blank? self.mods(0).title_info(title_index).part_number = part_number unless part_number.blank? self.mods(0).title_info(title_index).part_name = part_name unless part_name.blank? if args.present? raise 'broken args in Active Fedora 7' end args.each do |key, value| self.mods(0).title_info(title_index).send(key, Bplmodels::DatastreamInputFuncs.utf8Encode(value)) unless value.blank? end end |
#insert_type_of_resource(value = nil, manuscript = nil) ⇒ Object
724 725 726 727 728 729 730 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 724 def insert_type_of_resource(value=nil, manuscript=nil) resource_index = self.mods(0).type_of_resource.count if !self.mods(0).type_of_resource.include?(value) self.mods(0).type_of_resource(resource_index, value) unless value.blank? self.mods(0).type_of_resource(resource_index).manuscript = 'yes' unless manuscript.blank? end end |
#prefix(path = nil) ⇒ Object
Required for Active Fedora 9
650 651 652 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 650 def prefix(path=nil) return '' end |
#related_item_xref(index) ⇒ Object
1809 1810 1811 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1809 def (index) self.find_by_terms(:related_item_xref).slice(index.to_i).remove end |
#remove_access_links(index) ⇒ Object
820 821 822 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 820 def remove_access_links(index) self.find_by_terms(:access_links).slice(index.to_i).remove end |
#remove_extent(index) ⇒ Object
1498 1499 1500 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1498 def remove_extent(index) self.find_by_terms(:extent).slice(index.to_i).remove end |
#remove_genre(index) ⇒ Object
799 800 801 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 799 def remove_genre(index) self.find_by_terms(:genre).slice(index.to_i).remove end |
#remove_host(index) ⇒ Object
1769 1770 1771 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1769 def remove_host(index) self.find_by_terms(:mods, :host).slice(index.to_i).remove end |
#remove_identifier(index) ⇒ Object
1880 1881 1882 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1880 def remove_identifier(index) self.find_by_terms(:identifier).slice(index.to_i).remove end |
#remove_language(index) ⇒ Object
704 705 706 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 704 def remove_language(index) self.find_by_terms(:language).slice(index.to_i).remove end |
#remove_mcgreevy(index) ⇒ Object
1916 1917 1918 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1916 def remove_mcgreevy(index) self.find_by_terms(:mcgreevy).slice(index.to_i).remove end |
#remove_name(index) ⇒ Object
1083 1084 1085 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1083 def remove_name(index) self.find_by_terms(:mods, :name).slice(index.to_i).remove end |
#remove_node(term, index) ⇒ Object
1933 1934 1935 1936 1937 1938 1939 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1933 def remove_node(term, index) node = self.find_by_terms(term.to_sym => index.to_i).first unless node.nil? node.remove self.dirty = true end end |
#remove_note(index) ⇒ Object
1508 1509 1510 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1508 def remove_note(index) self.find_by_terms(:note).slice(index.to_i).remove end |
#remove_physical_description(index) ⇒ Object
679 680 681 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 679 def remove_physical_description(index) self.find_by_terms(:physical_description).slice(index.to_i).remove end |
#remove_physical_location(index) ⇒ Object
1819 1820 1821 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1819 def remove_physical_location(index) self.find_by_terms(:physical_location).slice(index.to_i).remove end |
#remove_publisher(index) ⇒ Object
745 746 747 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 745 def remove_publisher(index) self.find_by_terms(:mods, :publisher).slice(index.to_i).remove end |
#remove_related_item(index) ⇒ Object
1793 1794 1795 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1793 def (index) self.find_by_terms(:related_item).slice(index.to_i).remove end |
#remove_subject_cartographic(index) ⇒ Object
1741 1742 1743 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1741 def remove_subject_cartographic(index) self.find_by_terms(:subject_cartographic).slice(index.to_i).remove end |
#remove_subject_geographic(index) ⇒ Object
1699 1700 1701 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1699 def remove_subject_geographic(index) self.find_by_terms(:subject_geographic).slice(index.to_i).remove end |
#remove_subject_topic(index) ⇒ Object
1556 1557 1558 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1556 def remove_subject_topic(index) self.find_by_terms(:mods, :subject_topic).slice(index.to_i).remove end |
#remove_table_of_contents(index) ⇒ Object
1751 1752 1753 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1751 def remove_table_of_contents(index) self.find_by_terms(:table_of_contents).slice(index.to_i).remove end |
#remove_title(index) ⇒ Object
1031 1032 1033 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 1031 def remove_title(index) self.find_by_terms(:mods, :title_info).slice(index.to_i).remove end |
#remove_type_of_resource(index) ⇒ Object
732 733 734 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 732 def remove_type_of_resource(index) self.find_by_terms(:type_of_resource).slice(index.to_i).remove end |
#to_xml(xml = nil) ⇒ Object
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
# File 'app/models/bplmodels/mods_desc_metadata.rb', line 626 def to_xml(xml = nil) xml = self.ng_xml if xml.nil? ng_xml = self.ng_xml if ng_xml.respond_to?(:root) && ng_xml.root.nil? && self.class.respond_to?(:root_property_ref) && !self.class.root_property_ref.nil? ng_xml = self.class.generate(self.class.root_property_ref, "") if xml.root.nil? xml = ng_xml end end unless xml == ng_xml || ng_xml.root.nil? if xml.kind_of?(Nokogiri::XML::Document) xml.root.add_child(ng_xml.root) elsif xml.kind_of?(Nokogiri::XML::Node) xml.add_child(ng_xml.root) else raise "You can only pass instances of Nokogiri::XML::Node into this method. You passed in #{xml}" end end return xml.to_xml(:encoding=>'UTF-8').strip end |