hydramata-works 0.0.1.prerelease
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.hound.yml +818 -0
- data/.rspec +2 -0
- data/.travis.yml +20 -0
- data/CONTRIBUTING.md +220 -0
- data/Gemfile +36 -0
- data/Guardfile +36 -0
- data/LICENSE +15 -0
- data/README.md +36 -0
- data/Rakefile +47 -0
- data/TODO.md +74 -0
- data/VISION.md +19 -0
- data/app/forms/hydramata/works/entity_form.rb +92 -0
- data/app/forms/hydramata/works/validation_service.rb +78 -0
- data/app/models/hydramata/works/data_definition.rb +57 -0
- data/app/models/hydramata/works/entities.rb +11 -0
- data/app/models/hydramata/works/entity.rb +75 -0
- data/app/models/hydramata/works/predicate.rb +35 -0
- data/app/models/hydramata/works/predicate_presentation_sequences/storage.rb +29 -0
- data/app/models/hydramata/works/predicate_set.rb +44 -0
- data/app/models/hydramata/works/predicate_sets/storage.rb +45 -0
- data/app/models/hydramata/works/predicates.rb +14 -0
- data/app/models/hydramata/works/predicates/storage.rb +33 -0
- data/app/models/hydramata/works/presentation_structure.rb +29 -0
- data/app/models/hydramata/works/property.rb +72 -0
- data/app/models/hydramata/works/property_set.rb +89 -0
- data/app/models/hydramata/works/validations.rb +6 -0
- data/app/models/hydramata/works/value.rb +34 -0
- data/app/models/hydramata/works/work_type.rb +49 -0
- data/app/models/hydramata/works/work_types.rb +14 -0
- data/app/models/hydramata/works/work_types/storage.rb +42 -0
- data/app/parsers/hydramata/works/datastream_parser.rb +36 -0
- data/app/parsers/hydramata/works/datastream_parsers/rdf_ntriples_parser.rb +60 -0
- data/app/parsers/hydramata/works/datastream_parsers/simple_xml_parser.rb +27 -0
- data/app/parsers/hydramata/works/predicate_parser.rb +31 -0
- data/app/parsers/hydramata/works/predicate_parsers/simple_parser.rb +13 -0
- data/app/parsers/hydramata/works/validations_parser.rb +22 -0
- data/app/parsers/hydramata/works/value_parser.rb +26 -0
- data/app/parsers/hydramata/works/value_parsers.rb +27 -0
- data/app/parsers/hydramata/works/value_parsers/date_parser.rb +13 -0
- data/app/parsers/hydramata/works/value_parsers/interrogation_parser.rb +18 -0
- data/app/parsers/hydramata/works/value_parsers/simple_parser.rb +14 -0
- data/app/presenters/hydramata/works/base_presenter.rb +146 -0
- data/app/presenters/hydramata/works/dom_attributes_builder.rb +24 -0
- data/app/presenters/hydramata/works/entity_presenter.rb +67 -0
- data/app/presenters/hydramata/works/fieldset_presenter.rb +54 -0
- data/app/presenters/hydramata/works/property_presenter.rb +51 -0
- data/app/presenters/hydramata/works/value_presenter.rb +60 -0
- data/app/renderers/hydramata/works/entity_renderer.rb +45 -0
- data/app/views/hydramata/works/fieldsets/_edit.html.erb +4 -0
- data/app/views/hydramata/works/fieldsets/_show.html.erb +8 -0
- data/app/views/hydramata/works/fieldsets/_show.json.jbuilder +8 -0
- data/app/views/hydramata/works/properties/_edit.html.erb +12 -0
- data/app/views/hydramata/works/properties/_show.html.erb +3 -0
- data/app/views/hydramata/works/properties/_show.json.jbuilder +1 -0
- data/app/views/hydramata/works/works/_edit.html.erb +8 -0
- data/app/views/hydramata/works/works/_new.html.erb +8 -0
- data/app/views/hydramata/works/works/_show.html.erb +3 -0
- data/app/views/hydramata/works/works/_show.json.jbuilder +13 -0
- data/app/wranglers/hydramata/works/fedora_wrangler.rb +66 -0
- data/bin/rails +12 -0
- data/db/migrate/20140606132349_create_hydramata_work_predicates.rb +13 -0
- data/db/migrate/20140606132350_create_hydramata_work_types.rb +9 -0
- data/db/migrate/20140606132351_create_hydramata_work_predicate_sets.rb +13 -0
- data/db/migrate/20140606132352_create_hydramata_work_predicate_presentation_sequences.rb +12 -0
- data/db/migrate/20140623200635_add_validations_to_predicates.rb +5 -0
- data/db/migrate/20140627134133_adding_item_type_schema_dot_org_to_work_type.rb +5 -0
- data/db/migrate/20140627140840_adding_item_prop_schema_dot_org_to_predicate.rb +5 -0
- data/db/seeds.rb +36 -0
- data/documents/administrative-set-strawperson.md +45 -0
- data/documents/diagrams/hydramata-refactor-tasks.dot +88 -0
- data/documents/diagrams/hydramata-sip-dip-aip.dot +88 -0
- data/documents/diagrams/hydramata-work-architecture.dot +129 -0
- data/documents/diagrams/hydramata-work-subcomponents.dot +36 -0
- data/documents/diagrams/map-from-database-to-work-object.dot +44 -0
- data/documents/diagrams/map-from-fedora-to-work-object.dot +51 -0
- data/documents/diagrams/map-from-input-to-work-object.dot +37 -0
- data/documents/diagrams/map-from-work-object-to-database.dot +31 -0
- data/documents/diagrams/work-rendering.dot +53 -0
- data/documents/diagrams/work-structure.dot +32 -0
- data/documents/handling-work.md +224 -0
- data/documents/high-level-stories.md +105 -0
- data/documents/hydramata-components.md +82 -0
- data/documents/interface-between-work-and-permissions.md +131 -0
- data/documents/interface-between-work-and-workflow.md +6 -0
- data/documents/timeline.md +75 -0
- data/fs +3 -0
- data/gemfiles/rails4.1.gemfile +12 -0
- data/gemfiles/rails4.gemfile +13 -0
- data/hydramata-works.gemspec +43 -0
- data/lib/hydramata-works.rb +23 -0
- data/lib/hydramata/works/conversions.rb +21 -0
- data/lib/hydramata/works/conversions/exceptions.rb +18 -0
- data/lib/hydramata/works/conversions/predicate.rb +22 -0
- data/lib/hydramata/works/conversions/predicate_set.rb +28 -0
- data/lib/hydramata/works/conversions/presented_fieldsets.rb +28 -0
- data/lib/hydramata/works/conversions/presenter.rb +13 -0
- data/lib/hydramata/works/conversions/property.rb +31 -0
- data/lib/hydramata/works/conversions/property_set.rb +23 -0
- data/lib/hydramata/works/conversions/translation_key_fragment.rb +20 -0
- data/lib/hydramata/works/conversions/value.rb +20 -0
- data/lib/hydramata/works/conversions/work_type.rb +26 -0
- data/lib/hydramata/works/engine.rb +31 -0
- data/lib/hydramata/works/linters.rb +99 -0
- data/lib/hydramata/works/linters/implement_data_definition_interface_matcher.rb +17 -0
- data/lib/hydramata/works/linters/implement_entity_interface_matcher.rb +16 -0
- data/lib/hydramata/works/linters/implement_predicate_interface_matcher.rb +17 -0
- data/lib/hydramata/works/linters/implement_predicate_set_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_property_set_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_value_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_work_type_interface_matcher.rb +13 -0
- data/lib/hydramata/works/linters/interface_matcher_builder.rb +36 -0
- data/lib/hydramata/works/translator.rb +67 -0
- data/lib/hydramata/works/version.rb +5 -0
- data/lib/hydramata_works.rb +2 -0
- data/lib/tasks/hydramata_work_tasks.rake +4 -0
- data/run_each_spec_in_isolation +16 -0
- data/run_each_spec_in_isolation.txt +110 -0
- data/script/analyzer.rb +124 -0
- data/script/fast_specs +22 -0
- data/spec/features/fedora_to_in_memory_spec.rb +60 -0
- data/spec/features/format_and_view_path_overrides_spec.rb +72 -0
- data/spec/features/in_memory_to_output_buffer_spec.rb +109 -0
- data/spec/features/instantiate_entity_from_persisted_work_type_spec.rb +26 -0
- data/spec/features/new_user_input_to_in_memory_spec.rb +75 -0
- data/spec/features/translation_services_spec.rb +107 -0
- data/spec/features/validate_entity_based_on_work_type_structure_spec.rb +19 -0
- data/spec/fixtures/cassettes/fedora-object.yml +299 -0
- data/spec/fixtures/translations.yml +20 -0
- data/spec/forms/hydramata/works/entity_form_spec.rb +83 -0
- data/spec/forms/hydramata/works/validation_service_spec.rb +32 -0
- data/spec/lib/hydramata-work_spec.rb +14 -0
- data/spec/lib/hydramata/works/conversions/predicate_set_spec.rb +50 -0
- data/spec/lib/hydramata/works/conversions/predicate_spec.rb +43 -0
- data/spec/lib/hydramata/works/conversions/presented_fieldsets_spec.rb +52 -0
- data/spec/lib/hydramata/works/conversions/presenter_spec.rb +22 -0
- data/spec/lib/hydramata/works/conversions/property_set_spec.rb +42 -0
- data/spec/lib/hydramata/works/conversions/property_spec.rb +68 -0
- data/spec/lib/hydramata/works/conversions/translation_key_fragment_spec.rb +45 -0
- data/spec/lib/hydramata/works/conversions/value_spec.rb +36 -0
- data/spec/lib/hydramata/works/conversions/work_type_spec.rb +55 -0
- data/spec/lib/hydramata/works/translator_spec.rb +81 -0
- data/spec/models/hydramata/works/data_definition_spec.rb +53 -0
- data/spec/models/hydramata/works/entity_spec.rb +50 -0
- data/spec/models/hydramata/works/predicate_presentation_sequences/storage_spec.rb +15 -0
- data/spec/models/hydramata/works/predicate_set_spec.rb +63 -0
- data/spec/models/hydramata/works/predicate_sets/storage_spec.rb +37 -0
- data/spec/models/hydramata/works/predicate_spec.rb +16 -0
- data/spec/models/hydramata/works/predicates/storage_spec.rb +78 -0
- data/spec/models/hydramata/works/predicates_spec.rb +18 -0
- data/spec/models/hydramata/works/presentation_structure_spec.rb +27 -0
- data/spec/models/hydramata/works/property_set_spec.rb +135 -0
- data/spec/models/hydramata/works/property_spec.rb +74 -0
- data/spec/models/hydramata/works/value_spec.rb +61 -0
- data/spec/models/hydramata/works/work_type_spec.rb +45 -0
- data/spec/models/hydramata/works/work_types/storage_spec.rb +74 -0
- data/spec/models/hydramata/works/work_types_spec.rb +16 -0
- data/spec/parsers/hydramata/works/datastream_parser_spec.rb +29 -0
- data/spec/parsers/hydramata/works/datastream_parsers/rdf_ntriples_parser_spec.rb +65 -0
- data/spec/parsers/hydramata/works/datastream_parsers/simple_xml_parser_spec.rb +37 -0
- data/spec/parsers/hydramata/works/predicate_parser_spec.rb +30 -0
- data/spec/parsers/hydramata/works/predicate_parsers/simple_parser_spec.rb +20 -0
- data/spec/parsers/hydramata/works/validations_parser_spec.rb +31 -0
- data/spec/parsers/hydramata/works/value_parser_spec.rb +22 -0
- data/spec/parsers/hydramata/works/value_parsers/simple_parser_spec.rb +20 -0
- data/spec/parsers/hydramata/works/value_parsers_spec.rb +36 -0
- data/spec/presenters/hydramata/works/base_presenter_spec.rb +111 -0
- data/spec/presenters/hydramata/works/dom_attributes_builder_spec.rb +26 -0
- data/spec/presenters/hydramata/works/entity_presenter_spec.rb +51 -0
- data/spec/presenters/hydramata/works/fieldset_presenter_spec.rb +58 -0
- data/spec/presenters/hydramata/works/property_presenter_spec.rb +42 -0
- data/spec/presenters/hydramata/works/value_presenter_spec.rb +49 -0
- data/spec/renderers/hydramata/works/entity_renderer_spec.rb +25 -0
- data/spec/spec_active_record_helper.rb +30 -0
- data/spec/spec_fast_helper.rb +12 -0
- data/spec/spec_slow_helper.rb +56 -0
- data/spec/spec_view_helper.rb +14 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +21 -0
- data/spec/views/hydramata/works/fieldsets/_edit.html.erb_spec.rb +29 -0
- data/spec/views/hydramata/works/fieldsets/_show.html.erb_spec.rb +25 -0
- data/spec/views/hydramata/works/properties/_edit.html.erb_spec.rb +22 -0
- data/spec/views/hydramata/works/properties/_show.html.erb_spec.rb +22 -0
- data/spec/views/hydramata/works/works/_edit.html.erb_spec.rb +23 -0
- data/spec/views/hydramata/works/works/_new.html.erb_spec.rb +23 -0
- data/spec/views/hydramata/works/works/_show.html.erb_spec.rb +24 -0
- data/spec/wranglers/hydramata/works/fedora_wrangler_spec.rb +26 -0
- metadata +466 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'hydramata/works/base_presenter'
|
2
|
+
|
3
|
+
module Hydramata
|
4
|
+
module Works
|
5
|
+
# Responsible for coordinating the rendering of an in-memory
|
6
|
+
# PropertySet-like object to an output buffer.
|
7
|
+
#
|
8
|
+
# @TODO - Rename fieldset in presentation to property_set
|
9
|
+
class FieldsetPresenter < BasePresenter
|
10
|
+
attr_reader :entity
|
11
|
+
def initialize(collaborators = {})
|
12
|
+
fieldset = collaborators.fetch(:fieldset)
|
13
|
+
@entity = collaborators.fetch(:entity)
|
14
|
+
super(fieldset, collaborators)
|
15
|
+
end
|
16
|
+
|
17
|
+
def work_type
|
18
|
+
__getobj__.work_type || entity.work_type
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def default_dom_attributes
|
24
|
+
{ class: [dom_class, presenter_dom_class] }
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_presentation_context
|
28
|
+
entity.respond_to?(:presentation_context) ? entity.presentation_context : 'show'
|
29
|
+
end
|
30
|
+
|
31
|
+
def view_path_slug_for_object
|
32
|
+
'fieldsets'
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_partial_prefixes
|
36
|
+
entity_prefix = TranslationKeyFragment(entity)
|
37
|
+
fieldset_prefix = TranslationKeyFragment(name)
|
38
|
+
[
|
39
|
+
[entity_prefix, fieldset_prefix],
|
40
|
+
[fieldset_prefix]
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_translation_scopes
|
45
|
+
entity_prefix = TranslationKeyFragment(entity)
|
46
|
+
fieldset_prefix = TranslationKeyFragment(name)
|
47
|
+
[
|
48
|
+
['works', entity_prefix, view_path_slug_for_object, fieldset_prefix],
|
49
|
+
[view_path_slug_for_object, fieldset_prefix]
|
50
|
+
]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'hydramata/works/base_presenter'
|
2
|
+
module Hydramata
|
3
|
+
module Works
|
4
|
+
# Responsible for coordinating the rendering of an in-memory Property-like
|
5
|
+
# object to an output buffer.
|
6
|
+
class PropertyPresenter < BasePresenter
|
7
|
+
attr_reader :entity
|
8
|
+
def initialize(collaborators = {})
|
9
|
+
property = collaborators.fetch(:property)
|
10
|
+
@entity = collaborators.fetch(:entity)
|
11
|
+
super(property, collaborators)
|
12
|
+
end
|
13
|
+
|
14
|
+
def values
|
15
|
+
@values ||= __getobj__.values.collect {|value| ValuePresenter.new(value: value, predicate: self, entity: entity) }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def default_dom_attributes
|
21
|
+
{ class: [dom_class, presenter_dom_class] }
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_presentation_context
|
25
|
+
entity.respond_to?(:presentation_context) ? entity.presentation_context : 'show'
|
26
|
+
end
|
27
|
+
|
28
|
+
def view_path_slug_for_object
|
29
|
+
'properties'
|
30
|
+
end
|
31
|
+
|
32
|
+
def default_partial_prefixes
|
33
|
+
entity_prefix = TranslationKeyFragment(entity)
|
34
|
+
predicate_prefix = TranslationKeyFragment(predicate)
|
35
|
+
[
|
36
|
+
[entity_prefix, predicate_prefix],
|
37
|
+
[predicate_prefix]
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_translation_scopes
|
42
|
+
entity_prefix = TranslationKeyFragment(entity)
|
43
|
+
predicate_prefix = TranslationKeyFragment(predicate)
|
44
|
+
[
|
45
|
+
['works', entity_prefix, view_path_slug_for_object, predicate_prefix],
|
46
|
+
[view_path_slug_for_object, predicate_prefix]
|
47
|
+
]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'hydramata/works/base_presenter'
|
2
|
+
module Hydramata
|
3
|
+
module Works
|
4
|
+
# Responsible for coordinating the rendering of an in-memory Value-like
|
5
|
+
# object to an output buffer.
|
6
|
+
class ValuePresenter < BasePresenter
|
7
|
+
attr_reader :entity, :predicate
|
8
|
+
def initialize(collaborators = {})
|
9
|
+
value = collaborators.fetch(:value)
|
10
|
+
@predicate = collaborators.fetch(:predicate)
|
11
|
+
@entity = collaborators.fetch(:entity)
|
12
|
+
super(value, collaborators)
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(*args, &block)
|
16
|
+
begin
|
17
|
+
super(*args, &block)
|
18
|
+
rescue *template_missing_error
|
19
|
+
__getobj__.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def name
|
26
|
+
"#{predicate.name}_value"
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_dom_attributes
|
30
|
+
{ class: [dom_class, presenter_dom_class] }
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_presentation_context
|
34
|
+
entity.respond_to?(:presentation_context) ? entity.presentation_context : 'show'
|
35
|
+
end
|
36
|
+
|
37
|
+
def view_path_slug_for_object
|
38
|
+
'values'
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_partial_prefixes
|
42
|
+
entity_prefix = TranslationKeyFragment(entity)
|
43
|
+
predicate_prefix = TranslationKeyFragment(predicate)
|
44
|
+
[
|
45
|
+
[entity_prefix, predicate_prefix],
|
46
|
+
[predicate_prefix]
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_translation_scopes
|
51
|
+
entity_prefix = TranslationKeyFragment(entity)
|
52
|
+
predicate_prefix = TranslationKeyFragment(predicate)
|
53
|
+
[
|
54
|
+
['works', entity_prefix, view_path_slug_for_object, predicate_prefix],
|
55
|
+
[view_path_slug_for_object, predicate_prefix]
|
56
|
+
]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Hydramata
|
2
|
+
module Works
|
3
|
+
# For some reason if you want to render the object outside of the context
|
4
|
+
# of a controller, this provides the wrapper.
|
5
|
+
class EntityRenderer
|
6
|
+
attr_reader :template, :format, :entity, :view_path
|
7
|
+
def initialize(options = {})
|
8
|
+
@entity = options.fetch(:entity)
|
9
|
+
@format = options.fetch(:format) { default_format }
|
10
|
+
@view_path = options.fetch(:view_path) { default_view_path }
|
11
|
+
@template = options.fetch(:template) { default_template }
|
12
|
+
end
|
13
|
+
|
14
|
+
def render
|
15
|
+
entity.render(template: template)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def default_format
|
21
|
+
:html
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_template
|
25
|
+
view_container = ActionController::Base.new
|
26
|
+
# This appears to resolve the path relative to the Hydramata::Works
|
27
|
+
# Engine's paths['app/views']. I don't know if this will continue to
|
28
|
+
# work that way.
|
29
|
+
view_container.prepend_view_path(view_path) if view_path.present?
|
30
|
+
view = ActionView::Base.new(view_container.view_paths, {}, view_container, [format])
|
31
|
+
|
32
|
+
# Required if rendering a form. Defaults to false as this is a
|
33
|
+
# convenience object.
|
34
|
+
def view.protect_against_forgery?
|
35
|
+
false
|
36
|
+
end
|
37
|
+
view
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_view_path
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= content_tag('section', show.container_content_tag_attributes) do %>
|
2
|
+
<hgroup>
|
3
|
+
<%= content_tag('h1', show.t(:name), class: 'heading') %>
|
4
|
+
</hgroup>
|
5
|
+
<dl class="metadata">
|
6
|
+
<% show.properties.each do |property| %><%= property.render(template: self) %><% end %>
|
7
|
+
</dl>
|
8
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
show.each do |property|
|
2
|
+
# Why the locals?
|
3
|
+
# Without the local json declared the jbuilder rendering engine
|
4
|
+
# will call :target! and dump the attributes to JSON form.
|
5
|
+
# This means nested calls will result in multiple dump commands on the
|
6
|
+
# rendered value.
|
7
|
+
property.render(template: self, locals: {json: json})
|
8
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%# @TODO
|
2
|
+
Tidy this up. Not yet certain how to do this.
|
3
|
+
%>
|
4
|
+
<div class="<%= edit.dom_class %>">
|
5
|
+
<%= label_tag("work_#{edit.predicate}", edit.t(:predicate)) %>
|
6
|
+
<div class="values">
|
7
|
+
<% edit.each_with_index do |value, index| %>
|
8
|
+
<%= text_field_tag("work_#{edit.predicate}_#{index+1}", value, name: "work[#{edit.predicate}][]") %>
|
9
|
+
<% end %>
|
10
|
+
<%= text_field_tag("work_#{edit.predicate}_0", nil, name: "work[#{edit.predicate}][]") %>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<%= content_tag('dt', show.t(:name), show.container_content_tag_attributes(class: 'label')) %>
|
2
|
+
<%- show.values.each_with_index do |value, index| -%><%= content_tag('dd', show.container_content_tag_attributes(class: 'value')) do %><%= value.render(template: self) %><%- end -%>
|
3
|
+
<%- end -%>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.set! show.name, show.values
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%# @TODO
|
2
|
+
Consider replacing form_for with form_tag. By using form_for, the given `edit`
|
3
|
+
object must expose all of the property methods. This may work out as I steer
|
4
|
+
towards a solution.
|
5
|
+
%>
|
6
|
+
<%= form_for edit, as: :work, url: '/', method: :patch, html: { class: [edit.dom_class(prefix: 'edit'), 'work'] } do |form| %>
|
7
|
+
<% edit.fieldsets.each do |fieldset| %><%= fieldset.render(template: self, locals: { form: form } ) %><% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%# @TODO
|
2
|
+
Consider replacing form_for with form_tag. By using form_for, the given `new`
|
3
|
+
object must expose all of the property methods. This may work out as I steer
|
4
|
+
towards a solution.
|
5
|
+
%>
|
6
|
+
<%= form_for new, as: :work, url: '/', method: :post, html: { class: [new.dom_class(prefix: 'new'), 'work'] } do |form| %>
|
7
|
+
<% new.fieldsets.each do |fieldset| %><%= fieldset.render(template: self, locals: { form: form } ) %><% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
json.set! :work do
|
2
|
+
json.set! :work_type, show.work_type.to_s
|
3
|
+
json.properties do
|
4
|
+
show.fieldsets.each do |fieldset|
|
5
|
+
# Why the locals?
|
6
|
+
# Without the local json declared the jbuilder rendering engine
|
7
|
+
# will call :target! and dump the attributes to JSON form.
|
8
|
+
# This means nested calls will result in multiple dump commands on the
|
9
|
+
# rendered value.
|
10
|
+
fieldset.render(template: self, locals: {json: json})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Hydramata
|
2
|
+
module Works
|
3
|
+
# Responsible for wrangling up data from Fedora and passing that data to
|
4
|
+
# visiting :entity.
|
5
|
+
class FedoraWrangler
|
6
|
+
|
7
|
+
attr_reader :repository_connection, :entity, :datastream_parser
|
8
|
+
def initialize(collaborators = {})
|
9
|
+
@repository_connection = collaborators.fetch(:repository_connection) { default_repository_connection }
|
10
|
+
@datastream_parser = collaborators.fetch(:datastream_parser) { default_datastream_parser }
|
11
|
+
@entity = collaborators.fetch(:entity)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_datastream_parser
|
17
|
+
require 'hydramata/works/datastream_parser'
|
18
|
+
DatastreamParser
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_repository_connection
|
22
|
+
require 'rubydora'
|
23
|
+
# Please note: these parameters were used in building the VCR cassettes, so change at your own risk.
|
24
|
+
# TODO: This should be a configuration option analogous to ActiveFedora.
|
25
|
+
Rubydora.connect(url: 'http://127.0.0.1:8983/fedora', user: 'fedoraAdmin', password: 'fedoraAdmin')
|
26
|
+
end
|
27
|
+
|
28
|
+
public
|
29
|
+
|
30
|
+
def call(pid, options = {})
|
31
|
+
with_datastreams = options.fetch(:with_datastreams) { default_with_datastreams }
|
32
|
+
object = repository_connection.find(pid)
|
33
|
+
assign_work_type_from(object)
|
34
|
+
parse_datastreams(object) if with_datastreams
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def default_with_datastreams
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def assign_work_type_from(object)
|
44
|
+
object.models.each do |model|
|
45
|
+
if model =~ /\Ainfo:fedora\/afmodel\:(.*)\Z/
|
46
|
+
entity.work_type = Regexp.last_match[1]
|
47
|
+
break
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_datastreams(object)
|
53
|
+
object.datastreams.each do |_name, datastream|
|
54
|
+
parse_datastream_content(datastream)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_datastream_content(datastream)
|
59
|
+
datastream_parser.call(datastream: datastream, entity: entity) do |property|
|
60
|
+
entity.properties << property
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/hydramata/works/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateHydramataWorkPredicates < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :hydramata_works_predicates do |t|
|
4
|
+
t.string :identity, index: { unique: true }, null: false
|
5
|
+
t.string :name_for_application_usage
|
6
|
+
t.string :datastream_name
|
7
|
+
t.string :value_coercer_name
|
8
|
+
t.string :value_parser_name
|
9
|
+
t.string :indexing_strategy
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateHydramataWorkPredicateSets < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :hydramata_works_predicate_sets do |t|
|
4
|
+
t.integer :work_type_id, index: true, null: false
|
5
|
+
t.string :identity, index: true, null: false
|
6
|
+
t.integer :presentation_sequence, index: true, null: false
|
7
|
+
t.string :name_for_application_usage
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :hydramata_works_predicate_sets, [:work_type_id, :presentation_sequence], unique: true, name: :hydramata_works_predicate_set_sequence
|
11
|
+
add_index :hydramata_works_predicate_sets, [:work_type_id, :identity], unique: true, name: :hydramata_works_predicate_set_identity
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateHydramataWorkPredicatePresentationSequences < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :hydramata_works_predicate_presentation_sequences do |t|
|
4
|
+
t.integer :predicate_set_id, index: true, null: false
|
5
|
+
t.integer :predicate_id, index: true, null: false
|
6
|
+
t.integer :presentation_sequence, index: true, null: false
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :hydramata_works_predicate_presentation_sequences, [:predicate_set_id, :predicate_id], unique: true, name: :hydramata_works_predicate_presentation_sequences_identity
|
10
|
+
add_index :hydramata_works_predicate_presentation_sequences, [:predicate_set_id, :presentation_sequence], unique: true, name: :hydramata_works_predicate_presentation_sequences_presentation
|
11
|
+
end
|
12
|
+
end
|