Merge branch 'master' of https://github.com/OpenRefine/OpenRefine
This commit is contained in:
commit
3a3083a1de
19
licenses/recurser_jquery-i18n.LICENSE.txt
Normal file
19
licenses/recurser_jquery-i18n.LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -33,17 +33,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.commands.cell;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import com.google.refine.commands.Command;
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.cell.MultiValuedCellSplitOperation;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
import com.google.refine.process.Process;
|
||||
|
||||
public class SplitMultiValueCellsCommand extends Command {
|
||||
@ -58,11 +61,33 @@ public class SplitMultiValueCellsCommand extends Command {
|
||||
String keyColumnName = request.getParameter("keyColumnName");
|
||||
String separator = request.getParameter("separator");
|
||||
String mode = request.getParameter("mode");
|
||||
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(columnName, keyColumnName, separator, mode);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
performProcessAndRespond(request, response, project, process);
|
||||
Boolean regex = Boolean.parseBoolean(request.getParameter("regex"));
|
||||
|
||||
if ("separator".equals(mode)) {
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(columnName,
|
||||
keyColumnName,
|
||||
separator,
|
||||
regex);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
performProcessAndRespond(request, response, project, process);
|
||||
} else {
|
||||
String s = request.getParameter("fieldLengths");
|
||||
|
||||
JSONArray a = ParsingUtilities.evaluateJsonStringToArray(s);
|
||||
int[] fieldLengths = new int[a.length()];
|
||||
|
||||
for (int i = 0; i < fieldLengths.length; i++) {
|
||||
fieldLengths[i] = a.getInt(i);
|
||||
}
|
||||
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(columnName,
|
||||
keyColumnName,
|
||||
fieldLengths);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
performProcessAndRespond(request, response, project, process);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
|
@ -33,9 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.operations.cell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.json.JSONException;
|
||||
@ -50,32 +51,64 @@ import com.google.refine.model.Project;
|
||||
import com.google.refine.model.Row;
|
||||
import com.google.refine.model.changes.MassRowChange;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.util.JSONUtilities;
|
||||
|
||||
public class MultiValuedCellSplitOperation extends AbstractOperation {
|
||||
final protected String _columnName;
|
||||
final protected String _keyColumnName;
|
||||
final protected String _separator;
|
||||
final protected String _mode;
|
||||
final protected String _separator;
|
||||
final protected boolean _regex;
|
||||
|
||||
final protected int[] _fieldLengths;
|
||||
|
||||
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
|
||||
return new MultiValuedCellSplitOperation(
|
||||
obj.getString("columnName"),
|
||||
obj.getString("keyColumnName"),
|
||||
obj.getString("separator"),
|
||||
obj.getString("mode")
|
||||
);
|
||||
String mode = obj.getString("mode");
|
||||
|
||||
if ("separator".equals(mode)) {
|
||||
return new MultiValuedCellSplitOperation(
|
||||
obj.getString("columnName"),
|
||||
obj.getString("keyColumnName"),
|
||||
obj.getString("separator"),
|
||||
obj.getBoolean("regex")
|
||||
);
|
||||
} else {
|
||||
return new MultiValuedCellSplitOperation(
|
||||
obj.getString("columnName"),
|
||||
obj.getString("keyColumnName"),
|
||||
JSONUtilities.getIntArray(obj, "fieldLengths")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public MultiValuedCellSplitOperation(
|
||||
String columnName,
|
||||
String keyColumnName,
|
||||
String separator,
|
||||
String mode
|
||||
String separator,
|
||||
boolean regex
|
||||
) {
|
||||
_columnName = columnName;
|
||||
_keyColumnName = keyColumnName;
|
||||
_separator = separator;
|
||||
_mode = mode;
|
||||
_mode = "separator";
|
||||
_regex = regex;
|
||||
|
||||
_fieldLengths = null;
|
||||
}
|
||||
|
||||
public MultiValuedCellSplitOperation(
|
||||
String columnName,
|
||||
String keyColumnName,
|
||||
int[] fieldLengths
|
||||
) {
|
||||
_columnName = columnName;
|
||||
_keyColumnName = keyColumnName;
|
||||
|
||||
_mode = "lengths";
|
||||
_separator = null;
|
||||
_regex = false;
|
||||
|
||||
_fieldLengths = fieldLengths;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,8 +120,17 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
|
||||
writer.key("description"); writer.value("Split multi-valued cells in column " + _columnName);
|
||||
writer.key("columnName"); writer.value(_columnName);
|
||||
writer.key("keyColumnName"); writer.value(_keyColumnName);
|
||||
writer.key("separator"); writer.value(_separator);
|
||||
writer.key("mode"); writer.value(_mode);
|
||||
if ("separator".equals(_mode)) {
|
||||
writer.key("separator"); writer.value(_separator);
|
||||
writer.key("regex"); writer.value(_regex);
|
||||
} else {
|
||||
writer.key("fieldLengths"); writer.array();
|
||||
for (int l : _fieldLengths) {
|
||||
writer.value(l);
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
@ -110,7 +152,7 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
|
||||
throw new Exception("No key column named " + _keyColumnName);
|
||||
}
|
||||
int keyCellIndex = keyColumn.getCellIndex();
|
||||
|
||||
|
||||
List<Row> newRows = new ArrayList<Row>();
|
||||
|
||||
int oldRowCount = project.rows.size();
|
||||
@ -124,8 +166,28 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
|
||||
Object value = oldRow.getCellValue(cellIndex);
|
||||
String s = value instanceof String ? ((String) value) : value.toString();
|
||||
String[] values = null;
|
||||
if (_mode.equals("regex")) {
|
||||
values = s.split(_separator);
|
||||
if("lengths".equals(_mode)) {
|
||||
if (_fieldLengths.length >= 0 && _fieldLengths[0] > 0) {
|
||||
values = new String[_fieldLengths.length];
|
||||
|
||||
int lastIndex = 0;
|
||||
|
||||
for (int i = 0; i < _fieldLengths.length; i++) {
|
||||
int thisIndex = lastIndex;
|
||||
|
||||
Object o = _fieldLengths[i];
|
||||
if (o instanceof Number) {
|
||||
thisIndex = Math.min(s.length(), lastIndex + Math.max(0, ((Number) o).intValue()));
|
||||
}
|
||||
|
||||
values[i] = s.substring(lastIndex, thisIndex);
|
||||
lastIndex = thisIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_regex) {
|
||||
Pattern pattern = Pattern.compile(_separator);
|
||||
values = pattern.split(s);
|
||||
} else {
|
||||
values = StringUtils.splitByWholeSeparatorPreserveAllTokens(s, _separator);
|
||||
}
|
||||
@ -138,14 +200,14 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
|
||||
// First value goes into the same row
|
||||
{
|
||||
Row firstNewRow = oldRow.dup();
|
||||
firstNewRow.setCell(cellIndex, new Cell(values[0].trim(), null));
|
||||
firstNewRow.setCell(cellIndex, new Cell(values[0], null));
|
||||
|
||||
newRows.add(firstNewRow);
|
||||
}
|
||||
|
||||
int r2 = r + 1;
|
||||
for (int v = 1; v < values.length; v++) {
|
||||
Cell newCell = new Cell(values[v].trim(), null);
|
||||
Cell newCell = new Cell(values[v], null);
|
||||
|
||||
if (r2 < project.rows.size()) {
|
||||
Row oldRow2 = project.rows.get(r2);
|
||||
|
@ -0,0 +1,223 @@
|
||||
/*
|
||||
|
||||
Copyright 2010, Google Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
package com.google.refine.tests.model;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.ProjectManager;
|
||||
import com.google.refine.ProjectMetadata;
|
||||
import com.google.refine.RefineServlet;
|
||||
import com.google.refine.importers.SeparatorBasedImporter;
|
||||
import com.google.refine.importing.ImportingJob;
|
||||
import com.google.refine.importing.ImportingManager;
|
||||
import com.google.refine.io.FileProjectManager;
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
import com.google.refine.model.ModelException;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.process.Process;
|
||||
import com.google.refine.operations.cell.MultiValuedCellSplitOperation;
|
||||
import com.google.refine.tests.RefineServletStub;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
|
||||
public class SplitMultiValuedCellsTests extends RefineTest {
|
||||
// dependencies
|
||||
private RefineServlet servlet;
|
||||
private Project project;
|
||||
private ProjectMetadata pm;
|
||||
private JSONObject options;
|
||||
private ImportingJob job;
|
||||
private SeparatorBasedImporter importer;
|
||||
|
||||
|
||||
@Override
|
||||
@BeforeTest
|
||||
public void init() {
|
||||
logger = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp() throws JSONException, IOException, ModelException {
|
||||
servlet = new RefineServletStub();
|
||||
File dir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
|
||||
FileProjectManager.initialize(dir);
|
||||
project = new Project();
|
||||
pm = new ProjectMetadata();
|
||||
pm.setName("SplitMultiValuedCells test");
|
||||
ProjectManager.singleton.registerProject(project, pm);
|
||||
options = mock(JSONObject.class);
|
||||
|
||||
ImportingManager.initialize(servlet);
|
||||
job = ImportingManager.createJob();
|
||||
importer = new SeparatorBasedImporter();
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void TearDown() {
|
||||
ImportingManager.disposeJob(job.id);
|
||||
ProjectManager.singleton.deleteProject(project.id);
|
||||
job = null;
|
||||
project = null;
|
||||
pm = null;
|
||||
options = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to demonstrate the intended behaviour of the function, for issue #1268
|
||||
* https://github.com/OpenRefine/OpenRefine/issues/1268
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testSplitMultiValuedCellsTextSeparator() throws Exception {
|
||||
String csv = "Key,Value\n"
|
||||
+ "Record_1,one:two;three four\n";
|
||||
prepareOptions(",", 10, 0, 0, 1, false, false);
|
||||
List<Exception> exceptions = new ArrayList<Exception>();
|
||||
importer.parseOneFile(project, pm, job, "filesource", new StringReader(csv), -1, options, exceptions);
|
||||
project.update();
|
||||
ProjectManager.singleton.registerProject(project, pm);
|
||||
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(
|
||||
"Value",
|
||||
"Key",
|
||||
":",
|
||||
false);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
process.performImmediate();
|
||||
|
||||
int keyCol = project.columnModel.getColumnByName("Key").getCellIndex();
|
||||
int valueCol = project.columnModel.getColumnByName("Value").getCellIndex();
|
||||
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(keyCol), "Record_1");
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(valueCol), "one");
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(valueCol), "two;three four");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitMultiValuedCellsRegExSeparator() throws Exception {
|
||||
String csv = "Key,Value\n"
|
||||
+ "Record_1,one:two;three four\n";
|
||||
prepareOptions(",", 10, 0, 0, 1, false, false);
|
||||
List<Exception> exceptions = new ArrayList<Exception>();
|
||||
importer.parseOneFile(project, pm, job, "filesource", new StringReader(csv), -1, options, exceptions);
|
||||
project.update();
|
||||
ProjectManager.singleton.registerProject(project, pm);
|
||||
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(
|
||||
"Value",
|
||||
"Key",
|
||||
"\\W",
|
||||
true);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
process.performImmediate();
|
||||
|
||||
int keyCol = project.columnModel.getColumnByName("Key").getCellIndex();
|
||||
int valueCol = project.columnModel.getColumnByName("Value").getCellIndex();
|
||||
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(keyCol), "Record_1");
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(valueCol), "one");
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(valueCol), "two");
|
||||
Assert.assertEquals(project.rows.get(2).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(2).getCellValue(valueCol), "three");
|
||||
Assert.assertEquals(project.rows.get(3).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(3).getCellValue(valueCol), "four");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitMultiValuedCellsLengths() throws Exception {
|
||||
String csv = "Key,Value\n"
|
||||
+ "Record_1,one:two;three four\n";
|
||||
prepareOptions(",", 10, 0, 0, 1, false, false);
|
||||
List<Exception> exceptions = new ArrayList<Exception>();
|
||||
importer.parseOneFile(project, pm, job, "filesource", new StringReader(csv), -1, options, exceptions);
|
||||
project.update();
|
||||
ProjectManager.singleton.registerProject(project, pm);
|
||||
int[] lengths = {4,4,6,4};
|
||||
|
||||
AbstractOperation op = new MultiValuedCellSplitOperation(
|
||||
"Value",
|
||||
"Key",
|
||||
lengths);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
process.performImmediate();
|
||||
|
||||
int keyCol = project.columnModel.getColumnByName("Key").getCellIndex();
|
||||
int valueCol = project.columnModel.getColumnByName("Value").getCellIndex();
|
||||
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(keyCol), "Record_1");
|
||||
Assert.assertEquals(project.rows.get(0).getCellValue(valueCol), "one:");
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(1).getCellValue(valueCol), "two;");
|
||||
Assert.assertEquals(project.rows.get(2).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(2).getCellValue(valueCol), "three ");
|
||||
Assert.assertEquals(project.rows.get(3).getCellValue(keyCol), null);
|
||||
Assert.assertEquals(project.rows.get(3).getCellValue(valueCol), "four");
|
||||
}
|
||||
|
||||
private void prepareOptions(
|
||||
String sep, int limit, int skip, int ignoreLines,
|
||||
int headerLines, boolean guessValueType, boolean ignoreQuotes) {
|
||||
|
||||
whenGetStringOption("separator", options, sep);
|
||||
whenGetIntegerOption("limit", options, limit);
|
||||
whenGetIntegerOption("skipDataLines", options, skip);
|
||||
whenGetIntegerOption("ignoreLines", options, ignoreLines);
|
||||
whenGetIntegerOption("headerLines", options, headerLines);
|
||||
whenGetBooleanOption("guessCellValueTypes", options, guessValueType);
|
||||
whenGetBooleanOption("processQuotes", options, !ignoreQuotes);
|
||||
whenGetBooleanOption("storeBlankCellsAsNulls", options, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
9597
main/webapp/modules/core/externals/jquery-1.9.1.js
vendored
9597
main/webapp/modules/core/externals/jquery-1.9.1.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,4 @@
|
||||
/*! jQuery based internationalization library, Copyright 2010 Dave Perrett, http://recursive-design.com/
|
||||
* Released under the MIT license -- https://opensource.org/licenses/MIT */
|
||||
(function(f){f.i18n={dict:null,plural:null,setDictionary:function(a){null===this.dict?this.dict=a:f.extend(this.dict,a)},setPlural:function(a){this.plural=a},_p:function(a,d,e){var c=this.dict[a],b=[];b.push(e);if(void 0===c||null===this.plural)return this.printf(1<e?d:a,b);a=this.plural.replace(/n%/g,e+"%");eval(a);return this.printf(c[plural],b)},_:function(a,d){var e=a;this.dict&&this.dict[a]&&(e=this.dict[a]);return this.printf(e,d)},printf:function(a,d){if(!d)return a;for(var e="",c=/%(\d+)\$s/g,
|
||||
b=c.exec(a);b;){var f=parseInt(b[1],10)-1;a=a.replace("%"+b[1]+"$s",d[f]);b=c.exec(a)}c=a.split("%s");if(1<c.length)for(b=0;b<d.length;b++)0<c[b].length&&c[b].lastIndexOf("%")==c[b].length-1&&(c[b]+="s"+c.splice(b+1,1)[0]),e+=c[b]+d[b];return e+c[c.length-1]}};f.fn._t=function(a,d){return f(this).text(f.i18n._(a,d))}})(jQuery);
|
@ -532,6 +532,7 @@
|
||||
"split-col": "Split column",
|
||||
"several-col": "into several columns",
|
||||
"how-split": "How to Split Column",
|
||||
"how-split-cells": "How to split multi-valued cells",
|
||||
"by-sep": "by separator",
|
||||
"separator": "Separator",
|
||||
"reg-exp": "regular expression",
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Français",
|
||||
"core-index": {
|
||||
"change-value": "Changer la valeur de la clé de préférence",
|
||||
"change-value": "Changer la valeur de cette préférence",
|
||||
"preferences": "Préférences",
|
||||
"about": "À propos",
|
||||
"slogan": "Un outil puissant pour travailler avec des données désordonnées",
|
||||
@ -10,17 +10,17 @@
|
||||
"edit": "Éditer",
|
||||
"add-pref": "Ajouter une préférence",
|
||||
"value": "Valeur",
|
||||
"no-proj": "Aucun projet n’existe. Cliquer sur 'Créer un projet' sur la gauche pour créer un nouveau projet.",
|
||||
"no-proj": "Aucun projet n’existe. Cliquer sur \"Créer un projet\" sur la gauche pour créer un nouveau projet.",
|
||||
"try-these": "Si vous ne disposez d’aucun jeu de données, vous pouvez essayer ces",
|
||||
"version": "Version",
|
||||
"key": "Clé",
|
||||
"key": "Préférence",
|
||||
"error-rename": "Échec du renommage du projet :",
|
||||
"download": "Télécharger",
|
||||
"sample-data": "jeux de données d'exemple",
|
||||
"new-version": "Nouvelle version !",
|
||||
"now": "maintenant",
|
||||
"delete-key": "Supprimer la clé de préférence",
|
||||
"pref-key": "Valeur de la clé de préférence :",
|
||||
"delete-key": "Supprimer la préférence",
|
||||
"pref-key": "Valeur de la préférence :",
|
||||
"delete": "Supprimer"
|
||||
},
|
||||
"core-index-create": {
|
||||
@ -85,7 +85,7 @@
|
||||
},
|
||||
"core-index-open": {
|
||||
"rename": "renommer",
|
||||
"del-body": "Êtes-vous sûr de supprimer ce projet \"",
|
||||
"del-body": "Êtes-vous sûr de vouloir supprimer ce projet \"",
|
||||
"open-proj": "Ouvrir un projet",
|
||||
"browse": "Parcourir le dossier de l’espace de travail",
|
||||
"warning-proj-name": "Vous devez donner un nom au projet.",
|
||||
@ -99,7 +99,7 @@
|
||||
"core-index-lang": {
|
||||
"lang-settings": "Langue",
|
||||
"send-req": "Changer la langue",
|
||||
"page-reload": "Cette page doit être actualisée pour appliquer le changement.",
|
||||
"page-reload": "Cette page sera actualisée pour appliquer le changement.",
|
||||
"label": "Choisir sa langue préférée"
|
||||
},
|
||||
"core-index-parser": {
|
||||
@ -134,7 +134,7 @@
|
||||
},
|
||||
"core-dialogs": {
|
||||
"help": "Aide",
|
||||
"medium-format": "Format local moyen",
|
||||
"medium-format": "Format moyen",
|
||||
"html-table": "Table HTML",
|
||||
"internal-err": "Erreur interne",
|
||||
"from-total": "</b> total",
|
||||
@ -144,11 +144,11 @@
|
||||
"keying-function": "Fonction de codage",
|
||||
"reuse": "Réutiliser",
|
||||
"date-format": "Pour la date/heure, utiliser le format",
|
||||
"focusing-on": "centre sur",
|
||||
"focusing-on": "centrer sur",
|
||||
"fingerprint": "empreinte",
|
||||
"block-chars": "Bloc de caractères",
|
||||
"long-format": "Format local long",
|
||||
"short-format": "Format local court",
|
||||
"long-format": "Format long",
|
||||
"short-format": "Format court",
|
||||
"leven": "Levenshtein",
|
||||
"rotated-clock": "Tourné de 45°",
|
||||
"upload": "Téléverser",
|
||||
@ -323,7 +323,7 @@
|
||||
"watch-cast": "Regarder ces tutoriels vidéos",
|
||||
"continue-remaining": "Poursuivre avec les opérations restantes",
|
||||
"remove-all": "Supprimer toutes les facettes",
|
||||
"complete": "terminer",
|
||||
"complete": "effectué",
|
||||
"undo": "Défaire",
|
||||
"warning-align": "Vous n’avez encore défini aucun schéma d’alignement,\n il n’y a donc aucun triplet à exporter.\n\n Utiliser la commande Freebase > Éditer le squelette du schéma d’alignement...\n pour commencer par aligner vos données avec les schémas Freebase.",
|
||||
"use-to-select": "Utiliser les facettes et les filtres pour sélectionner les sous-ensembles de données à traiter. Choisir les méthodes de facette et de filtre dans les menus situés dans les entêtes de colonne.",
|
||||
@ -367,7 +367,7 @@
|
||||
"all": "Tous les encodages",
|
||||
"years-ago": "années avant",
|
||||
"week-ago": "semaine dernière",
|
||||
"working": "En fonctionement",
|
||||
"working": "En fonctionnement",
|
||||
"encoding": "Encodage",
|
||||
"months-ago": "mois avant",
|
||||
"yesterday": "hier",
|
||||
|
@ -158,8 +158,8 @@ ExpressionPreviewDialog.Widget.prototype.getExpression = function(commit) {
|
||||
s = this._getLanguage() + ":" + s;
|
||||
if (commit) {
|
||||
$.post(
|
||||
"command/core/log-expression?" + $.param({ project: theProject.id, expression: s }),
|
||||
null,
|
||||
"command/core/log-expression?" + $.param({ project: theProject.id }),
|
||||
{ expression: s },
|
||||
function(data) {
|
||||
},
|
||||
"json"
|
||||
@ -390,7 +390,6 @@ ExpressionPreviewDialog.Widget.prototype.update = function() {
|
||||
var expression = this.expression = $.trim(this._elmts.expressionPreviewTextarea[0].value);
|
||||
var params = {
|
||||
project: theProject.id,
|
||||
expression: this._getLanguage() + ":" + expression,
|
||||
cellIndex: this._cellIndex
|
||||
};
|
||||
this._prepareUpdate(params);
|
||||
@ -398,6 +397,7 @@ ExpressionPreviewDialog.Widget.prototype.update = function() {
|
||||
$.post(
|
||||
"command/core/preview-expression?" + $.param(params),
|
||||
{
|
||||
expression: this._getLanguage() + ":" + expression,
|
||||
rowIndices: JSON.stringify(this._rowIndices)
|
||||
},
|
||||
function(data) {
|
||||
@ -421,10 +421,12 @@ ExpressionPreviewDialog.Widget.prototype._renderPreview = function(expression, d
|
||||
var table = $('<table></table>').appendTo(
|
||||
$('<div>').addClass("expression-preview-table-wrapper").appendTo(container))[0];
|
||||
|
||||
var truncExpression = expression.length > 30 ? expression.substring(0, 30) + ' ...' : expression;
|
||||
|
||||
var tr = table.insertRow(0);
|
||||
$(tr.insertCell(0)).addClass("expression-preview-heading").text("row");
|
||||
$(tr.insertCell(1)).addClass("expression-preview-heading").text("value");
|
||||
$(tr.insertCell(2)).addClass("expression-preview-heading").text(expression);
|
||||
$(tr.insertCell(2)).addClass("expression-preview-heading").text(truncExpression);
|
||||
|
||||
var renderValue = function(td, v) {
|
||||
if (v !== null && v !== undefined) {
|
||||
|
@ -178,7 +178,7 @@ Refine.reinitializeProjectData = function(f, fError) {
|
||||
$.getJSON(
|
||||
"command/core/get-project-metadata?" + $.param({ project: theProject.id }), null,
|
||||
function(data) {
|
||||
if (data.status == 'error') {
|
||||
if (data.status == "error") {
|
||||
alert(data.message);
|
||||
if (fError) {
|
||||
fError();
|
||||
@ -220,7 +220,7 @@ Refine._renameProject = function() {
|
||||
data: { "project" : theProject.id, "name" : name },
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data && typeof data.code != 'undefined' && data.code == "ok") {
|
||||
if (data && typeof data.code != "undefined" && data.code == "ok") {
|
||||
theProject.metadata.name = name;
|
||||
Refine.setTitle();
|
||||
} else {
|
||||
@ -425,9 +425,12 @@ Refine.fetchRows = function(start, limit, onDone, sorting) {
|
||||
}
|
||||
|
||||
$.post(
|
||||
"command/core/get-rows?" + $.param({ project: theProject.id, start: start, limit: limit }) + "&callback=?",
|
||||
"command/core/get-rows?" + $.param({ project: theProject.id, start: start, limit: limit }),
|
||||
body,
|
||||
function(data) {
|
||||
if(data.code === "error") {
|
||||
data = theProject.rowModel;
|
||||
}
|
||||
theProject.rowModel = data;
|
||||
|
||||
// Un-pool objects
|
||||
@ -445,7 +448,7 @@ Refine.fetchRows = function(start, limit, onDone, sorting) {
|
||||
onDone();
|
||||
}
|
||||
},
|
||||
"jsonp"
|
||||
"json"
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
function BrowsingEngine(div, facetConfigs) {
|
||||
this._div = div;
|
||||
this._mode = theProject.recordModel.hasRecords ? 'record-based' : 'row-based';
|
||||
this._mode = theProject.recordModel.hasRecords ? "record-based" : "row-based";
|
||||
|
||||
this._facets = [];
|
||||
this._initializeUI();
|
||||
@ -101,6 +101,7 @@ BrowsingEngine.prototype._initializeUI = function() {
|
||||
'<p>'+$.i18n._('core-project')["not-sure"]+'<br /><a href="https://github.com/OpenRefine/OpenRefine/wiki/Screencasts" target="_blank"><b>'+$.i18n._('core-project')["watch-cast"]+'</b></a></p>' +
|
||||
'</div>' +
|
||||
'<div class="browsing-panel-header" bind="header">' +
|
||||
'<div class="browsing-panel-errors" bind="errors"></div>' +
|
||||
'<div class="browsing-panel-indicator" bind="indicator">' +
|
||||
'<img src="images/small-spinner.gif" /> '+$.i18n._('core-project')["refreshing-facet"]+'' +
|
||||
'</div>' +
|
||||
@ -240,19 +241,31 @@ BrowsingEngine.prototype.update = function(onDone) {
|
||||
|
||||
this._elmts.header.show();
|
||||
this._elmts.controls.css("visibility", "hidden");
|
||||
this._elmts.indicator.css("visibility", "visible");
|
||||
this._elmts.indicator.css("display", "block");
|
||||
|
||||
$.post(
|
||||
"command/core/compute-facets?" + $.param({ project: theProject.id }),
|
||||
{ engine: JSON.stringify(this.getJSON(true)) },
|
||||
function(data) {
|
||||
if(data.code === "error") {
|
||||
var clearErr = $('#err-text').remove();
|
||||
var err = $('<div id="err-text">')
|
||||
.text(data.message)
|
||||
.appendTo(self._elmts.errors);
|
||||
self._elmts.errors.css("display", "block");
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
return;
|
||||
}
|
||||
var facetData = data.facets;
|
||||
|
||||
for (var i = 0; i < facetData.length; i++) {
|
||||
self._facets[i].facet.updateState(facetData[i]);
|
||||
}
|
||||
|
||||
self._elmts.indicator.css("visibility", "hidden");
|
||||
self._elmts.indicator.css("display", "none");
|
||||
self._elmts.errors.css("display", "none");
|
||||
if (self._facets.length > 0) {
|
||||
self._elmts.header.show();
|
||||
self._elmts.controls.css("visibility", "visible");
|
||||
|
@ -96,10 +96,13 @@ ProcessPanel.prototype.showUndo = function(historyEntry) {
|
||||
|
||||
this._latestHistoryEntry = historyEntry;
|
||||
|
||||
truncDescription = historyEntry.description.length > 250 ?
|
||||
historyEntry.description.substring(0, 250) + " ..." : historyEntry.description
|
||||
|
||||
this._div.stop(true, false);
|
||||
this._elmts.progressDiv.hide();
|
||||
this._elmts.undoDiv.show();
|
||||
this._elmts.undoDescription.text(historyEntry.description);
|
||||
this._elmts.undoDescription.text( truncDescription );
|
||||
this._elmts.undoLink.unbind().click(function() { self.undo(); });
|
||||
|
||||
this._div
|
||||
|
@ -36,13 +36,12 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
||||
Refine.postCoreProcess(
|
||||
"text-transform",
|
||||
{
|
||||
columnName: column.name,
|
||||
expression: expression,
|
||||
columnName: column.name,
|
||||
onError: onError,
|
||||
repeat: repeat,
|
||||
repeatCount: repeatCount
|
||||
},
|
||||
null,
|
||||
{ expression: expression },
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
};
|
||||
@ -125,7 +124,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
||||
{
|
||||
columnName: column.name,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator
|
||||
separator
|
||||
},
|
||||
null,
|
||||
{ rowsChanged: true }
|
||||
@ -134,20 +133,76 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
||||
};
|
||||
|
||||
var doSplitMultiValueCells = function() {
|
||||
var separator = window.prompt($.i18n._('core-views')["what-separator"], ",");
|
||||
if (separator !== null) {
|
||||
|
||||
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/split-multi-valued-cells-dialog.html"));
|
||||
var elmts = DOM.bind(frame);
|
||||
elmts.dialogHeader.text($.i18n._('core-views')["split-cells"]);
|
||||
|
||||
elmts.or_views_howSplit.text($.i18n._('core-views')["how-split-cells"]);
|
||||
elmts.or_views_bySep.text($.i18n._('core-views')["by-sep"]);
|
||||
elmts.or_views_separator.text($.i18n._('core-views')["separator"]);
|
||||
elmts.or_views_regExp.text($.i18n._('core-views')["reg-exp"]);
|
||||
|
||||
elmts.or_views_fieldLen.text($.i18n._('core-views')["field-len"]);
|
||||
elmts.or_views_listInt.text($.i18n._('core-views')["list-int"]);
|
||||
|
||||
elmts.okButton.html($.i18n._('core-buttons')["ok"]);
|
||||
elmts.cancelButton.text($.i18n._('core-buttons')["cancel"]);
|
||||
|
||||
var level = DialogSystem.showDialog(frame);
|
||||
var dismiss = function() { DialogSystem.dismissUntil(level - 1); };
|
||||
|
||||
elmts.cancelButton.click(dismiss);
|
||||
elmts.okButton.click(function() {
|
||||
var mode = $("input[name='split-by-mode']:checked")[0].value;
|
||||
var config = {
|
||||
columnName: column.name,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
mode
|
||||
};
|
||||
if (mode === "separator") {
|
||||
config.separator = elmts.separatorInput[0].value;
|
||||
if (!(config.separator)) {
|
||||
alert($.i18n._('core-views')["specify-sep"]);
|
||||
return;
|
||||
}
|
||||
|
||||
config.regex = elmts.regexInput[0].checked;
|
||||
|
||||
} else {
|
||||
var s = "[" + elmts.lengthsTextarea[0].value + "]";
|
||||
try {
|
||||
var a = JSON.parse(s);
|
||||
|
||||
var lengths = [];
|
||||
$.each(a, function(i,n) {
|
||||
if (typeof n == "number") {
|
||||
lengths.push(n);
|
||||
}
|
||||
});
|
||||
|
||||
if (lengths.length === 0) {
|
||||
alert($.i18n._('core-views')["warning-no-length"]);
|
||||
return;
|
||||
}
|
||||
|
||||
config.fieldLengths = JSON.stringify(lengths);
|
||||
|
||||
} catch (e) {
|
||||
alert($.i18n._('core-views')["warning-format"]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Refine.postCoreProcess(
|
||||
"split-multi-value-cells",
|
||||
{
|
||||
columnName: column.name,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator,
|
||||
mode: "plain"
|
||||
},
|
||||
config,
|
||||
null,
|
||||
{ rowsChanged: true }
|
||||
);
|
||||
}
|
||||
|
||||
dismiss();
|
||||
});
|
||||
};
|
||||
|
||||
MenuSystem.appendTo(menu, [ "core/edit-cells" ], [
|
||||
|
@ -72,13 +72,12 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
||||
Refine.postCoreProcess(
|
||||
"add-column",
|
||||
{
|
||||
baseColumnName: column.name,
|
||||
expression: previewWidget.getExpression(true),
|
||||
baseColumnName: column.name,
|
||||
newColumnName: columnName,
|
||||
columnInsertIndex: columnIndex + 1,
|
||||
onError: $('input[name="create-column-dialog-onerror-choice"]:checked')[0].value
|
||||
},
|
||||
null,
|
||||
{ expression: previewWidget.getExpression(true) },
|
||||
{ modelsChanged: true },
|
||||
{
|
||||
onDone: function(o) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
<div class="dialog-frame" style="width: 600px;">
|
||||
<div class="dialog-border">
|
||||
<div class="dialog-header" bind="dialogHeader"></div>
|
||||
<div class="dialog-body" bind="dialogBody">
|
||||
<div class="grid-layout layout-looser layout-full"><table><tr>
|
||||
<td>
|
||||
<div class="grid-layout layout-tighter"><table>
|
||||
<tr>
|
||||
<td colspan="3"><h3><span bind="or_views_howSplit"></span></h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="1%"><input type="radio" checked="true" name="split-by-mode" value="separator" id="$split-multi-valued-cells-by-separator" /></td>
|
||||
<td colspan="2"><label for="$split-multi-valued-cells-by-separator" bind="or_views_bySep"></label></td>
|
||||
</tr>
|
||||
<tr><td></td>
|
||||
<td bind="or_views_separator"></td>
|
||||
<td><input size="10" value="," bind="separatorInput" />
|
||||
<input type="checkbox" bind="regexInput" id="$split-column-regex" />
|
||||
<label for="$split-multi-valued-cells-regex" bind="or_views_regExp"></label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="1%"><input type="radio" name="split-by-mode" value="lengths" id="$split-multi-valued-cells-by-lengths" /></td>
|
||||
<td colspan="2"><label for="$split-multi-valued-cells-by-lengths" bind="or_views_fieldLen"></label></td>
|
||||
</tr>
|
||||
<tr><td></td>
|
||||
<td colspan="2"><textarea style="width: 100%;" bind="lengthsTextarea"></textarea></td>
|
||||
</tr>
|
||||
<tr><td></td>
|
||||
<td colspan="2" bind="or_views_listInt"></td>
|
||||
</tr>
|
||||
</table></div>
|
||||
</td>
|
||||
</table></div>
|
||||
</div>
|
||||
<div class="dialog-footer" bind="dialogFooter">
|
||||
<button class="button" bind="okButton"></button>
|
||||
<button class="button" bind="cancelButton"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -38,9 +38,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
display: none;
|
||||
}
|
||||
|
||||
.browsing-panel-errors {
|
||||
display: none;
|
||||
position: relative;
|
||||
height: auto;
|
||||
margin: 5px;
|
||||
text-align: center;
|
||||
background: #fff0f4;
|
||||
color: #c51244;
|
||||
padding: 4px 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.browsing-panel-indicator {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
display: none;
|
||||
position: relative;
|
||||
width: 50%;
|
||||
margin: 5px;
|
||||
top: 0em;
|
||||
|
21
refine
21
refine
@ -823,6 +823,22 @@ whitespace() {
|
||||
done
|
||||
}
|
||||
|
||||
checkJavaMajorVersion() {
|
||||
java_ver=$($JAVA -version 2>&1 | grep version | cut -d ' ' -f 3 | tr -d \")
|
||||
# Java 6, 7, 8 starts with 1.x
|
||||
if [ ${java_ver:0:2} == "1." ] ; then
|
||||
major=`echo ${java_ver} | sed -E 's/1\.([0-9])[0-9_.]{2,6}/\1/g'`
|
||||
else
|
||||
# Java 9+ starts with x using semver versioning
|
||||
major=`echo ${java_ver} | sed -E 's/([0-9]+)(-ea|(\.[0-9]+)*)/\1/g'`
|
||||
fi
|
||||
|
||||
JAVA_VERSION=$(echo ${major} | egrep '^(6|7|8|9)')
|
||||
if [ -z "$JAVA_VERSION" ] ; then
|
||||
error "OpenRefine requires Java version 6 or later. If you have multiple versions of Java installed, please set the environment variable JAVA_HOME to the correct version."
|
||||
fi
|
||||
}
|
||||
|
||||
# -------------------------- script -----------------------------
|
||||
|
||||
# ----- Normalize the current directory -------------------------
|
||||
@ -873,10 +889,7 @@ if [ ! -x "$JAVA" ] ; then
|
||||
error "Could not find the 'java' executable at '$JAVA', are you sure your JAVA_HOME environment variable is pointing to a proper java installation?"
|
||||
fi
|
||||
|
||||
JAVA_VERSION=`$JAVA -version 2>&1 | grep version | cut -d ' ' -f 3 | egrep '^\"1\.(6|7|8|9)'`
|
||||
if [ -z "$JAVA_VERSION" ] ; then
|
||||
error "OpenRefine requires Java version 6 or later. If you have multiple versions of Java installed, please set the environment variable JAVA_HOME to the correct version."
|
||||
fi
|
||||
checkJavaMajorVersion
|
||||
|
||||
# ----- Parse the command line args ------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user