collectionspace-client 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CollectionSpace
4
+ # CollectionSpace report
5
+ class Report
6
+ def self.all
7
+ [
8
+ {
9
+ name: "Acquisition Summary",
10
+ notes: "An acquisition summary report. Runs on a single record only.",
11
+ doctype: "Acquisition",
12
+ supports_single_doc: "true",
13
+ supports_doc_list: "false",
14
+ supports_group: "false",
15
+ supports_no_context: "false",
16
+ filename: "acq_basic.jrxml",
17
+ mimetype: "application/pdf"
18
+ },
19
+ {
20
+ name: "Acquisition Basic List",
21
+ notes: "Catalog info for objects related to an acquisition record. Runs on a single record only.",
22
+ doctype: "Acquisition",
23
+ supports_single_doc: "true",
24
+ supports_doc_list: "false",
25
+ supports_group: "false",
26
+ supports_no_context: "false",
27
+ filename: "Acq_List_Basic.jrxml",
28
+ mimetype: "application/pdf"
29
+ },
30
+ {
31
+ name: "Condition Check Basic List",
32
+ notes: "Catalog info for objects related to a condition check record. Runs on a single record only.",
33
+ doctype: "Conditioncheck",
34
+ supports_single_doc: "true",
35
+ supports_doc_list: "false",
36
+ supports_group: "false",
37
+ supports_no_context: "false",
38
+ filename: "CC_List_Basic.jrxml",
39
+ mimetype: "application/pdf"
40
+ },
41
+ {
42
+ name: "Exhibition Basic List",
43
+ notes: "Catalog info for objects related to a exhibition record. Runs on a single record only.",
44
+ doctype: "Exhibition",
45
+ supports_single_doc: "true",
46
+ supports_doc_list: "false",
47
+ supports_group: "false",
48
+ supports_no_context: "false",
49
+ filename: "Exhibition_List_Basic.jrxml",
50
+ mimetype: "application/pdf"
51
+ },
52
+ {
53
+ name: "Group Basic List",
54
+ notes: "Catalog info for objects related to a group record. Runs on a single record only.",
55
+ doctype: "Group",
56
+ supports_single_doc: "true",
57
+ supports_doc_list: "false",
58
+ supports_group: "false",
59
+ supports_no_context: "false",
60
+ filename: "Group_List_Basic.jrxml",
61
+ mimetype: "application/pdf"
62
+ },
63
+ {
64
+ name: "Loan In Basic List",
65
+ notes: "Catalog info for objects related to a loan in record. Runs on a single record only.",
66
+ doctype: "Loanin",
67
+ supports_single_doc: "true",
68
+ supports_doc_list: "false",
69
+ supports_group: "false",
70
+ supports_no_context: "false",
71
+ filename: "LoansIn_List_Basic.jrxml",
72
+ mimetype: "application/pdf"
73
+ },
74
+ {
75
+ name: "Loan Out Basic List",
76
+ notes: "Catalog info for objects related to a loan out record. Runs on a single record only.",
77
+ doctype: "Loanout",
78
+ supports_single_doc: "true",
79
+ supports_doc_list: "false",
80
+ supports_group: "false",
81
+ supports_no_context: "false",
82
+ filename: "LoansOut_List_Basic.jrxml",
83
+ mimetype: "application/pdf"
84
+ },
85
+ {
86
+ name: "Acquisition Ethnographic Object List",
87
+ notes: "Core acquisition report. Runs on a single record only.",
88
+ doctype: "Acquisition",
89
+ supports_single_doc: "true",
90
+ supports_doc_list: "false",
91
+ supports_group: "false",
92
+ supports_no_context: "false",
93
+ filename: "coreAcquisition.jrxml",
94
+ mimetype: "application/pdf"
95
+ },
96
+ {
97
+ name: "Group Object Ethnographic Object List",
98
+ notes: "Core group object report. Runs on a single record only.",
99
+ doctype: "Group",
100
+ supports_single_doc: "true",
101
+ supports_doc_list: "false",
102
+ supports_group: "false",
103
+ supports_no_context: "false",
104
+ filename: "coreGroupObject.jrxml",
105
+ mimetype: "application/pdf"
106
+ },
107
+ {
108
+ name: "Intake Ethnographic Object List",
109
+ notes: "Core intake report. Runs on a single record only.",
110
+ doctype: "Intake",
111
+ supports_single_doc: "true",
112
+ supports_doc_list: "false",
113
+ supports_group: "false",
114
+ supports_no_context: "false",
115
+ filename: "coreIntake.jrxml",
116
+ mimetype: "application/pdf"
117
+ },
118
+ {
119
+ name: "Loan In Ethnographic Object List",
120
+ notes: "Core loan in report. Runs on a single record only.",
121
+ doctype: "Loanin",
122
+ supports_single_doc: "true",
123
+ supports_doc_list: "false",
124
+ supports_group: "false",
125
+ supports_no_context: "false",
126
+ filename: "coreLoanIn.jrxml",
127
+ mimetype: "application/pdf"
128
+ },
129
+ {
130
+ name: "Loan Out Ethnographic Object List",
131
+ notes: "Core loan out report. Runs on a single record only.",
132
+ doctype: "Loanout",
133
+ supports_single_doc: "true",
134
+ supports_doc_list: "false",
135
+ supports_group: "false",
136
+ supports_no_context: "false",
137
+ filename: "coreLoanOut.jrxml",
138
+ mimetype: "application/pdf"
139
+ },
140
+ {
141
+ name: "Object Exit Ethnographic Object List",
142
+ notes: "Core object exit report. Runs on a single record only.",
143
+ doctype: "ObjectExit",
144
+ supports_single_doc: "true",
145
+ supports_doc_list: "false",
146
+ supports_group: "false",
147
+ supports_no_context: "false",
148
+ filename: "coreObjectExit.jrxml",
149
+ mimetype: "application/pdf"
150
+ },
151
+ {
152
+ name: "Object Valuation",
153
+ notes: "Returns latest valuation information for selected objects",
154
+ doctype: "CollectionObject",
155
+ supports_single_doc: "false",
156
+ supports_doc_list: "true",
157
+ supports_group: "false",
158
+ supports_no_context: "true",
159
+ filename: "object_valuation.jrxml",
160
+ mimetype: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
161
+ },
162
+ {
163
+ name: "Systematic Inventory",
164
+ notes: "Generate a checklist for performing an inventory on a range of storage locations. Runs on all records, using the provided start and end locations.",
165
+ doctype: "Locationitem",
166
+ supports_single_doc: "false",
167
+ supports_doc_list: "false",
168
+ supports_group: "false",
169
+ supports_no_context: "true",
170
+ filename: "systematicInventory.jrxml",
171
+ mimetype: "application/pdf"
172
+ }
173
+ ]
174
+ end
175
+
176
+ def self.find(key, value)
177
+ all.find { |report| report[key] == value }
178
+ end
179
+ end
180
+ end
@@ -11,21 +11,21 @@ module CollectionSpace
11
11
  delete: {},
12
12
  get: {},
13
13
  post: {
14
- 'Content-Type' => 'application/xml',
15
- 'Content-Length' => 'nnnn'
14
+ "Content-Type" => "application/xml",
15
+ "Content-Length" => "nnnn"
16
16
  },
17
17
  put: {
18
- 'Content-Type' => 'application/xml',
19
- 'Content-Length' => 'nnnn'
18
+ "Content-Type" => "application/xml",
19
+ "Content-Length" => "nnnn"
20
20
  }
21
21
  }
22
22
  headers[method]
23
23
  end
24
24
 
25
- def initialize(config, method = 'GET', path = '', options = {})
25
+ def initialize(config, method = "GET", path = "", options = {})
26
26
  @config = config
27
27
  @method = method.downcase.to_sym
28
- @path = path.gsub(%r{^/}, '')
28
+ @path = path.gsub(%r{^/}, "")
29
29
 
30
30
  @auth = {
31
31
  username: config.username,
@@ -35,11 +35,12 @@ module CollectionSpace
35
35
  headers = default_headers(@method).merge(options.fetch(:headers, {}))
36
36
  @options = options
37
37
  @options[:basic_auth] = @auth
38
- @options[:headers] = headers
39
- @options[:verify] = config.verify_ssl
40
- @options[:query] = options.fetch(:query, {})
38
+ @options[:headers] = headers
39
+ @options[:verify] = config.verify_ssl
40
+ @options[:query] = options.fetch(:query, {})
41
41
 
42
42
  self.class.base_uri config.base_uri
43
+ self.class.debug_output $stdout if config.verbose
43
44
  self.class.default_params(
44
45
  wf_deleted: config.include_deleted,
45
46
  pgSz: config.page_size
@@ -6,19 +6,19 @@ module CollectionSpace
6
6
  attr_reader :result, :parsed, :status_code, :xml
7
7
 
8
8
  def initialize(result)
9
- @result = result
10
- @parsed = result.parsed_response
9
+ @result = result
10
+ @parsed = result.parsed_response
11
11
  @status_code = result.code.to_i
12
12
  body = result.body
13
- @xml = @result.success? && body =~ /<?xml/ ? Nokogiri::XML(body) : nil
13
+ @xml = (@result.success? && body =~ /<?xml/) ? Nokogiri::XML(body) : nil
14
14
  end
15
15
 
16
16
  def find(list_type, item_type, property, value)
17
- total = parsed[list_type]['totalItems'].to_i
17
+ total = parsed[list_type]["totalItems"].to_i
18
18
  return unless total.positive?
19
19
 
20
- list = parsed[list_type][item_type]
21
- list = [list] if total == 1 # wrap if single item
20
+ list = parsed[list_type][item_type]
21
+ list = [list] if total == 1 # wrap if single item
22
22
  list.find { |i| i[property] == value }
23
23
  end
24
24
  end
@@ -5,12 +5,12 @@ module CollectionSpace
5
5
  class Search
6
6
  attr_accessor :path, :namespace, :field, :expression
7
7
 
8
- DEFAULT_SORT = 'collectionspace_core:updatedAt DESC'
8
+ DEFAULT_SORT = "collectionspace_core:updatedAt DESC"
9
9
 
10
10
  def initialize(path: nil, namespace: nil, field: nil, expression: nil)
11
- @path = path
12
- @namespace = namespace
13
- @field = field
11
+ @path = path
12
+ @namespace = namespace
13
+ @field = field
14
14
  @expression = expression
15
15
  end
16
16
 
@@ -3,192 +3,198 @@
3
3
  module CollectionSpace
4
4
  # CollectionSpace service
5
5
  class Service
6
- TERM_SUFFIX = 'TermGroupList/0/termDisplayName'
7
- def self.get(type:, subtype: '')
6
+ TERM_SUFFIX = "TermGroupList/0/termDisplayName"
7
+ def self.get(type:, subtype: "")
8
8
  {
9
- 'acquisitions' => {
10
- identifier: 'acquisitionReferenceNumber',
11
- ns_prefix: 'acquisitions',
12
- path: 'acquisitions',
9
+ "acquisitions" => {
10
+ identifier: "acquisitionReferenceNumber",
11
+ ns_prefix: "acquisitions",
12
+ path: "acquisitions",
13
13
  term: nil
14
14
  },
15
- 'citationauthorities' => {
16
- identifier: 'shortIdentifier',
17
- ns_prefix: 'citations',
15
+ "citationauthorities" => {
16
+ identifier: "shortIdentifier",
17
+ ns_prefix: "citations",
18
18
  path: "citationauthorities/urn:cspace:name(#{subtype})/items",
19
19
  term: "citation#{TERM_SUFFIX}"
20
20
  },
21
- 'claims' => {
22
- identifier: 'claimNumber',
23
- ns_prefix: 'claims',
24
- path: 'claims',
21
+ "claims" => {
22
+ identifier: "claimNumber",
23
+ ns_prefix: "claims",
24
+ path: "claims",
25
25
  term: nil
26
26
  },
27
- 'collectionobjects' => {
28
- identifier: 'objectNumber',
29
- ns_prefix: 'collectionobjects',
30
- path: 'collectionobjects',
27
+ "collectionobjects" => {
28
+ identifier: "objectNumber",
29
+ ns_prefix: "collectionobjects",
30
+ path: "collectionobjects",
31
31
  term: nil
32
32
  },
33
- 'conceptauthorities' => {
34
- identifier: 'shortIdentifier',
35
- ns_prefix: 'concepts',
33
+ "conceptauthorities" => {
34
+ identifier: "shortIdentifier",
35
+ ns_prefix: "concepts",
36
36
  path: "conceptauthorities/urn:cspace:name(#{subtype})/items",
37
37
  term: "concept#{TERM_SUFFIX}"
38
38
  },
39
- 'conditionchecks' => {
40
- identifier: 'conditionCheckRefNumber',
41
- ns_prefix: 'conditionchecks',
42
- path: 'conditionchecks',
39
+ "conditionchecks" => {
40
+ identifier: "conditionCheckRefNumber",
41
+ ns_prefix: "conditionchecks",
42
+ path: "conditionchecks",
43
43
  term: nil
44
44
  },
45
- 'conservation' => {
46
- identifier: 'conservationNumber',
47
- ns_prefix: 'conservation',
48
- path: 'conservation',
45
+ "conservation" => {
46
+ identifier: "conservationNumber",
47
+ ns_prefix: "conservation",
48
+ path: "conservation",
49
49
  term: nil
50
50
  },
51
- 'exhibitions' => {
52
- identifier: 'exhibitionNumber',
53
- ns_prefix: 'exhibitions',
54
- path: 'exhibitions',
51
+ "exhibitions" => {
52
+ identifier: "exhibitionNumber",
53
+ ns_prefix: "exhibitions",
54
+ path: "exhibitions",
55
55
  term: nil
56
56
  },
57
- 'groups' => {
58
- identifier: 'title',
59
- ns_prefix: 'groups',
60
- path: 'groups',
57
+ "groups" => {
58
+ identifier: "title",
59
+ ns_prefix: "groups",
60
+ path: "groups",
61
61
  term: nil
62
62
  },
63
- 'insurances' => {
64
- identifier: 'insuranceIndemnityReferenceNumber',
65
- ns_prefix: 'insurances',
66
- path: 'insurances',
63
+ "insurances" => {
64
+ identifier: "insuranceIndemnityReferenceNumber",
65
+ ns_prefix: "insurances",
66
+ path: "insurances",
67
67
  term: nil
68
68
  },
69
- 'intakes' => {
70
- identifier: 'entryNumber',
71
- ns_prefix: 'intakes',
72
- path: 'intakes',
69
+ "intakes" => {
70
+ identifier: "entryNumber",
71
+ ns_prefix: "intakes",
72
+ path: "intakes",
73
73
  term: nil
74
74
  },
75
- 'loansin' => {
76
- identifier: 'loanInNumber',
77
- ns_prefix: 'loansin',
78
- path: 'loansin',
75
+ "iterationreports" => {
76
+ identifier: "iterationIdentificationNumber",
77
+ ns_prefix: "iterationreports",
78
+ path: "iterationreports",
79
79
  term: nil
80
80
  },
81
- 'loansout' => {
82
- identifier: 'loanOutNumber',
83
- ns_prefix: 'loansout',
84
- path: 'loansout',
81
+ "loansin" => {
82
+ identifier: "loanInNumber",
83
+ ns_prefix: "loansin",
84
+ path: "loansin",
85
85
  term: nil
86
86
  },
87
- 'locationauthorities' => {
88
- identifier: 'shortIdentifier',
89
- ns_prefix: 'locations',
87
+ "loansout" => {
88
+ identifier: "loanOutNumber",
89
+ ns_prefix: "loansout",
90
+ path: "loansout",
91
+ term: nil
92
+ },
93
+ "locationauthorities" => {
94
+ identifier: "shortIdentifier",
95
+ ns_prefix: "locations",
90
96
  path: "locationauthorities/urn:cspace:name(#{subtype})/items",
91
97
  term: "loc#{TERM_SUFFIX}"
92
98
  },
93
- 'materialauthorities' => {
94
- identifier: 'shortIdentifier',
95
- ns_prefix: 'materials',
99
+ "materialauthorities" => {
100
+ identifier: "shortIdentifier",
101
+ ns_prefix: "materials",
96
102
  path: "materialauthorities/urn:cspace:name(#{subtype})/items",
97
103
  term: "material#{TERM_SUFFIX}"
98
104
  },
99
- 'media' => {
100
- identifier: 'identificationNumber',
101
- ns_prefix: 'media',
102
- path: 'media',
105
+ "media" => {
106
+ identifier: "identificationNumber",
107
+ ns_prefix: "media",
108
+ path: "media",
103
109
  term: nil
104
110
  },
105
- 'movements' => {
106
- identifier: 'movementReferenceNumber',
107
- ns_prefix: 'movements',
108
- path: 'movements',
111
+ "movements" => {
112
+ identifier: "movementReferenceNumber",
113
+ ns_prefix: "movements",
114
+ path: "movements",
109
115
  term: nil
110
116
  },
111
- 'objectexit' => {
112
- identifier: 'exitNumber',
113
- ns_prefix: 'objectexit',
114
- path: 'objectexit',
117
+ "objectexit" => {
118
+ identifier: "exitNumber",
119
+ ns_prefix: "objectexit",
120
+ path: "objectexit",
115
121
  term: nil
116
122
  },
117
- 'orgauthorities' => {
118
- identifier: 'shortIdentifier',
119
- ns_prefix: 'organizations',
123
+ "orgauthorities" => {
124
+ identifier: "shortIdentifier",
125
+ ns_prefix: "organizations",
120
126
  path: "orgauthorities/urn:cspace:name(#{subtype})/items",
121
127
  term: "org#{TERM_SUFFIX}"
122
128
  },
123
- 'osteology' => {
124
- identifier: 'InventoryID',
125
- ns_prefix: 'osteology',
126
- path: 'osteology',
129
+ "osteology" => {
130
+ identifier: "InventoryID",
131
+ ns_prefix: "osteology",
132
+ path: "osteology",
127
133
  term: nil
128
134
  },
129
- 'personauthorities' => {
130
- identifier: 'shortIdentifier',
131
- ns_prefix: 'persons',
135
+ "personauthorities" => {
136
+ identifier: "shortIdentifier",
137
+ ns_prefix: "persons",
132
138
  path: "personauthorities/urn:cspace:name(#{subtype})/items",
133
139
  term: "person#{TERM_SUFFIX}"
134
140
  },
135
- 'placeauthorities' => {
136
- identifier: 'shortIdentifier',
137
- ns_prefix: 'places',
141
+ "placeauthorities" => {
142
+ identifier: "shortIdentifier",
143
+ ns_prefix: "places",
138
144
  path: "placeauthorities/urn:cspace:name(#{subtype})/items",
139
145
  term: "place#{TERM_SUFFIX}"
140
146
  },
141
- 'pottags' => {
142
- identifier: 'potTagNumber',
143
- ns_prefix: 'pottags',
144
- path: 'pottags',
147
+ "pottags" => {
148
+ identifier: "potTagNumber",
149
+ ns_prefix: "pottags",
150
+ path: "pottags",
145
151
  term: nil
146
152
  },
147
- 'propagations' => {
148
- identifier: 'propNumber',
149
- ns_prefix: 'propagations',
150
- path: 'propagations',
153
+ "propagations" => {
154
+ identifier: "propNumber",
155
+ ns_prefix: "propagations",
156
+ path: "propagations",
151
157
  term: nil
152
158
  },
153
- 'relations' => {
154
- identifier: 'csid',
155
- ns_prefix: 'relations',
156
- path: 'relations',
159
+ "relations" => {
160
+ identifier: "csid",
161
+ ns_prefix: "relations",
162
+ path: "relations",
157
163
  term: nil
158
164
  },
159
- 'taxonomyauthority' => {
160
- identifier: 'shortIdentifier',
161
- ns_prefix: 'taxon',
165
+ "taxonomyauthority" => {
166
+ identifier: "shortIdentifier",
167
+ ns_prefix: "taxon",
162
168
  path: "taxonomyauthority/urn:cspace:name(#{subtype})/items",
163
169
  term: "taxon#{TERM_SUFFIX}"
164
170
  },
165
- 'transports' => {
166
- identifier: 'transportReferenceNumber',
167
- ns_prefix: 'transports',
168
- path: 'transports',
171
+ "transports" => {
172
+ identifier: "transportReferenceNumber",
173
+ ns_prefix: "transports",
174
+ path: "transports",
169
175
  term: nil
170
176
  },
171
- 'uoc' => {
172
- identifier: 'referenceNumber',
173
- ns_prefix: 'uoc',
174
- path: 'uoc',
177
+ "uoc" => {
178
+ identifier: "referenceNumber",
179
+ ns_prefix: "uoc",
180
+ path: "uoc",
175
181
  term: nil
176
182
  },
177
- 'valuationcontrols' => {
178
- identifier: 'valuationcontrolRefNumber',
179
- ns_prefix: 'valuationcontrols',
180
- path: 'valuationcontrols',
183
+ "valuationcontrols" => {
184
+ identifier: "valuationcontrolRefNumber",
185
+ ns_prefix: "valuationcontrols",
186
+ path: "valuationcontrols",
181
187
  term: nil
182
188
  },
183
- 'vocabularies' => {
184
- identifier: 'shortIdentifier',
185
- ns_prefix: 'vocabularyitems',
189
+ "vocabularies" => {
190
+ identifier: "shortIdentifier",
191
+ ns_prefix: "vocabularyitems",
186
192
  path: "vocabularies/urn:cspace:name(#{subtype})/items",
187
- term: 'displayName'
193
+ term: "displayName"
188
194
  },
189
- 'workauthorities' => {
190
- identifier: 'shortIdentifier',
191
- ns_prefix: 'works',
195
+ "workauthorities" => {
196
+ identifier: "shortIdentifier",
197
+ ns_prefix: "works",
192
198
  path: "workauthorities/urn:cspace:name(#{subtype})/items",
193
199
  term: "work#{TERM_SUFFIX}"
194
200
  }
@@ -3,12 +3,12 @@
3
3
  module CollectionSpace
4
4
  module Template
5
5
  def self.list
6
- Dir.glob File.join(templates_path, '*.erb')
6
+ Dir.glob File.join(templates_path, "*.erb")
7
7
  end
8
8
 
9
9
  def self.process(template, data)
10
10
  t = ERB.new(read(template))
11
- r = t.result(binding).gsub(/\n+/, "\n")
11
+ r = t.result(binding).squeeze("\n")
12
12
  Nokogiri::XML.parse(r).to_xml
13
13
  end
14
14
 
@@ -18,8 +18,8 @@ module CollectionSpace
18
18
 
19
19
  def self.templates_path
20
20
  ENV.fetch(
21
- 'COLLECTIONSPACE_CLIENT_TEMPLATES_PATH',
22
- File.join(File.dirname(File.expand_path(__FILE__)), 'templates')
21
+ "COLLECTIONSPACE_CLIENT_TEMPLATES_PATH",
22
+ File.join(File.dirname(File.expand_path(__FILE__)), "templates")
23
23
  )
24
24
  end
25
25
  end
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document name="batch">
3
+ <ns2:batch_common xmlns:ns2="http://collectionspace.org/services/batch">
4
+ <name><%= data.fetch(:name) %></name>
5
+ <notes><%= data.fetch(:notes, data[:name]) %></notes>
6
+ <forDocTypes>
7
+ <% data.fetch(:doctype).each do |doctype| %>
8
+ <forDocType><%= doctype %></forDocType>
9
+ <% end %>
10
+ </forDocTypes>
11
+ <supportsSingleDoc><%= data.fetch(:supports_single_doc, 'true') %></supportsSingleDoc>
12
+ <supportsDocList><%= data.fetch(:supports_doc_list, 'false') %></supportsDocList>
13
+ <supportsGroup><%= data.fetch(:supports_group, 'false') %></supportsGroup>
14
+ <supportsNoContext><%= data.fetch(:supports_no_context, 'true') %></supportsNoContext>
15
+ <createsNewFocus><%= data.fetch(:creates_new_focus, 'false') %></createsNewFocus>
16
+ <className><%= data.fetch(:classname) %></className>
17
+ </ns2:batch_common>
18
+ </document>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CollectionSpace
4
4
  class Client
5
- VERSION = '0.14.1'
5
+ VERSION = "0.15.0"
6
6
  end
7
7
  end