Allow reinitializatoin of ProjectManager singleton - fixes #787
This commit is contained in:
parent
844b8182a4
commit
3315136681
@ -40,6 +40,8 @@ import java.util.Properties;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONWriter;
|
import org.json.JSONWriter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.refine.Jsonizable;
|
import com.google.refine.Jsonizable;
|
||||||
import com.google.refine.ProjectManager;
|
import com.google.refine.ProjectManager;
|
||||||
@ -53,6 +55,7 @@ import com.google.refine.util.ParsingUtilities;
|
|||||||
* obtain information about a change without actually loading the change.
|
* obtain information about a change without actually loading the change.
|
||||||
*/
|
*/
|
||||||
public class HistoryEntry implements Jsonizable {
|
public class HistoryEntry implements Jsonizable {
|
||||||
|
final static Logger logger = LoggerFactory.getLogger("HistoryEntry");
|
||||||
final public long id;
|
final public long id;
|
||||||
final public long projectID;
|
final public long projectID;
|
||||||
final public String description;
|
final public String description;
|
||||||
@ -82,13 +85,7 @@ public class HistoryEntry implements Jsonizable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HistoryEntry(long id, Project project, String description, AbstractOperation operation, Change change) {
|
public HistoryEntry(long id, Project project, String description, AbstractOperation operation, Change change) {
|
||||||
this.id = id;
|
this(id,project.id,description,operation,new Date());
|
||||||
this.projectID = project.id;
|
|
||||||
this.description = description;
|
|
||||||
this.operation = operation;
|
|
||||||
this.time = new Date();
|
|
||||||
|
|
||||||
this._manager = ProjectManager.singleton.getHistoryEntryManager();
|
|
||||||
setChange(change);
|
setChange(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +96,10 @@ public class HistoryEntry implements Jsonizable {
|
|||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this._manager = ProjectManager.singleton.getHistoryEntryManager();
|
this._manager = ProjectManager.singleton.getHistoryEntryManager();
|
||||||
|
if (this._manager == null) {
|
||||||
|
logger.error("Failed to get history entry manager from project manager: "
|
||||||
|
+ ProjectManager.singleton );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,13 +69,13 @@ public class FileProjectManager extends ProjectManager {
|
|||||||
final static Logger logger = LoggerFactory.getLogger("FileProjectManager");
|
final static Logger logger = LoggerFactory.getLogger("FileProjectManager");
|
||||||
|
|
||||||
static public synchronized void initialize(File dir) {
|
static public synchronized void initialize(File dir) {
|
||||||
if (singleton == null) {
|
if (singleton != null) {
|
||||||
logger.info("Using workspace directory: {}", dir.getAbsolutePath());
|
logger.warn("Overwriting singleton already set: " + singleton);
|
||||||
singleton = new FileProjectManager(dir);
|
|
||||||
// This needs our singleton set, thus the unconventional control flow
|
|
||||||
((FileProjectManager) singleton).recover();
|
|
||||||
}
|
}
|
||||||
|
logger.info("Using workspace directory: {}", dir.getAbsolutePath());
|
||||||
|
singleton = new FileProjectManager(dir);
|
||||||
|
// This needs our singleton set, thus the unconventional control flow
|
||||||
|
((FileProjectManager) singleton).recover();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FileProjectManager(File dir) {
|
protected FileProjectManager(File dir) {
|
||||||
|
Loading…
Reference in New Issue
Block a user