Skip to content

Commit

Permalink
Rename pref variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Feb 8, 2017
1 parent 07a1c44 commit 367f992
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/logic/cleanup/CleanupWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CleanupWorker {
private final BibDatabaseContext databaseContext;
private final String fileNamePattern;
private final String fileDirPattern;
private final LayoutFormatterPreferences prefs;
private final LayoutFormatterPreferences layoutPrefs;
private final FileDirectoryPreferences fileDirectoryPreferences;
private int unsuccessfulRenames;

Expand All @@ -25,7 +25,7 @@ public CleanupWorker(BibDatabaseContext databaseContext, CleanupPreferences clea
this.databaseContext = databaseContext;
this.fileNamePattern = cleanupPreferences.getFileNamePattern();
this.fileDirPattern = cleanupPreferences.getFileDirPattern();
this.prefs = cleanupPreferences.getLayoutFormatterPreferences();
this.layoutPrefs = cleanupPreferences.getLayoutFormatterPreferences();
this.fileDirectoryPreferences = cleanupPreferences.getFileDirectoryPreferences();
}

Expand Down Expand Up @@ -69,14 +69,14 @@ private List<CleanupJob> determineCleanupActions(CleanupPreset preset) {
jobs.add(new FileLinksCleanup());
}
if (preset.isMovePDF()) {
jobs.add(new MoveFilesCleanup(databaseContext, fileDirPattern, fileDirectoryPreferences, prefs));
jobs.add(new MoveFilesCleanup(databaseContext, fileDirPattern, fileDirectoryPreferences, layoutPrefs));
}
if (preset.isMakePathsRelative()) {
jobs.add(new RelativePathsCleanup(databaseContext, fileDirectoryPreferences));
}
if (preset.isRenamePDF()) {
RenamePdfCleanup cleaner = new RenamePdfCleanup(preset.isRenamePdfOnlyRelativePaths(), databaseContext,
fileNamePattern, fileDirPattern, prefs, fileDirectoryPreferences);
fileNamePattern, fileDirPattern, layoutPrefs, fileDirectoryPreferences);
jobs.add(cleaner);
unsuccessfulRenames += cleaner.getUnsuccessfulRenames();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ public class MoveFilesCleanup implements CleanupJob {

private final BibDatabaseContext databaseContext;
private final FileDirectoryPreferences fileDirectoryPreferences;
private final LayoutFormatterPreferences prefs;
private final LayoutFormatterPreferences layoutPrefs;

private final String fileDirPattern;
private static final Log LOGGER = LogFactory.getLog(MoveFilesCleanup.class);

private ParsedFileField singleFieldCleanup = null;

public MoveFilesCleanup(BibDatabaseContext databaseContext, String fileDirPattern,
FileDirectoryPreferences fileDirectoryPreferences, LayoutFormatterPreferences prefs) {
FileDirectoryPreferences fileDirectoryPreferences, LayoutFormatterPreferences layoutPrefs) {
this.databaseContext = Objects.requireNonNull(databaseContext);
this.fileDirPattern = Objects.requireNonNull(fileDirPattern);
this.fileDirectoryPreferences = Objects.requireNonNull(fileDirectoryPreferences);
this.prefs = Objects.requireNonNull(prefs);
this.layoutPrefs = Objects.requireNonNull(layoutPrefs);
}

public MoveFilesCleanup(BibDatabaseContext databaseContext, String fileDirPattern,
Expand Down Expand Up @@ -95,7 +95,7 @@ public List<FieldChange> cleanup(BibEntry entry) {
String targetDirName = "";
if (!fileDirPattern.isEmpty()) {
targetDirName = FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), entry, fileDirPattern,
prefs);
layoutPrefs);
}

Path newTargetFile = targetDirectory.get().toPath().resolve(targetDirName).resolve(oldFile.get().getName());
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/sf/jabref/logic/cleanup/RenamePdfCleanup.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@ public class RenamePdfCleanup implements CleanupJob {
private final boolean onlyRelativePaths;
private final String fileNamePattern;
private final String fileDirPattern;
private final LayoutFormatterPreferences prefs;
private final LayoutFormatterPreferences layoutPrefs;
private final FileDirectoryPreferences fileDirectoryPreferences;
private int unsuccessfulRenames;
private ParsedFileField singleFieldCleanup;

public RenamePdfCleanup(boolean onlyRelativePaths, BibDatabaseContext databaseContext, String fileNamePattern,
String fileDirPattern, LayoutFormatterPreferences prefs,
String fileDirPattern, LayoutFormatterPreferences layoutPrefs,
FileDirectoryPreferences fileDirectoryPreferences) {
this.databaseContext = Objects.requireNonNull(databaseContext);
this.onlyRelativePaths = onlyRelativePaths;
this.fileNamePattern = Objects.requireNonNull(fileNamePattern);
this.fileDirPattern = Objects.requireNonNull(fileDirPattern);
this.prefs = Objects.requireNonNull(prefs);
this.layoutPrefs = Objects.requireNonNull(layoutPrefs);
this.fileDirectoryPreferences = fileDirectoryPreferences;
}

public RenamePdfCleanup(boolean onlyRelativePaths, BibDatabaseContext databaseContext, String fileNamePattern,
String fileDirPattern, LayoutFormatterPreferences prefs,
FileDirectoryPreferences fileDirectoryPreferences, ParsedFileField singleField) {

this(onlyRelativePaths, databaseContext, fileNamePattern, fileDirPattern, prefs,
fileDirectoryPreferences);
this.singleFieldCleanup = singleField;
Expand Down Expand Up @@ -85,12 +86,13 @@ public List<FieldChange> cleanup(BibEntry entry) {
}

StringBuilder targetFileName = new StringBuilder(FileUtil
.createFileNameFromPattern(databaseContext.getDatabase(), entry, fileNamePattern, prefs).trim());
.createFileNameFromPattern(databaseContext.getDatabase(), entry, fileNamePattern, layoutPrefs)
.trim());

String targetDirName = "";
if (!fileDirPattern.isEmpty()) {
targetDirName = FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), entry, fileDirPattern,
prefs);
layoutPrefs);
}

//Add extension to newFilename
Expand Down Expand Up @@ -131,7 +133,7 @@ public List<FieldChange> cleanup(BibEntry entry) {
}
} catch (IOException e) {
// TODO Auto-generated catch block
LOGGER.error("Could no create target necessary target directoires for renaming", e);
LOGGER.error("Could no create necessary target directoires for renaming", e);
}
//do rename
boolean renameSuccessful = FileUtil.renameFile(Paths.get(expandedOldFilePath), newPath, true);
Expand Down

0 comments on commit 367f992

Please sign in to comment.