adiwg / mdTranslator

Metadata translation tool built using Ruby
https://www.adiwg.org/mdTranslator/
The Unlicense
14 stars 12 forks source link

sbJSON association mapping error #149

Closed jlblcc closed 7 years ago

jlblcc commented 7 years ago

"Produced" is actually mapping to "prodcutOf", should be mapping to "project". Looks like "productOf" is mapping to "product" when translating from the product. This should be mapping to "parentProject". See the project example below for reference:

SB Item: https://www.sciencebase.gov/catalog/item/54b83e7de4b03ff52703c997?community=LC+MAP+-+Landscape+Conservation+Management+and+Analysis+Portal

Need to get this fixed ASAP.

zephyrr commented 7 years ago

Let me broaden this and be pretty specific as it affects both directions.

In ScienceBase suppose a Project is correctly linked to a Project with a (bidirectional) Associated Item type of "produced", which looks like "product of" from the Product end.

Imported via the api to mdJSON in mdEditor, this becomes:

Basically, the translation gets the direction backward, AND uses productOf (which is not an allowed type in mdEditor) rather than "parentProject" (which is allowed).

zephyrr commented 7 years ago

I couldn't check in the other direction, but let's be sure we get it working both directions!

jlblcc commented 7 years ago

I think we've got it figured out. Patched release forthcoming.

jlblcc commented 7 years ago

image

stansmith907 commented 7 years ago

ADIwg tools mdJson/mdTranslator/mdEditor as well as ISO use a mono-directional relationship, i.e. all relationships are expressed 'how the associated item relates to the main resource (resource being described by the metadata)'. ScienceBase sbJson uses bi-directional relationships to support webpage display and navigation in addition to basic metadata description. ADIwg also uses ISO relationship codes augmented with a few of our own. The meanings of the sbJson and ADIwg codes do not always line up well further complicating translation. It can all get rather confusing trying to keep the two systems in sync.

Josh and I revisited and adjusted the two translation tables. Hopefully this will solve the problems.

Code for mdTranslator's sbJson reader sbJson linkType to ISO associationTypeCode translation tables:

# mdJson/mdTranslator view point is always: how the associated resource relates to the main resource
# dropped 'copiedFrom', 'copiedInfo' from translation tables

# scienceBaseId = relatedItemId (forward)
# assoc2main = the associated resource is (a) ___ of the main resource
# example = the associated resource is 'constituentOf' the main resource
# so the adiwg equivalent is 'ifPartOf'
@association_sb2adiwg_assoc2main = [
   {sb: 'alternate', adiwg: 'alternate'},
   {sb: 'constituentOf', adiwg: 'isPartOf'},
   {sb: 'derivativeOf', adiwg: 'derivativeResource'},
   {sb: 'precededBy', adiwg: 'series'},
   {sb: 'productOf', adiwg: 'product'},
   {sb: 'related', adiwg: 'crossReference'},
   {sb: 'subprojectOf', adiwg: 'subProject'}
]

# scienceBaseId = itemId (reverse)
# main2assoc = the main resource is (a) ___ of the associated resource
# example = the main resource is 'constituentOf' the associated resource
# reverse the direction for mdJson/mdTranslator which is mono-directional
# so the adiwg equivalent is 'isComposedOf'
@association_sb2adiwg_main2assoc = [
   {sb: 'alternate', adiwg: 'alternate'},
   {sb: 'constituentOf', adiwg: 'isComposedOf'},
   {sb: 'derivativeOf', adiwg: 'source'},
   {sb: 'precededBy', adiwg: 'series'},
   {sb: 'productOf', adiwg: 'parentProject'},
   {sb: 'related', adiwg: 'crossReference'},
   {sb: 'subprojectOf', adiwg: 'parentProject'}
]

Code for mdTranslator's sbJson reader to determine relationship direction.

# determine relationship direction
# forward: how the associated resource relates to the main resource
# ... in other words - the relationship is defined in terms of the associated resource
# ... example: the associated resource is a 'subProject' of the main resource
# reverse: how the main resource relates to the associated resource
# ... in other words - the relationship is defined in terms of the main resource
# ... example: the main resource is the 'parentProject' of the associated resource
# all mdJson/mdTranslator relationships must be expressed as forward
forward = nil
if hItem.has_key?('itemId')
   forward = false if sbId == hItem['itemId']
end
if hItem.has_key?('relatedItemId')
   forward = true if sbId == hItem['relatedItemId']
end
if forward.nil?
   hResponseObj[:readerExecutionMessages] << 'Main ScienceBase id was not referenced in related item'
   return hMetadata
end

Also note that the associationType in mdEditor is open for editing, you are not limited to the choices in the dropdown. Also note that the sbJson linkTypes of 'copiedFrom' and 'copiedInto' were dropped from the translation tables because we could not find a way to make them work. So these two may show up in the mdEditor at which point you can change to whatever you wish or leave them be.