solr_ead 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,17 +53,19 @@ module SolrEad::Behaviors
53
53
  # parent_unittitles_display:: Stored as a display fields so it is not indexed. See parent_id_list for more info.
54
54
  # component_level_i:: numeric level of the component
55
55
  # component_children_b:: Boolean field indicating whether or not the component has any child <c> nodes attached to it
56
+ # document_unittitle_display:: Title field of the ead document of which this component is a part
56
57
  #
57
58
  # These fields are used so that we may reconstruct placement of a single component
58
59
  # within the hierarchy of the original ead.
59
60
  def additional_component_fields(node, addl_fields = Hash.new)
60
- addl_fields["id"] = [node.xpath("//eadid").text, node.attr("id")].join(":")
61
- addl_fields["eadid_s"] = node.xpath("//eadid").text
62
- addl_fields["parent_id_s"] = node.parent.attr("id") unless node.parent.attr("id").nil?
63
- addl_fields["parent_ids_display"] = parent_id_list(node)
64
- addl_fields["parent_unittitles_display"] = parent_unittitle_list(node)
65
- addl_fields["component_level_i"] = parent_id_list(node).length + 1
66
- addl_fields["component_children_b"] = component_children?(node)
61
+ addl_fields["id"] = [node.xpath("//eadid").text, node.attr("id")].join(":")
62
+ addl_fields["eadid_s"] = node.xpath("//eadid").text
63
+ addl_fields["parent_id_s"] = node.parent.attr("id") unless node.parent.attr("id").nil?
64
+ addl_fields["parent_ids_display"] = parent_id_list(node)
65
+ addl_fields["parent_unittitles_display"] = parent_unittitle_list(node)
66
+ addl_fields["component_level_i"] = parent_id_list(node).length + 1
67
+ addl_fields["component_children_b"] = component_children?(node)
68
+ addl_fields["document_unittitle_display"] = node.xpath("//archdesc/did/unittitle").text
67
69
  return addl_fields
68
70
  end
69
71
 
@@ -68,7 +68,7 @@ class SolrEad::Component
68
68
  def to_solr(solr_doc = Hash.new)
69
69
  super(solr_doc)
70
70
  solr_doc.merge!({"format" => "Archival Item"})
71
- solr_doc.merge!({"heading_display" => [ solr_doc["parent_unittitle_list_t"], self.title.first ].join(" >> ") })
71
+ solr_doc["parent_unittitles_display"].length > 0 ? solr_doc.merge!({"heading_display" => [ solr_doc["parent_unittitles_display"], self.title.first].join(" >> ") }) : solr_doc.merge!({"heading_display" => self.title.first })
72
72
  end
73
73
 
74
74
  end
@@ -1,3 +1,3 @@
1
1
  module SolrEad
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -11,12 +11,12 @@ describe SolrEad::Component do
11
11
 
12
12
  it "should accept additional fields from a hash" do
13
13
  additional_fields = {
14
- "id" => "TEST-0001:ref010",
15
- "eadid_s" => "TEST-0001",
16
- "parent_id_s" => "ref001",
17
- "parent_id_list_t" => ["ref001", "ref002", "ref003"],
18
- "parent_unittitle_list_t" => ["Series I", "Subseries A", "Subseries 1"],
19
- "component_children_b" => FALSE
14
+ "id" => "TEST-0001:ref010",
15
+ "eadid_s" => "TEST-0001",
16
+ "parent_id_s" => "ref001",
17
+ "parent_ids_display" => ["ref001", "ref002", "ref003"],
18
+ "parent_unittitles_display" => ["Series I", "Subseries A", "Subseries 1"],
19
+ "component_children_b" => FALSE
20
20
  }
21
21
  solr_doc = @doc.to_solr(additional_fields)
22
22
  solr_doc["id"].should == "TEST-0001:ref010"
@@ -27,6 +27,24 @@ describe SolrEad::Component do
27
27
 
28
28
  end
29
29
 
30
+ it "should format heading_display with only one element" do
31
+ additional_fields = {
32
+ "id" => "TEST-0001:ref010",
33
+ "eadid_s" => "TEST-0001",
34
+ "parent_id_s" => "ref001",
35
+ "parent_ids_display" => ["ref001", "ref002", "ref003"],
36
+ "parent_unittitles_display" => [],
37
+ "component_children_b" => FALSE
38
+ }
39
+ solr_doc = @doc.to_solr(additional_fields)
40
+ solr_doc["id"].should == "TEST-0001:ref010"
41
+ solr_doc["level_facet"].should include "item"
42
+ solr_doc["heading_display"].should == "Internal Revenue Service Form Information Return [RESTRICTED]"
43
+ solr_doc["accessrestrict_t"].first.should match /^This item .* is available.$/
44
+ solr_doc["accessrestrict_heading_display"].should include "Access Restrictions"
45
+
46
+ end
47
+
30
48
  end
31
49
 
32
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solr_ead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: om