Search in sources :

Example 11 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class TemplatingExporterTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new TemplatingExporter();
    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) ProjectManagerStub(com.google.refine.tests.ProjectManagerStub) StringWriter(java.io.StringWriter) ProjectMetadata(com.google.refine.ProjectMetadata) TemplatingExporter(com.google.refine.exporters.TemplatingExporter) Properties(java.util.Properties) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 12 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class CacheTests method SetUp.

@BeforeMethod
public void SetUp() throws JSONException, IOException, ModelException {
    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);
    engine = new Engine(project);
    engine_config = new JSONObject(ENGINE_JSON_DUPLICATES);
    //        engine_config.getJSONArray("facets").getJSONObject(0).getJSONArray("selection").put(new JSONArray());
    engine.initializeFromJSON(engine_config);
    engine.setMode(Engine.Mode.RowBased);
    bindings = new Properties();
    bindings.put("project", project);
}
Also used : Project(com.google.refine.model.Project) JSONObject(org.json.JSONObject) Column(com.google.refine.model.Column) ProjectMetadata(com.google.refine.ProjectMetadata) Properties(java.util.Properties) File(java.io.File) Engine(com.google.refine.browsing.Engine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 13 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class ImportProjectCommand method doPost.

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ProjectManager.singleton.setBusy(true);
    try {
        Properties options = ParsingUtilities.parseUrlParameters(request);
        long projectID = Project.generateID();
        logger.info("Importing existing project using new ID {}", projectID);
        internalImport(request, options, projectID);
        ProjectManager.singleton.loadProjectMetadata(projectID);
        ProjectMetadata pm = ProjectManager.singleton.getProjectMetadata(projectID);
        if (pm != null) {
            if (options.containsKey("project-name")) {
                String projectName = options.getProperty("project-name");
                if (projectName != null && projectName.length() > 0) {
                    pm.setName(projectName);
                }
            }
            redirect(response, "/project?project=" + projectID);
        } else {
            respondWithErrorPage(request, response, "Failed to import project. Reason unknown.", null);
        }
    } catch (Exception e) {
        respondWithErrorPage(request, response, "Failed to import project", e);
    } finally {
        ProjectManager.singleton.setBusy(false);
    }
}
Also used : ProjectMetadata(com.google.refine.ProjectMetadata) Properties(java.util.Properties) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 14 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class RenameProjectCommand method doPost.

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
        String name = request.getParameter("name");
        ProjectMetadata pm = getProjectMetadata(request);
        pm.setName(name);
        respond(response, "{ \"code\" : \"ok\" }");
    } catch (Exception e) {
        respondException(response, e);
    }
}
Also used : ProjectMetadata(com.google.refine.ProjectMetadata) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 15 with ProjectMetadata

use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.

the class ImportingJob method prepareNewProject.

public void prepareNewProject() {
    if (project != null) {
        project.dispose();
    }
    // Make sure all projects have been saved in case we run out of memory 
    // or have some other catastrophe on import
    ProjectManager.singleton.save(true);
    project = new Project();
    metadata = new ProjectMetadata();
}
Also used : Project(com.google.refine.model.Project) ProjectMetadata(com.google.refine.ProjectMetadata)

Aggregations

ProjectMetadata (com.google.refine.ProjectMetadata)22 Project (com.google.refine.model.Project)16 Properties (java.util.Properties)10 BeforeMethod (org.testng.annotations.BeforeMethod)9 File (java.io.File)7 JSONObject (org.json.JSONObject)6 Engine (com.google.refine.browsing.Engine)5 Column (com.google.refine.model.Column)4 ProjectManagerStub (com.google.refine.tests.ProjectManagerStub)4 IOException (java.io.IOException)4 ServletException (javax.servlet.ServletException)3 JSONException (org.json.JSONException)3 Cell (com.google.refine.model.Cell)2 Row (com.google.refine.model.Row)2 RefineServletStub (com.google.refine.tests.RefineServletStub)2 StringWriter (java.io.StringWriter)2 JSONWriter (org.json.JSONWriter)2 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 AuthenticationException (com.google.gdata.util.AuthenticationException)1