Search in sources :

Example 1 with Project

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

the class ImportingUtilities method createProject.

public static long createProject(final ImportingJob job, final String format, final JSONObject optionObj, final List<Exception> exceptions, boolean synchronous) {
    final Format record = ImportingManager.formatToRecord.get(format);
    if (record == null || record.parser == null) {
        // TODO: what to do?
        return -1;
    }
    job.setState("creating-project");
    final Project project = new Project();
    if (synchronous) {
        createProjectSynchronously(job, format, optionObj, exceptions, record, project);
    } else {
        new Thread() {

            @Override
            public void run() {
                createProjectSynchronously(job, format, optionObj, exceptions, record, project);
            }
        }.start();
    }
    return project.id;
}
Also used : Project(com.google.refine.model.Project) Format(com.google.refine.importing.ImportingManager.Format) NumberFormat(java.text.NumberFormat)

Example 2 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.tests.ProjectManagerStub) XlsExporter(com.google.refine.exporters.XlsExporter) 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 3 with Project

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

the class BooleanTests method SetUp.

@BeforeMethod
public void SetUp() throws IOException, ModelException {
    bindings = new Properties();
    File dir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
    FileProjectManager.initialize(dir);
    project = new Project();
    ProjectMetadata pm = new ProjectMetadata();
    pm.setName("TNG Test Project");
    ProjectManager.singleton.registerProject(project, pm);
    int index = project.columnModel.allocateNewCellIndex();
    Column column = new Column(index, "Column A");
    project.columnModel.addColumn(index, column, true);
    options = mock(Properties.class);
    bindings.put("project", project);
    // Five rows of a's and five of 1s
    for (int i = 0; i < 10; i++) {
        Row row = new Row(1);
        row.setCell(0, new Cell(i < 5 ? "a" : new Integer(1), null));
        project.rows.add(row);
    }
}
Also used : Project(com.google.refine.model.Project) Column(com.google.refine.model.Column) ProjectMetadata(com.google.refine.ProjectMetadata) Row(com.google.refine.model.Row) Properties(java.util.Properties) File(java.io.File) Cell(com.google.refine.model.Cell) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with Project

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

the class GrelTests method SetUp.

@BeforeMethod
public void SetUp() {
    project = new Project();
    bindings = ExpressionUtils.createBindings(project);
}
Also used : Project(com.google.refine.model.Project) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with Project

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

the class HistoryTests method canAddEntry.

@Test
public void canAddEntry() {
    //local dependencies
    HistoryEntry entry = mock(HistoryEntry.class);
    Project project = mock(Project.class);
    ProjectMetadata projectMetadata = mock(ProjectMetadata.class);
    when(projectManager.getProject(Mockito.anyLong())).thenReturn(project);
    when(projectManager.getProjectMetadata(Mockito.anyLong())).thenReturn(projectMetadata);
    SUT.addEntry(entry);
    verify(projectManager, times(1)).getProject(Mockito.anyLong());
    verify(entry, times(1)).apply(project);
    verify(projectMetadata, times(1)).updateModified();
    Assert.assertEquals(SUT.getLastPastEntries(1).get(0), entry);
}
Also used : Project(com.google.refine.model.Project) ProjectMetadata(com.google.refine.ProjectMetadata) HistoryEntry(com.google.refine.history.HistoryEntry) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

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