Skip to content

Commit

Permalink
Add cocina-models
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Oct 28, 2019
1 parent 68ad035 commit 9d2ffb9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gem 'sidekiq-statistic'
gem 'uuidtools', '~> 2.1.4'

# DLSS/domain-specific dependencies
gem 'cocina-models', '~> 0.6.0'
gem 'cocina-models', '~> 0.7.0'
gem 'dor-services', '~> 8.0'
gem 'dor-workflow-client', '~> 3.9'
gem 'marc'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ GEM
capistrano-sidekiq (1.0.3)
capistrano (>= 3.9.0)
sidekiq (>= 3.4, < 6.0)
cocina-models (0.6.0)
cocina-models (0.7.0)
dry-struct (~> 1.0)
dry-types (~> 1.1)
zeitwerk (~> 2.1)
Expand Down Expand Up @@ -487,7 +487,7 @@ DEPENDENCIES
capistrano-rails
capistrano-shared_configs
capistrano-sidekiq
cocina-models (~> 0.6.0)
cocina-models (~> 0.7.0)
config
coveralls (~> 0.8)
deprecation
Expand Down
3 changes: 3 additions & 0 deletions app/services/cocina/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def dro_props
embargoReleaseDate: item.embargoMetadata.release_date.iso8601
}
end
props[:structural] = {
contains: item.contentMetadata.resource.id
}
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class AddModelTypeToOrmResources < ActiveRecord::Migration[5.2]
def change
add_column :orm_resources, :resource_type, :string
end
end
3 changes: 2 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ CREATE TABLE public.orm_resources (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
metadata jsonb DEFAULT '{}'::jsonb NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
updated_at timestamp without time zone NOT NULL,
resource_type character varying
);


Expand Down
8 changes: 6 additions & 2 deletions lib/tasks/valkyrie.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ namespace :valkyrie do
desc "Import resources to valkyie"
task import: :environment do
Dor::Item.all.each do |item|
puts "Item: #{item.pid}"
model = Cocina::Mapper.build(item)
Orm::Resource.create
item.contentMetadata.resource.each do |resource|
puts resource
fileset = Cocina::Models::FileSet.new
Orm::Resource.create(metadata: fileset.as_json, resource_type: 'FileSet')
end
Orm::Resource.create(metadata: model.as_json, resource_type: item.class)
end
end
end

0 comments on commit 9d2ffb9

Please sign in to comment.