change MetaData to Metadata
This commit is contained in:
parent
fc2f81046f
commit
31943f6c9f
@ -71,7 +71,7 @@ public class ProjectMetadata implements Jsonizable {
|
||||
private int _rowNumber; // at the creation. Essential for cleaning old projects too heavy
|
||||
|
||||
// import options is an array for 1-n data sources
|
||||
private JSONArray _importOptionMetaData = new JSONArray();
|
||||
private JSONArray _importOptionMetadata = new JSONArray();
|
||||
|
||||
// user metadata
|
||||
private JSONArray _userMetadata = new JSONArray();;
|
||||
@ -120,9 +120,9 @@ public class ProjectMetadata implements Jsonizable {
|
||||
writer.endObject();
|
||||
|
||||
// write JSONArray directly
|
||||
if (_importOptionMetaData.length() > 0 ) {
|
||||
writer.key("importOptionMetaData");
|
||||
writer.value(_importOptionMetaData);
|
||||
if (_importOptionMetadata.length() > 0 ) {
|
||||
writer.key("importOptionMetadata");
|
||||
writer.value(_importOptionMetadata);
|
||||
}
|
||||
|
||||
// write user metadata in {name, value, display} form:
|
||||
@ -231,10 +231,10 @@ public class ProjectMetadata implements Jsonizable {
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.has("importOptionMetaData") && !obj.isNull("importOptionMetaData")) {
|
||||
if (obj.has("importOptionMetadata") && !obj.isNull("importOptionMetadata")) {
|
||||
try {
|
||||
JSONArray jsonArray = obj.getJSONArray("importOptionMetaData");
|
||||
pm._importOptionMetaData = jsonArray;
|
||||
JSONArray jsonArray = obj.getJSONArray("importOptionMetadata");
|
||||
pm._importOptionMetadata = jsonArray;
|
||||
} catch (JSONException e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
}
|
||||
@ -330,17 +330,17 @@ public class ProjectMetadata implements Jsonizable {
|
||||
updateModified();
|
||||
}
|
||||
|
||||
public JSONArray getImportOptionMetaData() {
|
||||
return _importOptionMetaData;
|
||||
public JSONArray getImportOptionMetadata() {
|
||||
return _importOptionMetadata;
|
||||
}
|
||||
|
||||
public void setImportOptionMetaData(JSONArray jsonArray) {
|
||||
_importOptionMetaData = jsonArray;
|
||||
public void setImportOptionMetadata(JSONArray jsonArray) {
|
||||
_importOptionMetadata = jsonArray;
|
||||
updateModified();
|
||||
}
|
||||
|
||||
public void appendImportOptionMetaData(JSONObject obj) {
|
||||
_importOptionMetaData.put(obj);
|
||||
public void appendImportOptionMetadata(JSONObject obj) {
|
||||
_importOptionMetadata.put(obj);
|
||||
updateModified();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import com.google.refine.ProjectMetadata;
|
||||
import com.google.refine.commands.Command;
|
||||
import com.google.refine.model.Project;
|
||||
|
||||
public class SetProjectMetaDataCommand extends Command {
|
||||
public class SetProjectMetadataCommand extends Command {
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
@ -76,11 +76,11 @@ public class GetAllProjectMetadataCommand extends Command {
|
||||
}
|
||||
writer.endObject();
|
||||
|
||||
String userMeta = (String)ProjectManager.singleton.getPreferenceStore().get("userMetaData");
|
||||
String userMeta = (String)ProjectManager.singleton.getPreferenceStore().get("userMetadata");
|
||||
if (userMeta != null) {
|
||||
writer.key("customMetaDataColumns");
|
||||
JSONArray customMetaDataColumns = new JSONArray(userMeta);
|
||||
writer.value(customMetaDataColumns);
|
||||
writer.key("customMetadataColumns");
|
||||
JSONArray customMetadataColumns = new JSONArray(userMeta);
|
||||
writer.value(customMetadataColumns);
|
||||
}
|
||||
|
||||
writer.endObject();
|
||||
|
@ -155,7 +155,7 @@ abstract public class ImportingParserBase implements ImportingParser {
|
||||
// ignore
|
||||
}
|
||||
// set the import options to metadata:
|
||||
metadata.appendImportOptionMetaData(options);
|
||||
metadata.appendImportOptionMetadata(options);
|
||||
}
|
||||
|
||||
public void parseOneFile(
|
||||
|
@ -431,7 +431,7 @@ public class FileProjectManager extends ProjectManager {
|
||||
boolean found = false;
|
||||
JSONObject placeHolderJsonObj = userMetadataPreference.getJSONObject(index);
|
||||
|
||||
if (!isValidUserMetaDataDefinition(placeHolderJsonObj)) {
|
||||
if (!isValidUserMetadataDefinition(placeHolderJsonObj)) {
|
||||
logger.warn("Skipped invalid user metadata definition" + placeHolderJsonObj.toString());
|
||||
continue;
|
||||
}
|
||||
@ -463,7 +463,7 @@ public class FileProjectManager extends ProjectManager {
|
||||
* @param placeHolderJsonObj
|
||||
* @return
|
||||
*/
|
||||
private boolean isValidUserMetaDataDefinition(JSONObject placeHolderJsonObj) {
|
||||
private boolean isValidUserMetadataDefinition(JSONObject placeHolderJsonObj) {
|
||||
return (placeHolderJsonObj != null &&
|
||||
placeHolderJsonObj.has("name") &&
|
||||
placeHolderJsonObj.has("display"));
|
||||
|
@ -48,7 +48,7 @@ import com.google.refine.Jsonizable;
|
||||
import com.google.refine.RefineServlet;
|
||||
|
||||
public class PreferenceStore implements Jsonizable {
|
||||
public static final String USER_METADATA_KEY = "userMetaData";
|
||||
public static final String USER_METADATA_KEY = "userMetadata";
|
||||
|
||||
private boolean dirty = false;
|
||||
protected Map<String, Object> _prefs = new HashMap<String, Object>();
|
||||
|
@ -68,11 +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, "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, "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());
|
||||
|
@ -4,7 +4,7 @@ function EditMetadataDialog(metaData, targetRowElem) {
|
||||
this._metaDataUIs = [];
|
||||
this._metaData = metaData;
|
||||
|
||||
this._MetaDataUI = function(tr, key, value, project) {
|
||||
this._MetadataUI = function(tr, key, value, project) {
|
||||
var self = this;
|
||||
var td0 = tr.insertCell(0);
|
||||
$(td0).text(key);
|
||||
@ -14,7 +14,7 @@ function EditMetadataDialog(metaData, targetRowElem) {
|
||||
|
||||
var td2 = tr.insertCell(2);
|
||||
|
||||
if (key !== "modified" && key !== "rowNumber" && key !== "importOptionMetaData" && key !== "id") {
|
||||
if (key !== "modified" && key !== "rowNumber" && key !== "importOptionMetadata" && key !== "id") {
|
||||
$('<button class="button">').text($.i18n._('core-index')["edit"]).appendTo(td2).click(function() {
|
||||
var newValue = window.prompt($.i18n._('core-index')["change-metadata-value"]+" " + key, value);
|
||||
if (newValue !== null) {
|
||||
@ -78,19 +78,19 @@ EditMetadataDialog.prototype._createDialog = function() {
|
||||
return toReturn;
|
||||
};
|
||||
|
||||
var flatMetaData = flattenObject(this._metaData, "userMetaData");
|
||||
var flatMetadata = flattenObject(this._metaData, "userMetadata");
|
||||
|
||||
for (var k in flatMetaData) {
|
||||
for (var k in flatMetadata) {
|
||||
var tr = metadataTable.insertRow(metadataTable.rows.length);
|
||||
var v;
|
||||
|
||||
if (typeof flatMetaData[k] === 'string') {
|
||||
v = flatMetaData[k].replace(/\"/g, "");
|
||||
if (typeof flatMetadata[k] === 'string') {
|
||||
v = flatMetadata[k].replace(/\"/g, "");
|
||||
} else {
|
||||
v = JSON.stringify(flatMetaData[k]);
|
||||
v = JSON.stringify(flatMetadata[k]);
|
||||
}
|
||||
|
||||
this._metaDataUIs.push(new this._MetaDataUI(tr, k, v, flatMetaData.id));
|
||||
this._metaDataUIs.push(new this._MetadataUI(tr, k, v, flatMetadata.id));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -108,17 +108,17 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
var project = data.projects[n];
|
||||
project.id = n;
|
||||
project.date = Date.parseExact(project.modified, "yyyy-MM-ddTHH:mm:ssZ");
|
||||
for (var n in data.customMetaDataColumns) {
|
||||
for (var n in data.customMetadataColumns) {
|
||||
var found = false;
|
||||
for(var i = 0; i < project.userMetaData.length; i++) {
|
||||
if (project.userMetaData[i].name === data.customMetaDataColumns[n].name) {
|
||||
for(var i = 0; i < project.userMetadata.length; i++) {
|
||||
if (project.userMetadata[i].name === data.customMetadataColumns[n].name) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
project.userMetaData.push({
|
||||
name: data.customMetaDataColumns[n].name,
|
||||
dispay: data.customMetaDataColumns[n].display,
|
||||
project.userMetadata.push({
|
||||
name: data.customMetadataColumns[n].name,
|
||||
dispay: data.customMetadataColumns[n].display,
|
||||
value: ""
|
||||
});
|
||||
}
|
||||
@ -148,9 +148,9 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
'<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>';
|
||||
for (var n in data.customMetadataColumns) {
|
||||
if (data.customMetadataColumns[n].display) {
|
||||
htmlDisplay += '<th>'+ data.customMetadataColumns[n].name + '</th>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
$(tr.insertCell(tr.cells.length)).css('width', '1%')
|
||||
);
|
||||
|
||||
var editMetaDataLink = $('<a></a>')
|
||||
var editMetadataLink = $('<a></a>')
|
||||
.text($.i18n._('core-index-open')["edit-meta-data"])
|
||||
.addClass("secondary")
|
||||
.attr("href", "javascript:{}")
|
||||
@ -257,7 +257,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
appendMetaField(project.description, '20%');
|
||||
appendMetaField(project.rowNumber);
|
||||
|
||||
var data = project.userMetaData;
|
||||
var data = project.userMetadata;
|
||||
for(var i in data)
|
||||
{
|
||||
if (data[i].display === true) {
|
||||
@ -268,11 +268,11 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
|
||||
$(tr).mouseenter(function() {
|
||||
renameLink.css("visibility", "visible");
|
||||
deleteLink.css("visibility", "visible");
|
||||
editMetaDataLink.css("visibility", "visible");
|
||||
editMetadataLink.css("visibility", "visible");
|
||||
}).mouseleave(function() {
|
||||
renameLink.css("visibility", "hidden");
|
||||
deleteLink.css("visibility", "hidden");
|
||||
editMetaDataLink.css("visibility", "hidden");
|
||||
editMetadataLink.css("visibility", "hidden");
|
||||
});
|
||||
};
|
||||
|
||||
@ -347,22 +347,22 @@ Refine.OpenProjectUI.refreshProject = function(tr, metaData) {
|
||||
refreshMetaField(metaData.description,index); index++;
|
||||
refreshMetaField(metaData.rowNumbe,index); index++;
|
||||
|
||||
var updateUserMetaData = function(ob) {
|
||||
var userMetaData = ob.userMetaData;
|
||||
var updateUserMetadata = function(ob) {
|
||||
var userMetadata = ob.userMetadata;
|
||||
|
||||
for ( var n in ob) {
|
||||
for ( var i in userMetaData) {
|
||||
if (n === userMetaData[i].name) {
|
||||
userMetaData[i].value = ob[n];
|
||||
for ( var i in userMetadata) {
|
||||
if (n === userMetadata[i].name) {
|
||||
userMetadata[i].value = ob[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob.userMetaData = userMetaData;
|
||||
ob.userMetadata = userMetadata;
|
||||
};
|
||||
updateUserMetaData(metaData);
|
||||
var data = metaData.userMetaData;
|
||||
updateUserMetadata(metaData);
|
||||
var data = metaData.userMetadata;
|
||||
for(var i in data)
|
||||
{
|
||||
if (data[i].display === true) {
|
||||
|
Loading…
Reference in New Issue
Block a user