t.add :runtime_constraints
t.add :state
t.add :use_existing
+ t.add :output_uuid
end
# Supported states for a container request
# Finalize the container request after the container has
# finished/cancelled.
def finalize!
- update_attributes!(state: Final)
+ out_uuid = nil
c = Container.find_by_uuid(container_uuid)
['output', 'log'].each do |out_type|
pdh = c.send(out_type)
next if pdh.nil?
manifest = Collection.where(portable_data_hash: pdh).first.manifest_text
- Collection.create!(owner_uuid: owner_uuid,
+ coll = Collection.create!(owner_uuid: owner_uuid,
manifest_text: manifest,
portable_data_hash: pdh,
name: "Container #{out_type} for request #{uuid}",
'type' => out_type,
'container_request' => uuid,
})
+ out_uuid = coll.uuid if out_type == 'output'
end
+ update_attributes!(state: Final, output_uuid: out_uuid)
end
protected
errors.add :state, "of container request can only be set to Final by system."
end
- if self.state_changed? || self.name_changed? || self.description_changed?
- permitted.push :state, :name, :description
+ if self.state_changed? || self.name_changed? || self.description_changed? || self.output_uuid_changed?
+ permitted.push :state, :name, :description, :output_uuid
else
errors.add :state, "does not allow updates"
end
--- /dev/null
+require 'has_uuid'
+
+class AddOutputUuidToContainerRequest < ActiveRecord::Migration
+ extend HasUuid::ClassMethods
+
+ def up
+ add_column :container_requests, :output_uuid, :string
+
+ no_such_coll = Server::Application.config.uuid_prefix + '-' + '4zz18' + '-xxxxxxxxxxxxxxx'
+ update_sql <<-EOS
+update container_requests set output_uuid = ('#{no_such_coll}');
+EOS
+ end
+
+ def down
+ remove_column :container_requests, :output_uuid
+ end
+end
filters text,
updated_at timestamp without time zone NOT NULL,
container_count integer DEFAULT 0,
- use_existing boolean DEFAULT true
+ use_existing boolean DEFAULT true,
+ output_uuid character varying(255)
);
INSERT INTO schema_migrations (version) VALUES ('20160926194129');
-INSERT INTO schema_migrations (version) VALUES ('20161019171346');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20161019171346');
+
+INSERT INTO schema_migrations (version) VALUES ('20161110171221');
\ No newline at end of file
cr.reload
assert_equal "Committed", cr.state
+ output_pdh = '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
act_as_system_user do
c.update_attributes!(state: Container::Complete,
- output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
+ output: output_pdh,
log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
end
owner_uuid: project.uuid).count,
"Container #{out_type} should be copied to #{project.uuid}")
end
+ assert_not_nil cr.output_uuid
+ output = Collection.find_by_uuid cr.output_uuid
+ assert_equal output_pdh, output.portable_data_hash
end
test "Container makes container request, then is cancelled" do