Search in sources :

Example 96 with Project

use of com.google.refine.model.Project in project OpenRefine by OpenRefine.

the class ExpressionUtils method bind.

public static void bind(Properties bindings, Row row, int rowIndex, String columnName, Cell cell) {
    Project project = (Project) bindings.get("project");
    bindings.put("rowIndex", rowIndex);
    bindings.put("row", new WrappedRow(project, rowIndex, row));
    bindings.put("cells", new CellTuple(project, row));
    if (columnName != null) {
        bindings.put("columnName", columnName);
    }
    if (cell == null) {
        bindings.remove("cell");
        bindings.remove("value");
    } else {
        bindings.put("cell", new WrappedCell(project, columnName, cell));
        if (cell.value == null) {
            bindings.remove("value");
        } else {
            bindings.put("value", cell.value);
        }
    }
    for (Binder binder : s_binders) {
        binder.bind(bindings, row, rowIndex, columnName, cell);
    }
}
Also used : Project(com.google.refine.model.Project)

Example 97 with Project

use of com.google.refine.model.Project in project OpenRefine by OpenRefine.

the class TsvExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    // new TsvExporter();
    SUT = new CsvExporter('\t');
    writer = new StringWriter();
    project = new Project();
    engine = new Engine(project);
    options = mock(Properties.class);
}
Also used : Project(com.google.refine.model.Project) StringWriter(java.io.StringWriter) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 98 with Project

use of com.google.refine.model.Project in project OpenRefine by OpenRefine.

the class XlsExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new XlsExporter(false);
    stream = new ByteArrayOutputStream();
    ProjectManager.singleton = new ProjectManagerStub();
    projectMetadata = new ProjectMetadata();
    project = new Project();
    projectMetadata.setName(TEST_PROJECT_NAME);
    ProjectManager.singleton.registerProject(project, projectMetadata);
    engine = new Engine(project);
    options = mock(Properties.class);
}
Also used : Project(com.google.refine.model.Project) ProjectManagerStub(com.google.refine.ProjectManagerStub) ProjectMetadata(com.google.refine.ProjectMetadata) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 99 with Project

use of com.google.refine.model.Project in project OpenRefine by OpenRefine.

the class SqlExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new SqlExporter();
    writer = new StringWriter();
    ProjectManager.singleton = new ProjectManagerStub();
    projectMetadata = new ProjectMetadata();
    project = new Project();
    projectMetadata.setName(TEST_PROJECT_NAME);
    ProjectManager.singleton.registerProject(project, projectMetadata);
    engine = new Engine(project);
    options = mock(Properties.class);
}
Also used : Project(com.google.refine.model.Project) SqlExporter(com.google.refine.exporters.sql.SqlExporter) ProjectManagerStub(com.google.refine.ProjectManagerStub) StringWriter(java.io.StringWriter) ProjectMetadata(com.google.refine.ProjectMetadata) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 100 with Project

use of com.google.refine.model.Project in project OpenRefine by OpenRefine.

the class SetProjectMetadataCommandTests method SetUp.

@BeforeMethod
public void SetUp() throws IOException {
    projMan = mock(ProjectManager.class);
    ProjectManager.singleton = projMan;
    proj = mock(Project.class);
    pw = mock(PrintWriter.class);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    SUT = new SetProjectMetadataCommand();
    ProjectMetadata metadata = new ProjectMetadata();
    metadata.setUserMetadata((ArrayNode) ParsingUtilities.mapper.readTree("[ {name: \"clientID\", display: true} ]"));
    // mock dependencies
    when(request.getParameter("project")).thenReturn(PROJECT_ID);
    when(request.getParameter("csrf_token")).thenReturn(Command.csrfFactory.getFreshToken());
    when(projMan.getProject(anyLong())).thenReturn(proj);
    when(proj.getMetadata()).thenReturn(metadata);
    try {
        when(response.getWriter()).thenReturn(pw);
    } catch (IOException e1) {
        Assert.fail();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Project(com.google.refine.model.Project) ProjectMetadata(com.google.refine.ProjectMetadata) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) ProjectManager(com.google.refine.ProjectManager) PrintWriter(java.io.PrintWriter) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Project (com.google.refine.model.Project)146 Properties (java.util.Properties)46 IOException (java.io.IOException)40 Engine (com.google.refine.browsing.Engine)37 Test (org.testng.annotations.Test)37 ServletException (javax.servlet.ServletException)35 ProjectMetadata (com.google.refine.ProjectMetadata)33 BeforeMethod (org.testng.annotations.BeforeMethod)31 Cell (com.google.refine.model.Cell)29 Row (com.google.refine.model.Row)29 RefineTest (com.google.refine.RefineTest)25 Column (com.google.refine.model.Column)25 BeforeTest (org.testng.annotations.BeforeTest)18 Process (com.google.refine.process.Process)17 AbstractOperation (com.google.refine.model.AbstractOperation)14 StringWriter (java.io.StringWriter)13 RowVisitor (com.google.refine.browsing.RowVisitor)11 ArrayList (java.util.ArrayList)11 File (java.io.File)10 WrappedCell (com.google.refine.expr.WrappedCell)9