use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.
the class CrossTests method crossFunctionOneArgumentTest1.
@Test
public void crossFunctionOneArgumentTest1() throws Exception {
Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", 0, "")).get(0)).row);
String address = row.getCell(1).value.toString();
Assert.assertEquals(address, "mary");
}
use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.
the class LookupCacheManager method computeLookup.
protected void computeLookup(ProjectLookup lookup) throws LookupException {
if (lookup.targetProjectID < 0) {
return;
}
Project targetProject = ProjectManager.singleton.getProject(lookup.targetProjectID);
ProjectMetadata targetProjectMetadata = ProjectManager.singleton.getProjectMetadata(lookup.targetProjectID);
if (targetProject == null) {
return;
}
// if this is a lookup on the index column
if (lookup.targetColumnName.equals(Cross.INDEX_COLUMN_NAME)) {
for (int r = 0; r < targetProject.rows.size(); r++) {
lookup.valueToRowIndices.put(String.valueOf(r), Collections.singletonList(r));
}
// return directly
return;
}
Column targetColumn = targetProject.columnModel.getColumnByName(lookup.targetColumnName);
if (targetColumn == null) {
throw new LookupException("Unable to find column " + lookup.targetColumnName + " in project " + targetProjectMetadata.getName());
}
// We can't use for-each here, because we'll need the row index when creating WrappedRow
int count = targetProject.rows.size();
for (int r = 0; r < count; r++) {
Row targetRow = targetProject.rows.get(r);
Object value = targetRow.getCellValue(targetColumn.getCellIndex());
if (ExpressionUtils.isNonBlankData(value)) {
String valueStr = value.toString();
lookup.valueToRowIndices.putIfAbsent(valueStr, new ArrayList<>());
lookup.valueToRowIndices.get(valueStr).add(r);
}
}
}
use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.
the class CrossTests method crossFunctionDoubleArgumentTest1.
@Test
public void crossFunctionDoubleArgumentTest1() throws Exception {
Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", 3.14f, "My Address Book", "friend")).get(0)).row);
String address = row.getCell(1).value.toString();
Assert.assertEquals(address, "double");
}
use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.
the class CrossTests method crossFunctionSameColumnTest.
@Test
public void crossFunctionSameColumnTest() throws Exception {
Project project = (Project) bindings.get("project");
Cell c = project.rows.get(0).cells.get(1);
WrappedCell lookup = new WrappedCell(project, "recipient", c);
Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", lookup, "My Address Book", "friend")).get(0)).row);
String address = row.getCell(1).value.toString();
Assert.assertEquals(address, "50 Broadway Ave.");
}
use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.
the class CrossTests method crossFunctionDoubleArgumentTest2.
@Test
public void crossFunctionDoubleArgumentTest2() throws Exception {
Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", "3.14", "My Address Book", "friend")).get(0)).row);
String address = row.getCell(1).value.toString();
Assert.assertEquals(address, "double");
}
Aggregations