ld4l-works_rdf 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +25 -0
  4. data/.travis.yml +14 -0
  5. data/CHANGES.md +3 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +170 -0
  9. data/Rakefile +2 -0
  10. data/ld4l-works_rdf.gemspec +42 -0
  11. data/lib/ld4l/works_rdf.rb +131 -0
  12. data/lib/ld4l/works_rdf/configuration.rb +41 -0
  13. data/lib/ld4l/works_rdf/models/bibframe/bibframe_identifier.rb +17 -0
  14. data/lib/ld4l/works_rdf/models/bibframe/bibframe_instance.rb +23 -0
  15. data/lib/ld4l/works_rdf/models/bibframe/bibframe_organization.rb +16 -0
  16. data/lib/ld4l/works_rdf/models/bibframe/bibframe_person.rb +16 -0
  17. data/lib/ld4l/works_rdf/models/bibframe/bibframe_place.rb +16 -0
  18. data/lib/ld4l/works_rdf/models/bibframe/bibframe_provider.rb +18 -0
  19. data/lib/ld4l/works_rdf/models/bibframe/bibframe_title.rb +18 -0
  20. data/lib/ld4l/works_rdf/models/bibframe/bibframe_work.rb +16 -0
  21. data/lib/ld4l/works_rdf/models/bibo/bibo_book.rb +19 -0
  22. data/lib/ld4l/works_rdf/models/bibo/bibo_document.rb +14 -0
  23. data/lib/ld4l/works_rdf/models/bibo/vivo_authorship.rb +15 -0
  24. data/lib/ld4l/works_rdf/models/bibo/vivo_book.rb +18 -0
  25. data/lib/ld4l/works_rdf/models/generic_work.rb +13 -0
  26. data/lib/ld4l/works_rdf/models/schema/oclc_schema_book.rb +16 -0
  27. data/lib/ld4l/works_rdf/models/schema/schema_book.rb +23 -0
  28. data/lib/ld4l/works_rdf/models/schema/schema_person.rb +17 -0
  29. data/lib/ld4l/works_rdf/models/schema/schema_publisher.rb +15 -0
  30. data/lib/ld4l/works_rdf/models/work_metadata.rb +212 -0
  31. data/lib/ld4l/works_rdf/services/attempt_generic_metadata_extraction.rb +41 -0
  32. data/lib/ld4l/works_rdf/services/conversion_services/get_rdfxml_from_marcxml.rb +44 -0
  33. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.ErrorCodes.xqy +56 -0
  34. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MARCXML-2-MADSRDF.xqy +1702 -0
  35. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MARCXML-2-RecordInfoRDF.xqy +216 -0
  36. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MARCXMLBIB-2-BIBFRAME.xqy +140 -0
  37. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MARCXMLBIB-BFUtils.xqy +3287 -0
  38. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MBIB-2-BIBFRAME-Shared.xqy +4112 -0
  39. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MBIB-Default-2-BF.xqy +61 -0
  40. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.MBIB-NotatedMusic-2-BF.xqy +105 -0
  41. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.RDFXML-2-ExhibitJSON.xqy +119 -0
  42. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.RDFXML-2-JSON.xqy +193 -0
  43. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.RDFXML-2-Ntriples.xqy +276 -0
  44. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/modules/module.RDFXMLnested-2-flat.xqy +380 -0
  45. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/xbin/ml.xqy +239 -0
  46. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/xbin/saxon.xqy +134 -0
  47. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/xbin/zorba.xqy +359 -0
  48. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/xbin/zorba2-0.xqy +249 -0
  49. data/lib/ld4l/works_rdf/services/conversion_services/marc2bibframe/xbin/zorba3-0.xqy +362 -0
  50. data/lib/ld4l/works_rdf/services/conversion_services/saxon/saxon9he.jar +0 -0
  51. data/lib/ld4l/works_rdf/services/get_metadata_from_marcxml_uri.rb +43 -0
  52. data/lib/ld4l/works_rdf/services/get_metadata_from_oclc_uri.rb +25 -0
  53. data/lib/ld4l/works_rdf/services/get_metadata_from_solr_query.rb +29 -0
  54. data/lib/ld4l/works_rdf/services/get_metadata_from_vivo_uri.rb +25 -0
  55. data/lib/ld4l/works_rdf/services/get_model_from_uri.rb +62 -0
  56. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_bibframe_models.rb +60 -0
  57. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_bibo_model.rb +42 -0
  58. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_generic_model.rb +41 -0
  59. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_oclc_model.rb +42 -0
  60. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_solr_doc.rb +67 -0
  61. data/lib/ld4l/works_rdf/services/metadata_services/get_metadata_from_vivo_model.rb +45 -0
  62. data/lib/ld4l/works_rdf/services/metadata_services/set_error_in_metadata.rb +27 -0
  63. data/lib/ld4l/works_rdf/services/model_services/populate_bibframe_models_from_repository.rb +46 -0
  64. data/lib/ld4l/works_rdf/services/model_services/populate_generic_model_from_repository.rb +30 -0
  65. data/lib/ld4l/works_rdf/services/model_services/populate_oclc_model_from_repository.rb +27 -0
  66. data/lib/ld4l/works_rdf/services/model_services/populate_vivo_model_from_repository.rb +27 -0
  67. data/lib/ld4l/works_rdf/services/negotiation_services/get_marcxml_from_uri.rb +35 -0
  68. data/lib/ld4l/works_rdf/services/negotiation_services/get_rdfxml_from_uri.rb +37 -0
  69. data/lib/ld4l/works_rdf/services/negotiation_services/get_solr_results_from_solr_query.rb +35 -0
  70. data/lib/ld4l/works_rdf/services/negotiation_services/get_turtle_from_uri.rb +37 -0
  71. data/lib/ld4l/works_rdf/services/negotiation_services/response_header.rb +51 -0
  72. data/lib/ld4l/works_rdf/services/repository_services/populate_graph_from_rdfxml.rb +22 -0
  73. data/lib/ld4l/works_rdf/services/repository_services/populate_graph_from_turtle.rb +21 -0
  74. data/lib/ld4l/works_rdf/services/repository_services/populate_repository_from_graph.rb +25 -0
  75. data/lib/ld4l/works_rdf/version.rb +5 -0
  76. data/lib/ld4l/works_rdf/vocab/bf.rb +29 -0
  77. data/lib/ld4l/works_rdf/vocab/bgn.rb +5 -0
  78. data/lib/ld4l/works_rdf/vocab/bibo.rb +10 -0
  79. data/lib/ld4l/works_rdf/vocab/library.rb +6 -0
  80. data/lib/ld4l/works_rdf/vocab/vitro.rb +5 -0
  81. data/lib/ld4l/works_rdf/vocab/vivo.rb +11 -0
  82. data/spec/ld4l/works_rdf/configuration_spec.rb +166 -0
  83. data/spec/ld4l/works_rdf/models/books/vivo_book_rdf_spec.rb +267 -0
  84. data/spec/ld4l/works_rdf/services/get_metadata_from_uri_spec.rb +39 -0
  85. data/spec/ld4l/works_rdf/services/get_model_from_uri_spec.rb +34 -0
  86. data/spec/ld4l/works_rdf_spec.rb +53 -0
  87. data/spec/spec_helper.rb +26 -0
  88. metadata +321 -0
@@ -0,0 +1,17 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeIdentifier < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="i"
7
+
8
+ configure :type => RDFVocabularies::BF.Identifier,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :identifier_scheme, :predicate => RDFVocabularies::BF.identifierScheme # uri
13
+ property :identifier_value, :predicate => RDFVocabularies::BF.identifierValue # string
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeInstance < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BF.Instance,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :instance_of, :predicate => RDFVocabularies::BF.instanceOf, :class_name => LD4L::WorksRDF::BibframeWork
13
+ property :title, :predicate => RDFVocabularies::BF.instanceTitle, :class_name => LD4L::WorksRDF::BibframeTitle
14
+ property :title_statement, :predicate => RDFVocabularies::BF.titleStatement
15
+ property :system_number, :predicate => RDFVocabularies::BF.systemNumber, :class_name => LD4L::WorksRDF::BibframeIdentifier # has OCLC URI in one of these
16
+ property :publication, :predicate => RDFVocabularies::BF.publication, :class_name => LD4L::WorksRDF::BibframeProvider
17
+ property :provider_statement, :predicate => RDFVocabularies::BF.providerStatement
18
+ property :copyright_date, :predicate => RDFVocabularies::BF.copyrightDate
19
+ property :book_edition, :predicate => RDFVocabularies::BF.edition
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,16 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeOrganization < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BF.Organization,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :label, :predicate => RDFVocabularies::BF.label # string
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframePerson < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="p"
7
+
8
+ configure :type => RDFVocabularies::BF.Person,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :label, :predicate => RDFVocabularies::BF.label # string
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframePlace < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BF.Place,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :label, :predicate => RDFVocabularies::BF.label # string
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeProvider < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="p"
7
+
8
+ configure :type => RDFVocabularies::BF.Provider,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :provider_date, :predicate => RDFVocabularies::BF.providerDate # string
13
+ property :provider_name, :predicate => RDFVocabularies::BF.providerName, :class_name => LD4L::WorksRDF::BibframeOrganization # string
14
+ property :provider_place, :predicate => RDFVocabularies::BF.providerPlace, :class_name => LD4L::WorksRDF::BibframePlace
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeTitle < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="t"
7
+
8
+ configure :type => RDFVocabularies::BF.Title,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :title_value, :predicate => RDFVocabularies::BF.titleValue # string
13
+ property :subtitle, :predicate => RDFVocabularies::BF.subtitle # string
14
+ property :label, :predicate => RDFVocabularies::BF.label # string
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BibframeWork < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BF.Work,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :creator, :predicate => RDFVocabularies::BF.creator, :class_name => LD4L::WorksRDF::BibframePerson
13
+ property :contributor, :predicate => RDFVocabularies::BF.contributor, :class_name => LD4L::WorksRDF::BibframePerson
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BiboBook < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BIBO.Book,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :title, :predicate => RDF::DC11.title
13
+ property :label, :predicate => RDF::RDFS.label
14
+ property :isbn10, :predicate => RDFVocabularies::BIBO.isbn10
15
+ property :isbn13, :predicate => RDFVocabularies::BIBO.isbn13
16
+ property :oclcnum, :predicate => RDFVocabularies::BIBO.oclcnum
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class BiboDocument < LD4L::WorksRDF::BiboBook
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDFVocabularies::BIBO.Document,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class VivoAuthorship < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="p"
7
+
8
+ configure :type => RDFVocabularies::VIVO.Authorship,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :relates, :predicate => RDFVocabularies::VIVO.relates, :class_name => LD4L::WorksRDF::VivoBook
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class VivoBook < LD4L::WorksRDF::BiboBook
4
+ class << self; attr_reader :localname_prefix end
5
+ @localname_prefix="w"
6
+
7
+ configure :type => RDFVocabularies::VIVO.Book,
8
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
9
+ :repository => :default
10
+
11
+ property :most_specific_type, :predicate => RDFVocabularies::VITRO.mostSpecificType
12
+ property :date_time_value, :predicate => RDFVocabularies::VIVO.dateTimeValue, :cast => false
13
+ property :place_of_publication, :predicate => RDFVocabularies::VIVO.placeOfPublication
14
+ property :publisher, :predicate => RDFVocabularies::VIVO.publisher, :class_name => LD4L::FoafRDF::Agent
15
+ property :relatedBy, :predicate => RDFVocabularies::VIVO.relatedBy, :class_name => LD4L::WorksRDF::VivoAuthorship # author
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class GenericWork < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :base_uri => LD4L::WorksRDF.configuration.base_uri,
9
+ :repository => :default
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class OclcSchemaBook < LD4L::WorksRDF::SchemaBook
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDF::SCHEMA.Book,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :oclcnum, :predicate => RDFVocabularies::LIBRARY.oclcnum
13
+ property :place_of_publication, :predicate => RDFVocabularies::LIBRARY.placeOfPublication
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class SchemaBook < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="w"
7
+
8
+ configure :type => RDF::SCHEMA.Book,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :title, :predicate => RDF::SCHEMA.name
13
+ property :creator, :predicate => RDF::SCHEMA.creator, :class_name => LD4L::WorksRDF::SchemaPerson # author
14
+ property :book_edition, :predicate => RDF::SCHEMA.bookEdition
15
+ property :copyright_year, :predicate => RDF::SCHEMA.copyrightYear
16
+ property :date_published, :predicate => RDF::SCHEMA.datePublished
17
+ property :description, :predicate => RDF::SCHEMA.description
18
+ property :genre, :predicate => RDF::SCHEMA.genre
19
+ property :in_language, :predicate => RDF::SCHEMA.inLanguage
20
+ property :publisher, :predicate => RDF::SCHEMA.publisher
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class SchemaPerson < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="p"
7
+
8
+ configure :type => RDFVocabularies::VIVO.Authorship,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :family_name, :predicate => RDF::SCHEMA.familyName
13
+ property :given_name, :predicate => RDF::SCHEMA.givenName
14
+ property :full_name, :predicate => RDF::SCHEMA.name
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class SchemaPublisher < ActiveTriples::Resource
4
+
5
+ class << self; attr_reader :localname_prefix end
6
+ @localname_prefix="p"
7
+
8
+ configure :type => RDFVocabularies::BGN.Agent,
9
+ :base_uri => LD4L::WorksRDF.configuration.base_uri,
10
+ :repository => :default
11
+
12
+ property :publisher_name, :predicate => RDF::SCHEMA.name
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,212 @@
1
+ module LD4L
2
+ module WorksRDF
3
+ class WorkMetadata
4
+
5
+ attr_reader :work_type # valid values: :UNKNOWN, :BOOK, :VIDEO, :MUSIC
6
+ attr_reader :rdf_types
7
+ attr_reader :model
8
+ attr_accessor :uri
9
+ attr_accessor :title
10
+ attr_accessor :subtitle
11
+ attr_accessor :author
12
+ attr_accessor :pub_date
13
+ attr_accessor :pub_info
14
+ attr_accessor :language
15
+ attr_accessor :edition
16
+ attr_accessor :oclc_id
17
+ attr_reader :source_id # valid values: :UNKNOWN, :OCLC, :CORNELL_VIVO, :CORNELL_LIBRARY, :STANFORD_LIBRARY
18
+ attr_accessor :source
19
+ attr_accessor :local_id
20
+ attr_accessor :local_location
21
+ attr_accessor :local_callnumber
22
+ # attr_accessor :availability # TODO: for Cornell only???
23
+ attr_accessor :error
24
+ attr_accessor :error_message
25
+
26
+ def initialize( the_work=nil )
27
+
28
+ # displayable:
29
+ # line 1 @titla @pubdate (year only)
30
+ # line 2 @author
31
+ # line 3 @format @pub_info @language @edition
32
+ # line 4 @local_location @local_callnumber
33
+ # sortable: @title, @author, @pub_date (year only)
34
+ # facetable: @format, @author, @pub_date (year_only), @language, @subject, @subject_region, @subject_era, @genre, @fiction_or_non, @local_location, @local_callnumber
35
+
36
+ @work_type = :UNKNOWN
37
+ @rdf_types = ""
38
+ @uri = "" # :displayable (used as URL for link)
39
+ @model = "" # :stored
40
+ @title = "" # :displayable, :searchable, :sortable
41
+ @subtitle = "" # :displayable, :searchable
42
+ @author = "" # :facetable, :displayable, :searchable, :sortable
43
+ @pub_date = "" # :facetable, :displayable, :sortable (year only)
44
+ @pub_info = "" # :displayable, :searchable
45
+ @language = "" # :facetable, :displayable
46
+ # @subject = "" # :facetable
47
+ # @subject_region = "" # :facetable
48
+ # @subject_era = "" # :facetable
49
+ # @genre = "" # :facetable
50
+ # @fiction_or_non = "" # :facetable
51
+ @edition = "" # :displayable
52
+ @oclc_id = "" # :displayable
53
+ @source_id = :UNKNOWN
54
+ @source = ""
55
+ @local_id = ""
56
+ @local_location = "" # :facetable
57
+ @local_callnumber = "" # :facetable
58
+ @format = "" # :facetable, :displayable
59
+ @error = false
60
+ @error_message = ""
61
+ unless the_work.nil?
62
+ @model = the_work
63
+ @rdf_types = []
64
+ the_work.type.each do |t|
65
+ rdf_types << t.to_s
66
+ end
67
+ end
68
+ end
69
+
70
+ def generate_solr_doc
71
+ solr_doc = {}
72
+
73
+ solr_doc[:resource_title_ti] = @title
74
+ solr_doc[:resource_title_sort_ss] = @title
75
+ solr_doc[:resource_subtitle_ti] = @subtitle
76
+ solr_doc[:resource_author_ti] = @author
77
+ solr_doc[:resource_author_facet_sim] = @author
78
+ solr_doc[:resource_author_sort_ss] = @author
79
+ # solr_doc[:resource_subject_tim] = @subject
80
+ solr_doc[:resource_pub_date_iti] = @pub_date # year only, e.g.: 2005
81
+ solr_doc[:resource_pub_info] = @pub_info # format: "Champaign, IL :Human Kinetics, c2005."
82
+ solr_doc[:resource_language] = @language
83
+ solr_doc[:resource_edition] = @edition
84
+ solr_doc[:resource_oclc_id] = @oclc_id
85
+ solr_doc[:resource_source_id] = @source_id
86
+ solr_doc[:resource_source] = @source
87
+ solr_doc[:resource_local_id] = @local_id
88
+ solr_doc[:resource_local_location] = @local_location
89
+ solr_doc[:resource_local_callnumber] = @local_callnumber
90
+ solr_doc[:resource_profile_ss] = serialize
91
+ solr_doc
92
+ end
93
+
94
+ def load_from_solr_doc( solr_doc )
95
+ deserialize solr_doc[:resource_profile_ss] if solr_doc.has_key? :resource_profile_ss
96
+ end
97
+
98
+ def serialize
99
+ attrs = {}
100
+ attrs[:title] = @title
101
+ attrs[:subtitle] = @subtitle
102
+ attrs[:author] = @author
103
+ attrs[:pub_date] = @pub_date
104
+ attrs[:pub_info] = @pub_info
105
+ attrs[:language] = @language
106
+ attrs[:edition] = @edition
107
+ attrs[:oclc_id] = @oclc_id
108
+ attrs[:source_id] = @source_id
109
+ attrs[:source] = @source
110
+ attrs[:local_id] = @local_id
111
+ attrs[:local_location] = @local_location
112
+ attrs[:local_callnumber] = @local_callnumber
113
+ attrs.to_json
114
+ end
115
+
116
+ def deserialize( serialization )
117
+ attrs = JSON.parse serialization
118
+
119
+ @title = attrs["title"]
120
+ @subtitle = attrs["subtitle"]
121
+ @author = attrs["author"]
122
+ @pub_date = attrs["pub_date"]
123
+ @pub_info = attrs["pub_info"]
124
+ @language = attrs["language"]
125
+ @edition = attrs["edition"]
126
+ @oclc_id = attrs["oclc_id"]
127
+ @source_id = attrs["source_id"]
128
+ @source = attrs["source"]
129
+ @local_id = attrs["local_id"]
130
+ @local_location = attrs["local_location"]
131
+ @local_callnumber = attrs["local_callnumber"]
132
+ self
133
+ end
134
+
135
+ def set_type(format) # TODO validate format, don't just use it
136
+ @work_type = format.upcase.to_sym if format.is_a? String # TODO sometimes format is an array (e.g. ["Thesis","Book"])
137
+ end
138
+
139
+ def set_type_to_book
140
+ @work_type = :BOOK
141
+ end
142
+ def is_book?
143
+ return true if @work_type == :BOOK
144
+ false
145
+ end
146
+
147
+ def set_type_to_video
148
+ @work_type = :VIDEO
149
+ end
150
+ def is_video?
151
+ return true if @work_type == :VIDEO
152
+ false
153
+ end
154
+
155
+ def set_type_to_music
156
+ @work_type = :MUSIC
157
+ end
158
+ def is_music?
159
+ return true if @work_type == :MUSIC
160
+ false
161
+ end
162
+
163
+ def set_source_to_unknown
164
+ @source_id = :UNKNOWN
165
+ end
166
+ def is_source_unknown?
167
+ return true if @source_id == :UNKNOWN
168
+ false
169
+ end
170
+
171
+ def set_source_to_cornell_vivo
172
+ @source_id = :CORNELL_VIVO
173
+ end
174
+ def is_cornell_vivo?
175
+ return true if @source_id == :CORNELL_VIVO
176
+ false
177
+ end
178
+
179
+ def set_source_to_oclc
180
+ @source_id = :OCLC
181
+ end
182
+ def is_oclc?
183
+ return true if @source_id == :OCLC
184
+ false
185
+ end
186
+
187
+ def set_source_to_cornell_library
188
+ @source_id = :CORNELL_LIBRARY
189
+ end
190
+ def is_cornell_library?
191
+ return true if @source_id == :CORNELL_LIBRARY
192
+ false
193
+ end
194
+
195
+ def set_source_to_stanford_library
196
+ @source_id = :STANFORD_LIBRARY
197
+ end
198
+ def is_stanford_library?
199
+ return true if @source_id == :STANFORD_LIBRARY
200
+ false
201
+ end
202
+
203
+ def set_source_to_harvard_library
204
+ @source_id = :HARVARD_LIBRARY
205
+ end
206
+ def is_harvard_library?
207
+ return true if @source_id == :HARVARD_LIBRARY
208
+ false
209
+ end
210
+ end
211
+ end
212
+ end