Class: Dor::AdministrativeMetadataDS

Inherits:
ActiveFedora::OmDatastream
  • Object
show all
Defined in:
lib/dor/datastreams/administrative_metadata_ds.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.xml_templateObject



92
93
94
95
96
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 92

def self.xml_template
  Nokogiri::XML::Builder.new do |xml|
    xml. {}
  end.doc
end

Instance Method Details

#add_default_collection(val) ⇒ Object

Add a collection to the listing of collections for items governed by this apo.

Parameters:

  • val (String)

    pid of the collection, ex. druid:ab123cd4567



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 127

def add_default_collection(val)
  xml = ng_xml
  ng_xml_will_change!
  reg = xml.search('//administrativeMetadata/registration').first
  unless reg
    reg = Nokogiri::XML::Node.new('registration', xml)
    xml.search('/administrativeMetadata').first.add_child(reg)
  end
  node = Nokogiri::XML::Node.new('collection', xml)
  node['id'] = val
  reg.add_child(node)
end

#default_collectionsArray

get all collections listed for this APO, used during registration

Returns:

  • (Array)

    array of pids



121
122
123
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 121

def default_collections
  term_values(:registration, :default_collection)
end

#default_shelving_pathObject



115
116
117
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 115

def default_shelving_path
  defaults.shelving.path.first
end

#default_shelving_path=(path) ⇒ Object



111
112
113
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 111

def default_shelving_path=(path)
  defaults.shelving.path = path
end

#default_workflow=(wf_name) ⇒ Object

set a single default workflow

Parameters:

  • wf_name (String)

    the name of the workflow, ex. ‘digitizationWF’

Raises:

  • (ArgumentError)


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 165

def default_workflow=(wf_name)
  raise ArgumentError, 'Must have a valid workflow for default' if wf_name.blank?

  xml = ng_xml
  ng_xml_will_change!
  nodes = xml.search('//registration/workflow')
  if nodes.first
    nodes.first['id'] = wf_name
  else
    nodes = xml.search('//registration')
    unless nodes.first
      reg_node = Nokogiri::XML::Node.new('registration', xml)
      xml.root.add_child(reg_node)
    end
    nodes = xml.search('//registration')
    wf_node = Nokogiri::XML::Node.new('workflow', xml)
    wf_node['id'] = wf_name
    nodes.first.add_child(wf_node)
  end
end

#default_workflow_laneObject



107
108
109
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 107

def default_workflow_lane
  defaults.initiate_workflow.lane.first
end

#default_workflow_lane=(lane) ⇒ Object

Convenience methods to get and set properties Hides complexity/verbosity of OM TermOperators for simple, non-repeating values



103
104
105
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 103

def default_workflow_lane=(lane)
  defaults.initiate_workflow.lane = lane
end

#default_workflowsArray

List of default workflows, used to provide choices at registration

Returns:

  • (Array)

    and array of pids, ex [‘druid:ab123cd4567’]



159
160
161
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 159

def default_workflows
  term_values(:registration, :workflow_id)
end

#desc_metadata_formatObject



186
187
188
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 186

def 
  .first
end

#desc_metadata_format=(format) ⇒ Object



190
191
192
193
194
195
196
197
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 190

def (format)
  # create the node if it isnt there already
  unless .first
    ng_xml_will_change!
    add_child_node(ng_xml.root, :metadata_format)
  end
  update_values([:metadata_format] => format)
end

#desc_metadata_sourceObject



199
200
201
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 199

def 
  .first
end

#desc_metadata_source=(_source) ⇒ Object



203
204
205
206
207
208
209
210
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 203

def (_source)
  # create the node if it isnt there already
  unless .first
    ng_xml_will_change!
    add_child_node(.ng_xml.root, :metadata_source)
  end
  update_values([:metadata_source] => format)
end

#metadata_sourceObject



145
146
147
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 145

def 
  super.first
end

#metadata_source=(val) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 149

def (val)
  if .nil?
    ng_xml_will_change!
    add_child_node(, :descMetadata)
  end
  update_values(%i[descMetadata source] => val)
end

#prefixObject

maintain AF < 8 indexing behavior



213
214
215
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 213

def prefix
  ''
end

#remove_default_collection(val) ⇒ Object



140
141
142
143
# File 'lib/dor/datastreams/administrative_metadata_ds.rb', line 140

def remove_default_collection(val)
  ng_xml_will_change!
  ng_xml.search('//administrativeMetadata/registration/collection[@id=\'' + val + '\']').remove
end