Fixed bug introduced recently by changing the preference key of the expression history from "expressions" to "scripting.expressions".
Added code in FileProjectManager for trying to recover projects in the workspace dir but are not recorded in the workspace json file. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1144 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
586fcc8f52
commit
e70f16025b
@ -344,7 +344,7 @@ public abstract class ProjectManager {
|
||||
* @return
|
||||
*/
|
||||
public List<String> getExpressions() {
|
||||
return ((TopList) _preferenceStore.get("expressions")).getList();
|
||||
return ((TopList) _preferenceStore.get("scripting.expressions")).getList();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -406,7 +406,7 @@ public abstract class ProjectManager {
|
||||
*/
|
||||
public void addLatestExpression(String s) {
|
||||
synchronized (this) {
|
||||
((TopList) _preferenceStore.get("expressions")).add(s);
|
||||
((TopList) _preferenceStore.get("scripting.expressions")).add(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,9 +95,9 @@ public class ProjectMetadata implements Jsonizable {
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.has("expressions") && !obj.isNull("expressions")) {
|
||||
if (obj.has("expressions") && !obj.isNull("expressions")) { // backward compatibility
|
||||
try {
|
||||
((TopList) pm._preferenceStore.get("expressions"))
|
||||
((TopList) pm._preferenceStore.get("scripting.expressions"))
|
||||
.load(obj.getJSONArray("expressions"));
|
||||
} catch (JSONException e) {
|
||||
// ignore
|
||||
|
@ -29,6 +29,7 @@ import com.google.gridworks.model.Project;
|
||||
import com.google.gridworks.preference.TopList;
|
||||
|
||||
public class FileProjectManager extends ProjectManager {
|
||||
final static protected String s_projectDirNameSuffix = ".project";
|
||||
|
||||
protected File _workspaceDir;
|
||||
|
||||
@ -48,6 +49,7 @@ public class FileProjectManager extends ProjectManager {
|
||||
_workspaceDir.mkdirs();
|
||||
|
||||
load();
|
||||
recover();
|
||||
}
|
||||
|
||||
public File getWorkspaceDir() {
|
||||
@ -55,7 +57,7 @@ public class FileProjectManager extends ProjectManager {
|
||||
}
|
||||
|
||||
static public File getProjectDir(File workspaceDir, long projectID) {
|
||||
File dir = new File(workspaceDir, projectID + ".project");
|
||||
File dir = new File(workspaceDir, projectID + s_projectDirNameSuffix);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir();
|
||||
}
|
||||
@ -309,8 +311,8 @@ public class FileProjectManager extends ProjectManager {
|
||||
_preferenceStore.load(obj.getJSONObject("preferences"));
|
||||
}
|
||||
|
||||
if (obj.has("expressions") && !obj.isNull("expressions")) {
|
||||
((TopList) _preferenceStore.get("expressions"))
|
||||
if (obj.has("expressions") && !obj.isNull("expressions")) { // backward compatibility
|
||||
((TopList) _preferenceStore.get("scripting.expressions"))
|
||||
.load(obj.getJSONArray("expressions"));
|
||||
}
|
||||
|
||||
@ -330,7 +332,35 @@ public class FileProjectManager extends ProjectManager {
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
protected void recover() {
|
||||
for (File file : _workspaceDir.listFiles()) {
|
||||
if (file.isDirectory() && !file.isHidden()) {
|
||||
String name = file.getName();
|
||||
if (file.getName().endsWith(s_projectDirNameSuffix)) {
|
||||
String idString = name.substring(0, name.length() - s_projectDirNameSuffix.length());
|
||||
long id = -1;
|
||||
try {
|
||||
id = Long.parseLong(idString);
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (id > 0 && !_projectsMetadata.containsKey(id)) {
|
||||
if (loadProjectMetadata(id)) {
|
||||
logger.info(
|
||||
"Recovered project named " +
|
||||
getProjectMetadata(id).getName() +
|
||||
" in directory " + name);
|
||||
} else {
|
||||
logger.warn("Failed to recover project in directory " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HistoryEntryManager getHistoryEntryManager(){
|
||||
return new FileHistoryEntryManager();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user