lib/cul/fedora/arm/builder.rb in cul-fedora-arm-0.5.2 vs lib/cul/fedora/arm/builder.rb in cul-fedora-arm-0.6.0

- old
+ new

@@ -21,11 +21,11 @@ # columns that must be included in a template MANDATORY_COLUMNS = [:sequence, :target, :model_type] # list of columns which may have values - VALID_COLUMNS = [:sequence, :target, :model_type, :source, :template_type, :dc_format, :id, :pid, :action, :license] + VALID_COLUMNS = [:sequence, :target, :model_type, :source, :template_type, :dc_format, :title_attr, :mime, :id, :pid, :action, :license] FOXML_BUILDER = FoxmlBuilder.new() # array of individual hash: each hash corresponds to a metadata or resource. attr_reader :parts, :connector @@ -126,10 +126,24 @@ data = FOXML_BUILDER.build(value_hash) task = Tasks::InsertFoxmlTask.new(data) task.post(@connector) task.response end + + def update_aggregator(value_hash) + self.purge(value_hash[:pid]) + insert_aggregator(value_hash) + end + def update_metadata(value_hash) + self.purge(value_hash[:pid]) + insert_metadata(value_hash) + end + def update_resource(value_hash) + self.purge(value_hash[:pid]) + insert_resource(value_hash) + end + def reserve_pids(parts=@parts) assigned = [] if (parts.nil?) return assigned @@ -180,10 +194,10 @@ # checks keys of a hash to make sure all elements of REQUIRED_COLUMNS are contained. def test_for_required_columns(value_hash) missing_values = REQUIRED_COLUMNS.select { |col| !value_hash.has_key?(col) || value_hash[col].nil? } if (value_hash.has_key?(:action) and value_hash[:action].eql?('update')) - raise "Update operations require a PID" unless (value_hash.has_key(:pid) and !value_hash[:pid].strip().eql?('')) + raise "Update operations require a PID" unless (value_hash.has_key?(:pid) and !value_hash[:pid].strip().eql?('')) end raise "Missing required values #{missing_values.join(",")}" unless missing_values.empty? end # checks list of column names to make sure every one is in VALID_COLUMNS \ No newline at end of file