support metadata edit
This commit is contained in:
parent
63c1714d0a
commit
249fa4d8d5
@ -193,7 +193,7 @@ public abstract class ProjectManager {
|
||||
* @param projectId
|
||||
* @throws Exception
|
||||
*/
|
||||
protected abstract void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception;
|
||||
public abstract void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception;
|
||||
|
||||
/**
|
||||
* Save project to the data store
|
||||
|
@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.google.refine;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -114,13 +115,13 @@ public class ProjectMetadata implements Jsonizable {
|
||||
}
|
||||
writer.endObject();
|
||||
|
||||
// write JSONArray to file directly
|
||||
// write JSONArray directly
|
||||
if (_importOptionMetaData.length() > 0 ) {
|
||||
writer.key("importOptionMetaData");
|
||||
writer.value(_importOptionMetaData);
|
||||
}
|
||||
|
||||
if ("save".equals(options.getProperty("mode"))) {
|
||||
if (isSaveMode(options)) {
|
||||
writer.key("password"); writer.value(_password);
|
||||
|
||||
writer.key("encoding"); writer.value(_encoding);
|
||||
@ -131,10 +132,20 @@ public class ProjectMetadata implements Jsonizable {
|
||||
|
||||
writer.endObject();
|
||||
|
||||
if ("save".equals(options.getProperty("mode"))) {
|
||||
if (isSaveMode(options)) {
|
||||
written = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeWithoutOption(JSONWriter writer)
|
||||
throws JSONException {
|
||||
write(writer,
|
||||
new Properties());
|
||||
}
|
||||
|
||||
private boolean isSaveMode(Properties options) {
|
||||
return "save".equals(options.getProperty("mode"));
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return written == null || _modified.after(written);
|
||||
@ -369,5 +380,17 @@ public class ProjectMetadata implements Jsonizable {
|
||||
this._rowNumber = rowNumber;
|
||||
updateModified();
|
||||
}
|
||||
|
||||
public void setAnyField(String metaName, String valueString) {
|
||||
Class<? extends ProjectMetadata> metaClass = this.getClass();
|
||||
try {
|
||||
Field metaField = metaClass.getDeclaredField("_" + metaName);
|
||||
|
||||
metaField.set(this, valueString);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
// do nothing
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,9 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import com.google.refine.ProjectManager;
|
||||
@ -62,6 +64,7 @@ public class GetAllProjectMetadataCommand extends Command {
|
||||
Properties options = new Properties();
|
||||
|
||||
writer.object();
|
||||
|
||||
writer.key("projects");
|
||||
writer.object();
|
||||
Map<Long, ProjectMetadata> m = ProjectManager.singleton.getAllProjectMetadata();
|
||||
@ -73,6 +76,12 @@ public class GetAllProjectMetadataCommand extends Command {
|
||||
}
|
||||
}
|
||||
writer.endObject();
|
||||
|
||||
writer.key("customMetaDataColumns");
|
||||
JSONArray customMetaDataColumns = new JSONArray(
|
||||
(String)ProjectManager.singleton.getPreferenceStore().get("userMetaData"));
|
||||
writer.value(customMetaDataColumns);
|
||||
|
||||
writer.endObject();
|
||||
} catch (JSONException e) {
|
||||
respondException(response, e);
|
||||
|
@ -215,7 +215,7 @@ public class FileProjectManager extends ProjectManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception {
|
||||
public void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception {
|
||||
File projectDir = getProjectDir(projectId);
|
||||
ProjectMetadataUtilities.save(metadata, projectDir);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
var html = "text/html";
|
||||
var encoding = "UTF-8";
|
||||
var ClientSideResourceManager = Packages.com.google.refine.ClientSideResourceManager;
|
||||
var bundle = true;
|
||||
var bundle = false;
|
||||
|
||||
var templatedFiles = {
|
||||
// Requests with last path segments mentioned here
|
||||
@ -68,9 +68,11 @@ function registerCommands() {
|
||||
|
||||
RS.registerCommand(module, "get-project-metadata", new Packages.com.google.refine.commands.project.GetProjectMetadataCommand());
|
||||
RS.registerCommand(module, "get-all-project-metadata", new Packages.com.google.refine.commands.workspace.GetAllProjectMetadataCommand());
|
||||
RS.registerCommand(module, "set-metaData", new Packages.com.google.refine.commands.project.SetProjectMetaDataCommand());
|
||||
|
||||
RS.registerCommand(module, "delete-project", new Packages.com.google.refine.commands.project.DeleteProjectCommand());
|
||||
RS.registerCommand(module, "rename-project", new Packages.com.google.refine.commands.project.RenameProjectCommand());
|
||||
RS.registerCommand(module, "set-project-metadata", new Packages.com.google.refine.commands.project.SetProjectMetaDataCommand());
|
||||
|
||||
RS.registerCommand(module, "get-models", new Packages.com.google.refine.commands.project.GetModelsCommand());
|
||||
RS.registerCommand(module, "get-rows", new Packages.com.google.refine.commands.row.GetRowsCommand());
|
||||
@ -350,7 +352,8 @@ function init() {
|
||||
"scripts/index/parser-interfaces/rdf-triples-parser-ui.js",
|
||||
"scripts/index/parser-interfaces/wikitext-parser-ui.js",
|
||||
|
||||
"scripts/reconciliation/recon-manager.js" // so that reconciliation functions are available to importers
|
||||
"scripts/reconciliation/recon-manager.js", // so that reconciliation functions are available to importers
|
||||
"scripts/index/edit-metadata-dialog.js"
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -87,6 +87,12 @@
|
||||
"open-proj": "Open Project",
|
||||
"name": "Name",
|
||||
"rename": "rename",
|
||||
"edit-meta-data": "Edit meta data",
|
||||
"creator": "Creator",
|
||||
"contributors": "Contributors",
|
||||
"subject": "Subject",
|
||||
"description": "Description",
|
||||
"row-number": "Row Number",
|
||||
"last-mod": "Last modified",
|
||||
"del-title": "Delete this project",
|
||||
"del-body": "Are you sure you want to delete project \"",
|
||||
|
@ -1 +0,0 @@
|
||||
{}
|
@ -123,8 +123,23 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
'<table class="list-table"><tr>' +
|
||||
'<th></th>' +
|
||||
'<th></th>' +
|
||||
'<th></th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["last-mod"]+'</th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["name"]+'</th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["creator"]+'</th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["subject"]+'</th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["description"]+'</th>' +
|
||||
'<th>'+$.i18n._('core-index-open')["row-number"]+'</th>' +
|
||||
(function() {
|
||||
var htmlDisplay = "";
|
||||
for (var n in data.customMetaDataColumns) {
|
||||
if (data.customMetaDataColumns[n].display) {
|
||||
htmlDisplay += '<th>'+ data.customMetaDataColumns[n].name + '</th>';
|
||||
}
|
||||
}
|
||||
|
||||
return htmlDisplay;
|
||||
})() +
|
||||
'</tr></table>'
|
||||
).appendTo(container)[0];
|
||||
|
||||
@ -189,7 +204,19 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
}).appendTo(
|
||||
$(tr.insertCell(tr.cells.length)).css('width', '1%')
|
||||
);
|
||||
|
||||
|
||||
var editMetaDataLink = $('<a></a>')
|
||||
.text($.i18n._('core-index-open')["edit-meta-data"])
|
||||
.addClass("secondary")
|
||||
.attr("href", "javascript:{}")
|
||||
.css("visibility", "hidden")
|
||||
.click(function() {
|
||||
new EditMetadataDialog(project);
|
||||
})
|
||||
.appendTo(
|
||||
$(tr.insertCell(tr.cells.length)).css('width', '6%')
|
||||
);
|
||||
|
||||
$('<div></div>')
|
||||
.html(formatRelativeDate(project.date))
|
||||
.addClass("last-modified")
|
||||
@ -205,9 +232,11 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
$(tr).mouseenter(function() {
|
||||
renameLink.css("visibility", "visible");
|
||||
deleteLink.css("visibility", "visible");
|
||||
editMetaDataLink.css("visibility", "visible");
|
||||
}).mouseleave(function() {
|
||||
renameLink.css("visibility", "hidden");
|
||||
deleteLink.css("visibility", "hidden");
|
||||
editMetaDataLink.css("visibility", "hidden");
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -87,3 +87,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#metadata-body tr:nth-child(even) {background: #CCC}
|
||||
#metadata-body tr:nth-child(odd) {background: #FFF}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user