X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bb741f18407fd0190e1b6c642c14ef9f502b004e..3911cd836c4e937262d48f9b0af703a9d7d68cdd:/services/api/app/models/workflow.rb diff --git a/services/api/app/models/workflow.rb b/services/api/app/models/workflow.rb index 97be6dccbc..94890c6632 100644 --- a/services/api/app/models/workflow.rb +++ b/services/api/app/models/workflow.rb @@ -1,40 +1,54 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class Workflow < ArvadosModel include HasUuid include KindAndEtag include CommonApiTemplate - validate :validate_workflow + validate :validate_definition before_save :set_name_and_description api_accessible :user, extend: :common do |t| t.add :name t.add :description - t.add :workflow + t.add :definition end - def validate_workflow + def validate_definition begin - @workflow_yaml = YAML.load self.workflow if !workflow.nil? - rescue - errors.add :validate_workflow, "#{self.workflow} is not valid yaml" + @definition_yaml = YAML.load self.definition if !definition.nil? + rescue => e + errors.add :definition, "is not valid yaml: #{e.message}" end end def set_name_and_description + old_wf = {} begin - old_wf = {} - old_wf = YAML.load self.workflow_was if !self.workflow_was.nil? - ['name', 'description'].each do |a| - if !self.changes.include?(a) - v = self.read_attribute(a) - if !v.present? or v == old_wf[a] - val = @workflow_yaml[a] if self.workflow and @workflow_yaml - self[a] = val - end + old_wf = YAML.load self.definition_was if !self.definition_was.nil? + rescue => e + logger.warn "set_name_and_description error: #{e.message}" + return + end + + ['name', 'description'].each do |a| + if !self.changes.include?(a) + v = self.read_attribute(a) + if !v.present? or v == old_wf[a] + val = @definition_yaml[a] if self.definition and @definition_yaml + self[a] = val end end - rescue ActiveRecord::RecordInvalid - errors.add :set_name_and_description, "#{self.workflow_was} is not valid yaml" end end + + def self.full_text_searchable_columns + super - ["definition"] + end + + def self.limit_index_columns_read + ["definition"] + end end