From f0e66d79b1f4a6aaf36cd2daa1de40a38a8cb540 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 31 Aug 2020 17:38:48 +0200 Subject: [PATCH 01/16] Add ADR-0015 --- docs/adr/0015-allow-model-access-logic.md | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/adr/0015-allow-model-access-logic.md diff --git a/docs/adr/0015-allow-model-access-logic.md b/docs/adr/0015-allow-model-access-logic.md new file mode 100644 index 00000000000..d81b3c7a971 --- /dev/null +++ b/docs/adr/0015-allow-model-access-logic.md @@ -0,0 +1,40 @@ +# Allow org.jabref.model to access org.jabref.logic + +## Context and Problem Statement + +- How to create a maintainable architecture? +- How to split model, logic, and UI + +## Decision Drivers + +* New comers should find the architecture "split" natural +* The architecture should be a help (and not a burden) + +## Considered Options + +* `org.jabref.model` uses `org.jabref.model` (and external libraries) only +* `org.jabref.model` may use `org.jabref.logic` in defined cases +* `org.jabref.model` and `org.jabref.logic` may access each other freely + +## Decision Outcome + +Chosen option: "`org.jabref.model` may use `org.jabref.logic` in defined cases", because comes out best \(see below\). + +## Pros and Cons of the Options + +### `org.jabref.model` uses `org.jabref.model` (and external libraries) only + +* Good, because clear separation of model and logic +* Bad, because this leads to an [Anemic Domain Model](https://martinfowler.com/bliki/AnemicDomainModel.html) + +### `org.jabref.model` may use `org.jabref.logic` in defined cases + +* Good, because model and logic are still separated +* Neutral, because each exception has to be discussed and agreed +* Bad, because new comers have to be informed that there are certain (agreed) exceptions for model to access logic + +### `org.jabref.model` and `org.jabref.logic` may access each other freely + +* Bad, because may lead to spaghetti code +* Bad, because coupling between model and logic is increased +* Bad, because cohesion inside model is decreased From 5e34e42c2f56a3f965bab60b26687b782c81a499 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 31 Aug 2020 21:10:10 +0200 Subject: [PATCH 02/16] Move files --- src/main/java/org/jabref/JabRefGUI.java | 2 +- .../java/org/jabref/cli/AuxCommandLine.java | 4 +- src/main/java/org/jabref/gui/BasePanel.java | 2 +- src/main/java/org/jabref/gui/JabRefFrame.java | 2 +- .../auximport/AuxParserResultViewModel.java | 2 +- .../jabref/gui/auximport/FromAuxDialog.java | 4 +- .../CitationKeyPatternDialog.java | 2 +- .../CitationKeyPatternPanel.java | 4 +- .../gui/cleanup/CleanupPresetPanel.java | 2 +- .../CitationKeyPatternPanel.java | 2 +- .../CitationKeyPatternPanelViewModel.java | 2 +- .../FieldFormatterCleanupsPanel.java | 4 +- .../FieldFormatterCleanupsPanelViewModel.java | 4 +- .../gui/exporter/SaveDatabaseAction.java | 2 +- .../contextmenu/CaseChangeMenu.java | 2 +- .../contextmenu/ConversionMenu.java | 2 +- .../contextmenu/ProtectedTermsMenu.java | 2 +- .../importer/actions/OpenDatabaseAction.java | 2 +- .../LibraryPropertiesDialogViewModel.java | 6 +- .../CitationKeyPatternTabViewModel.java | 2 +- .../shared/PullChangesFromSharedAction.java | 2 +- .../shared/SharedDatabaseLoginDialogView.java | 2 +- .../SharedDatabaseLoginDialogViewModel.java | 6 +- .../gui/shared/SharedDatabaseUIManager.java | 4 +- .../{model => logic}/auxparser/AuxParser.java | 2 +- .../auxparser/AuxParserResult.java | 2 +- .../logic/auxparser/DefaultAuxParser.java | 2 - .../AbstractCitationKeyPattern.java | 59 ++++---- .../citationkeypattern/BracketedPattern.java | 2 +- .../CitationKeyGenerator.java | 2 - .../CitationKeyPatternPreferences.java | 2 - .../DatabaseCitationKeyPattern.java | 2 +- .../GlobalCitationKeyPattern.java | 2 +- .../{model => logic}/cleanup/CleanupJob.java | 2 +- .../jabref/logic/cleanup/CleanupPreset.java | 2 - .../jabref/logic/cleanup/CleanupWorker.java | 1 - .../org/jabref/logic/cleanup/Cleanups.java | 3 - .../cleanup/ConvertToBiblatexCleanup.java | 1 - .../logic/cleanup/ConvertToBibtexCleanup.java | 1 - .../org/jabref/logic/cleanup/DoiCleanup.java | 2 - .../jabref/logic/cleanup/EprintCleanup.java | 1 - .../cleanup/FieldFormatterCleanup.java | 2 +- .../cleanup/FieldFormatterCleanups.java | 64 ++++----- .../logic/cleanup/FileLinksCleanup.java | 1 - .../{model => logic}/cleanup/Formatter.java | 2 +- .../org/jabref/logic/cleanup/ISSNCleanup.java | 1 - .../logic/cleanup/MoveFieldCleanup.java | 1 - .../logic/cleanup/MoveFilesCleanup.java | 1 - .../cleanup/NormalizeNewlinesFormatter.java | 2 +- .../logic/cleanup/RelativePathsCleanup.java | 1 - .../logic/cleanup/RenamePdfCleanup.java | 1 - .../cleanup/UpgradePdfPsToFileCleanup.java | 1 - .../logic/exporter/BibDatabaseWriter.java | 8 +- .../logic/exporter/MetaDataSerializer.java | 6 +- .../jabref/logic/formatter/Formatters.java | 2 +- .../logic/formatter/IdentityFormatter.java | 2 +- .../bibtexfields/AddBracesFormatter.java | 2 +- .../bibtexfields/CleanupUrlFormatter.java | 2 +- .../bibtexfields/ClearFormatter.java | 2 +- .../EscapeAmpersandsFormatter.java | 2 +- .../EscapeUnderscoresFormatter.java | 2 +- .../bibtexfields/HtmlToLatexFormatter.java | 2 +- .../bibtexfields/HtmlToUnicodeFormatter.java | 2 +- .../bibtexfields/LatexCleanupFormatter.java | 2 +- .../bibtexfields/NormalizeDateFormatter.java | 2 +- .../NormalizeEnDashesFormatter.java | 2 +- .../bibtexfields/NormalizeMonthFormatter.java | 2 +- .../bibtexfields/NormalizeNamesFormatter.java | 2 +- .../bibtexfields/NormalizePagesFormatter.java | 2 +- .../OrdinalsToSuperscriptFormatter.java | 2 +- .../bibtexfields/RegexFormatter.java | 2 +- .../bibtexfields/RemoveBracesFormatter.java | 2 +- .../bibtexfields/RemoveDigitsFormatter.java | 2 +- .../RemoveHyphenatedNewlinesFormatter.java | 2 +- .../bibtexfields/RemoveNewlinesFormatter.java | 2 +- .../RemoveRedundantSpacesFormatter.java | 2 +- .../ReplaceTabsBySpaceFormater.java | 2 +- .../bibtexfields/ShortenDOIFormatter.java | 2 +- .../bibtexfields/TrimWhitespaceFormatter.java | 2 +- .../bibtexfields/UnicodeToLatexFormatter.java | 2 +- .../bibtexfields/UnitsToLatexFormatter.java | 2 +- .../casechanger/CapitalizeFormatter.java | 2 +- .../casechanger/LowerCaseFormatter.java | 2 +- .../casechanger/ProtectTermsFormatter.java | 2 +- .../casechanger/SentenceCaseFormatter.java | 2 +- .../casechanger/TitleCaseFormatter.java | 2 +- .../casechanger/UpperCaseFormatter.java | 2 +- .../minifier/MinifyNameListFormatter.java | 2 +- .../formatter/minifier/TruncateFormatter.java | 2 +- .../importer}/AuthorListParser.java | 128 +++++++++--------- .../importer/EntryBasedParserFetcher.java | 2 +- .../logic/importer/IdBasedParserFetcher.java | 2 +- .../logic/importer/IdParserFetcher.java | 2 +- .../importer/SearchBasedParserFetcher.java | 2 +- .../fetcher/AstrophysicsDataSystem.java | 2 +- .../logic/importer/fetcher/CiteSeer.java | 4 +- ...fComputerScienceBibliographiesFetcher.java | 2 +- .../logic/importer/fetcher/CrossRef.java | 2 +- .../logic/importer/fetcher/DBLPFetcher.java | 4 +- .../logic/importer/fetcher/DoiFetcher.java | 2 +- .../importer/fetcher/INSPIREFetcher.java | 2 +- .../fetcher/IsbnViaEbookDeFetcher.java | 2 +- .../logic/importer/fetcher/MathSciNet.java | 2 +- .../importer/fetcher/MedlineFetcher.java | 2 +- .../jabref/logic/importer/fetcher/ZbMATH.java | 2 +- .../layout/LayoutFormatterBasedFormatter.java | 4 +- .../format/LatexToUnicodeFormatter.java | 2 +- .../ReplaceUnicodeLigaturesFormatter.java | 2 +- .../jabref/logic/shared/DBMSConnection.java | 2 - .../shared/DBMSConnectionProperties.java | 2 - .../DBMSConnectionPropertiesBuilder.java | 2 - .../jabref/logic/shared/DBMSProcessor.java | 3 - .../jabref/logic/shared/DBMSSynchronizer.java | 6 +- .../database => logic}/shared/DBMSType.java | 10 +- .../shared/DatabaseConnection.java | 2 +- .../shared/DatabaseConnectionProperties.java | 2 +- .../shared/DatabaseLocation.java | 2 +- .../shared/DatabaseNotSupportedException.java | 5 +- .../shared/DatabaseSynchronizer.java | 2 +- .../jabref/logic/shared/MySQLProcessor.java | 2 - .../jabref/logic/shared/OracleProcessor.java | 1 - .../logic/shared/PostgreSQLProcessor.java | 1 - .../prefs/SharedDatabasePreferences.java | 2 +- .../migrations/PreferencesMigrations.java | 2 +- .../model/database/BibDatabaseContext.java | 4 +- .../org/jabref/model/entry/AuthorList.java | 5 +- .../org/jabref/model/groups/TexGroup.java | 4 +- .../org/jabref/model/metadata/MetaData.java | 8 +- .../jabref/preferences/JabRefPreferences.java | 4 +- .../preferences/PreferencesService.java | 2 +- .../gui/exporter/SaveDatabaseActionTest.java | 4 +- .../jabref/logic/auxparser/AuxParserTest.java | 2 - .../CitationKeyGeneratorTest.java | 1 - .../MakeLabelWithDatabaseTest.java | 2 - .../logic/cleanup/CleanupWorkerTest.java | 2 - .../cleanup/FieldFormatterCleanupTest.java | 1 - .../exporter/BibtexDatabaseWriterTest.java | 10 +- .../exporter/FieldFormatterCleanupsTest.java | 4 +- .../exporter/MetaDataSerializerTest.java | 6 +- .../jabref/logic/formatter/FormatterTest.java | 2 +- .../importer/fileformat/BibtexParserTest.java | 10 +- .../logic/integrity/IntegrityCheckTest.java | 2 +- .../shared/DBMSConnectionPropertiesTest.java | 2 - .../logic/shared/DBMSConnectionTest.java | 1 - .../logic/shared/DBMSProcessorTest.java | 1 - .../logic/shared/DBMSSynchronizerTest.java | 7 +- .../org/jabref/logic/shared/DBMSTypeTest.java | 1 - .../shared/SynchronizationTestSimulator.java | 2 +- .../jabref/logic/shared/TestConnector.java | 1 - .../org/jabref/logic/shared/TestManager.java | 2 - .../model/entry/AuthorListParserTest.java | 2 + 151 files changed, 281 insertions(+), 344 deletions(-) rename src/main/java/org/jabref/{model => logic}/auxparser/AuxParser.java (91%) rename src/main/java/org/jabref/{model => logic}/auxparser/AuxParserResult.java (98%) rename src/main/java/org/jabref/{model/bibtexkeypattern => logic/citationkeypattern}/AbstractCitationKeyPattern.java (85%) rename src/main/java/org/jabref/{model/bibtexkeypattern => logic/citationkeypattern}/DatabaseCitationKeyPattern.java (92%) rename src/main/java/org/jabref/{model/bibtexkeypattern => logic/citationkeypattern}/GlobalCitationKeyPattern.java (92%) rename src/main/java/org/jabref/{model => logic}/cleanup/CleanupJob.java (87%) rename src/main/java/org/jabref/{model => logic}/cleanup/FieldFormatterCleanup.java (99%) rename src/main/java/org/jabref/{model => logic}/cleanup/FieldFormatterCleanups.java (99%) rename src/main/java/org/jabref/{model => logic}/cleanup/Formatter.java (98%) rename src/main/java/org/jabref/{model => logic}/cleanup/NormalizeNewlinesFormatter.java (97%) rename src/main/java/org/jabref/{model/entry => logic/importer}/AuthorListParser.java (92%) rename src/main/java/org/jabref/{model/database => logic}/shared/DBMSType.java (97%) rename src/main/java/org/jabref/{model/database => logic}/shared/DatabaseConnection.java (78%) rename src/main/java/org/jabref/{model/database => logic}/shared/DatabaseConnectionProperties.java (89%) rename src/main/java/org/jabref/{model/database => logic}/shared/DatabaseLocation.java (81%) rename src/main/java/org/jabref/{model/database => logic}/shared/DatabaseNotSupportedException.java (68%) rename src/main/java/org/jabref/{model/database => logic}/shared/DatabaseSynchronizer.java (91%) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index fd228609a3d..ab5d0200fe6 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -23,9 +23,9 @@ import org.jabref.logic.importer.OpenDatabase; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.shared.DatabaseNotSupportedException; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.logic.shared.exception.NotASharedDatabaseException; -import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; import impl.org.controlsfx.skin.DecorationPane; diff --git a/src/main/java/org/jabref/cli/AuxCommandLine.java b/src/main/java/org/jabref/cli/AuxCommandLine.java index 00cb424fb54..61f4c133008 100644 --- a/src/main/java/org/jabref/cli/AuxCommandLine.java +++ b/src/main/java/org/jabref/cli/AuxCommandLine.java @@ -3,9 +3,9 @@ import java.nio.file.Path; import org.jabref.gui.auximport.AuxParserResultViewModel; +import org.jabref.logic.auxparser.AuxParser; +import org.jabref.logic.auxparser.AuxParserResult; import org.jabref.logic.auxparser.DefaultAuxParser; -import org.jabref.model.auxparser.AuxParser; -import org.jabref.model.auxparser.AuxParserResult; import org.jabref.model.database.BibDatabase; import org.jabref.model.strings.StringUtil; diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index eacb550283a..91b401415fb 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -33,6 +33,7 @@ import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.logic.search.SearchQuery; +import org.jabref.logic.shared.DatabaseLocation; import org.jabref.logic.util.UpdateField; import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabase; @@ -40,7 +41,6 @@ import org.jabref.model.database.event.BibDatabaseContextChangedEvent; import org.jabref.model.database.event.EntriesAddedEvent; import org.jabref.model.database.event.EntriesRemovedEvent; -import org.jabref.model.database.shared.DatabaseLocation; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.event.EntriesEventSource; import org.jabref.model.entry.event.EntryChangedEvent; diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index a7590558a1c..43fddebf96f 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -128,13 +128,13 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.WebFetchers; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.shared.DatabaseLocation; import org.jabref.logic.undo.AddUndoableActionEvent; import org.jabref.logic.undo.UndoChangeEvent; import org.jabref.logic.undo.UndoRedoEvent; import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.database.shared.DatabaseLocation; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java b/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java index e30753c8542..d565151eb71 100644 --- a/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java +++ b/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java @@ -1,7 +1,7 @@ package org.jabref.gui.auximport; +import org.jabref.logic.auxparser.AuxParserResult; import org.jabref.logic.l10n.Localization; -import org.jabref.model.auxparser.AuxParserResult; public class AuxParserResultViewModel { diff --git a/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java b/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java index ccbf6c53c29..518b09efc2b 100644 --- a/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java +++ b/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java @@ -16,11 +16,11 @@ import org.jabref.gui.JabRefFrame; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.FileDialogConfiguration; +import org.jabref.logic.auxparser.AuxParser; +import org.jabref.logic.auxparser.AuxParserResult; import org.jabref.logic.auxparser.DefaultAuxParser; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.StandardFileType; -import org.jabref.model.auxparser.AuxParser; -import org.jabref.model.auxparser.AuxParserResult; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.PreferencesService; diff --git a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java index e051ff2dcbb..6639840417b 100644 --- a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java +++ b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java @@ -5,8 +5,8 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.util.BaseDialog; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; import org.jabref.logic.l10n.Localization; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; import org.jabref.model.metadata.MetaData; public class CitationKeyPatternDialog extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java index c9114dc89dd..1f1a705bec3 100644 --- a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java +++ b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java @@ -15,10 +15,10 @@ import org.jabref.gui.actions.ActionFactory; import org.jabref.gui.actions.StandardActions; import org.jabref.gui.help.HelpAction; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; +import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern; import org.jabref.logic.help.HelpFile; import org.jabref.logic.l10n.Localization; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.types.EntryType; diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java index 3ea9fa7c8c7..dd8f2e15793 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java @@ -14,8 +14,8 @@ import org.jabref.gui.commonfxcontrols.FieldFormatterCleanupsPanel; import org.jabref.logic.cleanup.CleanupPreset; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.field.StandardField; import org.jabref.model.metadata.FilePreferences; diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java index 42b28084211..58b10118b8b 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java @@ -13,8 +13,8 @@ import org.jabref.gui.icon.IconTheme; import org.jabref.gui.util.ValueTableCellFactory; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; import org.jabref.logic.l10n.Localization; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.JabRefPreferences; diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java index 6f906b98c38..f36cac91c21 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java @@ -9,8 +9,8 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; import org.jabref.logic.l10n.Localization; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.JabRefPreferences; diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java index d0ded8f1863..ed6df61fce5 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java @@ -18,9 +18,9 @@ import org.jabref.gui.util.FieldsUtil; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.gui.util.ViewModelListCellFactory; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.field.Field; import com.airhacks.afterburner.views.ViewLoader; diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java index 24258baa7ac..2626446a5f9 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java @@ -12,8 +12,8 @@ import org.jabref.Globals; import org.jabref.gui.util.NoSelectionModel; import org.jabref.logic.cleanup.Cleanups; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.Formatter; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.Formatter; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java index 8abfc0dfc18..4f81d5ee975 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java @@ -28,11 +28,11 @@ import org.jabref.logic.exporter.SavePreferences; import org.jabref.logic.l10n.Encodings; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.shared.DatabaseLocation; import org.jabref.logic.shared.prefs.SharedDatabasePreferences; import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.event.ChangePropagation; -import org.jabref.model.database.shared.DatabaseLocation; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.preferences.JabRefPreferences; diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java index 6539516b776..8cb78b2049f 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java @@ -11,10 +11,10 @@ import javafx.scene.control.Tooltip; import org.jabref.Globals; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.Formatters; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; class CaseChangeMenu extends Menu { diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java index 1bf5a1cd5ed..8e6743933b4 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java @@ -6,9 +6,9 @@ import javafx.scene.control.Menu; import javafx.scene.control.Tooltip; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.Formatters; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Menu to show up on right-click in a text field for converting text formats diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java index 85e4f8f46a1..9fb0975b0b9 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java @@ -9,11 +9,11 @@ import javafx.scene.control.TextInputControl; import org.jabref.Globals; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsList; import org.jabref.logic.protectedterms.ProtectedTermsLoader; -import org.jabref.model.cleanup.Formatter; class ProtectedTermsMenu extends Menu { diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java index cf78a65f58d..584ed828960 100644 --- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -27,10 +27,10 @@ import org.jabref.logic.importer.OpenDatabase; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.shared.DatabaseNotSupportedException; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.util.StandardFileType; -import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java index 80a11f70b63..a05c2ef2c7c 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java @@ -18,12 +18,12 @@ import org.jabref.gui.DialogService; import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.logic.cleanup.Cleanups; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.l10n.Encodings; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; +import org.jabref.logic.shared.DatabaseLocation; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; -import org.jabref.model.database.shared.DatabaseLocation; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; import org.jabref.model.entry.field.InternalField; diff --git a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabViewModel.java b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabViewModel.java index e718922687a..324d4cba644 100644 --- a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabViewModel.java @@ -17,7 +17,7 @@ import org.jabref.gui.commonfxcontrols.CitationKeyPatternPanelItemModel; import org.jabref.gui.commonfxcontrols.CitationKeyPatternPanelViewModel; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.preferences.PreferencesService; public class CitationKeyPatternTabViewModel implements PreferenceTabViewModel { diff --git a/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java b/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java index 72bf0e9c129..c3c75e18e2a 100644 --- a/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java +++ b/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java @@ -3,7 +3,7 @@ import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.model.database.shared.DatabaseSynchronizer; +import org.jabref.logic.shared.DatabaseSynchronizer; public class PullChangesFromSharedAction extends SimpleCommand { diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java index fefdbbd68f6..df2562ddd5d 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java @@ -18,7 +18,7 @@ import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.IconValidationDecorator; import org.jabref.logic.l10n.Localization; -import org.jabref.model.database.shared.DBMSType; +import org.jabref.logic.shared.DBMSType; import com.airhacks.afterburner.views.ViewLoader; import com.tobiasdiez.easybind.EasyBind; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 28ab38de947..249af2eea4e 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -32,14 +32,14 @@ import org.jabref.logic.l10n.Localization; import org.jabref.logic.shared.DBMSConnectionProperties; import org.jabref.logic.shared.DBMSConnectionPropertiesBuilder; +import org.jabref.logic.shared.DBMSType; +import org.jabref.logic.shared.DatabaseLocation; +import org.jabref.logic.shared.DatabaseNotSupportedException; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.logic.shared.prefs.SharedDatabasePreferences; import org.jabref.logic.shared.security.Password; import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.database.shared.DBMSType; -import org.jabref.model.database.shared.DatabaseLocation; -import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; import com.tobiasdiez.easybind.EasyBind; diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 41047ab80ec..8737af6ace1 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -22,6 +22,8 @@ import org.jabref.logic.shared.DBMSConnection; import org.jabref.logic.shared.DBMSConnectionProperties; import org.jabref.logic.shared.DBMSSynchronizer; +import org.jabref.logic.shared.DatabaseNotSupportedException; +import org.jabref.logic.shared.DatabaseSynchronizer; import org.jabref.logic.shared.event.ConnectionLostEvent; import org.jabref.logic.shared.event.SharedEntriesNotPresentEvent; import org.jabref.logic.shared.event.UpdateRefusedEvent; @@ -29,8 +31,6 @@ import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.shared.prefs.SharedDatabasePreferences; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.database.shared.DatabaseNotSupportedException; -import org.jabref.model.database.shared.DatabaseSynchronizer; import org.jabref.model.entry.BibEntry; import com.google.common.eventbus.Subscribe; diff --git a/src/main/java/org/jabref/model/auxparser/AuxParser.java b/src/main/java/org/jabref/logic/auxparser/AuxParser.java similarity index 91% rename from src/main/java/org/jabref/model/auxparser/AuxParser.java rename to src/main/java/org/jabref/logic/auxparser/AuxParser.java index ff0c168ba39..0869923e29e 100644 --- a/src/main/java/org/jabref/model/auxparser/AuxParser.java +++ b/src/main/java/org/jabref/logic/auxparser/AuxParser.java @@ -1,4 +1,4 @@ -package org.jabref.model.auxparser; +package org.jabref.logic.auxparser; import java.nio.file.Path; diff --git a/src/main/java/org/jabref/model/auxparser/AuxParserResult.java b/src/main/java/org/jabref/logic/auxparser/AuxParserResult.java similarity index 98% rename from src/main/java/org/jabref/model/auxparser/AuxParserResult.java rename to src/main/java/org/jabref/logic/auxparser/AuxParserResult.java index 28bdbeef840..d9ca4460f74 100644 --- a/src/main/java/org/jabref/model/auxparser/AuxParserResult.java +++ b/src/main/java/org/jabref/logic/auxparser/AuxParserResult.java @@ -1,4 +1,4 @@ -package org.jabref.model.auxparser; +package org.jabref.logic.auxparser; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java index fdc36748b5a..62b22934c01 100644 --- a/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java +++ b/src/main/java/org/jabref/logic/auxparser/DefaultAuxParser.java @@ -11,8 +11,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.model.auxparser.AuxParser; -import org.jabref.model.auxparser.AuxParserResult; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/model/bibtexkeypattern/AbstractCitationKeyPattern.java b/src/main/java/org/jabref/logic/citationkeypattern/AbstractCitationKeyPattern.java similarity index 85% rename from src/main/java/org/jabref/model/bibtexkeypattern/AbstractCitationKeyPattern.java rename to src/main/java/org/jabref/logic/citationkeypattern/AbstractCitationKeyPattern.java index 4674bbb41d7..083aebb736c 100644 --- a/src/main/java/org/jabref/model/bibtexkeypattern/AbstractCitationKeyPattern.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/AbstractCitationKeyPattern.java @@ -1,4 +1,4 @@ -package org.jabref.model.bibtexkeypattern; +package org.jabref.logic.citationkeypattern; import java.util.ArrayList; import java.util.HashMap; @@ -21,6 +21,28 @@ public abstract class AbstractCitationKeyPattern { protected Map> data = new HashMap<>(); + /** + * This method takes a string of the form [field1]spacer[field2]spacer[field3]..., where the fields are the + * (required) fields of a BibTex entry. The string is split into fields and spacers by recognizing the [ and ]. + * + * @param bibtexKeyPattern a String + * @return an ArrayList The first item of the list is a string representation of the key pattern (the + * parameter), the remaining items are the fields + */ + public static List split(String bibtexKeyPattern) { + // A holder for fields of the entry to be used for the key + List fieldList = new ArrayList<>(); + + // Before we do anything, we add the parameter to the ArrayLIst + fieldList.add(bibtexKeyPattern); + + StringTokenizer tok = new StringTokenizer(bibtexKeyPattern, "[]", true); + while (tok.hasMoreTokens()) { + fieldList.add(tok.nextToken()); + } + return fieldList; + } + public void addCitationKeyPattern(EntryType type, String pattern) { data.put(type, AbstractCitationKeyPattern.split(pattern)); } @@ -52,12 +74,10 @@ public int hashCode() { } /** - * Gets an object for a desired key from this CitationKeyPattern or one of it's - * parents (in the case of DatabaseCitationKeyPattern). This method first tries to obtain the object from this - * CitationKeyPattern via the get method of Hashtable. - * If this fails, we try the default.
- * If that fails, we try the parent.
- * If that fails, we return the DEFAULT_LABELPATTERN
+ * Gets an object for a desired key from this CitationKeyPattern or one of it's parents (in the case of + * DatabaseCitationKeyPattern). This method first tries to obtain the object from this CitationKeyPattern via the + * get method of Hashtable. If this fails, we try the default.
If that fails, we try + * the parent.
If that fails, we return the DEFAULT_LABELPATTERN
* * @param entryType a String * @return the list of Strings for the given key. First entry: the complete key @@ -75,31 +95,6 @@ public List getValue(EntryType entryType) { } } return result; - - } - - /** - * This method takes a string of the form [field1]spacer[field2]spacer[field3]..., - * where the fields are the (required) fields of a BibTex entry. The string is split - * into fields and spacers by recognizing the [ and ]. - * - * @param bibtexKeyPattern a String - * @return an ArrayList The first item of the list - * is a string representation of the key pattern (the parameter), - * the remaining items are the fields - */ - public static List split(String bibtexKeyPattern) { - // A holder for fields of the entry to be used for the key - List fieldList = new ArrayList<>(); - - // Before we do anything, we add the parameter to the ArrayLIst - fieldList.add(bibtexKeyPattern); - - StringTokenizer tok = new StringTokenizer(bibtexKeyPattern, "[]", true); - while (tok.hasMoreTokens()) { - fieldList.add(tok.nextToken()); - } - return fieldList; } /** diff --git a/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java index 4254ed940bf..fc02dc44e3e 100644 --- a/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java @@ -15,10 +15,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.Formatters; import org.jabref.logic.formatter.casechanger.Word; import org.jabref.logic.layout.format.RemoveLatexCommandsFormatter; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java b/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java index dd858bfcd46..e070de0ea97 100644 --- a/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java @@ -8,8 +8,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java b/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java index bda74688b06..3017dbaec15 100644 --- a/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java @@ -1,7 +1,5 @@ package org.jabref.logic.citationkeypattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; - public class CitationKeyPatternPreferences { public enum KeySuffix { diff --git a/src/main/java/org/jabref/model/bibtexkeypattern/DatabaseCitationKeyPattern.java b/src/main/java/org/jabref/logic/citationkeypattern/DatabaseCitationKeyPattern.java similarity index 92% rename from src/main/java/org/jabref/model/bibtexkeypattern/DatabaseCitationKeyPattern.java rename to src/main/java/org/jabref/logic/citationkeypattern/DatabaseCitationKeyPattern.java index 5604696914c..33e643d4a4c 100644 --- a/src/main/java/org/jabref/model/bibtexkeypattern/DatabaseCitationKeyPattern.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/DatabaseCitationKeyPattern.java @@ -1,4 +1,4 @@ -package org.jabref.model.bibtexkeypattern; +package org.jabref.logic.citationkeypattern; import java.util.List; diff --git a/src/main/java/org/jabref/model/bibtexkeypattern/GlobalCitationKeyPattern.java b/src/main/java/org/jabref/logic/citationkeypattern/GlobalCitationKeyPattern.java similarity index 92% rename from src/main/java/org/jabref/model/bibtexkeypattern/GlobalCitationKeyPattern.java rename to src/main/java/org/jabref/logic/citationkeypattern/GlobalCitationKeyPattern.java index e85f6696442..38c6b3000b9 100644 --- a/src/main/java/org/jabref/model/bibtexkeypattern/GlobalCitationKeyPattern.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/GlobalCitationKeyPattern.java @@ -1,4 +1,4 @@ -package org.jabref.model.bibtexkeypattern; +package org.jabref.logic.citationkeypattern; import java.util.List; diff --git a/src/main/java/org/jabref/model/cleanup/CleanupJob.java b/src/main/java/org/jabref/logic/cleanup/CleanupJob.java similarity index 87% rename from src/main/java/org/jabref/model/cleanup/CleanupJob.java rename to src/main/java/org/jabref/logic/cleanup/CleanupJob.java index cca52a11fdf..a36f12a2408 100644 --- a/src/main/java/org/jabref/model/cleanup/CleanupJob.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupJob.java @@ -1,4 +1,4 @@ -package org.jabref.model.cleanup; +package org.jabref.logic.cleanup; import java.util.List; diff --git a/src/main/java/org/jabref/logic/cleanup/CleanupPreset.java b/src/main/java/org/jabref/logic/cleanup/CleanupPreset.java index a326dc6eed8..d35d70affdb 100644 --- a/src/main/java/org/jabref/logic/cleanup/CleanupPreset.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupPreset.java @@ -6,8 +6,6 @@ import java.util.Objects; import java.util.Set; -import org.jabref.model.cleanup.FieldFormatterCleanups; - public class CleanupPreset { private final Set activeJobs; diff --git a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java index 1831064a286..2b9a7bdd134 100644 --- a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java @@ -5,7 +5,6 @@ import java.util.Objects; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.FilePreferences; diff --git a/src/main/java/org/jabref/logic/cleanup/Cleanups.java b/src/main/java/org/jabref/logic/cleanup/Cleanups.java index d5bbc705523..726da9eb134 100644 --- a/src/main/java/org/jabref/logic/cleanup/Cleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/Cleanups.java @@ -14,9 +14,6 @@ import org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter; import org.jabref.logic.layout.format.LatexToUnicodeFormatter; import org.jabref.logic.layout.format.ReplaceUnicodeLigaturesFormatter; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.field.FieldFactory; import org.jabref.model.entry.field.InternalField; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanup.java b/src/main/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanup.java index 006bf203f9e..c6e2ab13309 100644 --- a/src/main/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanup.java @@ -6,7 +6,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.Date; import org.jabref.model.entry.EntryConverter; diff --git a/src/main/java/org/jabref/logic/cleanup/ConvertToBibtexCleanup.java b/src/main/java/org/jabref/logic/cleanup/ConvertToBibtexCleanup.java index a58812703ad..20a524cfac8 100644 --- a/src/main/java/org/jabref/logic/cleanup/ConvertToBibtexCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/ConvertToBibtexCleanup.java @@ -5,7 +5,6 @@ import java.util.Map; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.EntryConverter; import org.jabref.model.entry.field.Field; diff --git a/src/main/java/org/jabref/logic/cleanup/DoiCleanup.java b/src/main/java/org/jabref/logic/cleanup/DoiCleanup.java index 8c339b91b54..c830e86ab7d 100644 --- a/src/main/java/org/jabref/logic/cleanup/DoiCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/DoiCleanup.java @@ -7,8 +7,6 @@ import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/cleanup/EprintCleanup.java b/src/main/java/org/jabref/logic/cleanup/EprintCleanup.java index df76bd3e7ac..8f332ae029a 100644 --- a/src/main/java/org/jabref/logic/cleanup/EprintCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/EprintCleanup.java @@ -6,7 +6,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java b/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanup.java similarity index 99% rename from src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java rename to src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanup.java index 1509d1a100e..b02049573c5 100644 --- a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanup.java @@ -1,4 +1,4 @@ -package org.jabref.model.cleanup; +package org.jabref.logic.cleanup; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanups.java b/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanups.java similarity index 99% rename from src/main/java/org/jabref/model/cleanup/FieldFormatterCleanups.java rename to src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanups.java index a63bc577fa2..d480f5bfc9f 100644 --- a/src/main/java/org/jabref/model/cleanup/FieldFormatterCleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanups.java @@ -1,4 +1,4 @@ -package org.jabref.model.cleanup; +package org.jabref.logic.cleanup; import java.util.ArrayList; import java.util.Collections; @@ -27,6 +27,37 @@ public FieldFormatterCleanups(boolean enabled, List actio this.actions = Objects.requireNonNull(actions); } + private static String getMetaDataString(List actionList, String newline) { + // first, group all formatters by the field for which they apply + Map> groupedByField = new TreeMap<>(Comparator.comparing(Field::getName)); + for (FieldFormatterCleanup cleanup : actionList) { + Field key = cleanup.getField(); + + // add new list into the hashmap if needed + if (!groupedByField.containsKey(key)) { + groupedByField.put(key, new ArrayList<>()); + } + + // add the formatter to the map if it is not already there + List formattersForKey = groupedByField.get(key); + if (!formattersForKey.contains(cleanup.getFormatter().getKey())) { + formattersForKey.add(cleanup.getFormatter().getKey()); + } + } + + // convert the contents of the hashmap into the correct serialization + StringBuilder result = new StringBuilder(); + for (Map.Entry> entry : groupedByField.entrySet()) { + result.append(entry.getKey().getName()); + + StringJoiner joiner = new StringJoiner(",", "[", "]" + newline); + entry.getValue().forEach(joiner::add); + result.append(joiner.toString()); + } + + return result.toString(); + } + public boolean isEnabled() { return enabled; } @@ -88,35 +119,4 @@ public List getAsStringList(String newline) { stringRepresentation.add(formatterString); return stringRepresentation; } - - private static String getMetaDataString(List actionList, String newline) { - // first, group all formatters by the field for which they apply - Map> groupedByField = new TreeMap<>(Comparator.comparing(Field::getName)); - for (FieldFormatterCleanup cleanup : actionList) { - Field key = cleanup.getField(); - - // add new list into the hashmap if needed - if (!groupedByField.containsKey(key)) { - groupedByField.put(key, new ArrayList<>()); - } - - // add the formatter to the map if it is not already there - List formattersForKey = groupedByField.get(key); - if (!formattersForKey.contains(cleanup.getFormatter().getKey())) { - formattersForKey.add(cleanup.getFormatter().getKey()); - } - } - - // convert the contents of the hashmap into the correct serialization - StringBuilder result = new StringBuilder(); - for (Map.Entry> entry : groupedByField.entrySet()) { - result.append(entry.getKey().getName()); - - StringJoiner joiner = new StringJoiner(",", "[", "]" + newline); - entry.getValue().forEach(joiner::add); - result.append(joiner.toString()); - } - - return result.toString(); - } } diff --git a/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java b/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java index f863dea0795..a6a1621f10b 100644 --- a/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java @@ -5,7 +5,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/model/cleanup/Formatter.java b/src/main/java/org/jabref/logic/cleanup/Formatter.java similarity index 98% rename from src/main/java/org/jabref/model/cleanup/Formatter.java rename to src/main/java/org/jabref/logic/cleanup/Formatter.java index fa149b720c3..e1e377fdcc3 100644 --- a/src/main/java/org/jabref/model/cleanup/Formatter.java +++ b/src/main/java/org/jabref/logic/cleanup/Formatter.java @@ -1,4 +1,4 @@ -package org.jabref.model.cleanup; +package org.jabref.logic.cleanup; /** * The Formatter is used for a Filter design-pattern. Extending classes have to accept a String and returned a formatted diff --git a/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java b/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java index 261efb404ab..735e408b3a5 100644 --- a/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/ISSNCleanup.java @@ -5,7 +5,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.identifier.ISSN; diff --git a/src/main/java/org/jabref/logic/cleanup/MoveFieldCleanup.java b/src/main/java/org/jabref/logic/cleanup/MoveFieldCleanup.java index 0b5d5744ab2..bdf61432441 100644 --- a/src/main/java/org/jabref/logic/cleanup/MoveFieldCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/MoveFieldCleanup.java @@ -4,7 +4,6 @@ import java.util.Optional; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.util.OptionalUtil; diff --git a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java index 01c64512fa8..56ea9482fb3 100644 --- a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java @@ -8,7 +8,6 @@ import org.jabref.logic.externalfiles.LinkedFileHandler; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/model/cleanup/NormalizeNewlinesFormatter.java b/src/main/java/org/jabref/logic/cleanup/NormalizeNewlinesFormatter.java similarity index 97% rename from src/main/java/org/jabref/model/cleanup/NormalizeNewlinesFormatter.java rename to src/main/java/org/jabref/logic/cleanup/NormalizeNewlinesFormatter.java index 80c620fcd4e..42e59d01928 100644 --- a/src/main/java/org/jabref/model/cleanup/NormalizeNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/cleanup/NormalizeNewlinesFormatter.java @@ -1,4 +1,4 @@ -package org.jabref.model.cleanup; +package org.jabref.logic.cleanup; import java.util.Objects; diff --git a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java index c21c267650a..1ce4b616cbf 100644 --- a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java @@ -9,7 +9,6 @@ import org.jabref.logic.util.io.FileUtil; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java b/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java index a62a616da41..f659655454f 100644 --- a/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java @@ -9,7 +9,6 @@ import org.jabref.logic.externalfiles.LinkedFileHandler; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java b/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java index 188dc80d060..dfe69cdd0ef 100644 --- a/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java @@ -7,7 +7,6 @@ import java.util.Map; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.CleanupJob; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; diff --git a/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java b/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java index 3d28b2cb195..ecf8b0b4b07 100644 --- a/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java +++ b/src/main/java/org/jabref/logic/exporter/BibDatabaseWriter.java @@ -25,12 +25,12 @@ import org.jabref.logic.bibtex.comparator.FieldComparatorStack; import org.jabref.logic.bibtex.comparator.IdComparator; import org.jabref.logic.citationkeypattern.CitationKeyGenerator; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; +import org.jabref.logic.cleanup.NormalizeNewlinesFormatter; import org.jabref.logic.formatter.bibtexfields.TrimWhitespaceFormatter; import org.jabref.model.FieldChange; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; -import org.jabref.model.cleanup.NormalizeNewlinesFormatter; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index befd11f3648..b43af7288f2 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -7,10 +7,10 @@ import java.util.Map; import java.util.TreeMap; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.util.OS; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.entry.types.EntryType; import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.metadata.ContentSelector; diff --git a/src/main/java/org/jabref/logic/formatter/Formatters.java b/src/main/java/org/jabref/logic/formatter/Formatters.java index 405c854a1ec..a97c3a85235 100644 --- a/src/main/java/org/jabref/logic/formatter/Formatters.java +++ b/src/main/java/org/jabref/logic/formatter/Formatters.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.bibtexfields.CleanupUrlFormatter; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.EscapeAmpersandsFormatter; @@ -32,7 +33,6 @@ import org.jabref.logic.formatter.minifier.MinifyNameListFormatter; import org.jabref.logic.formatter.minifier.TruncateFormatter; import org.jabref.logic.layout.format.LatexToUnicodeFormatter; -import org.jabref.model.cleanup.Formatter; public class Formatters { private static final Pattern TRUNCATE_PATTERN = Pattern.compile("\\Atruncate\\d+\\z"); diff --git a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java index 23cf683c283..c5f63de22fa 100644 --- a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * It may seem useless, but is needed as a fallback option diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java index 7c1e03c2215..3d787e1f28b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class AddBracesFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/CleanupUrlFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/CleanupUrlFormatter.java index ac5bbf13b3f..6f480ac40e1 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/CleanupUrlFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/CleanupUrlFormatter.java @@ -5,8 +5,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java index c2ace6a7295..ec54760965b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class ClearFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeAmpersandsFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeAmpersandsFormatter.java index 75f08042b90..e7854336d7a 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeAmpersandsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeAmpersandsFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class EscapeAmpersandsFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java index a0dbd78195b..8a5a3c1a3b4 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class EscapeUnderscoresFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java index a526b637281..33faf96345b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java @@ -5,10 +5,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.layout.LayoutFormatter; import org.jabref.logic.util.strings.HTMLUnicodeConversionMaps; -import org.jabref.model.cleanup.Formatter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java index c5d7dafa01f..5ff4e95bb71 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; import org.jabref.architecture.ApacheCommonsLang3Allowed; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.layout.LayoutFormatter; -import org.jabref.model.cleanup.Formatter; import org.apache.commons.lang3.StringEscapeUtils; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java index 20dc360ba0f..5415156bb7b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java @@ -2,8 +2,8 @@ import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Simplifies LaTeX syntax. {@see org.jabref.logic.layout.format.RemoveLatexCommandsFormatter} for a formatter removing LaTeX commands completely. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java index 2ef6cb3dab3..385b36996ca 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java @@ -2,8 +2,8 @@ import java.util.Optional; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.Date; /** diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java index cb50cc6a10d..41fb5e5cd5d 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.bibtexfields; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class NormalizeEnDashesFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java index 2e71be8ea24..5dcc74847d2 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.Optional; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.Month; public class NormalizeMonthFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java index 8ef592833fa..10383eb983d 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.AuthorList; /** diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java index 7829a0c928b..ff0d6d7028e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java @@ -4,8 +4,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import com.google.common.base.Strings; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java index d5b9506c2bc..ff30823e416 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java @@ -4,8 +4,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * This class transforms ordinal numbers into LaTeX superscripts. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java index 1cd72c31660..0fdb4166e3e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java @@ -6,8 +6,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class RegexFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 11cf48722b1..fdbc4f21d09 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class RemoveBracesFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java index 3f27e81aa8c..124b7dc8907 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class RemoveDigitsFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java index c05786154cc..b31099fcc1a 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Removes all hyphenated line breaks in the string. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java index b4a8dabc04f..8f24a0aee0e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Removes all line breaks in the string. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java index 0a44f6f09fe..6cdd0ff373b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Finds any occurrence of consecutive spaces and replaces it with a single space diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java index f6f5bd5eaa3..3d42f46a68c 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Replaces any tab with a space diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ShortenDOIFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ShortenDOIFormatter.java index e689cc962da..5393210ec7d 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ShortenDOIFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ShortenDOIFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.importer.util.ShortDOIService; import org.jabref.logic.importer.util.ShortDOIServiceException; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.identifier.DOI; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/TrimWhitespaceFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/TrimWhitespaceFormatter.java index 6fefcb15b40..da83f421c63 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/TrimWhitespaceFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/TrimWhitespaceFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Trim all whitespace characters(defined in java) in the string. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java index 41147892971..cc5fc9f350e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java @@ -3,10 +3,10 @@ import java.util.Map; import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.layout.LayoutFormatter; import org.jabref.logic.util.strings.HTMLUnicodeConversionMaps; -import org.jabref.model.cleanup.Formatter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java index 140d8966b83..2f9413f9296 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.strings.StringLengthComparator; -import org.jabref.model.cleanup.Formatter; public class UnitsToLatexFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java index bf225dcf80d..01a7a6d5fc2 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class CapitalizeFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java index 239b35f8712..f608994fcf7 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class LowerCaseFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java index c0b7c81612e..19280858b36 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java @@ -3,10 +3,10 @@ import java.util.List; import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.util.strings.StringLengthComparator; -import org.jabref.model.cleanup.Formatter; public class ProtectTermsFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java index ab6098c44d2..3697f48d653 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class SentenceCaseFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java index 3d0f8e0c819..e70fd3a97fa 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class TitleCaseFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java index 6b743d7acf7..59f7e737f85 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class UpperCaseFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java index 136f8a38a39..0c2ccd0ed5e 100644 --- a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Replaces three or more authors with and others diff --git a/src/main/java/org/jabref/logic/formatter/minifier/TruncateFormatter.java b/src/main/java/org/jabref/logic/formatter/minifier/TruncateFormatter.java index 200fcf3e867..07930cd2064 100644 --- a/src/main/java/org/jabref/logic/formatter/minifier/TruncateFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/minifier/TruncateFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; public class TruncateFormatter extends Formatter { private final int TRUNCATE_AFTER; diff --git a/src/main/java/org/jabref/model/entry/AuthorListParser.java b/src/main/java/org/jabref/logic/importer/AuthorListParser.java similarity index 92% rename from src/main/java/org/jabref/model/entry/AuthorListParser.java rename to src/main/java/org/jabref/logic/importer/AuthorListParser.java index eca4ee598e9..25a11475f56 100644 --- a/src/main/java/org/jabref/model/entry/AuthorListParser.java +++ b/src/main/java/org/jabref/logic/importer/AuthorListParser.java @@ -1,4 +1,4 @@ -package org.jabref.model.entry; +package org.jabref.logic.importer; import java.util.ArrayList; import java.util.Arrays; @@ -10,6 +10,9 @@ import java.util.Optional; import java.util.Set; +import org.jabref.model.entry.Author; +import org.jabref.model.entry.AuthorList; + public class AuthorListParser { // Avoid partition where these values are contained @@ -25,19 +28,9 @@ public class AuthorListParser { private static final int OFFSET_TOKEN_TERM = 2; // Character -- token terminator (either " " or // "-") comma) - - // Token types (returned by getToken procedure) - private enum Token { - EOF, - AND, - COMMA, - WORD - } - // Constant HashSet containing names of TeX special characters private static final Set TEX_NAMES = Set.of( "aa", "ae", "l", "o", "oe", "i", "AA", "AE", "L", "O", "OE", "j"); - /** * the raw bibtex author/editor field */ @@ -64,6 +57,36 @@ private enum Token { */ private boolean tokenCase; + /** + * Builds a new array of strings with stringbuilder. Regarding to the name affixes. + * + * @return New string with correct seperation + */ + private static StringBuilder buildWithAffix(Collection indexArray, List nameList) { + StringBuilder stringBuilder = new StringBuilder(); + // avoidedTimes needs to be increased by the count of avoided terms for correct odd/even calculation + int avoidedTimes = 0; + for (int i = 0; i < nameList.size(); i++) { + if (indexArray.contains(i)) { + // We hit a name affix + stringBuilder.append(nameList.get(i)); + stringBuilder.append(','); + avoidedTimes++; + } else { + stringBuilder.append(nameList.get(i)); + if (((i + avoidedTimes) % 2) == 0) { + // Hit separation between last name and firstname --> comma has to be kept + stringBuilder.append(','); + } else { + // Hit separation between full names (e.g., Ali Babar, M. and Dingsøyr, T.) --> semicolon has to be used + // Will be treated correctly by AuthorList.parse(authors); + stringBuilder.append(';'); + } + } + } + return stringBuilder; + } + /** * Parses the String containing person names and returns a list of person information. * @@ -130,42 +153,10 @@ public AuthorList parse(String listOfNames) { return new AuthorList(authors); } - /** - * Builds a new array of strings with stringbuilder. - * Regarding to the name affixes. - * - * @return New string with correct seperation - */ - private static StringBuilder buildWithAffix(Collection indexArray, List nameList) { - StringBuilder stringBuilder = new StringBuilder(); - // avoidedTimes needs to be increased by the count of avoided terms for correct odd/even calculation - int avoidedTimes = 0; - for (int i = 0; i < nameList.size(); i++) { - if (indexArray.contains(i)) { - // We hit a name affix - stringBuilder.append(nameList.get(i)); - stringBuilder.append(','); - avoidedTimes++; - } else { - stringBuilder.append(nameList.get(i)); - if (((i + avoidedTimes) % 2) == 0) { - // Hit separation between last name and firstname --> comma has to be kept - stringBuilder.append(','); - } else { - // Hit separation between full names (e.g., Ali Babar, M. and Dingsøyr, T.) --> semicolon has to be used - // Will be treated correctly by AuthorList.parse(authors); - stringBuilder.append(';'); - } - } - } - return stringBuilder; - } - /** * Parses one author name and returns preformatted information. * - * @return Preformatted author name; Optional.empty() if author name is - * empty. + * @return Preformatted author name; Optional.empty() if author name is empty. */ private Optional getAuthor() { List tokens = new ArrayList<>(); // initialization @@ -337,13 +328,13 @@ private Optional getAuthor() { } /** - * Concatenates list of tokens from 'tokens' Vector. Tokens are separated by - * spaces or dashes, depending on stored in 'tokens'. Callers always ensure - * that start < end; thus, there exists at least one token to be - * concatenated. + * Concatenates list of tokens from 'tokens' Vector. Tokens are separated by spaces or dashes, depending on stored + * in 'tokens'. Callers always ensure that start < end; thus, there exists at least one token to be concatenated. * - * @param start index of the first token to be concatenated in 'tokens' Vector (always divisible by TOKEN_GROUP_LENGTH). - * @param end index of the first token not to be concatenated in 'tokens' Vector (always divisible by TOKEN_GROUP_LENGTH). + * @param start index of the first token to be concatenated in 'tokens' Vector (always divisible by + * TOKEN_GROUP_LENGTH). + * @param end index of the first token not to be concatenated in 'tokens' Vector (always divisible by + * TOKEN_GROUP_LENGTH). * @param offset offset within token group (used to request concatenation of either full tokens or abbreviation). * @param dotAfter true -- add period after each token, false -- * do not add. @@ -371,27 +362,24 @@ private String concatTokens(List tokens, int start, int end, int offset, /** * Parses the next token. *

- * The string being parsed is stored in global variable original, - * and position which parsing has to start from is stored in global variable + * The string being parsed is stored in global variable original, and position which parsing has to + * start from is stored in global variable * token_end; thus, token_end has to be set - * to 0 before the first invocation. Procedure updates token_end; - * thus, subsequent invocations do not require any additional variable - * settings. + * to 0 before the first invocation. Procedure updates token_end; thus, subsequent invocations do not + * require any additional variable settings. *

- * The type of the token is returned; if it is Token.WORD, - * additional information is given in global variables token_start, + * The type of the token is returned; if it is Token.WORD, additional information is given in global + * variables token_start, * token_end, token_abbr, token_term, - * and token_case; namely: original.substring(token_start,token_end) - * is the text of the token, original.substring(token_start,token_abbr) - * is the token abbreviation, token_term contains token - * terminator (space or dash), and token_case is true, - * if token is upper-case and false if token is lower-case. + * and token_case; namely: original.substring(token_start,token_end) is the text of the + * token, original.substring(token_start,token_abbr) is the token abbreviation, token_term + * contains token terminator (space or dash), and token_case is true, if token is + * upper-case and false if token is lower-case. * * @return Token.EOF -- no more tokens, Token.COMMA -- - * token is comma, Token.AND -- token is the word - * "and" (or "And", or "aND", etc.) or a semicolon, Token.WORD -- - * token is a word; additional information is given in global - * variables token_start, token_end, + * token is comma, Token.AND -- token is the word "and" (or "And", or "aND", etc.) or a semicolon, + * Token.WORD -- token is a word; additional information is given in global variables + * token_start, token_end, * token_abbr, token_term, and * token_case. */ @@ -476,4 +464,12 @@ private Token getToken() { return Token.WORD; } } + + // Token types (returned by getToken procedure) + private enum Token { + EOF, + AND, + COMMA, + WORD + } } diff --git a/src/main/java/org/jabref/logic/importer/EntryBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/EntryBasedParserFetcher.java index 5297d5ad1d2..48348c8f582 100644 --- a/src/main/java/org/jabref/logic/importer/EntryBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/EntryBasedParserFetcher.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Objects; -import org.jabref.model.cleanup.Formatter; +import org.jabref.logic.cleanup.Formatter; import org.jabref.model.entry.BibEntry; /** diff --git a/src/main/java/org/jabref/logic/importer/IdBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/IdBasedParserFetcher.java index 56547e303d0..bf3ba431063 100644 --- a/src/main/java/org/jabref/logic/importer/IdBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/IdBasedParserFetcher.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Optional; -import org.jabref.model.cleanup.Formatter; +import org.jabref.logic.cleanup.Formatter; import org.jabref.model.entry.BibEntry; import org.jabref.model.strings.StringUtil; diff --git a/src/main/java/org/jabref/logic/importer/IdParserFetcher.java b/src/main/java/org/jabref/logic/importer/IdParserFetcher.java index 26d67a8e190..bf4b2bb32b9 100644 --- a/src/main/java/org/jabref/logic/importer/IdParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/IdParserFetcher.java @@ -11,7 +11,7 @@ import java.util.Objects; import java.util.Optional; -import org.jabref.model.cleanup.Formatter; +import org.jabref.logic.cleanup.Formatter; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.identifier.Identifier; diff --git a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java index 1e403a4829d..e8b40c963ad 100644 --- a/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java +++ b/src/main/java/org/jabref/logic/importer/SearchBasedParserFetcher.java @@ -8,8 +8,8 @@ import java.util.Collections; import java.util.List; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.importer.fetcher.ComplexSearchQuery; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.BibEntry; import org.jabref.model.strings.StringUtil; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java b/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java index a1253589ce7..8b9da62ff09 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystem.java @@ -12,6 +12,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.cleanup.MoveFieldCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter; @@ -29,7 +30,6 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.net.URLDownload; import org.jabref.logic.util.BuildInfo; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CiteSeer.java b/src/main/java/org/jabref/logic/importer/fetcher/CiteSeer.java index 77c386a75be..1b51cf04b00 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CiteSeer.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CiteSeer.java @@ -12,6 +12,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter; import org.jabref.logic.formatter.casechanger.TitleCaseFormatter; import org.jabref.logic.help.HelpFile; @@ -20,8 +22,6 @@ import org.jabref.logic.importer.SearchBasedParserFetcher; import org.jabref.logic.importer.fileformat.CoinsParser; import org.jabref.logic.util.OS; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.InternalField; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 0d3b58e2847..3bcbd26a2fb 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.Arrays; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.RemoveDigitsFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveRedundantSpacesFormatter; @@ -13,7 +14,6 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java b/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java index 6eb3d8d07db..fc7603ecd5f 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter; import org.jabref.logic.importer.EntryBasedParserFetcher; @@ -19,7 +20,6 @@ import org.jabref.logic.importer.SearchBasedParserFetcher; import org.jabref.logic.importer.util.JsonReader; import org.jabref.logic.util.strings.StringSimilarity; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DBLPFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DBLPFetcher.java index b8daa91975a..cb223ce061d 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DBLPFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DBLPFetcher.java @@ -8,6 +8,8 @@ import java.util.Optional; import org.jabref.logic.cleanup.DoiCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.help.HelpFile; import org.jabref.logic.importer.FetcherException; @@ -17,8 +19,6 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.layout.LayoutFormatterBasedFormatter; import org.jabref.logic.layout.format.RemoveLatexCommandsFormatter; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.util.DummyFileUpdateMonitor; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java index b22f73f496e..ae1e3ab5961 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import org.jabref.logic.help.HelpFile; @@ -18,7 +19,6 @@ import org.jabref.logic.importer.util.MediaTypes; import org.jabref.logic.l10n.Localization; import org.jabref.logic.net.URLDownload; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.identifier.DOI; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java index 69ef0a86fdc..bc571309d93 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.Optional; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter; import org.jabref.logic.help.HelpFile; @@ -15,7 +16,6 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.importer.util.MediaTypes; import org.jabref.logic.net.URLDownload; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcher.java index fa9c7b74e9a..a83f04e39af 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaEbookDeFetcher.java @@ -4,11 +4,11 @@ import java.net.URISyntaxException; import java.net.URL; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java b/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java index f8085c6afe9..3ff0bd243b8 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java @@ -14,6 +14,7 @@ import java.util.stream.Collectors; import org.jabref.logic.cleanup.DoiCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.cleanup.MoveFieldCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.importer.EntryBasedParserFetcher; @@ -24,7 +25,6 @@ import org.jabref.logic.importer.SearchBasedParserFetcher; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.util.OS; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java index 5b1017b5d52..0050bc1fbf7 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java @@ -19,6 +19,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; @@ -30,7 +31,6 @@ import org.jabref.logic.importer.SearchBasedFetcher; import org.jabref.logic.importer.fileformat.MedlineImporter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java b/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java index 4ef889a7f34..75cd901c667 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java @@ -5,6 +5,7 @@ import java.net.URL; import java.util.Objects; +import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.cleanup.MoveFieldCleanup; import org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter; import org.jabref.logic.importer.FetcherException; @@ -13,7 +14,6 @@ import org.jabref.logic.importer.SearchBasedParserFetcher; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.net.URLDownload; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; diff --git a/src/main/java/org/jabref/logic/layout/LayoutFormatterBasedFormatter.java b/src/main/java/org/jabref/logic/layout/LayoutFormatterBasedFormatter.java index 72762fc8142..e5bc6682a26 100644 --- a/src/main/java/org/jabref/logic/layout/LayoutFormatterBasedFormatter.java +++ b/src/main/java/org/jabref/logic/layout/LayoutFormatterBasedFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.layout; -import org.jabref.model.cleanup.Formatter; +import org.jabref.logic.cleanup.Formatter; /** - * When having to use a LayoutFormatter as Formatter, this class is helpful. One usecase is {@link org.jabref.model.cleanup.FieldFormatterCleanup} + * When having to use a LayoutFormatter as Formatter, this class is helpful. One usecase is {@link org.jabref.logic.cleanup.FieldFormatterCleanup} */ public class LayoutFormatterBasedFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java b/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java index 920b3a67ec7..d0d40370cd3 100644 --- a/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java @@ -1,8 +1,8 @@ package org.jabref.logic.layout.format; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.layout.LayoutFormatter; -import org.jabref.model.cleanup.Formatter; import org.jabref.model.strings.LatexToUnicodeAdapter; /** diff --git a/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java b/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java index 5afa3bc90fc..0824258087b 100644 --- a/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java @@ -4,10 +4,10 @@ import java.util.Map; import java.util.regex.Pattern; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.layout.LayoutFormatter; import org.jabref.logic.util.strings.UnicodeLigaturesMap; -import org.jabref.model.cleanup.Formatter; public class ReplaceUnicodeLigaturesFormatter extends Formatter implements LayoutFormatter { diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnection.java b/src/main/java/org/jabref/logic/shared/DBMSConnection.java index b137a5cd8b6..a37f1d9532d 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSConnection.java +++ b/src/main/java/org/jabref/logic/shared/DBMSConnection.java @@ -8,8 +8,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; -import org.jabref.model.database.shared.DBMSType; -import org.jabref.model.database.shared.DatabaseConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java index e6d6a68ff43..c41c19d6167 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java +++ b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java @@ -8,8 +8,6 @@ import org.jabref.logic.shared.prefs.SharedDatabasePreferences; import org.jabref.logic.shared.security.Password; -import org.jabref.model.database.shared.DBMSType; -import org.jabref.model.database.shared.DatabaseConnectionProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java b/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java index 35e01f6e7f7..3547358dee8 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java +++ b/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java @@ -1,7 +1,5 @@ package org.jabref.logic.shared; -import org.jabref.model.database.shared.DBMSType; - public class DBMSConnectionPropertiesBuilder { private DBMSType type; private String host; diff --git a/src/main/java/org/jabref/logic/shared/DBMSProcessor.java b/src/main/java/org/jabref/logic/shared/DBMSProcessor.java index 08ad86646ba..539ac974e61 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSProcessor.java +++ b/src/main/java/org/jabref/logic/shared/DBMSProcessor.java @@ -19,9 +19,6 @@ import java.util.stream.Collectors; import org.jabref.logic.shared.exception.OfflineLockException; -import org.jabref.model.database.shared.DBMSType; -import org.jabref.model.database.shared.DatabaseConnection; -import org.jabref.model.database.shared.DatabaseConnectionProperties; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.SharedBibEntryData; import org.jabref.model.entry.event.EntriesEventSource; diff --git a/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java b/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java index d46925ec5a3..9aefa1049bb 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java +++ b/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java @@ -10,6 +10,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.logic.exporter.BibDatabaseWriter; import org.jabref.logic.exporter.MetaDataSerializer; import org.jabref.logic.importer.ParseException; @@ -18,15 +19,10 @@ import org.jabref.logic.shared.event.SharedEntriesNotPresentEvent; import org.jabref.logic.shared.event.UpdateRefusedEvent; import org.jabref.logic.shared.exception.OfflineLockException; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.event.EntriesAddedEvent; import org.jabref.model.database.event.EntriesRemovedEvent; -import org.jabref.model.database.shared.DatabaseConnection; -import org.jabref.model.database.shared.DatabaseConnectionProperties; -import org.jabref.model.database.shared.DatabaseNotSupportedException; -import org.jabref.model.database.shared.DatabaseSynchronizer; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.event.EntriesEvent; import org.jabref.model.entry.event.EntriesEventSource; diff --git a/src/main/java/org/jabref/model/database/shared/DBMSType.java b/src/main/java/org/jabref/logic/shared/DBMSType.java similarity index 97% rename from src/main/java/org/jabref/model/database/shared/DBMSType.java rename to src/main/java/org/jabref/logic/shared/DBMSType.java index cdf71b12449..c054f82f7aa 100644 --- a/src/main/java/org/jabref/model/database/shared/DBMSType.java +++ b/src/main/java/org/jabref/logic/shared/DBMSType.java @@ -1,4 +1,4 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; import java.util.Arrays; import java.util.Optional; @@ -24,6 +24,10 @@ private DBMSType(String type, String driverPath, String urlPattern, int defaultP this.defaultPort = defaultPort; } + public static Optional fromString(String typeName) { + return Arrays.stream(DBMSType.values()).filter(dbmsType -> dbmsType.type.equalsIgnoreCase(typeName)).findAny(); + } + @Override public String toString() { return this.type; @@ -49,8 +53,4 @@ public String getUrl(String host, int port, String database) { public int getDefaultPort() { return this.defaultPort; } - - public static Optional fromString(String typeName) { - return Arrays.stream(DBMSType.values()).filter(dbmsType -> dbmsType.type.equalsIgnoreCase(typeName)).findAny(); - } } diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseConnection.java b/src/main/java/org/jabref/logic/shared/DatabaseConnection.java similarity index 78% rename from src/main/java/org/jabref/model/database/shared/DatabaseConnection.java rename to src/main/java/org/jabref/logic/shared/DatabaseConnection.java index 5f1507d3798..265d534a9a3 100644 --- a/src/main/java/org/jabref/model/database/shared/DatabaseConnection.java +++ b/src/main/java/org/jabref/logic/shared/DatabaseConnection.java @@ -1,4 +1,4 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; import java.sql.Connection; diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java b/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java similarity index 89% rename from src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java rename to src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java index 95a2b33cb30..6c3d44313a9 100644 --- a/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java +++ b/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java @@ -1,4 +1,4 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; public interface DatabaseConnectionProperties { diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseLocation.java b/src/main/java/org/jabref/logic/shared/DatabaseLocation.java similarity index 81% rename from src/main/java/org/jabref/model/database/shared/DatabaseLocation.java rename to src/main/java/org/jabref/logic/shared/DatabaseLocation.java index 1356b065c7d..836384bdd1e 100644 --- a/src/main/java/org/jabref/model/database/shared/DatabaseLocation.java +++ b/src/main/java/org/jabref/logic/shared/DatabaseLocation.java @@ -1,4 +1,4 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; import org.jabref.model.database.BibDatabaseContext; diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseNotSupportedException.java b/src/main/java/org/jabref/logic/shared/DatabaseNotSupportedException.java similarity index 68% rename from src/main/java/org/jabref/model/database/shared/DatabaseNotSupportedException.java rename to src/main/java/org/jabref/logic/shared/DatabaseNotSupportedException.java index bd652ae5865..cb7427bd42d 100644 --- a/src/main/java/org/jabref/model/database/shared/DatabaseNotSupportedException.java +++ b/src/main/java/org/jabref/logic/shared/DatabaseNotSupportedException.java @@ -1,7 +1,8 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; /** - * This exception is thrown in case that the SQL database structure is not compatible with the current shared database support mechanisms. + * This exception is thrown in case that the SQL database structure is not compatible with the current shared database + * support mechanisms. */ public class DatabaseNotSupportedException extends Exception { diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseSynchronizer.java b/src/main/java/org/jabref/logic/shared/DatabaseSynchronizer.java similarity index 91% rename from src/main/java/org/jabref/model/database/shared/DatabaseSynchronizer.java rename to src/main/java/org/jabref/logic/shared/DatabaseSynchronizer.java index 5a9906045a6..1d30d31bfc6 100644 --- a/src/main/java/org/jabref/model/database/shared/DatabaseSynchronizer.java +++ b/src/main/java/org/jabref/logic/shared/DatabaseSynchronizer.java @@ -1,4 +1,4 @@ -package org.jabref.model.database.shared; +package org.jabref.logic.shared; import org.jabref.model.entry.BibEntry; diff --git a/src/main/java/org/jabref/logic/shared/MySQLProcessor.java b/src/main/java/org/jabref/logic/shared/MySQLProcessor.java index b4a350e2fee..bdac07e5fa0 100644 --- a/src/main/java/org/jabref/logic/shared/MySQLProcessor.java +++ b/src/main/java/org/jabref/logic/shared/MySQLProcessor.java @@ -2,8 +2,6 @@ import java.sql.SQLException; -import org.jabref.model.database.shared.DatabaseConnection; - /** * Processes all incoming or outgoing bib data to MySQL Database and manages its structure. */ diff --git a/src/main/java/org/jabref/logic/shared/OracleProcessor.java b/src/main/java/org/jabref/logic/shared/OracleProcessor.java index 868f08a2220..9c4a8401525 100644 --- a/src/main/java/org/jabref/logic/shared/OracleProcessor.java +++ b/src/main/java/org/jabref/logic/shared/OracleProcessor.java @@ -10,7 +10,6 @@ import java.util.stream.Collectors; import org.jabref.logic.shared.listener.OracleNotificationListener; -import org.jabref.model.database.shared.DatabaseConnection; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; diff --git a/src/main/java/org/jabref/logic/shared/PostgreSQLProcessor.java b/src/main/java/org/jabref/logic/shared/PostgreSQLProcessor.java index 74ff626405e..6cab1a56ea9 100644 --- a/src/main/java/org/jabref/logic/shared/PostgreSQLProcessor.java +++ b/src/main/java/org/jabref/logic/shared/PostgreSQLProcessor.java @@ -8,7 +8,6 @@ import org.jabref.JabRefExecutorService; import org.jabref.logic.shared.listener.PostgresSQLNotificationListener; -import org.jabref.model.database.shared.DatabaseConnection; import org.jabref.model.entry.BibEntry; import org.postgresql.PGConnection; diff --git a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java index 45346f334a2..d3b6bbb5770 100644 --- a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java +++ b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java @@ -7,8 +7,8 @@ import java.util.prefs.Preferences; import org.jabref.JabRefMain; +import org.jabref.logic.shared.DatabaseConnectionProperties; import org.jabref.logic.shared.security.Password; -import org.jabref.model.database.shared.DatabaseConnectionProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 6d9d81f5d76..e294e7efe02 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -18,7 +18,7 @@ import org.jabref.JabRefMain; import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.EntryTypeFactory; diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index 20d3c85ddbb..8e67b3b262f 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -8,9 +8,9 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.jabref.logic.shared.DatabaseLocation; +import org.jabref.logic.shared.DatabaseSynchronizer; import org.jabref.model.database.event.CoarseChangeFilter; -import org.jabref.model.database.shared.DatabaseLocation; -import org.jabref.model.database.shared.DatabaseSynchronizer; import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; diff --git a/src/main/java/org/jabref/model/entry/AuthorList.java b/src/main/java/org/jabref/model/entry/AuthorList.java index 4f2467da8f9..a5432d3b5cc 100644 --- a/src/main/java/org/jabref/model/entry/AuthorList.java +++ b/src/main/java/org/jabref/model/entry/AuthorList.java @@ -7,6 +7,7 @@ import java.util.WeakHashMap; import java.util.stream.Collectors; +import org.jabref.logic.importer.AuthorListParser; import org.jabref.model.strings.LatexToUnicodeAdapter; /** @@ -142,11 +143,11 @@ public class AuthorList { * * @param authors the list of authors which should underlie this instance */ - protected AuthorList(List authors) { + public AuthorList(List authors) { this.authors = Objects.requireNonNull(authors); } - protected AuthorList(Author author) { + public AuthorList(Author author) { this(Collections.singletonList(author)); } diff --git a/src/main/java/org/jabref/model/groups/TexGroup.java b/src/main/java/org/jabref/model/groups/TexGroup.java index 63e35555352..40923337eb2 100644 --- a/src/main/java/org/jabref/model/groups/TexGroup.java +++ b/src/main/java/org/jabref/model/groups/TexGroup.java @@ -8,8 +8,8 @@ import java.util.Objects; import java.util.Set; -import org.jabref.model.auxparser.AuxParser; -import org.jabref.model.auxparser.AuxParserResult; +import org.jabref.logic.auxparser.AuxParser; +import org.jabref.logic.auxparser.AuxParserResult; import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileHelper; diff --git a/src/main/java/org/jabref/model/metadata/MetaData.java b/src/main/java/org/jabref/model/metadata/MetaData.java index c76442373fc..5d4791549a2 100644 --- a/src/main/java/org/jabref/model/metadata/MetaData.java +++ b/src/main/java/org/jabref/model/metadata/MetaData.java @@ -9,10 +9,10 @@ import java.util.Objects; import java.util.Optional; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanups; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; +import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.database.event.ChangePropagation; import org.jabref.model.entry.field.Field; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index b07ba7fe889..835f799b9d3 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -59,11 +59,13 @@ import org.jabref.logic.bibtex.FieldContentFormatterPreferences; import org.jabref.logic.bibtex.FieldWriterPreferences; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.logic.citationstyle.CitationStyle; import org.jabref.logic.citationstyle.CitationStylePreviewLayout; import org.jabref.logic.cleanup.CleanupPreferences; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.cleanup.Cleanups; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.exporter.ExporterFactory; import org.jabref.logic.exporter.SavePreferences; import org.jabref.logic.exporter.TemplateExporter; @@ -93,8 +95,6 @@ import org.jabref.logic.util.io.AutoLinkPreferences; import org.jabref.logic.util.io.FileHistory; import org.jabref.logic.xmp.XmpPreferences; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.BibEntryTypesManager; diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java index f521b0a7315..190d9602f77 100644 --- a/src/main/java/org/jabref/preferences/PreferencesService.java +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -18,6 +18,7 @@ import org.jabref.logic.bibtex.FieldContentFormatterPreferences; import org.jabref.logic.bibtex.FieldWriterPreferences; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.logic.cleanup.CleanupPreferences; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.exporter.SavePreferences; @@ -35,7 +36,6 @@ import org.jabref.logic.remote.RemotePreferences; import org.jabref.logic.util.io.AutoLinkPreferences; import org.jabref.logic.xmp.XmpPreferences; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.BibEntryTypesManager; diff --git a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java index 3e54d4b06f7..205d778d5ae 100644 --- a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java +++ b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java @@ -18,11 +18,11 @@ import org.jabref.logic.bibtex.FieldContentFormatterPreferences; import org.jabref.logic.bibtex.FieldWriterPreferences; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.logic.exporter.SavePreferences; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.shared.DatabaseLocation; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.database.shared.DatabaseLocation; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java index c2a80b7c7b1..e171fb56ccd 100644 --- a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java @@ -12,8 +12,6 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; -import org.jabref.model.auxparser.AuxParser; -import org.jabref.model.auxparser.AuxParserResult; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; diff --git a/src/test/java/org/jabref/logic/citationkeypattern/CitationKeyGeneratorTest.java b/src/test/java/org/jabref/logic/citationkeypattern/CitationKeyGeneratorTest.java index 60dce65c498..dac2892c109 100644 --- a/src/test/java/org/jabref/logic/citationkeypattern/CitationKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/citationkeypattern/CitationKeyGeneratorTest.java @@ -6,7 +6,6 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.fileformat.BibtexParser; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/citationkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/citationkeypattern/MakeLabelWithDatabaseTest.java index ea55e8de8be..4d08b07d116 100644 --- a/src/test/java/org/jabref/logic/citationkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/citationkeypattern/MakeLabelWithDatabaseTest.java @@ -2,8 +2,6 @@ import java.util.Optional; -import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java index 75cb1c30d2a..75e66d561b6 100644 --- a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java +++ b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java @@ -21,8 +21,6 @@ import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.protectedterms.ProtectedTermsPreferences; import org.jabref.model.FieldChange; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; diff --git a/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java index dc0b5a9958c..27cbd8d322d 100644 --- a/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java @@ -5,7 +5,6 @@ import org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter; import org.jabref.logic.formatter.casechanger.UpperCaseFormatter; -import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.InternalField; diff --git a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java index 5f486594a6d..4c3f3cb8637 100644 --- a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java +++ b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java @@ -11,6 +11,11 @@ import java.util.Collection; import java.util.Collections; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; +import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; import org.jabref.logic.formatter.casechanger.TitleCaseFormatter; import org.jabref.logic.formatter.casechanger.UpperCaseFormatter; @@ -19,11 +24,6 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.util.OS; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; diff --git a/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java b/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java index b6a9b8de6c7..1d63aabf653 100644 --- a/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java +++ b/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java @@ -6,12 +6,12 @@ import java.util.Optional; import org.jabref.logic.cleanup.Cleanups; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.formatter.IdentityFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.StandardEntryType; diff --git a/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java b/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java index 51200ddc429..a36a482bffb 100644 --- a/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java +++ b/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java @@ -6,11 +6,11 @@ import java.util.Map; import java.util.TreeMap; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; import org.jabref.logic.util.OS; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.entry.field.StandardField; import org.jabref.model.metadata.ContentSelector; import org.jabref.model.metadata.MetaData; diff --git a/src/test/java/org/jabref/logic/formatter/FormatterTest.java b/src/test/java/org/jabref/logic/formatter/FormatterTest.java index 412483c5907..d465658add7 100644 --- a/src/test/java/org/jabref/logic/formatter/FormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/FormatterTest.java @@ -5,11 +5,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import org.jabref.logic.formatter.minifier.TruncateFormatter; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.protectedterms.ProtectedTermsPreferences; -import org.jabref.model.cleanup.Formatter; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java index d988b03bce4..c72d834d827 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -11,17 +11,17 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; +import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.exporter.SavePreferences; import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.util.OS; -import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryType; diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java index eeb5f5e5845..06fbc698367 100644 --- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java +++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java @@ -11,8 +11,8 @@ import org.jabref.logic.citationkeypattern.CitationKeyGenerator; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.logic.journals.JournalAbbreviationLoader; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; diff --git a/src/test/java/org/jabref/logic/shared/DBMSConnectionPropertiesTest.java b/src/test/java/org/jabref/logic/shared/DBMSConnectionPropertiesTest.java index 6b8aef0fbf0..5f7e6e983b8 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSConnectionPropertiesTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSConnectionPropertiesTest.java @@ -1,7 +1,5 @@ package org.jabref.logic.shared; -import org.jabref.model.database.shared.DBMSType; - import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java b/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java index c272d604e7f..9187bf81904 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java @@ -2,7 +2,6 @@ import java.sql.SQLException; -import org.jabref.model.database.shared.DBMSType; import org.jabref.testutils.category.DatabaseTest; import org.junit.jupiter.params.ParameterizedTest; diff --git a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java index 653f0a11f3e..aa4c8679a52 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java @@ -12,7 +12,6 @@ import java.util.stream.Collectors; import org.jabref.logic.shared.exception.OfflineLockException; -import org.jabref.model.database.shared.DBMSType; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.InternalField; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/shared/DBMSSynchronizerTest.java b/src/test/java/org/jabref/logic/shared/DBMSSynchronizerTest.java index 2fd54058701..36534eb7da2 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSSynchronizerTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSSynchronizerTest.java @@ -6,15 +6,14 @@ import java.util.List; import java.util.Map; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.exporter.MetaDataSerializer; import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; -import org.jabref.model.database.shared.DBMSType; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.event.EntriesEventSource; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/shared/DBMSTypeTest.java b/src/test/java/org/jabref/logic/shared/DBMSTypeTest.java index 1854ddd41db..9b087519da1 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSTypeTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSTypeTest.java @@ -2,7 +2,6 @@ import java.util.Optional; -import org.jabref.model.database.shared.DBMSType; import org.jabref.testutils.category.DatabaseTest; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/shared/SynchronizationTestSimulator.java b/src/test/java/org/jabref/logic/shared/SynchronizationTestSimulator.java index 6a331d632b6..c439f7c2aa4 100644 --- a/src/test/java/org/jabref/logic/shared/SynchronizationTestSimulator.java +++ b/src/test/java/org/jabref/logic/shared/SynchronizationTestSimulator.java @@ -3,7 +3,7 @@ import java.sql.SQLException; import java.util.List; -import org.jabref.model.bibtexkeypattern.GlobalCitationKeyPattern; +import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; diff --git a/src/test/java/org/jabref/logic/shared/TestConnector.java b/src/test/java/org/jabref/logic/shared/TestConnector.java index f48bb98e422..a2a3f98674c 100644 --- a/src/test/java/org/jabref/logic/shared/TestConnector.java +++ b/src/test/java/org/jabref/logic/shared/TestConnector.java @@ -3,7 +3,6 @@ import java.sql.SQLException; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; -import org.jabref.model.database.shared.DBMSType; import org.jabref.testutils.category.DatabaseTest; /** diff --git a/src/test/java/org/jabref/logic/shared/TestManager.java b/src/test/java/org/jabref/logic/shared/TestManager.java index 55c79812083..48012830211 100644 --- a/src/test/java/org/jabref/logic/shared/TestManager.java +++ b/src/test/java/org/jabref/logic/shared/TestManager.java @@ -3,8 +3,6 @@ import java.sql.SQLException; import java.util.Objects; -import org.jabref.model.database.shared.DBMSType; - /** * This class provides helping methods for database tests. Furthermore it determines database systems which are ready to * be used for tests. diff --git a/src/test/java/org/jabref/model/entry/AuthorListParserTest.java b/src/test/java/org/jabref/model/entry/AuthorListParserTest.java index c2112663f65..8f5b37c67bf 100644 --- a/src/test/java/org/jabref/model/entry/AuthorListParserTest.java +++ b/src/test/java/org/jabref/model/entry/AuthorListParserTest.java @@ -2,6 +2,8 @@ import java.util.stream.Stream; +import org.jabref.logic.importer.AuthorListParser; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; From 901265334fca6061569cbe6bfb48b2979f582ada Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 1 Sep 2020 22:45:49 +0200 Subject: [PATCH 03/16] Move stuff and change tests --- .../architecture/AllowedToUseLogic.java | 10 + .../org/jabref/gui/cleanup/CleanupDialog.java | 2 +- .../gui/cleanup/CleanupPresetPanel.java | 2 +- .../externalfiles/AutoSetFileLinksUtil.java | 4 +- .../ExternalFilesEntryLinker.java | 2 +- .../externalfiletype/ExternalFileTypes.java | 2 +- .../gui/fieldeditors/LinkedFileViewModel.java | 2 +- .../LinkedFilesEditorViewModel.java | 4 +- .../gui/importer/ImportEntriesViewModel.java | 2 +- .../gui/maintable/BibEntryTableViewModel.java | 2 +- .../bibtex}/FileFieldWriter.java | 4 +- .../logic/cleanup/CleanupPreferences.java | 2 +- .../jabref/logic/cleanup/CleanupWorker.java | 2 +- .../logic/cleanup/FileLinksCleanup.java | 2 +- .../logic/cleanup/MoveFilesCleanup.java | 2 +- .../logic/cleanup/RelativePathsCleanup.java | 2 +- .../logic/cleanup/RenamePdfCleanup.java | 2 +- .../cleanup/UpgradePdfPsToFileCleanup.java | 2 +- .../externalfiles/LinkedFileHandler.java | 2 +- .../importer/util}/FileFieldParser.java | 4 +- .../jabref/logic/integrity/FieldCheckers.java | 2 +- .../jabref/logic/integrity/FileChecker.java | 4 +- .../logic/integrity/IntegrityCheck.java | 2 +- .../jabref/logic/layout/format/FileLink.java | 2 +- .../logic/layout/format/WrapFileLinks.java | 2 +- .../logic/pdf/EntryAnnotationImporter.java | 2 +- .../jabref/logic/pdf/FileAnnotationCache.java | 2 +- .../logic/texparser/DefaultLatexParser.java | 1 - .../texparser/LatexParser.java | 4 +- .../logic/util/io/DatabaseFileLookup.java | 2 +- .../model/database/BibDatabaseContext.java | 2 +- .../java/org/jabref/model/entry/BibEntry.java | 2 + .../org/jabref/model/entry/LinkedFile.java | 2 +- .../org/jabref/model/util/FileHelper.java | 2 +- .../FilePreferences.java | 2 +- .../jabref/preferences/JabRefPreferences.java | 1 - .../preferences/PreferencesService.java | 1 - .../architecture/MainArchitectureTests.java | 210 ++++++++++-------- .../MainArchitectureTestsWithArchUnit.java | 71 ------ .../AutoSetFileLinksUtilTest.java | 2 +- .../fieldeditors/LinkedFileViewModelTest.java | 2 +- .../logic/cleanup/CleanupWorkerTest.java | 4 +- .../jabref/logic/cleanup/ISSNCleanupTest.java | 2 +- .../logic/cleanup/MoveFilesCleanupTest.java | 4 +- .../logic/cleanup/RenamePdfCleanupTest.java | 4 +- .../logic/integrity/IntegrityCheckTest.java | 2 +- .../pdf/EntryAnnotationImporterTest.java | 2 +- .../database/BibDatabaseContextTest.java | 2 +- .../model/entry/FileFieldWriterTest.java | 3 + 49 files changed, 187 insertions(+), 212 deletions(-) create mode 100644 src/main/java/org/jabref/architecture/AllowedToUseLogic.java rename src/main/java/org/jabref/{model/entry => logic/bibtex}/FileFieldWriter.java (96%) rename src/main/java/org/jabref/{model/entry => logic/importer/util}/FileFieldParser.java (96%) rename src/main/java/org/jabref/{model => logic}/texparser/LatexParser.java (90%) rename src/main/java/org/jabref/{model/metadata => preferences}/FilePreferences.java (98%) delete mode 100644 src/test/java/org/jabref/architecture/MainArchitectureTestsWithArchUnit.java diff --git a/src/main/java/org/jabref/architecture/AllowedToUseLogic.java b/src/main/java/org/jabref/architecture/AllowedToUseLogic.java new file mode 100644 index 00000000000..ed6be5be7c4 --- /dev/null +++ b/src/main/java/org/jabref/architecture/AllowedToUseLogic.java @@ -0,0 +1,10 @@ +package org.jabref.architecture; + +/** + * Annotation to indicate that this logic class can be used in the model package. + */ +public @interface AllowedToUseLogic { + + // The rationale + String value(); +} diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java index 83d9e810b05..20d3648e940 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java @@ -6,7 +6,7 @@ import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class CleanupDialog extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java index dd8f2e15793..3d94fee18bc 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java @@ -18,7 +18,7 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import com.airhacks.afterburner.views.ViewLoader; diff --git a/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java b/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java index f771d0bed44..70927daa0a6 100644 --- a/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java +++ b/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java @@ -14,17 +14,17 @@ import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.DefaultTaskExecutor; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.util.io.AutoLinkPreferences; import org.jabref.logic.util.io.FileFinder; import org.jabref.logic.util.io.FileFinders; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.util.FileHelper; +import org.jabref.preferences.FilePreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java index 657ece362e5..2c5dfa66571 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java +++ b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java @@ -14,7 +14,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class ExternalFilesEntryLinker { diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 485a050523c..0412157ed38 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -11,7 +11,7 @@ import java.util.TreeSet; import org.jabref.Globals; -import org.jabref.model.entry.FileFieldWriter; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.strings.StringUtil; import org.jabref.model.util.FileHelper; diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index 7e4dafd5f04..29331dabf64 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -45,10 +45,10 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.strings.StringUtil; import org.jabref.model.util.FileHelper; import org.jabref.model.util.OptionalUtil; +import org.jabref.preferences.FilePreferences; import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator; import de.saxsys.mvvmfx.utils.validation.ValidationMessage; diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index 23b8c6b7dc5..8ce3a6da6b2 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -27,14 +27,14 @@ import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.TaskExecutor; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.importer.FulltextFetchers; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.logic.integrity.FieldCheckers; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldParser; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.Field; import org.jabref.model.util.FileHelper; diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java index 2c12cd4cda4..69d71147ded 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java @@ -34,9 +34,9 @@ import org.jabref.model.entry.BibtexString; import org.jabref.model.entry.LinkedFile; import org.jabref.model.groups.GroupTreeNode; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileUpdateMonitor; +import org.jabref.preferences.FilePreferences; import org.jabref.preferences.PreferencesService; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java index 1d368e5496c..75a72b4cdf3 100644 --- a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java +++ b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java @@ -14,9 +14,9 @@ import javafx.beans.value.ObservableValue; import org.jabref.gui.specialfields.SpecialFieldValueViewModel; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldParser; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.OrFields; diff --git a/src/main/java/org/jabref/model/entry/FileFieldWriter.java b/src/main/java/org/jabref/logic/bibtex/FileFieldWriter.java similarity index 96% rename from src/main/java/org/jabref/model/entry/FileFieldWriter.java rename to src/main/java/org/jabref/logic/bibtex/FileFieldWriter.java index 590f377f090..68f59c1e403 100644 --- a/src/main/java/org/jabref/model/entry/FileFieldWriter.java +++ b/src/main/java/org/jabref/logic/bibtex/FileFieldWriter.java @@ -1,10 +1,12 @@ -package org.jabref.model.entry; +package org.jabref.logic.bibtex; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.jabref.model.entry.LinkedFile; + public class FileFieldWriter { private FileFieldWriter() { diff --git a/src/main/java/org/jabref/logic/cleanup/CleanupPreferences.java b/src/main/java/org/jabref/logic/cleanup/CleanupPreferences.java index 5f548e16edf..5a0d5c5271d 100644 --- a/src/main/java/org/jabref/logic/cleanup/CleanupPreferences.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupPreferences.java @@ -1,7 +1,7 @@ package org.jabref.logic.cleanup; import org.jabref.logic.layout.LayoutFormatterPreferences; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class CleanupPreferences { diff --git a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java index 2b9a7bdd134..1fe79ea0258 100644 --- a/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java +++ b/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java @@ -7,7 +7,7 @@ import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class CleanupWorker { diff --git a/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java b/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java index a6a1621f10b..fb72153186f 100644 --- a/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/FileLinksCleanup.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.model.FieldChange; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java index 56ea9482fb3..4fad8316175 100644 --- a/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java @@ -11,8 +11,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.util.OptionalUtil; +import org.jabref.preferences.FilePreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java index 1ce4b616cbf..c7d08c70cf2 100644 --- a/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/RelativePathsCleanup.java @@ -12,7 +12,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class RelativePathsCleanup implements CleanupJob { diff --git a/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java b/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java index f659655454f..c9d04e14596 100644 --- a/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java @@ -12,8 +12,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.util.OptionalUtil; +import org.jabref.preferences.FilePreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java b/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java index dfe69cdd0ef..721cea7d883 100644 --- a/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java +++ b/src/main/java/org/jabref/logic/cleanup/UpgradePdfPsToFileCleanup.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Map; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.model.FieldChange; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java b/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java index 3f1e8bff7c7..ba89018c7bd 100644 --- a/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java +++ b/src/main/java/org/jabref/logic/externalfiles/LinkedFileHandler.java @@ -13,8 +13,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.util.FileHelper; +import org.jabref.preferences.FilePreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/model/entry/FileFieldParser.java b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java similarity index 96% rename from src/main/java/org/jabref/model/entry/FileFieldParser.java rename to src/main/java/org/jabref/logic/importer/util/FileFieldParser.java index 86ac1b2c443..3f00ab57f62 100644 --- a/src/main/java/org/jabref/model/entry/FileFieldParser.java +++ b/src/main/java/org/jabref/logic/importer/util/FileFieldParser.java @@ -1,8 +1,10 @@ -package org.jabref.model.entry; +package org.jabref.logic.importer.util; import java.util.ArrayList; import java.util.List; +import org.jabref.model.entry.LinkedFile; + public class FileFieldParser { public static List parse(String value) { diff --git a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java index de3461050db..e2b27412010 100644 --- a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java +++ b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java @@ -10,7 +10,7 @@ import org.jabref.model.entry.field.FieldFactory; import org.jabref.model.entry.field.InternalField; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; diff --git a/src/main/java/org/jabref/logic/integrity/FileChecker.java b/src/main/java/org/jabref/logic/integrity/FileChecker.java index a4b242744c0..70d4fc6a568 100644 --- a/src/main/java/org/jabref/logic/integrity/FileChecker.java +++ b/src/main/java/org/jabref/logic/integrity/FileChecker.java @@ -6,12 +6,12 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.entry.FileFieldParser; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.strings.StringUtil; +import org.jabref.preferences.FilePreferences; public class FileChecker implements ValueChecker { diff --git a/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java b/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java index 58f38dc674b..d37264b9a24 100644 --- a/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java +++ b/src/main/java/org/jabref/logic/integrity/IntegrityCheck.java @@ -9,7 +9,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; public class IntegrityCheck { diff --git a/src/main/java/org/jabref/logic/layout/format/FileLink.java b/src/main/java/org/jabref/logic/layout/format/FileLink.java index aa3352a83de..384d9544f75 100644 --- a/src/main/java/org/jabref/logic/layout/format/FileLink.java +++ b/src/main/java/org/jabref/logic/layout/format/FileLink.java @@ -5,8 +5,8 @@ import java.util.List; import java.util.stream.Collectors; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.logic.layout.ParamLayoutFormatter; -import org.jabref.model.entry.FileFieldParser; import org.jabref.model.entry.LinkedFile; /** diff --git a/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java b/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java index 8157efa9814..a7c44a2a795 100644 --- a/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java +++ b/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java @@ -8,8 +8,8 @@ import java.util.Map; import java.util.stream.Collectors; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.logic.layout.AbstractParamLayoutFormatter; -import org.jabref.model.entry.FileFieldParser; import org.jabref.model.entry.LinkedFile; import org.jabref.model.util.FileHelper; diff --git a/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java b/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java index 29537801f4a..e6d6c09beb7 100644 --- a/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java +++ b/src/main/java/org/jabref/logic/pdf/EntryAnnotationImporter.java @@ -9,8 +9,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.pdf.FileAnnotation; +import org.jabref.preferences.FilePreferences; /** * Here all PDF files attached to a BibEntry are scanned for annotations using a PdfAnnotationImporter. diff --git a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java index 86a3c29b53f..aa3f43f6fb0 100644 --- a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java +++ b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java @@ -6,8 +6,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.pdf.FileAnnotation; +import org.jabref.preferences.FilePreferences; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; diff --git a/src/main/java/org/jabref/logic/texparser/DefaultLatexParser.java b/src/main/java/org/jabref/logic/texparser/DefaultLatexParser.java index 60972fba036..fd790491fe2 100644 --- a/src/main/java/org/jabref/logic/texparser/DefaultLatexParser.java +++ b/src/main/java/org/jabref/logic/texparser/DefaultLatexParser.java @@ -16,7 +16,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.model.texparser.LatexParser; import org.jabref.model.texparser.LatexParserResult; import org.slf4j.Logger; diff --git a/src/main/java/org/jabref/model/texparser/LatexParser.java b/src/main/java/org/jabref/logic/texparser/LatexParser.java similarity index 90% rename from src/main/java/org/jabref/model/texparser/LatexParser.java rename to src/main/java/org/jabref/logic/texparser/LatexParser.java index 36526ed6ae5..9c64ff9a810 100644 --- a/src/main/java/org/jabref/model/texparser/LatexParser.java +++ b/src/main/java/org/jabref/logic/texparser/LatexParser.java @@ -1,8 +1,10 @@ -package org.jabref.model.texparser; +package org.jabref.logic.texparser; import java.nio.file.Path; import java.util.List; +import org.jabref.model.texparser.LatexParserResult; + /** * Parses a LaTeX file */ diff --git a/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java b/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java index becce9fc6d5..d8e5c0f0265 100644 --- a/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java +++ b/src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java @@ -13,7 +13,7 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; /** * Search class for files.
diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index 8e67b3b262f..e9ba943c93a 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -12,8 +12,8 @@ import org.jabref.logic.shared.DatabaseSynchronizer; import org.jabref.model.database.event.CoarseChangeFilter; import org.jabref.model.entry.BibEntry; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; /** * Represents everything related to a BIB file.

The entries are stored in BibDatabase, the other data in MetaData diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index de6abdc1f8c..b98fbca1639 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -20,6 +20,8 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableMap; +import org.jabref.logic.bibtex.FileFieldWriter; +import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.event.EntriesEventSource; diff --git a/src/main/java/org/jabref/model/entry/LinkedFile.java b/src/main/java/org/jabref/model/entry/LinkedFile.java index d57c2d6b35a..8730ff13171 100644 --- a/src/main/java/org/jabref/model/entry/LinkedFile.java +++ b/src/main/java/org/jabref/model/entry/LinkedFile.java @@ -17,8 +17,8 @@ import javafx.beans.property.StringProperty; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.util.FileHelper; +import org.jabref.preferences.FilePreferences; /** * Represents the link to an external file (e.g. associated PDF file). diff --git a/src/main/java/org/jabref/model/util/FileHelper.java b/src/main/java/org/jabref/model/util/FileHelper.java index 61d7da7d263..f4ee0576cc8 100644 --- a/src/main/java/org/jabref/model/util/FileHelper.java +++ b/src/main/java/org/jabref/model/util/FileHelper.java @@ -12,7 +12,7 @@ import java.util.Optional; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import org.apache.tika.config.TikaConfig; import org.apache.tika.detect.Detector; diff --git a/src/main/java/org/jabref/model/metadata/FilePreferences.java b/src/main/java/org/jabref/preferences/FilePreferences.java similarity index 98% rename from src/main/java/org/jabref/model/metadata/FilePreferences.java rename to src/main/java/org/jabref/preferences/FilePreferences.java index 462fec70cdf..6ce642c02db 100644 --- a/src/main/java/org/jabref/model/metadata/FilePreferences.java +++ b/src/main/java/org/jabref/preferences/FilePreferences.java @@ -1,4 +1,4 @@ -package org.jabref.model.metadata; +package org.jabref.preferences; import java.nio.file.Path; import java.util.Optional; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 835f799b9d3..eddb20d602b 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -104,7 +104,6 @@ import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.EntryType; import org.jabref.model.entry.types.EntryTypeFactory; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.SaveOrderConfig; import org.jabref.model.strings.StringUtil; diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java index 190d9602f77..0180d69f732 100644 --- a/src/main/java/org/jabref/preferences/PreferencesService.java +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -40,7 +40,6 @@ import org.jabref.model.entry.BibEntryType; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.entry.field.Field; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.SaveOrderConfig; public interface PreferencesService { diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 060896c560c..120d56b4eb2 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -1,26 +1,17 @@ package org.jabref.architecture; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class MainArchitectureTests { +import java.nio.file.Paths; + +import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.junit.AnalyzeClasses; +import com.tngtech.archunit.junit.ArchIgnore; +import com.tngtech.archunit.junit.ArchTest; + +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; +import static com.tngtech.archunit.library.Architectures.layeredArchitecture; + +@AnalyzeClasses(packages = "org.jabref") +class MainArchitectureTests { public static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals"; private static final String PACKAGE_JAVAX_SWING = "javax.swing"; @@ -35,79 +26,116 @@ public class MainArchitectureTests { private static final String EXCEPTION_CLASS_JAVA_FX_COLOR = "javafx.scene.paint.Color"; private static final String EXCEPTION_CLASS_JAVA_FX_PAIR = "javafx.util.Pair"; - private static Map> exceptions; - - @BeforeAll - static void setUp() { - exceptions = new HashMap<>(); - // Add exceptions for the architectural test here - // Note that bending the architectural constraints should not be done inconsiderately - - List logicExceptions = new ArrayList<>(4); - logicExceptions.add(EXCEPTION_PACKAGE_JAVA_AWT_GEOM); - logicExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS); - logicExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_BEANS); - logicExceptions.add(EXCEPTION_CLASS_JAVA_FX_COLOR); - logicExceptions.add(EXCEPTION_CLASS_JAVA_FX_PAIR); - - List modelExceptions = new ArrayList<>(4); - modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS); - modelExceptions.add(EXCEPTION_CLASS_JAVA_FX_COLOR); - modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS); - modelExceptions.add(EXCEPTION_PACKAGE_JAVA_FX_BEANS); - - exceptions.put(PACKAGE_ORG_JABREF_LOGIC, logicExceptions); - exceptions.put(PACKAGE_ORG_JABREF_MODEL, modelExceptions); + + @ArchTest + static void doNotUseApacheCommonsLang3(JavaClasses classes) { + noClasses().that().areNotAnnotatedWith(ApacheCommonsLang3Allowed.class) + .should().accessClassesThat().resideInAPackage("org.apache.commons.lang3") + .check(classes); + } + + @ArchTest + public static void doNotUseSwing(JavaClasses classes) { + // This checks for all all Swing packages, but not the UndoManager + noClasses().should().accessClassesThat().resideInAnyPackage("javax.swing", + "javax.swing.border..", + "javax.swing.colorchooser..", + "javax.swing.event..", + "javax.swing.filechooser..", + "javax.swing.plaf..", + "javax.swing.table..", + "javax.swing.text..", + "javax.swing.tree.." + ).check(classes); + } + + @ArchTest + public static void doNotUseJGoodies(JavaClasses classes) { + noClasses().should().accessClassesThat().resideInAPackage("com.jgoodies..") + .check(classes); + } + + @ArchTest + public static void doNotUseGlazedLists(JavaClasses classes) { + noClasses().should().accessClassesThat().resideInAPackage("ca.odell.glazedlists..") + .check(classes); + } + + @ArchTest + public static void doNotUseGlyphsDirectly(JavaClasses classes) { + noClasses().that().resideOutsideOfPackage("org.jabref.gui.icon") + .should().accessClassesThat().resideInAnyPackage("de.jensd.fx.glyphs", "de.jensd.fx.glyphs.materialdesignicons") + .check(classes); } - private static Stream getPackages() { - - return Stream.of( - Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_AWT), - Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVAX_SWING), - Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_FX), - Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_ORG_JABREF_GUI), - Arguments.of(PACKAGE_ORG_JABREF_LOGIC, CLASS_ORG_JABREF_GLOBALS), - - Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_AWT), - Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVAX_SWING), - Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_FX), - Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_GUI), - Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_LOGIC), - Arguments.of(PACKAGE_ORG_JABREF_MODEL, CLASS_ORG_JABREF_GLOBALS)); + @ArchTest + public static void doNotUseAssertJ(JavaClasses classes) { + noClasses().should().accessClassesThat().resideInAPackage("org.assertj..") + .check(classes); } - @ParameterizedTest(name = "{index} -- is {0} independent of {1}?") - @MethodSource("getPackages") - void firstPackageIsIndependentOfSecondPackage(String firstPackage, String secondPackage) throws IOException { - Predicate isExceptionPackage = (s) -> (s.startsWith("import " + secondPackage) - || s.startsWith("import static " + secondPackage)) - && exceptions.getOrDefault(firstPackage, Collections.emptyList()) - .stream() - .noneMatch(exception -> s.startsWith("import " + exception)); - - Predicate isPackage = (s) -> s.startsWith("package " + firstPackage); - - try (Stream pathStream = Files.walk(Path.of("src/main/"))) { - List files = pathStream - .filter(p -> p.toString().endsWith(".java")) - .filter(p -> { - try { - return Files.readAllLines(p, StandardCharsets.UTF_8).stream().anyMatch(isPackage); - } catch (IOException e) { - return false; - } - }) - .filter(p -> { - try { - return Files.readAllLines(p, StandardCharsets.UTF_8).stream().anyMatch(isExceptionPackage); - } catch (IOException e) { - return false; - } - }) - .collect(Collectors.toList()); - - assertEquals(Collections.emptyList(), files, "The following classes are not allowed to depend on " + secondPackage); - } + // "Currently disabled as there is no alternative for the rest of classes who need awt" + @ArchIgnore + @ArchTest + public static void doNotUseJavaAWT(JavaClasses classes) { + noClasses().should().accessClassesThat().resideInAPackage("java.awt..") + .check(classes); } + + @ArchTest + public static void doNotUsePaths(JavaClasses classes) { + noClasses().should() + .accessClassesThat() + .belongToAnyOf(Paths.class) + .check(classes); + } + + @ArchTest + static void respectLayeredArchitecture(JavaClasses classes) { + layeredArchitecture() + .layer("Gui").definedBy("org.jabref.gui") + .layer("Logic").definedBy("org.jabref.logic") + .layer("Model").definedBy("org.jabref.model") + .layer("Cli").definedBy("org.jabref.cli") + .layer("Migrations").definedBy("org.jabref.migrations") + .layer("Preferences").definedBy("org.jabref.preferences") + + .whereLayer("Gui").mayNotBeAccessedByAnyLayer() + .whereLayer("Logic").mayNotBeAccessedByAnyLayer() + .whereLayer("Model").mayNotBeAccessedByAnyLayer() + .whereLayer("Cli").mayNotBeAccessedByAnyLayer() + .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() + .whereLayer("Preferences").mayNotBeAccessedByAnyLayer() + + .check(classes); + } + + @ArchTest + static void doNotUseLogicInModel(JavaClasses classes) { + noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) + .should().dependOnClassesThat().resideInAPackage("org.jabref.logic") + .orShould().beAnnotatedWith(AllowedToUseLogic.class) + .check(classes); + } + + @ArchTest + static void restrictUsagesInModel(JavaClasses classes) { + noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) + .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) + .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) + .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_FX) + .orShould().dependOnClassesThat().haveFullyQualifiedName(CLASS_ORG_JABREF_GLOBALS) + .check(classes); + } + + @ArchTest + static void restrictUsagesInLogic(JavaClasses classes) { + noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC) + .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) + .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) + .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_FX) + .orShould().dependOnClassesThat().haveFullyQualifiedName(CLASS_ORG_JABREF_GLOBALS) + .check(classes); + } + } diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTestsWithArchUnit.java b/src/test/java/org/jabref/architecture/MainArchitectureTestsWithArchUnit.java deleted file mode 100644 index 0ac0430258b..00000000000 --- a/src/test/java/org/jabref/architecture/MainArchitectureTestsWithArchUnit.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.jabref.architecture; - -import java.nio.file.Paths; - -import com.tngtech.archunit.core.domain.JavaClasses; -import com.tngtech.archunit.junit.AnalyzeClasses; -import com.tngtech.archunit.junit.ArchIgnore; -import com.tngtech.archunit.junit.ArchTest; - -import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; - -@AnalyzeClasses(packages = "org.jabref") -class MainArchitectureTestsWithArchUnit { - - @ArchTest - static void doNotUseApacheCommonsLang3(JavaClasses classes) { - noClasses().that().areNotAnnotatedWith(ApacheCommonsLang3Allowed.class) - .should().accessClassesThat().resideInAPackage("org.apache.commons.lang3") - .check(classes); - } - - @ArchTest - public static void doNotUseSwing(JavaClasses classes) { - // This checks for all all Swing packages, but not the UndoManager - noClasses().should().accessClassesThat().resideInAnyPackage("javax.swing", - "javax.swing.border..", - "javax.swing.colorchooser..", - "javax.swing.event..", - "javax.swing.filechooser..", - "javax.swing.plaf..", - "javax.swing.table..", - "javax.swing.text..", - "javax.swing.tree.." - ).check(classes); - } - - @ArchTest - public static void doNotUseJGoodies(JavaClasses classes) { - noClasses().should().accessClassesThat().resideInAPackage("com.jgoodies..").check(classes); - } - - @ArchTest - public static void doNotUseGlazedLists(JavaClasses classes) { - noClasses().should().accessClassesThat().resideInAPackage("ca.odell.glazedlists..").check(classes); - } - - @ArchTest - public static void doNotUseGlyphsDirectly(JavaClasses classes) { - noClasses().that().resideOutsideOfPackage("org.jabref.gui.icon").should().accessClassesThat().resideInAnyPackage("de.jensd.fx.glyphs", "de.jensd.fx.glyphs.materialdesignicons").check(classes); - } - - @ArchTest - public static void doNotUseAssertJ(JavaClasses classes) { - noClasses().should().accessClassesThat().resideInAPackage("org.assertj..").check(classes); - } - - // "Currently disabled as there is no alternative for the rest of classes who need awt" - @ArchIgnore - @ArchTest - public static void doNotUseJavaAWT(JavaClasses classes) { - noClasses().should().accessClassesThat().resideInAPackage("java.awt..").check(classes); - } - - @ArchTest - public static void doNotUsePaths(JavaClasses classes) { - noClasses().should() - .accessClassesThat() - .belongToAnyOf(Paths.class) - .check(classes); - } -} diff --git a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java index a56080661ed..d5395987ab7 100644 --- a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java +++ b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java @@ -12,7 +12,7 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.types.StandardEntryType; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java index bac8b112273..63c9c3eb8bb 100644 --- a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java +++ b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java @@ -22,7 +22,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java index 75e66d561b6..ba2f98a708a 100644 --- a/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java +++ b/src/test/java/org/jabref/logic/cleanup/CleanupWorkerTest.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter; import org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter; @@ -24,12 +25,11 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java index f9d1b76d484..daf131f728e 100644 --- a/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java @@ -6,7 +6,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java index 8c792b7dd85..8a5add56731 100644 --- a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java @@ -8,15 +8,15 @@ import java.util.List; import java.util.Optional; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java index 136423d9a3c..1b67a2b227a 100644 --- a/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/RenamePdfCleanupTest.java @@ -6,14 +6,14 @@ import java.util.Arrays; import java.util.Optional; +import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.FileFieldWriter; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java index 06fbc698367..384f4d39f1a 100644 --- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java +++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java @@ -23,8 +23,8 @@ import org.jabref.model.entry.types.EntryType; import org.jabref.model.entry.types.IEEETranEntryType; import org.jabref.model.entry.types.StandardEntryType; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; diff --git a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java index 08c6e29d12b..8c2f8bb91b6 100644 --- a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java +++ b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java @@ -8,8 +8,8 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.pdf.FileAnnotation; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java b/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java index a714a5e672a..f73ae5c2408 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java @@ -6,8 +6,8 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.types.IEEETranEntryType; -import org.jabref.model.metadata.FilePreferences; import org.jabref.model.metadata.MetaData; +import org.jabref.preferences.FilePreferences; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java b/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java index 84aba43fcbf..f2a78184c8c 100644 --- a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java +++ b/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java @@ -3,6 +3,9 @@ import java.util.Arrays; import java.util.Collections; +import org.jabref.logic.bibtex.FileFieldWriter; +import org.jabref.logic.importer.util.FileFieldParser; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; From 1ae6c3011340884cbebbb915af4218cc1b641a24 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 1 Sep 2020 23:43:12 +0200 Subject: [PATCH 04/16] Fix build --- .../org/jabref/gui/preferences/LinkedFilesTabViewModel.java | 2 +- src/main/java/org/jabref/preferences/JabRefPreferences.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java index 0a40a7f6679..66539b9f197 100644 --- a/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java @@ -17,7 +17,7 @@ import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.io.AutoLinkPreferences; -import org.jabref.model.metadata.FilePreferences; +import org.jabref.preferences.FilePreferences; import org.jabref.preferences.PreferencesService; import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index fe4a21061a7..c6e4788abab 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -64,6 +64,7 @@ import org.jabref.logic.cleanup.CleanupPreferences; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.cleanup.Cleanups; +import org.jabref.logic.cleanup.FieldFormatterCleanups; import org.jabref.logic.exporter.SavePreferences; import org.jabref.logic.exporter.TemplateExporter; import org.jabref.logic.importer.ImportFormatPreferences; From fe8c493b9fcfba023b23526a6e23e629ed6a7929 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 00:01:03 +0200 Subject: [PATCH 05/16] Fix a few tests --- .../jabref/gui/importer/ImportEntriesViewModel.java | 7 ------- src/main/resources/l10n/JabRef_en.properties | 5 ++--- .../org/jabref/architecture/MainArchitectureTests.java | 10 +++++----- .../org/jabref/logic/database/DatabaseMergerTest.java | 3 +-- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java index a533e1819c4..8e37e5d40a8 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java @@ -29,19 +29,12 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.groups.GroupTreeNode; -import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.FilePreferences; import org.jabref.preferences.PreferencesService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ImportEntriesViewModel extends AbstractViewModel { - private static final Logger LOGGER = LoggerFactory.getLogger(ImportEntriesViewModel.class); - private final StringProperty message; private final TaskExecutor taskExecutor; private final BibDatabaseContext databaseContext; diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 4c841c5ed24..3551bc90f32 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2269,6 +2269,5 @@ Replaces\ consecutive\ spaces\ with\ a\ single\ space\ in\ the\ field\ content.= Remove\ digits=Remove digits Removes\ digits.=Removes digits. The\ query\ cannot\ contain\ a\ year\ and\ year-range\ field.=The query cannot contain a year and year-range field. -This\ query\ uses\ an\ unsupported\ syntax.=This query uses an unsupported syntax. -This\ search\ contains\ entries\ that\ match\ all\ specified\ terms.=This search contains entries that match all specified terms. - +This\ query\ uses\ unsupported\ fields.=This query uses unsupported fields. +This\ query\ uses\ unsupported\ syntax.=This query uses unsupported syntax. diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 120d56b4eb2..a2fc33de8db 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -28,7 +28,7 @@ class MainArchitectureTests { @ArchTest - static void doNotUseApacheCommonsLang3(JavaClasses classes) { + public static void doNotUseApacheCommonsLang3(JavaClasses classes) { noClasses().that().areNotAnnotatedWith(ApacheCommonsLang3Allowed.class) .should().accessClassesThat().resideInAPackage("org.apache.commons.lang3") .check(classes); @@ -91,7 +91,7 @@ public static void doNotUsePaths(JavaClasses classes) { } @ArchTest - static void respectLayeredArchitecture(JavaClasses classes) { + public static void respectLayeredArchitecture(JavaClasses classes) { layeredArchitecture() .layer("Gui").definedBy("org.jabref.gui") .layer("Logic").definedBy("org.jabref.logic") @@ -111,7 +111,7 @@ static void respectLayeredArchitecture(JavaClasses classes) { } @ArchTest - static void doNotUseLogicInModel(JavaClasses classes) { + public static void doNotUseLogicInModel(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) .should().dependOnClassesThat().resideInAPackage("org.jabref.logic") .orShould().beAnnotatedWith(AllowedToUseLogic.class) @@ -119,7 +119,7 @@ static void doNotUseLogicInModel(JavaClasses classes) { } @ArchTest - static void restrictUsagesInModel(JavaClasses classes) { + public static void restrictUsagesInModel(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) @@ -129,7 +129,7 @@ static void restrictUsagesInModel(JavaClasses classes) { } @ArchTest - static void restrictUsagesInLogic(JavaClasses classes) { + public static void restrictUsagesInLogic(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC) .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) diff --git a/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java b/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java index fa56cb9324d..1574506d300 100644 --- a/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java +++ b/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java @@ -15,7 +15,6 @@ import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.metadata.ContentSelector; import org.jabref.model.metadata.MetaData; -import org.jabref.preferences.JabRefPreferences; import org.junit.jupiter.api.Test; @@ -144,7 +143,7 @@ void mergeMetaDataWithAllEntriesGroup() { List expectedContentSelectors = List.of(new ContentSelector(StandardField.AUTHOR, List.of("Test Author")), new ContentSelector(StandardField.TITLE, List.of("Test Title"))); - GroupTreeNode expectedImportedGroupNode = new GroupTreeNode(new ExplicitGroup("Imported unknown", GroupHierarchyType.INDEPENDENT, JabRefPreferences.getInstance().getKeywordDelimiter())); + GroupTreeNode expectedImportedGroupNode = new GroupTreeNode(new ExplicitGroup("Imported unknown", GroupHierarchyType.INDEPENDENT, ';')); new DatabaseMerger().mergeMetaData(target, other, "unknown", List.of()); From 15449959e4eb60719673342f9b3b73cd6baece82 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 00:17:58 +0200 Subject: [PATCH 06/16] Improve test file --- .../jabref/architecture/MainArchitectureTests.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index a2fc33de8db..59ba4df9ad4 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -20,12 +20,6 @@ class MainArchitectureTests { private static final String PACKAGE_ORG_JABREF_GUI = "org.jabref.gui"; private static final String PACKAGE_ORG_JABREF_LOGIC = "org.jabref.logic"; private static final String PACKAGE_ORG_JABREF_MODEL = "org.jabref.model"; - private static final String EXCEPTION_PACKAGE_JAVA_AWT_GEOM = "java.awt.geom"; - private static final String EXCEPTION_PACKAGE_JAVA_FX_COLLECTIONS = "javafx.collections"; - private static final String EXCEPTION_PACKAGE_JAVA_FX_BEANS = "javafx.beans"; - private static final String EXCEPTION_CLASS_JAVA_FX_COLOR = "javafx.scene.paint.Color"; - private static final String EXCEPTION_CLASS_JAVA_FX_PAIR = "javafx.util.Pair"; - @ArchTest public static void doNotUseApacheCommonsLang3(JavaClasses classes) { @@ -93,9 +87,9 @@ public static void doNotUsePaths(JavaClasses classes) { @ArchTest public static void respectLayeredArchitecture(JavaClasses classes) { layeredArchitecture() - .layer("Gui").definedBy("org.jabref.gui") - .layer("Logic").definedBy("org.jabref.logic") - .layer("Model").definedBy("org.jabref.model") + .layer("Gui").definedBy(PACKAGE_ORG_JABREF_GUI) + .layer("Logic").definedBy(PACKAGE_ORG_JABREF_LOGIC) + .layer("Model").definedBy(PACKAGE_ORG_JABREF_MODEL) .layer("Cli").definedBy("org.jabref.cli") .layer("Migrations").definedBy("org.jabref.migrations") .layer("Preferences").definedBy("org.jabref.preferences") @@ -113,7 +107,7 @@ public static void respectLayeredArchitecture(JavaClasses classes) { @ArchTest public static void doNotUseLogicInModel(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) - .should().dependOnClassesThat().resideInAPackage("org.jabref.logic") + .should().dependOnClassesThat().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC) .orShould().beAnnotatedWith(AllowedToUseLogic.class) .check(classes); } From 8606d277419346bbcd00ac317568dbb69d892e0e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 00:22:32 +0200 Subject: [PATCH 07/16] Reenable archunit --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index fb234d6534e..66d4f501691 100644 --- a/build.gradle +++ b/build.gradle @@ -210,6 +210,7 @@ dependencies { testImplementation 'org.mockito:mockito-core:3.5.7' testImplementation 'org.xmlunit:xmlunit-core:2.7.0' testImplementation 'org.xmlunit:xmlunit-matchers:2.7.0' + testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.14.1' testImplementation 'com.tngtech.archunit:archunit-junit5-api:0.14.1' testImplementation "org.testfx:testfx-core:4.0.17-alpha-SNAPSHOT" testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT" From 5ed5e75a7b4ea61670ea51e00f01f9dbd5340d54 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 00:44:50 +0200 Subject: [PATCH 08/16] Reenable archunit by running tests on classpath --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 66d4f501691..57dc45c7c0b 100644 --- a/build.gradle +++ b/build.gradle @@ -443,6 +443,10 @@ test { excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest' } + moduleOptions { + runOnClasspath = true + } + testLogging { // set options for log level LIFECYCLE // for debugging tests: add "STANDARD_OUT", "STANDARD_ERROR" From 38246c123da26f8333c047c855fcd641b2a0465f Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 00:45:09 +0200 Subject: [PATCH 09/16] Fix markdown lint --- docs/adr/0015-allow-model-access-logic.md | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/adr/0015-allow-model-access-logic.md b/docs/adr/0015-allow-model-access-logic.md index d81b3c7a971..5567fe198d4 100644 --- a/docs/adr/0015-allow-model-access-logic.md +++ b/docs/adr/0015-allow-model-access-logic.md @@ -3,18 +3,18 @@ ## Context and Problem Statement - How to create a maintainable architecture? -- How to split model, logic, and UI +- How to split model, logic, and UI ## Decision Drivers -* New comers should find the architecture "split" natural -* The architecture should be a help (and not a burden) +- New comers should find the architecture "split" natural +- The architecture should be a help (and not a burden) ## Considered Options -* `org.jabref.model` uses `org.jabref.model` (and external libraries) only -* `org.jabref.model` may use `org.jabref.logic` in defined cases -* `org.jabref.model` and `org.jabref.logic` may access each other freely +- `org.jabref.model` uses `org.jabref.model` (and external libraries) only +- `org.jabref.model` may use `org.jabref.logic` in defined cases +- `org.jabref.model` and `org.jabref.logic` may access each other freely ## Decision Outcome @@ -24,17 +24,17 @@ Chosen option: "`org.jabref.model` may use `org.jabref.logic` in defined cases", ### `org.jabref.model` uses `org.jabref.model` (and external libraries) only -* Good, because clear separation of model and logic -* Bad, because this leads to an [Anemic Domain Model](https://martinfowler.com/bliki/AnemicDomainModel.html) +- Good, because clear separation of model and logic +- Bad, because this leads to an [Anemic Domain Model](https://martinfowler.com/bliki/AnemicDomainModel.html) ### `org.jabref.model` may use `org.jabref.logic` in defined cases -* Good, because model and logic are still separated -* Neutral, because each exception has to be discussed and agreed -* Bad, because new comers have to be informed that there are certain (agreed) exceptions for model to access logic +- Good, because model and logic are still separated +- Neutral, because each exception has to be discussed and agreed +- Bad, because new comers have to be informed that there are certain (agreed) exceptions for model to access logic ### `org.jabref.model` and `org.jabref.logic` may access each other freely -* Bad, because may lead to spaghetti code -* Bad, because coupling between model and logic is increased -* Bad, because cohesion inside model is decreased +- Bad, because may lead to spaghetti code +- Bad, because coupling between model and logic is increased +- Bad, because cohesion inside model is decreased From 478bedb858d73f8d819f98e593f323a9d9ed0563 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 01:07:46 +0200 Subject: [PATCH 10/16] Fix tests and refine arch tests --- build.gradle | 1 + .../gui/fieldeditors/AbstractEditorViewModel.java | 5 ++--- src/main/resources/l10n/JabRef_en.properties | 4 ---- .../org/jabref/architecture/MainArchitectureTests.java | 10 ++++++---- .../org/jabref/logic/importer/OpenDatabaseTest.java | 4 +--- .../importer/fileformat/MedlinePlainImporterTest.java | 10 +++------- .../logic/protectedterms/ProtectedTermsLoaderTest.java | 9 ++++----- 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 57dc45c7c0b..564f51b7288 100644 --- a/build.gradle +++ b/build.gradle @@ -444,6 +444,7 @@ test { } moduleOptions { + // TODO: Remove this as soon as archunit is modularized runOnClasspath = true } diff --git a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java index 064b8808bdf..f806fe76ded 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java @@ -23,7 +23,6 @@ import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator; import de.saxsys.mvvmfx.utils.validation.ValidationMessage; import de.saxsys.mvvmfx.utils.validation.Validator; -import org.apache.commons.lang3.StringUtils; import org.controlsfx.control.textfield.AutoCompletionBinding; public class AbstractEditorViewModel extends AbstractViewModel { @@ -66,10 +65,10 @@ public void bindToEntry(BibEntry entry) { newValue -> { if (newValue != null) { // Controlsfx uses hardcoded \n for multiline fields, but JabRef stores them in OS Newlines format - String oldValue = entry.getField(field).map(value -> value.replace(OS.NEWLINE, "\n")).orElse(null); + String oldValue = entry.getField(field).map(value -> value.replace(OS.NEWLINE, "\n").trim()).orElse(null); // Autosave and save action trigger the entry editor to reload the fields, so we have to // check for changes here, otherwise the cursor position is annoyingly reset every few seconds - if (!(newValue.trim()).equals(StringUtils.trim(oldValue))) { + if (!(newValue.trim()).equals(oldValue)) { entry.setField(field, newValue); UndoManager undoManager = JabRefGUI.getMainFrame().getUndoManager(); undoManager.addEdit(new UndoableFieldChange(entry, field, oldValue, newValue)); diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 3551bc90f32..1cba3e23645 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -213,8 +213,6 @@ Default=Default Default\ encoding=Default encoding -Default\ grouping\ field=Default grouping field - Downloading=Downloading Execute\ default\ action\ in\ dialog=Execute default action in dialog @@ -262,8 +260,6 @@ Duplicate\ string\ name=Duplicate string name Duplicates\ found=Duplicates found -Dynamic\ groups=Dynamic groups - Dynamically\ group\ entries\ by\ a\ free-form\ search\ expression=Dynamically group entries by a free-form search expression Dynamically\ group\ entries\ by\ searching\ a\ field\ for\ a\ keyword=Dynamically group entries by searching a field for a keyword diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 59ba4df9ad4..7f1c2a7bf70 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -81,6 +81,7 @@ public static void doNotUsePaths(JavaClasses classes) { noClasses().should() .accessClassesThat() .belongToAnyOf(Paths.class) + .because("Path.of(...) should be used instead") .check(classes); } @@ -93,13 +94,14 @@ public static void respectLayeredArchitecture(JavaClasses classes) { .layer("Cli").definedBy("org.jabref.cli") .layer("Migrations").definedBy("org.jabref.migrations") .layer("Preferences").definedBy("org.jabref.preferences") + .layer("Styletester").definedBy("org.jabref.styletester") - .whereLayer("Gui").mayNotBeAccessedByAnyLayer() - .whereLayer("Logic").mayNotBeAccessedByAnyLayer() - .whereLayer("Model").mayNotBeAccessedByAnyLayer() + .whereLayer("Gui").mayOnlyBeAccessedByLayers("Gui") + .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui") + .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations") .whereLayer("Cli").mayNotBeAccessedByAnyLayer() .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() - .whereLayer("Preferences").mayNotBeAccessedByAnyLayer() + .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester") // TODO: Remove logic here .check(classes); } diff --git a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java index 10df92ac461..1bff22bbb94 100644 --- a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java +++ b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java @@ -5,7 +5,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Collection; import java.util.Optional; @@ -39,8 +38,7 @@ class OpenDatabaseTest { bibWrongHeader = Path.of(OpenDatabaseTest.class.getResource("wrong-header.bib").toURI()); bibHeader = Path.of(OpenDatabaseTest.class.getResource("encoding-header.bib").toURI()); bibHeaderAndSignature = Path.of(OpenDatabaseTest.class.getResource("jabref-header.bib").toURI()); - bibEncodingWithoutNewline = Paths - .get(OpenDatabaseTest.class.getResource("encodingWithoutNewline.bib").toURI()); + bibEncodingWithoutNewline = Path.of(OpenDatabaseTest.class.getResource("encodingWithoutNewline.bib").toURI()); } @BeforeEach diff --git a/src/test/java/org/jabref/logic/importer/fileformat/MedlinePlainImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/MedlinePlainImporterTest.java index 1a13480a197..fe48bcb86ca 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/MedlinePlainImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/MedlinePlainImporterTest.java @@ -7,7 +7,6 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -77,8 +76,7 @@ void doesNotRecognizeEmptyFiles() throws IOException { @Test void testImportMultipleEntriesInSingleFile() throws IOException, URISyntaxException { - Path inputFile = Paths - .get(MedlinePlainImporter.class.getResource("MedlinePlainImporterTestMultipleEntries.txt").toURI()); + Path inputFile = Path.of(MedlinePlainImporter.class.getResource("MedlinePlainImporterTestMultipleEntries.txt").toURI()); List entries = importer.importDatabase(inputFile, StandardCharsets.UTF_8).getDatabase() .getEntries(); @@ -198,8 +196,7 @@ void testWithNbibFile() throws IOException, URISyntaxException { @Test void testWithMultipleEntries() throws IOException, URISyntaxException { - Path file = Paths - .get(MedlinePlainImporter.class.getResource("MedlinePlainImporterStringOutOfBounds.txt").toURI()); + Path file = Path.of(MedlinePlainImporter.class.getResource("MedlinePlainImporterStringOutOfBounds.txt").toURI()); List entries = importer.importDatabase(file, Charsets.UTF_8).getDatabase().getEntries(); @@ -208,8 +205,7 @@ void testWithMultipleEntries() throws IOException, URISyntaxException { @Test void testInvalidFormat() throws URISyntaxException, IOException { - Path file = Paths - .get(MedlinePlainImporter.class.getResource("MedlinePlainImporterTestInvalidFormat.xml").toURI()); + Path file = Path.of(MedlinePlainImporter.class.getResource("MedlinePlainImporterTestInvalidFormat.xml").toURI()); List entries = importer.importDatabase(file, Charsets.UTF_8).getDatabase().getEntries(); diff --git a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java index 98bf2c7a709..65efb43cb4a 100644 --- a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java +++ b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java @@ -4,7 +4,6 @@ import java.io.FileNotFoundException; import java.net.URISyntaxException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -47,10 +46,10 @@ void testGetProtectedTerms() throws URISyntaxException { @Test void testAddProtectedTermsListFromFile() throws URISyntaxException { - String filename = Paths - .get(ProtectedTermsLoader.class.getResource("/org/jabref/logic/protectedterms/namedterms.terms") - .toURI()) - .toFile().getPath(); + String filename = Path.of( + ProtectedTermsLoader.class.getResource("/org/jabref/logic/protectedterms/namedterms.terms") + .toURI()) + .toFile().getPath(); assertEquals(ProtectedTermsLoader.getInternalLists().size(), loader.getProtectedTermsLists().size()); loader.addProtectedTermsListFromFile(filename, false); assertEquals(ProtectedTermsLoader.getInternalLists().size() + 1, loader.getProtectedTermsLists().size()); From 93947811b8f335cb924a1e87231660f6da0c72ca Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 01:24:02 +0200 Subject: [PATCH 11/16] Refine arch tests --- .../architecture/MainArchitectureTests.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 7f1c2a7bf70..fc777a544b8 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -14,12 +14,12 @@ class MainArchitectureTests { public static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals"; - private static final String PACKAGE_JAVAX_SWING = "javax.swing"; - private static final String PACKAGE_JAVA_AWT = "java.awt"; - private static final String PACKAGE_JAVA_FX = "javafx"; - private static final String PACKAGE_ORG_JABREF_GUI = "org.jabref.gui"; - private static final String PACKAGE_ORG_JABREF_LOGIC = "org.jabref.logic"; - private static final String PACKAGE_ORG_JABREF_MODEL = "org.jabref.model"; + private static final String PACKAGE_JAVAX_SWING = "javax.swing.."; + private static final String PACKAGE_JAVA_AWT = "java.awt.."; + private static final String PACKAGE_JAVA_FX = "javafx.."; + private static final String PACKAGE_ORG_JABREF_GUI = "org.jabref.gui.."; + private static final String PACKAGE_ORG_JABREF_LOGIC = "org.jabref.logic.."; + private static final String PACKAGE_ORG_JABREF_MODEL = "org.jabref.model.."; @ArchTest public static void doNotUseApacheCommonsLang3(JavaClasses classes) { @@ -91,17 +91,17 @@ public static void respectLayeredArchitecture(JavaClasses classes) { .layer("Gui").definedBy(PACKAGE_ORG_JABREF_GUI) .layer("Logic").definedBy(PACKAGE_ORG_JABREF_LOGIC) .layer("Model").definedBy(PACKAGE_ORG_JABREF_MODEL) - .layer("Cli").definedBy("org.jabref.cli") - .layer("Migrations").definedBy("org.jabref.migrations") - .layer("Preferences").definedBy("org.jabref.preferences") - .layer("Styletester").definedBy("org.jabref.styletester") + .layer("Cli").definedBy("org.jabref.cli..") + .layer("Migrations").definedBy("org.jabref.migrations..") + .layer("Preferences").definedBy("org.jabref.preferences..") + .layer("Styletester").definedBy("org.jabref.styletester..") - .whereLayer("Gui").mayOnlyBeAccessedByLayers("Gui") + .whereLayer("Gui").mayNotBeAccessedByAnyLayer() .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui") .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations") .whereLayer("Cli").mayNotBeAccessedByAnyLayer() .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() - .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester") // TODO: Remove logic here + .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester", "Cli") // TODO: Remove logic here .check(classes); } From 4fa7016b976faaf4c58df2d4a1174b363fa74bb4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 01:36:56 +0200 Subject: [PATCH 12/16] Refine arch tests --- .../java/org/jabref/architecture/MainArchitectureTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index fc777a544b8..8e10e5a0d8b 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -96,9 +96,9 @@ public static void respectLayeredArchitecture(JavaClasses classes) { .layer("Preferences").definedBy("org.jabref.preferences..") .layer("Styletester").definedBy("org.jabref.styletester..") - .whereLayer("Gui").mayNotBeAccessedByAnyLayer() - .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui") - .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations") + .whereLayer("Gui").mayOnlyBeAccessedByLayers("Preferences") // TODO: Remove preferences here + .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui", "Cli", "Model", "Migrations") + .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Cli") .whereLayer("Cli").mayNotBeAccessedByAnyLayer() .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester", "Cli") // TODO: Remove logic here From 687a06cb83a7ef4cc179b2c9867b439b7d76ebeb Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 01:45:53 +0200 Subject: [PATCH 13/16] Refine arch tests --- .../java/org/jabref/architecture/MainArchitectureTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 8e10e5a0d8b..8edc1ef6231 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -97,8 +97,8 @@ public static void respectLayeredArchitecture(JavaClasses classes) { .layer("Styletester").definedBy("org.jabref.styletester..") .whereLayer("Gui").mayOnlyBeAccessedByLayers("Preferences") // TODO: Remove preferences here - .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui", "Cli", "Model", "Migrations") - .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Cli") + .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui", "Cli", "Model", "Migrations", "Preferences") + .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Cli", "Preferences") .whereLayer("Cli").mayNotBeAccessedByAnyLayer() .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester", "Cli") // TODO: Remove logic here From b4b1a5e5ed9da6dcf83137be1664910e5edb74de Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 12:30:11 +0200 Subject: [PATCH 14/16] Refine arch tests and fix issues --- .../jabref/logic/autosaveandbackup/AutosaveManager.java | 2 +- .../jabref/logic/autosaveandbackup/BackupManager.java | 2 +- .../event => logic/util}/CoarseChangeFilter.java | 4 ++-- .../org/jabref/model/database/BibDatabaseContext.java | 4 +++- src/main/java/org/jabref/model/entry/AuthorList.java | 2 ++ src/main/java/org/jabref/model/entry/BibEntry.java | 2 ++ src/main/java/org/jabref/model/groups/TexGroup.java | 2 ++ src/main/java/org/jabref/model/metadata/MetaData.java | 2 ++ .../org/jabref/architecture/MainArchitectureTests.java | 9 ++++----- .../entry => logic/bibtex}/FileFieldWriterTest.java | 4 ++-- .../entry => logic/importer}/AuthorListParserTest.java | 8 +++++--- 11 files changed, 26 insertions(+), 15 deletions(-) rename src/main/java/org/jabref/{model/database/event => logic/util}/CoarseChangeFilter.java (96%) rename src/test/java/org/jabref/{model/entry => logic/bibtex}/FileFieldWriterTest.java (98%) rename src/test/java/org/jabref/{model/entry => logic/importer}/AuthorListParserTest.java (88%) diff --git a/src/main/java/org/jabref/logic/autosaveandbackup/AutosaveManager.java b/src/main/java/org/jabref/logic/autosaveandbackup/AutosaveManager.java index 4b657b4946f..1ba127033d1 100644 --- a/src/main/java/org/jabref/logic/autosaveandbackup/AutosaveManager.java +++ b/src/main/java/org/jabref/logic/autosaveandbackup/AutosaveManager.java @@ -4,11 +4,11 @@ import java.util.Set; import java.util.concurrent.ScheduledThreadPoolExecutor; +import org.jabref.logic.util.CoarseChangeFilter; import org.jabref.logic.util.DelayTaskThrottler; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.event.AutosaveEvent; import org.jabref.model.database.event.BibDatabaseContextChangedEvent; -import org.jabref.model.database.event.CoarseChangeFilter; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; diff --git a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java index 80d9e48d80d..36d1b0a1f53 100644 --- a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java @@ -15,11 +15,11 @@ import org.jabref.logic.exporter.AtomicFileWriter; import org.jabref.logic.exporter.BibtexDatabaseWriter; import org.jabref.logic.exporter.SavePreferences; +import org.jabref.logic.util.CoarseChangeFilter; import org.jabref.logic.util.DelayTaskThrottler; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.event.BibDatabaseContextChangedEvent; -import org.jabref.model.database.event.CoarseChangeFilter; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.preferences.JabRefPreferences; diff --git a/src/main/java/org/jabref/model/database/event/CoarseChangeFilter.java b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java similarity index 96% rename from src/main/java/org/jabref/model/database/event/CoarseChangeFilter.java rename to src/main/java/org/jabref/logic/util/CoarseChangeFilter.java index 46664113397..0c862b5de91 100644 --- a/src/main/java/org/jabref/model/database/event/CoarseChangeFilter.java +++ b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java @@ -1,9 +1,9 @@ -package org.jabref.model.database.event; +package org.jabref.logic.util; import java.util.Optional; -import org.jabref.logic.util.DelayTaskThrottler; import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.database.event.BibDatabaseContextChangedEvent; import org.jabref.model.entry.event.FieldChangedEvent; import org.jabref.model.entry.field.Field; diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index e9ba943c93a..9c3c76ff593 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -8,9 +8,10 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.shared.DatabaseLocation; import org.jabref.logic.shared.DatabaseSynchronizer; -import org.jabref.model.database.event.CoarseChangeFilter; +import org.jabref.logic.util.CoarseChangeFilter; import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.MetaData; import org.jabref.preferences.FilePreferences; @@ -19,6 +20,7 @@ * Represents everything related to a BIB file.

The entries are stored in BibDatabase, the other data in MetaData * and the options relevant for this file in Defaults. */ +@AllowedToUseLogic("because it needs access to shared database features") public class BibDatabaseContext { private final BibDatabase database; diff --git a/src/main/java/org/jabref/model/entry/AuthorList.java b/src/main/java/org/jabref/model/entry/AuthorList.java index a5432d3b5cc..b432088070c 100644 --- a/src/main/java/org/jabref/model/entry/AuthorList.java +++ b/src/main/java/org/jabref/model/entry/AuthorList.java @@ -7,6 +7,7 @@ import java.util.WeakHashMap; import java.util.stream.Collectors; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.importer.AuthorListParser; import org.jabref.model.strings.LatexToUnicodeAdapter; @@ -117,6 +118,7 @@ * K." * */ +@AllowedToUseLogic("because it needs access to AuthorList parser") public class AuthorList { private static final WeakHashMap AUTHOR_CACHE = new WeakHashMap<>(); diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index b98fbca1639..a4e0aeb131c 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -20,6 +20,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableMap; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.model.FieldChange; @@ -51,6 +52,7 @@ *

* In case you search for a builder as described in Item 2 of the book "Effective Java", you won't find one. Please use the methods {@link #withCiteKey(String)} and {@link #withField(Field, String)}. */ +@AllowedToUseLogic("because it needs access to parser and writers") public class BibEntry implements Cloneable { public static final EntryType DEFAULT_TYPE = StandardEntryType.Misc; diff --git a/src/main/java/org/jabref/model/groups/TexGroup.java b/src/main/java/org/jabref/model/groups/TexGroup.java index 40923337eb2..03eb1a57903 100644 --- a/src/main/java/org/jabref/model/groups/TexGroup.java +++ b/src/main/java/org/jabref/model/groups/TexGroup.java @@ -8,6 +8,7 @@ import java.util.Objects; import java.util.Set; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.auxparser.AuxParser; import org.jabref.logic.auxparser.AuxParserResult; import org.jabref.model.entry.BibEntry; @@ -19,6 +20,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@AllowedToUseLogic("because it needs access to aux parser") public class TexGroup extends AbstractGroup implements FileUpdateListener { private static final Logger LOGGER = LoggerFactory.getLogger(TexGroup.class); diff --git a/src/main/java/org/jabref/model/metadata/MetaData.java b/src/main/java/org/jabref/model/metadata/MetaData.java index 495fec7cdb2..cf6008e4ecb 100644 --- a/src/main/java/org/jabref/model/metadata/MetaData.java +++ b/src/main/java/org/jabref/model/metadata/MetaData.java @@ -9,6 +9,7 @@ import java.util.Objects; import java.util.Optional; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern; import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern; import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; @@ -25,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@AllowedToUseLogic("because it needs access to citation pattern and cleanups") public class MetaData { public static final String META_FLAG = "jabref-meta: "; diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 8edc1ef6231..22540c48d45 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -86,21 +86,22 @@ public static void doNotUsePaths(JavaClasses classes) { } @ArchTest + @ArchIgnore // Fails currently public static void respectLayeredArchitecture(JavaClasses classes) { layeredArchitecture() .layer("Gui").definedBy(PACKAGE_ORG_JABREF_GUI) .layer("Logic").definedBy(PACKAGE_ORG_JABREF_LOGIC) .layer("Model").definedBy(PACKAGE_ORG_JABREF_MODEL) .layer("Cli").definedBy("org.jabref.cli..") - .layer("Migrations").definedBy("org.jabref.migrations..") + .layer("Migrations").definedBy("org.jabref.migrations..") // TODO: Move to logic .layer("Preferences").definedBy("org.jabref.preferences..") .layer("Styletester").definedBy("org.jabref.styletester..") - .whereLayer("Gui").mayOnlyBeAccessedByLayers("Preferences") // TODO: Remove preferences here + .whereLayer("Gui").mayOnlyBeAccessedByLayers("Preferences", "Cli") // TODO: Remove preferences here .whereLayer("Logic").mayOnlyBeAccessedByLayers("Gui", "Cli", "Model", "Migrations", "Preferences") .whereLayer("Model").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Cli", "Preferences") .whereLayer("Cli").mayNotBeAccessedByAnyLayer() - .whereLayer("Migrations").mayNotBeAccessedByAnyLayer() + .whereLayer("Migrations").mayOnlyBeAccessedByLayers("Logic") .whereLayer("Preferences").mayOnlyBeAccessedByLayers("Gui", "Logic", "Migrations", "Styletester", "Cli") // TODO: Remove logic here .check(classes); @@ -119,7 +120,6 @@ public static void restrictUsagesInModel(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) - .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_FX) .orShould().dependOnClassesThat().haveFullyQualifiedName(CLASS_ORG_JABREF_GLOBALS) .check(classes); } @@ -129,7 +129,6 @@ public static void restrictUsagesInLogic(JavaClasses classes) { noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC) .should().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_AWT) .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVAX_SWING) - .orShould().dependOnClassesThat().resideInAPackage(PACKAGE_JAVA_FX) .orShould().dependOnClassesThat().haveFullyQualifiedName(CLASS_ORG_JABREF_GLOBALS) .check(classes); } diff --git a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java b/src/test/java/org/jabref/logic/bibtex/FileFieldWriterTest.java similarity index 98% rename from src/test/java/org/jabref/model/entry/FileFieldWriterTest.java rename to src/test/java/org/jabref/logic/bibtex/FileFieldWriterTest.java index f2a78184c8c..40b73e45d44 100644 --- a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java +++ b/src/test/java/org/jabref/logic/bibtex/FileFieldWriterTest.java @@ -1,10 +1,10 @@ -package org.jabref.model.entry; +package org.jabref.logic.bibtex; import java.util.Arrays; import java.util.Collections; -import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.importer.util.FileFieldParser; +import org.jabref.model.entry.LinkedFile; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/jabref/model/entry/AuthorListParserTest.java b/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java similarity index 88% rename from src/test/java/org/jabref/model/entry/AuthorListParserTest.java rename to src/test/java/org/jabref/logic/importer/AuthorListParserTest.java index 8f5b37c67bf..d6bb46531f0 100644 --- a/src/test/java/org/jabref/model/entry/AuthorListParserTest.java +++ b/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java @@ -1,9 +1,11 @@ -package org.jabref.model.entry; +package org.jabref.logic.importer; import java.util.stream.Stream; -import org.jabref.logic.importer.AuthorListParser; +import org.jabref.model.entry.Author; +import org.jabref.model.entry.AuthorList; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -31,7 +33,7 @@ private static Stream data() { @MethodSource("data") void parseCorrectly(String authorsString, Author authorsParsed) { AuthorListParser parser = new AuthorListParser(); - assertEquals(new AuthorList(authorsParsed), parser.parse(authorsString)); + Assertions.assertEquals(new AuthorList(authorsParsed), parser.parse(authorsString)); } @Test From 4e24042ebbd5a166b44bffbbc15d2eadebfe853c Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 13:08:11 +0200 Subject: [PATCH 15/16] Refine arch tests --- .../java/org/jabref/architecture/MainArchitectureTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 22540c48d45..c46aa576ac6 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -109,9 +109,8 @@ public static void respectLayeredArchitecture(JavaClasses classes) { @ArchTest public static void doNotUseLogicInModel(JavaClasses classes) { - noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL) + noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL).and().areNotAnnotatedWith(AllowedToUseLogic.class) .should().dependOnClassesThat().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC) - .orShould().beAnnotatedWith(AllowedToUseLogic.class) .check(classes); } From 320a5b8c31ef2b2578dabe1e0ae1b37c1e46ad20 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 2 Sep 2020 13:20:22 +0200 Subject: [PATCH 16/16] Refine arch tests --- src/test/java/org/jabref/model/groups/TexGroupTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/jabref/model/groups/TexGroupTest.java b/src/test/java/org/jabref/model/groups/TexGroupTest.java index 7cf52a66aa2..b27c496fd7e 100644 --- a/src/test/java/org/jabref/model/groups/TexGroupTest.java +++ b/src/test/java/org/jabref/model/groups/TexGroupTest.java @@ -2,6 +2,7 @@ import java.nio.file.Path; +import org.jabref.architecture.AllowedToUseLogic; import org.jabref.logic.auxparser.DefaultAuxParser; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; @@ -15,6 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +@AllowedToUseLogic("because class under test relies on logic classes") public class TexGroupTest { private MetaData metaData;