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

Story/cite-177 There needs to be an import from Crossref #22

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from

Conversation

PradnyaC11
Copy link

@PradnyaC11 PradnyaC11 commented Jun 13, 2024

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

The user should be able to search in crossref to references to import. whatever search results from Crossref a user selects should then be imported into citesphere. This could be all search results or just a few or one.

For now, let's put add an entry to the import menu and let the user select which group to import the results into from a dropdown menu.

The importing should be done from Citesphere Importer (not Citesphere), similar how entries from files are imported.

For querying crossref, this library should be used: https://github.com/diging/crossref-connect. However, this is not yet released into maven central, so talk to Julia before picking up this ticket.

... Put ticket description here and add link to ticket ...
https://diging.atlassian.net/browse/CITE-177

Are there any other pull requests that this one depends on?

diging/citesphere-messages#12
diging/citesphere#271

Anything else the reviewer needs to know?

... describe here ...

@diging-jenkins
Copy link

Can one of the admins verify this patch?

@PradnyaC11 PradnyaC11 changed the title Story/cite 177 Story/cite-177 There needs to be an import from Crossref Jun 13, 2024
@PradnyaC11 PradnyaC11 reopened this Jul 2, 2024
@PradnyaC11 PradnyaC11 requested a review from jdamerow July 2, 2024 22:53
@@ -15,7 +15,8 @@
<spring-data.version>Lovelace-RELEASE</spring-data.version>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<spring.kafka.version>2.2.6.RELEASE</spring.kafka.version>
<citesphere.messages.version>0.2</citesphere.messages.version>
<citesphere.messages.version>0.5</citesphere.messages.version>
<crossref-connect-version>0.3-SNAPSHOT</crossref-connect-version>
Copy link
Member

Choose a reason for hiding this comment

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

the current version of crossref-connect is 0.2. Where there changes and is there a pull request? If so, it needs to be linked. If not, this needs to be the correct version.


sendMessage(null, message.getId(), Status.PROCESSING, ResponseCode.P00);
BibEntryIterator bibIterator = null;
bibIterator = new CrossRefIterator(info);
Copy link
Member

Choose a reason for hiding this comment

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

merge with line 82


response = response != null ? response : new ItemCreationResponse();
sendMessage(response, message.getId(), Status.DONE, ResponseCode.S00); // giving error 500 as response code mentioned
}
Copy link
Member

Choose a reason for hiding this comment

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

this is a lot of duplicate code. This method should be in the superclass and in line 83 should getBibIterator() be called. The rest should then be the same. The logic of how the bibiterator is created will then be in that method.

articles = new ArrayList<>();
for (String doi : info.getDois()) {
try {
Item item = crossrefService.get(doi);
Copy link
Member

Choose a reason for hiding this comment

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

The way it is written right now, this should be done in next (only one) and also paced to make sure we don't bombard crossref with requests. Even better would probably be to pass in a list of dois and make only one request but that might not be implemented either in our connector or in the crossref api.

chair.setIds(Arrays.asList(contributorID));
contributors.add(chair);
}
// added Editors & translators to article meta.
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

Removed the comment.

ref.setReferenceId(itemRef.getKey());
ref.setReferenceString(itemRef.getUnstructured());
ref.setReferenceStringRaw(itemRef.getUnstructured());
references.add(ref);
Copy link
Member

Choose a reason for hiding this comment

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

content of for loop should go in its own method

Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

this still

return meta;
}

public List<Contributor> mapPersonToContributor(List<Person> personList) {
Copy link
Member

Choose a reason for hiding this comment

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

does this need to be public?

Copy link
Author

Choose a reason for hiding this comment

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

Changed to private

@@ -41,8 +42,11 @@ public ObjectNode generateJson(JsonNode template, BibEntry entry) {
ItemJsonGenerator generator = generators.get(entry.getArticleType());
if (generator != null) {
return generator.generate(template, entry);
} else if (entry instanceof Publication){
generator = generators.get("CrossRef");
return generator.generate(template, entry);
Copy link
Member

Choose a reason for hiding this comment

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

what is this code for?

Copy link
Author

Choose a reason for hiding this comment

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

Removed this block, as crossref generator is removed.

}

@Test
public void testStartImport_successful() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

test naming conventions not followed

Copy link
Author

Choose a reason for hiding this comment

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

Deleted the tests as CrossrefRefernceImport does not have much now.

@Test
public void testStartImport_successful() throws Exception {
when(info.getDois()).thenReturn(Arrays.asList("10.1234/example1", "10.5678/example2"));
when(handlerRegistry.handleFile(info, null)).thenReturn(bibIterator);
Copy link
Member

Choose a reason for hiding this comment

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

the crossref importer doesn't have a handlerregistry, does it?

Copy link
Author

Choose a reason for hiding this comment

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

Deleted the tests as CrossrefRefernceImport does not have much now.

@jdamerow jdamerow closed this Jul 5, 2024
@PradnyaC11 PradnyaC11 reopened this Jul 11, 2024
@PradnyaC11 PradnyaC11 requested a review from jdamerow July 11, 2024 23:47
@jdamerow
Copy link
Member

no need to make comments like "done" or "removed", etc. I just get more notifications and it drowns out the comments I really need to read and respond to.

@jdamerow jdamerow closed this Jul 12, 2024
@PradnyaC11 PradnyaC11 reopened this Jul 23, 2024
}
return file;
}
protected abstract BibEntryIterator getbibIterator(KafkaJobMessage message, JobInfo info);
Copy link
Member

Choose a reason for hiding this comment

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

should be getBibEntryIterator

public final static String EDITED_BOOK = "edited-book";
public final static String PROCEEDINGS_ARTICLE = "proceedings-article";
public final static String DISSERTATION = "dissertation";
public final static String BOOK_SECTION = "book-section";
Copy link
Member

Choose a reason for hiding this comment

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

this already exists (BOOK_CHAPTER)

@@ -12,6 +12,34 @@ public class Publication implements BibEntry {
public final static String NEWS_ITEM = "newspaperArticle";
public final static String PROCEEDINGS_PAPER = "conferencePaper";
public final static String DOCUMENT = "document";
// publication types in CrossRef
public final static String MONOGRAPH = "monograph";
Copy link
Member

Choose a reason for hiding this comment

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

we can use BOOK instead

public final static String POSTED_CONTENT = "posted-content";
public final static String COMPONENT = "component";
public final static String EDITED_BOOK = "edited-book";
public final static String PROCEEDINGS_ARTICLE = "proceedings-article";
Copy link
Member

Choose a reason for hiding this comment

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

this is the same as PROCEEDINGS_PAPER I believe

@@ -81,45 +65,105 @@ public void init() {
itemTypeMapping.put(Publication.NEWS_ITEM, ItemType.NEWSPAPER_ARTICLE);
itemTypeMapping.put(Publication.PROCEEDINGS_PAPER, ItemType.CONFERENCE_PAPER);
itemTypeMapping.put(Publication.DOCUMENT, ItemType.DOCUMENT);
itemTypeMapping.put(Publication.MONOGRAPH, ItemType.BOOK);
itemTypeMapping.put(Publication.JOURNAL_ISSUE, ItemType.JOURNAL_ARTICLE);
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong I believe, an issue is not an article. I think we will simply not deal with those and not import issues.

meta.setIssns(issnList);

List<Contributor> contributors = new ArrayList<>();
if(item.getChair() != null) {
Copy link
Member

Choose a reason for hiding this comment

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

?


private ArticleMeta parseArticleMeta(Item item) {
ArticleMeta meta = new ArticleMeta();
meta.setArticleTitle(String.join(", ", item.getTitle()));
Copy link
Member

Choose a reason for hiding this comment

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

?

ref.setReferenceId(itemRef.getKey());
ref.setReferenceString(itemRef.getUnstructured());
ref.setReferenceStringRaw(itemRef.getUnstructured());
references.add(ref);
Copy link
Member

Choose a reason for hiding this comment

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

?

BibEntry nextEntry = new Publication();;

try {
Item item = crossrefService.get(info.getDois().get(currentIndex));
Copy link
Member

Choose a reason for hiding this comment

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

instead of keeping an int around, just get an interator from the dois list and keep that

@@ -13,6 +13,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;

import edu.asu.diging.citesphere.importer.core.model.BibEntry;
import edu.asu.diging.citesphere.importer.core.model.impl.Publication;
Copy link
Member

Choose a reason for hiding this comment

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

is this needed?

@jdamerow jdamerow closed this Aug 1, 2024
Copy link
Member

Choose a reason for hiding this comment

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

I think the abstract import processor should still stay in the impl package, it's part implementation after all.


private ArticleMeta parseArticleMeta(Item item) {
ArticleMeta meta = new ArticleMeta();
meta.setArticleTitle(String.join(", ", item.getTitle()));
Copy link
Member

Choose a reason for hiding this comment

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

this still

ref.setReferenceId(itemRef.getKey());
ref.setReferenceString(itemRef.getUnstructured());
ref.setReferenceStringRaw(itemRef.getUnstructured());
references.add(ref);
Copy link
Member

Choose a reason for hiding this comment

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

this still

@jdamerow jdamerow closed this Sep 4, 2024
@PradnyaC11 PradnyaC11 reopened this Sep 5, 2024
Copy link
Member

@jdamerow jdamerow left a comment

Choose a reason for hiding this comment

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

unaddressed comments

@jdamerow jdamerow closed this Sep 6, 2024
@PradnyaC11 PradnyaC11 reopened this Sep 20, 2024
@jdamerow
Copy link
Member

Looks fine. Once the Citesphere PR is ready to be tested, I'll deploy this.

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.

4 participants