Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.logic.crawler.StudyRepository;
import org.jabref.logic.crawler.StudyYamlService;
import org.jabref.logic.crawler.StudyYamlParser;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.study.Study;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void execute() {

Study study;
try {
study = new StudyYamlService().parseStudyYamlFile(studyDirectory.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME));
study = new StudyYamlParser().parseStudyYamlFile(studyDirectory.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME));
} catch (IOException e) {
dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), e);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.WorkspacePreferences;
import org.jabref.logic.crawler.StudyRepository;
import org.jabref.logic.crawler.StudyYamlService;
import org.jabref.logic.crawler.StudyYamlParser;
import org.jabref.logic.git.GitHandler;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.ImporterPreferences;
Expand All @@ -30,7 +30,7 @@
import org.jabref.logic.importer.fetcher.SpringerNatureWebFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.study.Study;
import org.jabref.model.study.StudyCatalog;
import org.jabref.model.study.StudyDatabase;
import org.jabref.model.study.StudyQuery;

import org.eclipse.jgit.api.errors.GitAPIException;
Expand Down Expand Up @@ -103,15 +103,15 @@ public ManageStudyDefinitionViewModel(@NonNull Study study,
title.setValue(study.getTitle());
researchQuestions.addAll(study.getResearchQuestions());
queries.addAll(study.getQueries().stream().map(StudyQuery::getQuery).toList());
List<StudyCatalog> studyCatalogs = study.getCatalogs();
List<StudyDatabase> studyDatabases = study.getDatabases();
databases.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences)
.stream()
.map(SearchBasedFetcher::getName)
// The user wants to select specific fetchers
// The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR)
.filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name))
.map(name -> {
boolean enabled = studyCatalogs.contains(new StudyCatalog(name, true));
boolean enabled = studyDatabases.contains(new StudyDatabase(name, true));
return new StudyCatalogItem(name, enabled);
})
.toList());
Expand Down Expand Up @@ -172,7 +172,7 @@ public SlrStudyAndDirectory saveStudy() {
title.getValueSafe(),
researchQuestions,
queries.stream().map(StudyQuery::new).collect(Collectors.toList()),
databases.stream().map(studyDatabaseItem -> new StudyCatalog(studyDatabaseItem.getName(), studyDatabaseItem.isEnabled())).filter(StudyCatalog::isEnabled).collect(Collectors.toList()));
databases.stream().map(studyDatabaseItem -> new StudyDatabase(studyDatabaseItem.getName(), studyDatabaseItem.isEnabled())).filter(StudyDatabase::isEnabled).collect(Collectors.toList()));
Path studyDirectory;
final String studyDirectoryAsString = directory.getValueSafe();
try {
Expand All @@ -185,7 +185,7 @@ public SlrStudyAndDirectory saveStudy() {
}
Path studyDefinitionFile = studyDirectory.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME);
try {
new StudyYamlService().writeStudyYamlFile(study, studyDefinitionFile);
new StudyYamlParser().writeStudyYamlFile(study, studyDefinitionFile);
} catch (IOException e) {
LOGGER.error("Could not write study file {}", studyDefinitionFile, e);
dialogService.notify(Localization.lang("Please enter a valid file path.") +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.logic.crawler.StudyRepository;
import org.jabref.logic.crawler.StudyYamlService;
import org.jabref.logic.crawler.StudyYamlParser;
import org.jabref.logic.git.GitHandler;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.CliPreferences;
Expand Down Expand Up @@ -57,8 +57,8 @@ public StartNewStudyAction(LibraryTabContainer tabContainer,

@Override
protected void crawlPreparation(Path studyRepositoryRoot) throws IOException, GitAPIException {
StudyYamlService studyYamlService = new StudyYamlService();
studyYamlService.writeStudyYamlFile(newStudy, studyRepositoryRoot.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME));
StudyYamlParser studyYAMLParser = new StudyYamlParser();
studyYAMLParser.writeStudyYamlFile(newStudy, studyRepositoryRoot.resolve(StudyRepository.STUDY_DEFINITION_FILE_NAME));

// When execution reaches this point, the user created a new study.
// The GitHandler is already called to initialize the repository with one single commit "Initial commit".
Expand Down
4 changes: 2 additions & 2 deletions jabgui/src/main/java/org/jabref/gui/slr/StudyCatalogItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.model.study.StudyCatalog;
import org.jabref.model.study.StudyDatabase;

import org.jspecify.annotations.NonNull;

/**
* View representation of {@link StudyCatalog}
* View representation of {@link StudyDatabase}
*/
public class StudyCatalogItem {
private final StringProperty name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.model.study.Study;
import org.jabref.model.study.StudyCatalog;
import org.jabref.model.study.StudyDatabase;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -34,7 +34,7 @@ void setUp() {
}

@Test
void emptyStudyConstructorFillsCatalogsCorrectly() {
void emptyStudyConstructorFillsDatabasesCorrectly() {
ManageStudyDefinitionViewModel manageStudyDefinitionViewModel = new ManageStudyDefinitionViewModel(importFormatPreferences, importerPreferences, workspacePreferences, dialogService);
assertEquals(List.of(
new StudyCatalogItem("ACM Portal", true),
Expand Down Expand Up @@ -65,7 +65,7 @@ void emptyStudyConstructorFillsCatalogsCorrectly() {
}

@Test
void studyConstructorFillsCatalogsCorrectly(@TempDir Path tempDir) {
void studyConstructorFillsDatabasesCorrectly(@TempDir Path tempDir) {
ManageStudyDefinitionViewModel manageStudyDefinitionViewModel = getManageStudyDefinitionViewModel(tempDir);
assertEquals(List.of(
new StudyCatalogItem("ACM Portal", true),
Expand Down Expand Up @@ -96,14 +96,14 @@ void studyConstructorFillsCatalogsCorrectly(@TempDir Path tempDir) {
}

private ManageStudyDefinitionViewModel getManageStudyDefinitionViewModel(Path tempDir) {
List<StudyCatalog> catalogs = List.of(
new StudyCatalog("ACM Portal", true));
List<StudyDatabase> databases = List.of(
new StudyDatabase("ACM Portal", true));
Study study = new Study(
List.of("Name"),
"title",
List.of("Q1"),
List.of(),
catalogs
databases
);
return new ManageStudyDefinitionViewModel(
study,
Expand Down
1 change: 0 additions & 1 deletion jablib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
// TODO: Somwewhere we get a warning: unknown enum constant Id.CLASS reason: class file for com.fasterxml.jackson.annotation.JsonTypeInfo$Id not found
// implementation("com.fasterxml.jackson.core:jackson-annotations:2.19.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")

implementation("com.fasterxml:aalto-xml")

Expand Down
1 change: 0 additions & 1 deletion jablib/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,5 @@
requires org.jooq.jool;
requires org.libreoffice.uno;
requires transitive org.jspecify;
requires com.fasterxml.jackson.datatype.jdk8;
// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.importer.SearchBasedFetcher;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.model.study.StudyCatalog;
import org.jabref.model.study.StudyDatabase;

/**
* Converts library entries from the given study into their corresponding fetchers.
*/
class StudyCatalogToFetcherConverter {
private final List<StudyCatalog> libraryEntries;
private final List<StudyDatabase> libraryEntries;
private final ImportFormatPreferences importFormatPreferences;
private final ImporterPreferences importerPreferences;

public StudyCatalogToFetcherConverter(List<StudyCatalog> libraryEntries,
public StudyCatalogToFetcherConverter(List<StudyDatabase> libraryEntries,
ImportFormatPreferences importFormatPreferences,
ImporterPreferences importerPreferences) {
this.libraryEntries = libraryEntries;
Expand All @@ -44,7 +44,7 @@ public List<SearchBasedFetcher> getActiveFetchers() {
* @param libraryEntries List of entries
* @return List of fetcher instances
*/
private List<SearchBasedFetcher> getFetchersFromLibraryEntries(List<StudyCatalog> libraryEntries) {
private List<SearchBasedFetcher> getFetchersFromLibraryEntries(List<StudyDatabase> libraryEntries) {
return libraryEntries.parallelStream()
.map(this::createFetcherFromLibraryEntry)
.filter(Objects::nonNull)
Expand All @@ -54,12 +54,12 @@ private List<SearchBasedFetcher> getFetchersFromLibraryEntries(List<StudyCatalog
/**
* Transforms a library entry into a SearchBasedFetcher instance. This only works if the library entry specifies a supported fetcher.
*
* @param studyCatalog the entry that will be converted
* @param studyDatabase the entry that will be converted
* @return An instance of the fetcher defined by the library entry.
*/
private SearchBasedFetcher createFetcherFromLibraryEntry(StudyCatalog studyCatalog) {
private SearchBasedFetcher createFetcherFromLibraryEntry(StudyDatabase studyDatabase) {
Set<SearchBasedFetcher> searchBasedFetchers = WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences);
String libraryNameFromFetcher = studyCatalog.getName();
String libraryNameFromFetcher = studyDatabase.getName();
return searchBasedFetchers.stream()
.filter(searchBasedFetcher -> searchBasedFetcher.getName().equalsIgnoreCase(libraryNameFromFetcher))
.findAny()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.jabref.model.study.FetchResult;
import org.jabref.model.study.QueryResult;
import org.jabref.model.study.Study;
import org.jabref.model.study.StudyCatalog;
import org.jabref.model.study.StudyDatabase;
import org.jabref.model.study.StudyQuery;
import org.jabref.model.util.FileUpdateMonitor;

Expand Down Expand Up @@ -116,9 +116,9 @@ public StudyRepository(Path pathToRepository,

gitHandler.checkoutBranch(SEARCH_BRANCH);
// If study definition does not exist on this branch or was changed on work branch, copy it from work
boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlService().parseStudyYamlFile(studyDefinitionFile).equals(study));
boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile).equals(study));
if (studyDefinitionDoesNotExistOrChanged) {
new StudyYamlService().writeStudyYamlFile(study, studyDefinitionFile);
new StudyYamlParser().writeStudyYamlFile(study, studyDefinitionFile);
}
setUpRepositoryStructureForQueriesAndFetchers();
gitHandler.createCommitOnCurrentBranch(updateRepositoryStructureMessage, false);
Expand Down Expand Up @@ -175,7 +175,7 @@ public BibDatabaseContext getStudyResultEntries() throws IOException {
* @throws IOException Problem opening the input stream.
*/
private Study parseStudyFile() throws IOException {
return new StudyYamlService().parseStudyYamlFile(studyDefinitionFile);
return new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile);
}

/**
Expand All @@ -196,10 +196,10 @@ public List<String> getSearchQueryStrings() {
* @return List of BibEntries of type Library
* @throws IllegalArgumentException If a transformation from Library entry to LibraryDefinition fails
*/
public List<StudyCatalog> getActiveLibraryEntries() throws IllegalArgumentException {
return study.getCatalogs()
public List<StudyDatabase> getActiveLibraryEntries() throws IllegalArgumentException {
return study.getDatabases()
.parallelStream()
.filter(StudyCatalog::isEnabled)
.filter(StudyDatabase::isEnabled)
.collect(Collectors.toList());
}

Expand Down
100 changes: 0 additions & 100 deletions jablib/src/main/java/org/jabref/logic/crawler/StudyYamlMigrator.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;

/**
* Example use: <code>new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile);</code>
Expand All @@ -22,7 +21,6 @@ public class StudyYamlParser {
*/
public Study parseStudyYamlFile(Path studyYamlFile) throws IOException {
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
yamlMapper.registerModule(new Jdk8Module());
try (InputStream fileInputStream = Files.newInputStream(studyYamlFile)) {
return yamlMapper.readValue(fileInputStream, Study.class);
}
Expand All @@ -34,7 +32,6 @@ public Study parseStudyYamlFile(Path studyYamlFile) throws IOException {
public void writeStudyYamlFile(Study study, Path studyYamlFile) throws IOException {
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES));
yamlMapper.registerModule(new Jdk8Module());
yamlMapper.writeValue(studyYamlFile.toFile(), study);
}
}
Loading
Loading