change MetaData to Metadata

This commit is contained in:
Jacky 2017-11-08 20:30:01 -05:00
parent fc2f81046f
commit 31943f6c9f
9 changed files with 53 additions and 53 deletions

View File

@ -71,7 +71,7 @@ public class ProjectMetadata implements Jsonizable {
private int _rowNumber; // at the creation. Essential for cleaning old projects too heavy private int _rowNumber; // at the creation. Essential for cleaning old projects too heavy
// import options is an array for 1-n data sources // import options is an array for 1-n data sources
private JSONArray _importOptionMetaData = new JSONArray(); private JSONArray _importOptionMetadata = new JSONArray();
// user metadata // user metadata
private JSONArray _userMetadata = new JSONArray();; private JSONArray _userMetadata = new JSONArray();;
@ -120,9 +120,9 @@ public class ProjectMetadata implements Jsonizable {
writer.endObject(); writer.endObject();
// write JSONArray directly // write JSONArray directly
if (_importOptionMetaData.length() > 0 ) { if (_importOptionMetadata.length() > 0 ) {
writer.key("importOptionMetaData"); writer.key("importOptionMetadata");
writer.value(_importOptionMetaData); writer.value(_importOptionMetadata);
} }
// write user metadata in {name, value, display} form: // 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 { try {
JSONArray jsonArray = obj.getJSONArray("importOptionMetaData"); JSONArray jsonArray = obj.getJSONArray("importOptionMetadata");
pm._importOptionMetaData = jsonArray; pm._importOptionMetadata = jsonArray;
} catch (JSONException e) { } catch (JSONException e) {
logger.error(ExceptionUtils.getFullStackTrace(e)); logger.error(ExceptionUtils.getFullStackTrace(e));
} }
@ -330,17 +330,17 @@ public class ProjectMetadata implements Jsonizable {
updateModified(); updateModified();
} }
public JSONArray getImportOptionMetaData() { public JSONArray getImportOptionMetadata() {
return _importOptionMetaData; return _importOptionMetadata;
} }
public void setImportOptionMetaData(JSONArray jsonArray) { public void setImportOptionMetadata(JSONArray jsonArray) {
_importOptionMetaData = jsonArray; _importOptionMetadata = jsonArray;
updateModified(); updateModified();
} }
public void appendImportOptionMetaData(JSONObject obj) { public void appendImportOptionMetadata(JSONObject obj) {
_importOptionMetaData.put(obj); _importOptionMetadata.put(obj);
updateModified(); updateModified();
} }

View File

@ -13,7 +13,7 @@ import com.google.refine.ProjectMetadata;
import com.google.refine.commands.Command; import com.google.refine.commands.Command;
import com.google.refine.model.Project; import com.google.refine.model.Project;
public class SetProjectMetaDataCommand extends Command { public class SetProjectMetadataCommand extends Command {
@Override @Override
public void doPost(HttpServletRequest request, HttpServletResponse response) public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {

View File

@ -76,11 +76,11 @@ public class GetAllProjectMetadataCommand extends Command {
} }
writer.endObject(); writer.endObject();
String userMeta = (String)ProjectManager.singleton.getPreferenceStore().get("userMetaData"); String userMeta = (String)ProjectManager.singleton.getPreferenceStore().get("userMetadata");
if (userMeta != null) { if (userMeta != null) {
writer.key("customMetaDataColumns"); writer.key("customMetadataColumns");
JSONArray customMetaDataColumns = new JSONArray(userMeta); JSONArray customMetadataColumns = new JSONArray(userMeta);
writer.value(customMetaDataColumns); writer.value(customMetadataColumns);
} }
writer.endObject(); writer.endObject();

View File

@ -155,7 +155,7 @@ abstract public class ImportingParserBase implements ImportingParser {
// ignore // ignore
} }
// set the import options to metadata: // set the import options to metadata:
metadata.appendImportOptionMetaData(options); metadata.appendImportOptionMetadata(options);
} }
public void parseOneFile( public void parseOneFile(

View File

@ -431,7 +431,7 @@ public class FileProjectManager extends ProjectManager {
boolean found = false; boolean found = false;
JSONObject placeHolderJsonObj = userMetadataPreference.getJSONObject(index); JSONObject placeHolderJsonObj = userMetadataPreference.getJSONObject(index);
if (!isValidUserMetaDataDefinition(placeHolderJsonObj)) { if (!isValidUserMetadataDefinition(placeHolderJsonObj)) {
logger.warn("Skipped invalid user metadata definition" + placeHolderJsonObj.toString()); logger.warn("Skipped invalid user metadata definition" + placeHolderJsonObj.toString());
continue; continue;
} }
@ -463,7 +463,7 @@ public class FileProjectManager extends ProjectManager {
* @param placeHolderJsonObj * @param placeHolderJsonObj
* @return * @return
*/ */
private boolean isValidUserMetaDataDefinition(JSONObject placeHolderJsonObj) { private boolean isValidUserMetadataDefinition(JSONObject placeHolderJsonObj) {
return (placeHolderJsonObj != null && return (placeHolderJsonObj != null &&
placeHolderJsonObj.has("name") && placeHolderJsonObj.has("name") &&
placeHolderJsonObj.has("display")); placeHolderJsonObj.has("display"));

View File

@ -48,7 +48,7 @@ import com.google.refine.Jsonizable;
import com.google.refine.RefineServlet; import com.google.refine.RefineServlet;
public class PreferenceStore implements Jsonizable { 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; private boolean dirty = false;
protected Map<String, Object> _prefs = new HashMap<String, Object>(); protected Map<String, Object> _prefs = new HashMap<String, Object>();

View File

@ -68,11 +68,11 @@ function registerCommands() {
RS.registerCommand(module, "get-project-metadata", new Packages.com.google.refine.commands.project.GetProjectMetadataCommand()); 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, "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, "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, "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-models", new Packages.com.google.refine.commands.project.GetModelsCommand());
RS.registerCommand(module, "get-rows", new Packages.com.google.refine.commands.row.GetRowsCommand()); RS.registerCommand(module, "get-rows", new Packages.com.google.refine.commands.row.GetRowsCommand());

View File

@ -4,7 +4,7 @@ function EditMetadataDialog(metaData, targetRowElem) {
this._metaDataUIs = []; this._metaDataUIs = [];
this._metaData = metaData; this._metaData = metaData;
this._MetaDataUI = function(tr, key, value, project) { this._MetadataUI = function(tr, key, value, project) {
var self = this; var self = this;
var td0 = tr.insertCell(0); var td0 = tr.insertCell(0);
$(td0).text(key); $(td0).text(key);
@ -14,7 +14,7 @@ function EditMetadataDialog(metaData, targetRowElem) {
var td2 = tr.insertCell(2); 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() { $('<button class="button">').text($.i18n._('core-index')["edit"]).appendTo(td2).click(function() {
var newValue = window.prompt($.i18n._('core-index')["change-metadata-value"]+" " + key, value); var newValue = window.prompt($.i18n._('core-index')["change-metadata-value"]+" " + key, value);
if (newValue !== null) { if (newValue !== null) {
@ -78,19 +78,19 @@ EditMetadataDialog.prototype._createDialog = function() {
return toReturn; 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 tr = metadataTable.insertRow(metadataTable.rows.length);
var v; var v;
if (typeof flatMetaData[k] === 'string') { if (typeof flatMetadata[k] === 'string') {
v = flatMetaData[k].replace(/\"/g, ""); v = flatMetadata[k].replace(/\"/g, "");
} else { } 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));
} }
}; };

View File

@ -108,17 +108,17 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
var project = data.projects[n]; var project = data.projects[n];
project.id = n; project.id = n;
project.date = Date.parseExact(project.modified, "yyyy-MM-ddTHH:mm:ssZ"); 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; var found = false;
for(var i = 0; i < project.userMetaData.length; i++) { for(var i = 0; i < project.userMetadata.length; i++) {
if (project.userMetaData[i].name === data.customMetaDataColumns[n].name) { if (project.userMetadata[i].name === data.customMetadataColumns[n].name) {
found = true; found = true;
break; break;
} }
if (!found) { if (!found) {
project.userMetaData.push({ project.userMetadata.push({
name: data.customMetaDataColumns[n].name, name: data.customMetadataColumns[n].name,
dispay: data.customMetaDataColumns[n].display, dispay: data.customMetadataColumns[n].display,
value: "" value: ""
}); });
} }
@ -148,9 +148,9 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
'<th>'+$.i18n._('core-index-open')["row-number"]+'</th>' + '<th>'+$.i18n._('core-index-open')["row-number"]+'</th>' +
(function() { (function() {
var htmlDisplay = ""; var htmlDisplay = "";
for (var n in data.customMetaDataColumns) { for (var n in data.customMetadataColumns) {
if (data.customMetaDataColumns[n].display) { if (data.customMetadataColumns[n].display) {
htmlDisplay += '<th>'+ data.customMetaDataColumns[n].name + '</th>'; 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%') $(tr.insertCell(tr.cells.length)).css('width', '1%')
); );
var editMetaDataLink = $('<a></a>') var editMetadataLink = $('<a></a>')
.text($.i18n._('core-index-open')["edit-meta-data"]) .text($.i18n._('core-index-open')["edit-meta-data"])
.addClass("secondary") .addClass("secondary")
.attr("href", "javascript:{}") .attr("href", "javascript:{}")
@ -257,7 +257,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
appendMetaField(project.description, '20%'); appendMetaField(project.description, '20%');
appendMetaField(project.rowNumber); appendMetaField(project.rowNumber);
var data = project.userMetaData; var data = project.userMetadata;
for(var i in data) for(var i in data)
{ {
if (data[i].display === true) { if (data[i].display === true) {
@ -268,11 +268,11 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
$(tr).mouseenter(function() { $(tr).mouseenter(function() {
renameLink.css("visibility", "visible"); renameLink.css("visibility", "visible");
deleteLink.css("visibility", "visible"); deleteLink.css("visibility", "visible");
editMetaDataLink.css("visibility", "visible"); editMetadataLink.css("visibility", "visible");
}).mouseleave(function() { }).mouseleave(function() {
renameLink.css("visibility", "hidden"); renameLink.css("visibility", "hidden");
deleteLink.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.description,index); index++;
refreshMetaField(metaData.rowNumbe,index); index++; refreshMetaField(metaData.rowNumbe,index); index++;
var updateUserMetaData = function(ob) { var updateUserMetadata = function(ob) {
var userMetaData = ob.userMetaData; var userMetadata = ob.userMetadata;
for ( var n in ob) { for ( var n in ob) {
for ( var i in userMetaData) { for ( var i in userMetadata) {
if (n === userMetaData[i].name) { if (n === userMetadata[i].name) {
userMetaData[i].value = ob[n]; userMetadata[i].value = ob[n];
break; break;
} }
} }
} }
ob.userMetaData = userMetaData; ob.userMetadata = userMetadata;
}; };
updateUserMetaData(metaData); updateUserMetadata(metaData);
var data = metaData.userMetaData; var data = metaData.userMetadata;
for(var i in data) for(var i in data)
{ {
if (data[i].display === true) { if (data[i].display === true) {