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

sbJSON association mapping error #149

Closed
jlblcc opened this issue Oct 10, 2017 · 5 comments
Closed

sbJSON association mapping error #149

jlblcc opened this issue Oct 10, 2017 · 5 comments
Assignees
Labels
bug Unexpected problem or unintended behavior

Comments

@jlblcc
Copy link
Member

jlblcc commented Oct 10, 2017

"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.

@jlblcc jlblcc added the bug Unexpected problem or unintended behavior label Oct 10, 2017
@zephyrr
Copy link

zephyrr commented Oct 11, 2017

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:

  • Project has Associated Resource link to Product, of type "productOf" rather than "product"
  • Product has Associated Resource link to Project, of type "product" rather than "parentProject"

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
Copy link

zephyrr commented Oct 11, 2017

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

@jlblcc
Copy link
Member Author

jlblcc commented Oct 11, 2017

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

@jlblcc
Copy link
Member Author

jlblcc commented Oct 11, 2017

image

@stansmith907
Copy link
Contributor

stansmith907 commented Oct 11, 2017

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.

stansmith907 added a commit to stansmith907/mdTranslator that referenced this issue Oct 11, 2017
@jlblcc jlblcc closed this as completed Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants