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

Pass created, modified, issued date from thesaurus to the schemas #6972

Merged

Conversation

wangf1122
Copy link
Collaborator

This is to fix the issue metadata101/iso19139.ca.HNAP#308

The issue is the schema transformation style sheet doesn't know if the date is from the thesaurus itself or from the file system last modified date. Therefore, it cannot adjust logic to render different XML template.

@ianwallen
Copy link
Contributor

@wangf1122

I don't believe this is the fix that we are looking for....

@josegar74 @fxprunayre

I think the real bug in this case is that it should never set the last modified date to the system date or the file date.

In our case, we are regularly doing deployments in an K8S environment, and we always copy the thesaurus files during the deployment - this does not mean that the last modified date for the thesaurus was changed.
With this logic, the thesaurus dates on our application are changing almost every time a user does an update.

I believe it should instead just leave it last modified date empty and not modify the values that already exists in the metadata files. If someone really wants a last modified date set then the date should be managed in the thesaurus file.

What are your thoughts?

@josegar74
Copy link
Member

@ianwallen the "problem" is that https://github.com/geonetwork/core-geonetwork/blob/main/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl creates all the thesaurus block from scratch, probably as only receives the parameters of the keyword(s) to add and not the full metadata record.

For me the solution would be to store the creation/publish dates in the vocabulary file, which is possible. The current code server-side code retrieves the modification date (if it exists).

Element dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs);
Date thesaususDate = parseThesaurusDate(dateEl);
if (thesaususDate == null) {
dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs);
thesaususDate = parseThesaurusDate(dateEl);
}
if (thesaususDate != null) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
this.date = df.format(thesaususDate);
}

I think it can also be updated to handle the creation date.

@wangf1122 wangf1122 changed the title add isFileSystemDate flag to thesaurus model Pass created, modified, issued date from thesaurus to the schemas Apr 14, 2023
@wangf1122
Copy link
Collaborator Author

wangf1122 commented Apr 14, 2023

@ianwallen the "problem" is that https://github.com/geonetwork/core-geonetwork/blob/main/schemas/iso19139/src/main/plugin/iso19139/convert/thesaurus-transformation.xsl creates all the thesaurus block from scratch, probably as only receives the parameters of the keyword(s) to add and not the full metadata record.

For me the solution would be to store the creation/publish dates in the vocabulary file, which is possible. The current code server-side code retrieves the modification date (if it exists).

Element dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:issued|skos:Collection/dc:date", theNSs);
Date thesaususDate = parseThesaurusDate(dateEl);
if (thesaususDate == null) {
dateEl = Xml.selectElement(thesaurusEl, "skos:ConceptScheme/dcterms:modified", theNSs);
thesaususDate = parseThesaurusDate(dateEl);
}
if (thesaususDate != null) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
this.date = df.format(thesaususDate);
}

I think it can also be updated to handle the creation date.

The issue is this single default date is too general. At schema level (i.e. HNAP 19139) it's hard to tell what to do with it.

I have modified this pull request to pass all possible dates (created, modified, issued) to the schema level. And will let schema decides what to do with the dates. The original date logic is still there which I see it first uses issued date, then go modified. If none is found, then it will use the file system date.

I will make some PR at HNAP metadata to handle this logic. So this change will also give all schemas more flexibilities to deal with these dates.

@ianwallen ianwallen self-requested a review April 20, 2023 15:31
@ianwallen ianwallen added this to the 4.2.4 milestone Apr 21, 2023
@ianwallen ianwallen requested a review from josegar74 April 21, 2023 14:31
Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

I've tested and looks fine. Nice improvement.

@wangf1122 I've updated the PR with xslt changes also: https://github.com/GeoCat/core-geonetwork/tree/main.thesaurus.last.modify.date.flag-xsl-updates

But can't make a pull request to your repository, probably you'll need to give some permissions, otherwise include this commit changes also: GeoCat@4020bfa

@wangf1122
Copy link
Collaborator Author

@josegar74

I have cherry picked your commit into this pull request. All good. Thanks.

@josegar74 josegar74 requested a review from fxprunayre April 24, 2023 05:54
@ianwallen ianwallen merged commit f616aae into geonetwork:main Apr 24, 2023
ianwallen pushed a commit that referenced this pull request Apr 24, 2023
#6972)

* add isFileSystemDate flag to thesaurus model

* pass thesaurus created, issued, modified date to the schemas.

* Fixed null pointer exception.

* remove date conversion

* Revert default thesaurus date to original code

* add more dateformat to parsing Thesaurus date

* Update thesaurus-transformation.xsl

---------

Co-authored-by: Jose García <[email protected]>
fxprunayre added a commit that referenced this pull request Sep 30, 2024
#6972 adds retrieval of `dct:issued|modified|created` dates but multiple dates could be added more than one time with same date type code. Improve the mapping.
fxprunayre added a commit to SPW-DIG/metawal-core-geonetwork that referenced this pull request Sep 30, 2024
geonetwork#6972 adds retrieval of `dct:issued|modified|created` dates but multiple dates could be added more than one time with same date type code. Improve the mapping.
fxprunayre added a commit that referenced this pull request Oct 7, 2024
* Thesaurus / Date parsing fix.

https://github.com/geonetwork/core-geonetwork/pull/6972/files#diff-c7548d94bdb4268915f50f66df5a90f1f7868e4fb1de2f3d2938397e202aaf2fR1057
added month and year format support. This was resolving thesaurus date
to the last matching format ie. 1st January for the default date.

This can be tested using regions thesaurus which will contains 2 dates
for the thesaurus block.

* Thesaurus / Avoid having multiple dates with same type code

#6972 adds retrieval of `dct:issued|modified|created` dates but multiple dates could be added more than one time with same date type code. Improve the mapping.

* Thesaurus / INSPIRE registry / Only keep one date to avoid validation errors

* Thesaurus / LD registry registry / Only keep one date

No need for duplicated date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants