Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

95 property singularity determination #96

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/forms/concerns/allinson_flex/dynamic_form_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module DynamicFormBehavior
:visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
:visibility_during_lease, :lease_expiration_date, :visibility_after_lease,
:visibility, :ordered_member_ids, :source, :in_works_ids,
:member_of_collection_ids, :admin_set_id, :profile_version]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile_version is already on line 14.

:member_of_collection_ids, :admin_set_id]

self.required_fields = []
self.required_fields = []
end

class_methods do
Expand Down
5 changes: 3 additions & 2 deletions app/models/concerns/allinson_flex/dynamic_solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def load_allinson_flex
profile.properties.each do |prop|
attribute(
prop.name,
# if the property is singular, make it so
prop.cardinality_maximum == 1 ? Hyrax::SolrDocument::Metadata::Solr::String : Hyrax::SolrDocument::Metadata::Solr::Array,
# always default the value to be an array, then use the cardinality to determine how
# many values can exist in that array
Hyrax::SolrDocument::Metadata::Solr::Array,
"#{prop.name.to_s}_tesim"
)
end
Expand Down
15 changes: 5 additions & 10 deletions app/services/allinson_flex/allinson_flex_constructor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,18 @@ def self.build_schema(klass, context = nil)
property.name => {
'predicate' => property.property_uri,
'display_label' => display_label(property, klass, context),
'required' => required?(property.cardinality_minimum),
'singular' => singular?(property.cardinality_maximum),
'required' => required?(property.requirement, property.cardinality_minimum),
'singular' => false,
'indexing' => property.indexing
}.compact
}.compact
end.inject(:merge)
}
end

def self.required?(cardinality_minimum)
return false if cardinality_minimum.blank?
cardinality_minimum > 0
end

def self.singular?(cardinality_maximum)
return false if cardinality_maximum.blank? || cardinality_maximum > 1
return true if cardinality_maximum == 1
def self.required?(requirement, cardinality_minimum)
return true if requirement == 'required' || cardinality_minimum > 0
false
end

def self.display_label(property, klass, context = nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
},
"additionalProperties": {
"type": "object",
"required": ["display_label"],
"required": ["display_label"],
"properties": {

"display_label": {
Expand Down