-
Notifications
You must be signed in to change notification settings - Fork 3
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 #271
Open
PradnyaC11
wants to merge
20
commits into
develop
Choose a base branch
from
story/CITE-177
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2b1ce80
[CITE-177] setup and created service to query crossref
jdamerow 557f26f
[CITE-177] front end and backend changes to start crossref import
jdamerow dacc76f
[CITE-177] Clearing the div before fetching the results
PratikGiri 709aa15
[CITE-177] Added group ID to Kafka message
PradnyaC11 4791750
[CITE-177] Updated JobInfoController to add groupId to response
PradnyaC11 0e74de6
[CITE-177] Added test cases for ImportCrossrefJobManager & ImportCros…
PradnyaC11 90e71d2
Merge branch 'develop' into story/CITE-177
PradnyaC11 8faa45c
[CITE-177] Updated crossref.html to show alert
PradnyaC11 8b219a6
Merge branch 'story/CITE-177' of https://github.com/diging/citesphere…
PradnyaC11 836705d
[CITE-177] Addressing the PR comments
PradnyaC11 5495a62
[CITE-177] Changed crossref-connect-version in pom.xml
PradnyaC11 d9ad221
[CITE-177] Addressed PR comments
PradnyaC11 3fffd0e
[CITE-177] Addressing PR comments
PradnyaC11 7324581
[CITE-177] Addressing PR comments
PradnyaC11 fc238b9
[CITE-177] Addressed PR comments
PradnyaC11 4c7f0d9
[CITE-177] Corrected indentation for crossref.html
PradnyaC11 4c8c5ac
Merge branch 'story/CITE-177' of https://github.com/diging/citesphere…
PradnyaC11 ba4a409
[CITE-177] Addressed PR comments
PradnyaC11 baf03ad
[CITE-177] Addressing PR comments
PradnyaC11 9afba45
[CITE-177] Addressed PR comments
PradnyaC11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
citesphere/src/main/java/edu/asu/diging/citesphere/core/model/jobs/IImportCrossrefJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package edu.asu.diging.citesphere.core.model.jobs; | ||
|
||
import java.util.List; | ||
|
||
import edu.asu.diging.citesphere.model.bib.ICitationGroup; | ||
|
||
public interface IImportCrossrefJob extends IJob { | ||
|
||
/** | ||
* Get the DOIs of the resources to be imported from Crossref. | ||
* @return list of resources to be imported | ||
*/ | ||
List<String> getDois(); | ||
|
||
void setDois(List<String> dois); | ||
|
||
void setCitationGroup(String citationGroup); | ||
|
||
String getCitationGroup(); | ||
|
||
ICitationGroup getCitationGroupDetail(); | ||
|
||
void setCitationGroupDetail(ICitationGroup citationGroupDetail); | ||
|
||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...phere/src/main/java/edu/asu/diging/citesphere/core/model/jobs/impl/ImportCrossrefJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package edu.asu.diging.citesphere.core.model.jobs.impl; | ||
|
||
import java.util.List; | ||
|
||
import javax.persistence.ElementCollection; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Transient; | ||
|
||
import edu.asu.diging.citesphere.core.model.jobs.IImportCrossrefJob; | ||
import edu.asu.diging.citesphere.model.bib.ICitationGroup; | ||
|
||
@Entity | ||
public class ImportCrossrefJob extends Job implements IImportCrossrefJob { | ||
|
||
@ElementCollection | ||
private List<String> dois; | ||
private String citationGroup; | ||
@Transient | ||
private ICitationGroup citationGroupDetail; | ||
|
||
/** | ||
* Get the DOIs of the resources to be imported from Crossref. | ||
* @return list of resources to be imported | ||
*/ | ||
@Override | ||
public List<String> getDois() { | ||
return dois; | ||
} | ||
|
||
@Override | ||
public void setDois(List<String> dois) { | ||
this.dois = dois; | ||
} | ||
|
||
@Override | ||
public String getCitationGroup() { | ||
return citationGroup; | ||
} | ||
|
||
@Override | ||
public void setCitationGroup(String citationGroup) { | ||
this.citationGroup = citationGroup; | ||
} | ||
|
||
@Override | ||
public ICitationGroup getCitationGroupDetail() { | ||
return citationGroupDetail; | ||
} | ||
|
||
@Override | ||
public void setCitationGroupDetail(ICitationGroup citationGroupDetail) { | ||
this.citationGroupDetail = citationGroupDetail; | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...main/java/edu/asu/diging/citesphere/core/repository/jobs/ImportCrossrefJobRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package edu.asu.diging.citesphere.core.repository.jobs; | ||
|
||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import edu.asu.diging.citesphere.core.model.jobs.impl.ImportCrossrefJob; | ||
|
||
public interface ImportCrossrefJobRepository extends CrudRepository<ImportCrossrefJob, String> { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...sphere/src/main/java/edu/asu/diging/citesphere/core/service/crossref/CrossrefService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package edu.asu.diging.citesphere.core.service.crossref; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import edu.asu.diging.crossref.exception.RequestFailedException; | ||
import edu.asu.diging.crossref.model.Item; | ||
|
||
public interface CrossrefService { | ||
|
||
List<Item> search(String query, int page) throws RequestFailedException, IOException; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...c/main/java/edu/asu/diging/citesphere/core/service/crossref/impl/CrossrefServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package edu.asu.diging.citesphere.core.service.crossref.impl; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.stereotype.Service; | ||
|
||
import edu.asu.diging.citesphere.core.service.crossref.CrossrefService; | ||
import edu.asu.diging.crossref.exception.RequestFailedException; | ||
import edu.asu.diging.crossref.model.Item; | ||
import edu.asu.diging.crossref.service.CrossrefConfiguration; | ||
import edu.asu.diging.crossref.service.CrossrefWorksService; | ||
import edu.asu.diging.crossref.service.impl.CrossrefWorksServiceImpl; | ||
|
||
@Service | ||
@PropertySource("classpath:config.properties") | ||
public class CrossrefServiceImpl implements CrossrefService { | ||
|
||
@Value("${_crossref_default_pagesize}") | ||
private int defaultPageSize; | ||
|
||
private CrossrefWorksService service; | ||
|
||
@PostConstruct | ||
public void init() { | ||
service = new CrossrefWorksServiceImpl(CrossrefConfiguration.getDefaultConfig()); | ||
} | ||
|
||
|
||
@Override | ||
public List<Item> search(String query, int page) throws RequestFailedException, IOException { | ||
return service.search(query, defaultPageSize, (page-1)*defaultPageSize); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../src/main/java/edu/asu/diging/citesphere/core/service/jobs/IImportCrossrefJobManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package edu.asu.diging.citesphere.core.service.jobs; | ||
|
||
import java.util.List; | ||
|
||
import edu.asu.diging.citesphere.core.exceptions.GroupDoesNotExistException; | ||
import edu.asu.diging.citesphere.core.model.jobs.IImportCrossrefJob; | ||
import edu.asu.diging.citesphere.user.IUser; | ||
|
||
public interface IImportCrossrefJobManager { | ||
|
||
IImportCrossrefJob createJob(IUser user, String groupId, List<String> dois) throws GroupDoesNotExistException; | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
.../main/java/edu/asu/diging/citesphere/core/service/jobs/impl/ImportCrossrefJobManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package edu.asu.diging.citesphere.core.service.jobs.impl; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.List; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.stereotype.Service; | ||
|
||
import edu.asu.diging.citesphere.core.exceptions.GroupDoesNotExistException; | ||
import edu.asu.diging.citesphere.core.exceptions.MessageCreationException; | ||
import edu.asu.diging.citesphere.core.kafka.IKafkaRequestProducer; | ||
import edu.asu.diging.citesphere.core.model.jobs.IImportCrossrefJob; | ||
import edu.asu.diging.citesphere.core.model.jobs.JobStatus; | ||
import edu.asu.diging.citesphere.core.model.jobs.impl.ImportCrossrefJob; | ||
import edu.asu.diging.citesphere.core.model.jobs.impl.JobPhase; | ||
import edu.asu.diging.citesphere.core.repository.jobs.ImportCrossrefJobRepository; | ||
import edu.asu.diging.citesphere.core.service.IGroupManager; | ||
import edu.asu.diging.citesphere.core.service.jobs.IImportCrossrefJobManager; | ||
import edu.asu.diging.citesphere.core.service.jwt.IJwtTokenService; | ||
import edu.asu.diging.citesphere.messages.KafkaTopics; | ||
import edu.asu.diging.citesphere.messages.model.KafkaJobMessage; | ||
import edu.asu.diging.citesphere.model.bib.ICitationGroup; | ||
import edu.asu.diging.citesphere.user.IUser; | ||
|
||
@Service | ||
@Transactional | ||
@PropertySource("classpath:/config.properties") | ||
public class ImportCrossrefJobManager implements IImportCrossrefJobManager { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Value("${_job_page_size}") | ||
private int jobPageSize; | ||
|
||
@Autowired | ||
private IGroupManager groupManager; | ||
|
||
@Autowired | ||
private ImportCrossrefJobRepository jobRepo; | ||
|
||
@Autowired | ||
private IKafkaRequestProducer kafkaProducer; | ||
|
||
@Autowired | ||
private IJwtTokenService tokenService; | ||
|
||
@Override | ||
public IImportCrossrefJob createJob(IUser user, String groupId, List<String> dois) throws GroupDoesNotExistException { | ||
ICitationGroup group = groupManager.getGroup(user, groupId); | ||
if (group == null) { | ||
throw new GroupDoesNotExistException("Group does not exists"); | ||
} | ||
|
||
ImportCrossrefJob job = new ImportCrossrefJob(); | ||
job.setCreatedOn(OffsetDateTime.now()); | ||
job.setUsername(user.getUsername()); | ||
job.setDois(dois); | ||
job.setCitationGroup(groupId); | ||
job.setStatus(JobStatus.PREPARED); | ||
jobRepo.save(job); | ||
|
||
String token = tokenService.generateJobApiToken(job); | ||
try { | ||
kafkaProducer.sendRequest(new KafkaJobMessage(token), KafkaTopics.REFERENCES_IMPORT_CROSSREF_TOPIC); | ||
} catch (MessageCreationException e) { | ||
logger.error("Could not send Kafka message.", e); | ||
job.setStatus(JobStatus.FAILURE); | ||
job.getPhases().add(new JobPhase(JobStatus.FAILURE, e.getMessage())); | ||
jobRepo.save(job); | ||
} | ||
|
||
return job; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's time to clean this up. let's create a map that maps object type to methods that are then called here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still