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

Combination of EML annotation and custom xml safe generated identifiers raise error on save #2038

Closed
vchendrix opened this issue Jul 13, 2022 · 4 comments · Fixed by #2039
Closed
Labels
Milestone

Comments

@vchendrix
Copy link
Collaborator

Describe the bug
When updating a dataset with a repository that implements a custom MetacatUI theme that generates custom identifiers which are already xml safe (e.g. ess-dive-dd8dedc5a811a10-20220713T153145487), the following error is raised

Screen Shot 2022-07-13 at 1 25 15 PM

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://data-dev.ess-dive.lbl.gov/submit/ess-dive-0d45cb965fa7c66-20220623T162058401017
  2. Edit the title
  3. Click "Submit Dataset"
  4. See error

Expected behavior
The problem is that eml.packageId and eml.dataset.id are the same and that causes this error. Looking in the code I can see that replace the use of this.getXMLSafeID() with this.getUniqueEntityId(this) to make sure that the identifier is unique.

datasetNode.attr("id", this.getXMLSafeID());

Desktop (please complete the following information):

  • OS: MacOS X Monterey
  • Browser: Chrome
  • Version: 103.0.5060.114 (Official Build) (x86_64)
@vchendrix vchendrix added the bug label Jul 13, 2022
vchendrix added a commit that referenced this issue Jul 13, 2022
Combination of EML annotation and custom xml safe generated identifiers
raise error on save
+ replaces the use of this.getXMLSafeID() with
  this.getUniqueEntityId(this) in `EML211.serialize()` to make sure that the identifier is
  unique.

Closes #2038
@vchendrix
Copy link
Collaborator Author

Hi @laurenwalker, this is a pretty high priority issue as it is preventing us from editing datasets with annotations. Thanks!

@mbjones
Copy link
Member

mbjones commented Jul 13, 2022

@vchendrix You say that "The problem is that eml.packageId and eml.dataset.id are the same", but that has always been the case -- it is a requirement of the underlying EML validator that all @id fields and the @packageId field be unique. I don't understand why this happens for this dataset but not for others. Can you clarify the sequence of events that leads to those two fields being set to the same value on this dataset but not on others?

@vchendrix
Copy link
Collaborator Author

vchendrix commented Jul 13, 2022

@vchendrix You say that "The problem is that eml.packageId and eml.dataset.id are the same", but that has always been the case -- it is a requirement of the underlying EML validator that all @id fields and the @packageId field be unique. I don't understand why this happens for this dataset but not for others. Can you clarify the sequence of events that leads to those two fields being set to the same value on this dataset but not on others?

@mbjones Happy to explain further. When there are annotations the dataset element needs an id. Metacatui places an xml safe id in which all colons are converted to hyphens. So the packageId ends up being urn:uuid:e727256e-e3ce-42d6-a932-1acada618b9c while dataset.id is urn-uuid-e727256e-e3ce-42d6-a932-1acada618b9c (See actual eml snippet produced by EML211.serialize inside of EML211.save from the default metacatui theme)

<?xml version="1.0"?>
<eml:eml xmlns:eml="https://eml.ecoinformatics.org/eml-2.2.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:stmml="http://www.xml-cml.org/schema/stmml-1.1" 
packageId="urn:uuid:e727256e-e3ce-42d6-a932-1acada618b9c" system="ess-dive" xsi:schemaLocation="https://eml.ecoinformatics.org/eml-2.2.0 https://eml.ecoinformatics.org/eml-2.2.0/eml.xsd">    

<dataset id="urn-uuid-e727256e-e3ce-42d6-a932-1acada618b9c">
...

However, the ess-dive theme's identifiers are already xml safe and do not produce a different id and thus eml.packageId and eml.dataset.id are the same which causes this error.

I submitted a solution that utilizes an existing function in EML211 for generating a unique entity id.

        //Since there is at least one annotation, the dataset node needs to have an id attribute.
-       datasetNode.attr("id", this.getXMLSafeID());
+       datasetNode.attr("id", this.getUniqueEntityId(this));

@laurenwalker
Copy link
Member

This solution looks good to me. Merged to develop. I will be releasing a 2.X release next week with these changes along with your other PRs.

@laurenwalker laurenwalker added this to the 2.22.0 milestone Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants