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

Openalex fetch example #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

bkampe
Copy link
Contributor

@bkampe bkampe commented Aug 28, 2024

Added an example of fetching publication metadata from Openalex based on the JSON fetch.
Three example queries are available in example-scripts/bash-scripts/full-harvest-examples/1.13-1.15-examples/example-openalex/openAlexfetch.config.xml. Choose one for first test or modify it to fit to your needs.

OpenAlex fetch is already used in the Research Atlas: https://forschungsatlas.fid-bau.de/research

Namespace in example-scripts/bash-scripts/full-harvest-examples/1.13-1.15-examples/example-openalex/openalex-to-vivo.datamap.xsl needs to be adjusted according to your settings in runtime.properties:
<xsl:variable name = "baseURI">https://forschungsatlas.fid-bau.de/individual/</xsl:variable>

JSONFetch.java was extended to be capable of handling nested object. Also some filtering for unwanted characters was added to avoid problems with the XSLTranslator (javax.xml.transform)

Closes #56

@chenejac chenejac self-requested a review December 23, 2024 09:43
Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@bkampe thanks for this. I didn't test it yet, but I briefly reviewed the code. There is one tiny comment about gitignore file. And I have one more comment about SPARQL API based approach. Ivan Mrsulja makes SPARQL API based approach working in the case of DSpace ETL (#63). There is a parameter for the main script file (the value of the parameter might be tdb or sparql). I am wondering whether that approach might be copied in this PR as well?

Comment on lines +32 to +34
/example-scripts/bash-scripts/full-harvest-examples/1.13-1.15-examples/example-openalex/logs/
/example-scripts/bash-scripts/full-harvest-examples/1.13-1.15-examples/example-openalex/data/
/example-scripts/bash-scripts/full-harvest-examples/1.13-1.15-examples/example-openalex/previous-harvest/
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking that lines 3-7 includes this case?

Choose a reason for hiding this comment

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

I think that adding:

**/data
**/logs
**/previous-harvest

to root-level .gitignore will solve this issue.

Copy link

@ivanmrsulja ivanmrsulja left a comment

Choose a reason for hiding this comment

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

LGTM! Please check out my comments, I believe they can be helpfull.

Comment on lines +408 to +411
//log.trace("Adding record: " + fixedkey + "_" + recID);
//log.trace("data: "+ sb.toString());
//log.info("rhOutput: "+ this.rhOutput);
//log.info("recID: "+recID);

Choose a reason for hiding this comment

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

You can probably remove these comments (and also in the other places you commented-out the code snippets), it will clean up the code slightly.

Comment on lines +596 to +607
sb.append(" <");
sb.append(SpecialEntities.xmlEncode(field));
sb.append(">");

// insert field value
sb.append(SpecialEntities.xmlEncode(val.toString().trim()));

// Field END
sb.append("</");
sb.append(SpecialEntities.xmlEncode(field));
sb.append(">\n");
return sb.toString();

Choose a reason for hiding this comment

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

Can these appends be chained using StringBuilder's default builder pattern?

Comment on lines +389 to +391
.replaceAll(" |/", "_")
.replaceAll("\\(|\\)", "")
.replaceAll("/", "_");

Choose a reason for hiding this comment

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

I think you can use replaceAll("[ /]", "_").replaceAll("[()]", "") to make this more clear.

.replaceAll(" |/", "_")
.replaceAll("\\(|\\)", "")
.replaceAll("/", "_");
if (!Character.isDigit(fixedkey.charAt(0)) && !fixedkey.equals("abstract_inverted_index")) {

Choose a reason for hiding this comment

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

Can fixedKey ever be null? If yes, then I think there should be a null-check for that edge case.

}

public String getTagName(String field, Object val) {
StringBuffer sb = new StringBuffer();

Choose a reason for hiding this comment

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

Why is StringBuffer used here? If this class will not be used in a multithreaded environment I think we should switch to using StringBuilder everywhere because it is a lot faster.

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

Successfully merging this pull request may close these issues.

Add harvesting OpenAlex data for a certain institution Add harvesting script for OpenAlex
3 participants