Skip to content

Commit

Permalink
Implementation of shared database support (base system).
Browse files Browse the repository at this point in the history
  • Loading branch information
obraliar committed May 26, 2016
1 parent 6f2feeb commit e79c5ff
Show file tree
Hide file tree
Showing 76 changed files with 1,764 additions and 3,497 deletions.
Binary file added lib/ojdbc7.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions src/main/java/net/sf/jabref/BibDatabaseContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.database.BibDatabaseModeDetection;
import net.sf.jabref.model.database.DatabaseLocation;
import net.sf.jabref.remote.DBSynchronizer;

/**
* Represents everything related to a .bib file.
Expand All @@ -22,6 +24,7 @@ public class BibDatabaseContext {
private final Defaults defaults;
/** The file where this database was last saved to. */
private File file;
private DBSynchronizer dbSynchronizer;

public BibDatabaseContext() {
this(new Defaults());
Expand All @@ -35,6 +38,14 @@ public BibDatabaseContext(BibDatabase database) {
this(database, new Defaults());
}

public BibDatabaseContext(DatabaseLocation location) {
this(new BibDatabase(location));
}

public BibDatabaseContext(DatabaseLocation location, Defaults defaults) {
this(new BibDatabase(location), defaults);
}

public BibDatabaseContext(BibDatabase database, Defaults defaults) {
this(database, new MetaData(), defaults);
}
Expand All @@ -43,6 +54,11 @@ public BibDatabaseContext(BibDatabase database, MetaData metaData, Defaults defa
this.defaults = Objects.requireNonNull(defaults);
this.database = Objects.requireNonNull(database);
this.metaData = Objects.requireNonNull(metaData);

if (database.getLocation() == DatabaseLocation.REMOTE) {
this.dbSynchronizer = new DBSynchronizer();
database.registerListener(dbSynchronizer);
}
}

public BibDatabaseContext(BibDatabase database, MetaData metaData) {
Expand Down Expand Up @@ -178,4 +194,8 @@ private String getFileDirectoryPath(String directoryName) {
public List<String> getFileDirectory() {
return getFileDirectory(Globals.FILE_FIELD);
}

public DBSynchronizer getDBSynchronizer() {
return this.dbSynchronizer;
}
}
12 changes: 0 additions & 12 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import net.sf.jabref.logic.labelpattern.DatabaseLabelPattern;
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.sql.DBStrings;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -68,11 +67,8 @@ public class MetaData implements Iterable<String> {

private AbstractLabelPattern labelPattern;

private DBStrings dbStrings = new DBStrings();

private Charset encoding = Globals.prefs.getDefaultEncoding();


/**
* The MetaData object stores all meta data sets in Vectors. To ensure that
* the data is written correctly to string, the user of a meta data Vector
Expand Down Expand Up @@ -222,14 +218,6 @@ private static String getNextUnit(Reader reader) throws IOException {
return null;
}

public DBStrings getDBStrings() {
return dbStrings;
}

public void setDBStrings(DBStrings dbStrings) {
this.dbStrings = dbStrings;
}

/**
* @return the stored label patterns
*/
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/sf/jabref/event/EntryAddedEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.event;

import net.sf.jabref.event.location.EntryEventLocation;
import net.sf.jabref.model.entry.BibEntry;

/**
Expand All @@ -16,4 +17,12 @@ public EntryAddedEvent(BibEntry bibEntry) {
super(bibEntry);
}

/**
* @param bibEntry <code>BibEntry</code> object which has been added.
* @param location Location affected by this event
*/
public EntryAddedEvent(BibEntry bibEntry, EntryEventLocation location) {
super(bibEntry, location);
}

}
9 changes: 9 additions & 0 deletions src/main/java/net/sf/jabref/event/EntryChangedEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.event;

import net.sf.jabref.event.location.EntryEventLocation;
import net.sf.jabref.model.entry.BibEntry;

/**
Expand All @@ -15,4 +16,12 @@ public EntryChangedEvent(BibEntry bibEntry) {
super(bibEntry);
}

/**
* @param bibEntry <code>BibEntry</code> object the changes were applied on.
* @param location Location affected by this event
*/
public EntryChangedEvent(BibEntry bibEntry, EntryEventLocation location) {
super(bibEntry, location);
}

}
18 changes: 17 additions & 1 deletion src/main/java/net/sf/jabref/event/EntryEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.event;

import net.sf.jabref.event.location.EntryEventLocation;
import net.sf.jabref.model.entry.BibEntry;

/**
Expand All @@ -9,15 +10,30 @@
public abstract class EntryEvent {

private final BibEntry bibEntry;
private final EntryEventLocation location;


/**
* @param bibEntry BibEntry object which is involved in this event
* @param bibEntry BibEntry object which is involved in this event
*/
public EntryEvent(BibEntry bibEntry) {
this(bibEntry, EntryEventLocation.ALL);
}

/**
* @param bibEntry BibEntry object which is involved in this event
* @param location Location affected by this event
*/
public EntryEvent(BibEntry bibEntry, EntryEventLocation location) {
this.bibEntry = bibEntry;
this.location = location;
}

public BibEntry getBibEntry() {
return this.bibEntry;
}

public EntryEventLocation getEntryEventLocation() {
return this.location;
}
}
9 changes: 9 additions & 0 deletions src/main/java/net/sf/jabref/event/EntryRemovedEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.event;

import net.sf.jabref.event.location.EntryEventLocation;
import net.sf.jabref.model.entry.BibEntry;

/**
Expand All @@ -16,4 +17,12 @@ public EntryRemovedEvent(BibEntry bibEntry) {
super(bibEntry);
}

/**
* @param bibEntry <code>BibEntry</code> object which has been removed.
* @param location Location affected by this event
*/
public EntryRemovedEvent(BibEntry bibEntry, EntryEventLocation location) {
super(bibEntry, location);
}

}
13 changes: 13 additions & 0 deletions src/main/java/net/sf/jabref/event/FieldChangedEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.event;

import net.sf.jabref.event.location.EntryEventLocation;
import net.sf.jabref.model.entry.BibEntry;

/**
Expand All @@ -21,6 +22,18 @@ public FieldChangedEvent(BibEntry bibEntry, String fieldName, String newValue) {
this.newValue = newValue;
}

/**
* @param bibEntry Affected BibEntry object
* @param fieldName Name of field which has been changed
* @param newValue new field value
* @param location location Location affected by this event
*/
public FieldChangedEvent(BibEntry bibEntry, String fieldName, String newValue, EntryEventLocation location) {
super(bibEntry, location);
this.fieldName = fieldName;
this.newValue = newValue;
}

public String getFieldName() {
return fieldName;
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/net/sf/jabref/event/location/EntryEventLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Copyright (C) 2003-2016 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package net.sf.jabref.event.location;

/**
* This enum entries represent the radius which is affected by posting different EntryEvents.
*/
public enum EntryEventLocation {
ALL,
REMOTE,
LOCAL
}
Loading

0 comments on commit e79c5ff

Please sign in to comment.