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);
}
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);
}
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);
}
}
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);
}
}
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();
}
Aggregations