use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class SchemaExporterTest method testNoSchema.
@Test
public void testNoSchema() throws IOException {
Project project = this.createCSVProject("a,b\nc,d");
Engine engine = new Engine(project);
StringWriter writer = new StringWriter();
Properties properties = new Properties();
exporter.export(project, properties, engine, writer);
TestUtils.assertEqualAsJson("{\"itemDocuments\":[],\"siteIri\":null,\"mediaWikiApiEndpoint\":null,\"entityTypeSiteIRI\":{}}", writer.toString());
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class NewEntityLibraryTest method testUpdateReconciledCells.
@Test
public void testUpdateReconciledCells() {
Project project = createCSVProject(TestingData.inceptionWithNewCsv);
StandardReconConfig config = new StandardReconConfig("http://my.endpoint", "http://my.schema", "http://my.schema", "Q5", "human", true, Collections.emptyList());
project.columnModel.columns.get(0).setReconConfig(config);
project.rows.get(0).cells.set(0, TestingData.makeNewItemCell(3289L, "University of Ljubljana"));
project.rows.get(1).cells.set(0, TestingData.makeMatchedCell("Q865528", "University of Warwick"));
project.rows.get(2).cells.set(0, TestingData.makeNewItemCell(1234L, "new uni"));
isNewTo(3289L, project.rows.get(0).cells.get(0));
isMatchedTo("Q865528", project.rows.get(1).cells.get(0));
isNewTo(1234L, project.rows.get(2).cells.get(0));
library.updateReconciledCells(project, false);
Cell firstCell = project.rows.get(0).cells.get(0);
isMatchedTo("Q384", firstCell);
assertTrue((Boolean) firstCell.recon.getFeature(Recon.Feature_nameMatch));
isMatchedTo("Q865528", project.rows.get(1).cells.get(0));
isMatchedTo("Q345", project.rows.get(2).cells.get(0));
assertTrue(project.rows.get(2).cells.get(0).recon.getFeature(Recon.Feature_nameLevenshtein).equals(0));
library.updateReconciledCells(project, true);
isNewTo(3289L, project.rows.get(0).cells.get(0));
isMatchedTo("Q865528", project.rows.get(1).cells.get(0));
isNewTo(1234L, project.rows.get(2).cells.get(0));
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class GDataImportingController method doCreateProject.
private void doCreateProject(HttpServletRequest request, HttpServletResponse response, Properties parameters) throws ServletException, IOException {
final String token = TokenCookie.getToken(request);
long jobID = Long.parseLong(parameters.getProperty("jobID"));
final ImportingJob job = ImportingManager.getJob(jobID);
if (job == null) {
HttpUtilities.respond(response, "error", "No such import job");
return;
}
job.updating = true;
final ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(request.getParameter("options"));
final List<Exception> exceptions = new LinkedList<Exception>();
job.setState("creating-project");
final Project project = new Project();
new Thread() {
@Override
public void run() {
ProjectMetadata pm = new ProjectMetadata();
pm.setName(JSONUtilities.getString(optionObj, "projectName", "Untitled"));
pm.setEncoding(JSONUtilities.getString(optionObj, "encoding", "UTF-8"));
try {
GDataImporter.parse(token, project, pm, job, -1, optionObj, exceptions);
} catch (IOException e) {
logger.error(ExceptionUtils.getStackTrace(e));
}
if (!job.canceled) {
if (exceptions.size() > 0) {
job.setError(exceptions);
} else {
// update all internal models, indexes, caches, etc.
project.update();
ProjectManager.singleton.registerProject(project, pm);
job.setState("created-project");
job.setProjectID(project.id);
}
job.touch();
job.updating = false;
}
}
}.start();
HttpUtilities.respond(response, "ok", "done");
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class JythonEvaluableTest method testJythonConcurrent.
@Test
public void testJythonConcurrent() {
Properties props = new Properties();
Project project = new Project();
Row row = new Row(2);
row.setCell(0, new Cell("one", null));
row.setCell(0, new Cell("1", null));
props.put("columnName", "number");
props.put("true", "true");
props.put("false", "false");
props.put("rowIndex", "0");
props.put("value", 1);
props.put("project", project);
props.put("call", "number");
props.put("PI", "3.141592654");
props.put("cells", new CellTuple(project, row));
Evaluable eval1 = new JythonEvaluable("a = value\nreturn a * 2");
Long value1 = (Long) eval1.evaluate(props);
// create some unrelated evaluable
new JythonEvaluable("a = value\nreturn a * 10");
// repeat same previous test
Long value2 = (Long) eval1.evaluate(props);
Assert.assertEquals(value1, value2);
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class SavedConnectionCommandTest method setUp.
@BeforeMethod
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
File dir = DBExtensionTestUtils.createTempDirectory("OR_DBExtension_Test_WorkspaceDir");
FileProjectManager.initialize(dir);
servlet = new RefineDbServletStub();
ImportingManager.initialize(servlet);
project = new Project();
metadata = new ProjectMetadata();
// job = ImportingManager.createJob();
metadata.setName("Save DB Config Test Project");
ProjectManager.singleton.registerProject(project, metadata);
SUT = new SavedConnectionCommand();
}
Aggregations