Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Fixes - #270 Implemented mapping from DAMS4 to SHARE V2 API and updat… #450

Closed
wants to merge 7 commits into from

Conversation

hweng
Copy link
Contributor

@hweng hweng commented May 14, 2018

…ed push function.

Fixes #270 ; refs #270

@ucsdlib/developers - please review

}
json_data = {"jsonData": field_map}
end
end

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

}
json_data = {"jsonData": field_map}
end
end

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/TrailingWhitespace: Trailing whitespace detected.

'tags': osf_mads_fields(document),
'publisher': osf_publisher
'ertra': osf_extra(document)

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),

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),

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
url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|

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/IndentationWidth: Use 2 (not 3) spaces for indentation.

dams_data = document["#{field_name}"]
osf_data = {}
osf_data = ''

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 osf_uris(document)
field_name = "id"
def osf_description(document)
field_name = "otherNote_json_tesim"

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/IndentationWidth: Use 2 (not 1) spaces for indentation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
end
osf_data
end

def osf_uris(document)
field_name = "id"
def osf_description(document)

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 = other_note['value'] if other_note['type'] == 'description'
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

}
json_data = {"jsonData": field_map}
end

# Retrieve label from solr index instead of external record from repo
# Retrieve label from solr index instead of external record from repo

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/CommentIndentation: Incorrect indentation detected (column 2 instead of 1).

dams_data = document["#{field_name}"]
osf_data = {}
osf_data = ''

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.

def osf_uris(document)
field_name = "id"
def osf_description(document)
field_name = "otherNote_json_tesim"

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
end
osf_data
end
end

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.each do |datum|
other_note = JSON.parse(datum)
osf_data = other_note['value'] if other_note['type'] == 'description'
end

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/BlockAlignment: end at 123, 6 is not aligned with dams_data.each do |datum| at 120, 4.


if dams_data != nil
url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|

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/IndentationWidth: Use 2 (not 1) spaces for indentation.


def osf_uris(document)
field_name = "id"
def osf_description(document)

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

field_name = "otherNote_json_tesim"
dams_data = document["#{field_name}"]
osf_data = ''
osf_data = {}

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

@coveralls
Copy link

coveralls commented May 14, 2018

Coverage Status

Coverage decreased (-0.2%) to 66.037% when pulling 34a234a on feature/SHARE2_mapping into 92300c3 on develop.

end
osf_data
end
end

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/DefEndAlignment: end at 126, 2 is not aligned with def at 114, 4.
Layout/TrailingWhitespace: Trailing whitespace detected.

osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|
other_note = JSON.parse(datum)
osf_data = other_note['value'] if other_note['type'] == 'description'

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|
other_note = JSON.parse(datum)

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/IndentationWidth: Use 2 (not 0) spaces for indentation.


if dams_data != nil
url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|

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.

def osf_description(document)
field_name = "otherNote_json_tesim"
dams_data = document["#{field_name}"]
osf_data = ''

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.

dams_data = document["#{field_name}"]
osf_data = {}
def osf_description(document)
field_name = "otherNote_json_tesim"

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

field_name = "id"
dams_data = document["#{field_name}"]
osf_data = {}
def osf_description(document)

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.

end
osf_data
end
end

Choose a reason for hiding this comment

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

Layout/DefEndAlignment: end at 112, 4 is not aligned with def at 100, 2.

osf_data = other_note['value'] if other_note['type'] == 'description'
end
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end

Choose a reason for hiding this comment

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

Layout/BlockAlignment: end at 109, 8 is not aligned with dams_data.each do |datum| at 106, 6.


if dams_data != nil
dams_data.each do |datum|
other_note = JSON.parse(datum)
osf_data = other_note['value'] if other_note['type'] == 'description'
end
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'

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.

end
osf_data
end
end

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/DefEndAlignment: end at 126, 2 is not aligned with def at 114, 4.
Layout/TrailingWhitespace: Trailing whitespace detected.

osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|
other_note = JSON.parse(datum)
osf_data = other_note['value'] if other_note['type'] == 'description'

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|
other_note = JSON.parse(datum)

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/IndentationWidth: Use 2 (not 0) spaces for indentation.


if dams_data != nil
url = "http://library.ucsd.edu/dc/collection/#{dams_data}"
osf_data = {"canonicalUri": url, "providerUris": url}
dams_data.each do |datum|

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.

def osf_description(document)
field_name = "otherNote_json_tesim"
dams_data = document["#{field_name}"]
osf_data = ''

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.

dams_data = document["#{field_name}"]
osf_data = {}
def osf_description(document)
field_name = "otherNote_json_tesim"

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

field_name = "id"
dams_data = document["#{field_name}"]
osf_data = {}
def osf_description(document)

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.

end
osf_data
end
end

Choose a reason for hiding this comment

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

Layout/DefEndAlignment: end at 112, 4 is not aligned with def at 100, 2.

osf_data = other_note['value'] if other_note['type'] == 'description'
end
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end

Choose a reason for hiding this comment

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

Layout/BlockAlignment: end at 109, 8 is not aligned with dams_data.each do |datum| at 106, 6.


if dams_data != nil
dams_data.each do |datum|
other_note = JSON.parse(datum)
osf_data = other_note['value'] if other_note['type'] == 'description'
end
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'

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.

end
end
osf_data
end

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end
end
osf_data

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.

other_note = JSON.parse(datum)
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end
end

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/EndAlignment: end at 109, 4 is not aligned with if at 104, 3.

dams_data.each do |datum|
other_note = JSON.parse(datum)
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end

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'

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

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.
Style/NonNilCheck: Prefer !expression.nil? over expression != nil.

def osf_extra(document)
field_name = "otherNote_json_tesim"
dams_data = document["#{field_name}"]
osf_data = {}

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 osf_extra(document)
field_name = "otherNote_json_tesim"
dams_data = document["#{field_name}"]

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.
Style/UnneededInterpolation: Prefer to_s over string interpolation.

end

def osf_extra(document)
field_name = "otherNote_json_tesim"

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/IndentationWidth: Use 2 (not 1) spaces for indentation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

type = (share_agent_type.include? type) ? type : "Contributor"
end

def osf_extra(document)

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

'tags': osf_mads_fields(document),
'publisher': osf_publisher
'extra': osf_extra(document)

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)

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.

other_note = JSON.parse(datum)
osf_data = { funding: other_note['value'] } if other_note['type'] == 'funding'
end
end

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/EndAlignment: end at 108, 4 is not aligned with if at 103, 3.

dams_data = document["#{field_name}"]
osf_data = {}

if dams_data != nil

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.
Style/NonNilCheck: Prefer !expression.nil? over expression != nil.


def osf_extra(document)
field_name = 'otherNote_json_tesim'
dams_data = document["#{field_name}"]

Choose a reason for hiding this comment

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

Layout/Tab: Tab detected.
Style/UnneededInterpolation: Prefer to_s over string interpolation.

end

def osf_extra(document)
field_name = 'otherNote_json_tesim'

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/IndentationWidth: Use 2 (not 1) spaces for indentation.

type = (share_agent_type.include? type) ? type : "Contributor"
end

def osf_extra(document)

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

def metadata_display?(data)

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.

begin
ref = Rails.application.routes.recognize_path(uri.path.gsub(/^\/dc/,""))
ref[:controller]
rescue Exception => e

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?

uri = URI(request.referrer || "")
if uri.host == request.host
begin
ref = Rails.application.routes.recognize_path(uri.path.gsub(/^\/dc/,""))

Choose a reason for hiding this comment

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

Layout/SpaceAfterComma: Space missing after comma.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

# parse a request's referrer and figure out which controller it came from
def referrer_controller( request )
uri = URI(request.referrer || "")
if uri.host == request.host

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.


# parse a request's referrer and figure out which controller it came from
def referrer_controller( request )
uri = URI(request.referrer || "")

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

res.body
end

def get_data ( recursive = true, format )

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.
Layout/SpaceAfterMethodName: Do not put a space between a method name and the opening parenthesis.
Layout/SpaceInsideParens: Space inside parentheses detected.
Style/OptionalArguments: Optional arguments should appear at the end of the argument list.

def get_html_data ( params, controller_path )
xsl = (params[:xsl].nil? || params[:xsl].empty?)?'review.xsl':params[:xsl]
controller = (controller_path.nil? || controller_path.empty?)?'':'&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

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.
Metrics/LineLength: Line is too long. [154/150]

end
def get_html_data ( params, controller_path )
xsl = (params[:xsl].nil? || params[:xsl].empty?)?'review.xsl':params[:xsl]
controller = (controller_path.nil? || controller_path.empty?)?'':'&controller=' + URI.encode(controller_path)

Choose a reason for hiding this comment

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

Style/TernaryParentheses: Omit parentheses for ternary conditions.
Rails/Blank: Use controller_path.blank? instead of controller_path.nil? || controller_path.empty?.
Layout/SpaceAroundOperators: Surrounding space missing for operator ?.
Layout/SpaceAroundOperators: Surrounding space missing for operator :.
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.

result
end
def get_html_data ( params, controller_path )
xsl = (params[:xsl].nil? || params[:xsl].empty?)?'review.xsl':params[:xsl]

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.
Style/TernaryParentheses: Omit parentheses for ternary conditions.
Rails/Blank: Use params[:xsl].blank? instead of params[:xsl].nil? || params[:xsl].empty?.
Layout/SpaceAroundOperators: Surrounding space missing for operator ?.
Layout/SpaceAroundOperators: Surrounding space missing for operator :.

end
result
end
def get_html_data ( params, controller_path )

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.
Layout/SpaceAfterMethodName: Do not put a space between a method name and the opening parenthesis.
Layout/SpaceInsideParens: Space inside parentheses detected.

@hweng hweng closed this May 17, 2018
@hweng hweng deleted the feature/SHARE2_mapping branch May 17, 2018 20:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants