-
Notifications
You must be signed in to change notification settings - Fork 5
Fixes - #270 Implemented mapping from DAMS4 to SHARE V2 API and updated push function. #451
Conversation
…ed push function.
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding' | ||
end | ||
end | ||
osf_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationConsistency: Inconsistent indentation detected.
lib/dams/controller_helper.rb
Outdated
other_note = JSON.parse(datum) | ||
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding' | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/EndAlignment: end at 108, 4 is not aligned with if at 103, 3.
lib/dams/controller_helper.rb
Outdated
osf_data = {} | ||
|
||
if dams_data != nil | ||
dams_data.each do |datum| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.
lib/dams/controller_helper.rb
Outdated
dams_data = document["#{field_name}"] | ||
osf_data = {} | ||
|
||
if dams_data != nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationConsistency: Inconsistent indentation detected.
Style/NonNilCheck: Prefer !expression.nil? over expression != nil.
lib/dams/controller_helper.rb
Outdated
def osf_extra(document) | ||
field_name = 'otherNote_json_tesim' | ||
dams_data = document["#{field_name}"] | ||
osf_data = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationConsistency: Inconsistent indentation detected.
lib/dams/controller_helper.rb
Outdated
"creator", | ||
"funder", | ||
"host", | ||
"principalinvestigator", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/dams/controller_helper.rb
Outdated
"contributor", | ||
"creator", | ||
"funder", | ||
"host", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/dams/controller_helper.rb
Outdated
"agentworkrelation", | ||
"contributor", | ||
"creator", | ||
"funder", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/dams/controller_helper.rb
Outdated
"Publisher", | ||
"agentworkrelation", | ||
"contributor", | ||
"creator", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
lib/dams/controller_helper.rb
Outdated
"PrincipalInvestigatorContact", | ||
"Publisher", | ||
"agentworkrelation", | ||
"contributor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
dams_data.each do |datum| | ||
other_note = JSON.parse(datum) | ||
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/BlockAlignment: end at 107, 6 is not aligned with dams_data.each do |datum| at 104, 8.
osf_data = {} | ||
|
||
if !dams_data.nil | ||
dams_data.each do |datum| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationWidth: Use 2 (not 5) spaces for indentation.
dams_data = document["#{field_name}"] | ||
osf_data = {} | ||
|
||
if !dams_data.nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentationConsistency: Inconsistent indentation detected.
Style/NegatedIf: Favor unless over if for negative conditions.
lib/dams/controller_helper.rb
Outdated
classname = self.class.name.gsub("sController","") | ||
def get_data(recursive = true, format) | ||
format = format.presence || 'xml' | ||
viewerUrl = "#{dams_api_path}/api/objects/#{params[:id]}?" + (recursive ? 'recursive=true&' : '') + "format=#{format}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming/VariableName: Use snake_case for variable names.
lib/dams/controller_helper.rb
Outdated
end | ||
|
||
def audit( id = "unknown" ) | ||
classname = self.class.name.gsub("sController","") | ||
def get_data(recursive = true, format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/OptionalArguments: Optional arguments should appear at the end of the argument list.
lib/dams/controller_helper.rb
Outdated
def get_html_data(params, controller_path) | ||
xsl = params[:xsl].presence || 'review.xsl' | ||
controller = controller_path.blank? ? '' : '&controller=' + URI.encode(controller_path) | ||
viewerUrl = "#{dams_api_path}/api/objects/#{params[:id]}/transform?recursive=true&xsl=#{xsl}&baseurl=" + URI.encode(dams_api_path) + controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming/VariableName: Use snake_case for variable names.
Lint/UriEscapeUnescape: URI.encode method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
lib/dams/controller_helper.rb
Outdated
res.body | ||
def get_html_data(params, controller_path) | ||
xsl = params[:xsl].presence || 'review.xsl' | ||
controller = controller_path.blank? ? '' : '&controller=' + URI.encode(controller_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UriEscapeUnescape: URI.encode method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.
lib/dams/controller_helper.rb
Outdated
else | ||
return { alert: json['message'] } | ||
end | ||
rescue Exception => e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/RescueException: Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
lib/dams/controller_helper.rb
Outdated
ext = File.extname(file.original_filename) | ||
@ds += ext unless ext.nil? | ||
|
||
# check mime type and include derivatives hook if derivable | ||
mt = file.content_type | ||
if ext.include?("wav") || ext.include?("tif") || ext.include?("mov") || ext.include?("avi") || ext.include?("pdf") | ||
if ext.include?('wav') || ext.include?('tif') || ext.include?('mov') || ext.include?('avi') || ext.include?('pdf') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.
lib/dams/controller_helper.rb
Outdated
roleId = '' | ||
unless relationship.nil? | ||
relationship.each do |relation| | ||
roleId = relation.role.first.pid unless relation.role.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming/VariableName: Use snake_case for variable names.
lib/dams/controller_helper.rb
Outdated
relationship = object.relationship | ||
roleId = '' | ||
unless relationship.nil? | ||
relationship.each do |relation| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [36/25]
lib/dams/controller_helper.rb
Outdated
def get_relationships(object) | ||
relationshipArray = [] | ||
relationship = object.relationship | ||
roleId = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming/VariableName: Use snake_case for variable names.
lib/dams/controller_helper.rb
Outdated
end | ||
|
||
def get_relationships(object) | ||
relationshipArray = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming/VariableName: Use snake_case for variable names.
93faf66
to
3b42cb5
Compare
'tags': osf_mads_fields(document), | ||
'publisher': osf_publisher | ||
'extra': osf_extra(document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
'languages': osf_languages(document), | ||
'providerUpdatedDateTime': osf_date(document), | ||
'date_published': osf_date_published(document), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
def export_to_API(document) | ||
field_map = { | ||
'title': osf_title(document), | ||
'description': osf_description(document), | ||
'contributor': osf_contributors(document), | ||
'uris': osf_uris(document), | ||
'related_agents': osf_related_agents(document), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
@@ -70,7 +135,7 @@ def osf_uris(document) | |||
osf_data | |||
end | |||
|
|||
def osf_date(document) | |||
def osf_date_published(document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
end | ||
end | ||
osf_data | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
if !dams_data.nil | ||
dams_data.each do |datum| | ||
other_note = JSON.parse(datum) | ||
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
|
||
if !dams_data.nil | ||
dams_data.each do |datum| | ||
other_note = JSON.parse(datum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
dams_data = document["#{field_name}"] | ||
osf_data = {} | ||
|
||
if !dams_data.nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
Layout/IndentationConsistency: Inconsistent indentation detected.
Style/NegatedIf: Favor unless over if for negative conditions.
type = (share_agent_type.include? type) ? type : 'Contributor' | ||
end | ||
|
||
def osf_extra(document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
'publisher' | ||
] | ||
type = (share_agent_type.include? type) ? type : 'Contributor' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.
Fixes #270 ; refs #270