use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class ImportingUtilities method createProjectSynchronously.
private static void createProjectSynchronously(final ImportingJob job, final String format, final ObjectNode optionObj, final List<Exception> exceptions, final Format record, final Project project) {
ProjectMetadata pm = createProjectMetadata(optionObj);
record.parser.parse(project, pm, job, job.getSelectedFileRecords(), format, -1, optionObj, exceptions);
if (!job.canceled) {
if (exceptions.size() == 0) {
// update all internal models, indexes, caches, etc.
project.update();
ProjectManager.singleton.registerProject(project, pm);
job.setProjectID(project.id);
job.setState("created-project");
} else {
job.setError(exceptions);
}
job.touch();
job.updating = false;
}
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class ProjectMetadataUtilities method load.
public static ProjectMetadata load(File projectDir) {
ProjectMetadata pm = null;
pm = loadMetaDataIfExist(projectDir, ProjectMetadata.DEFAULT_FILE_NAME);
if (pm == null) {
pm = loadMetaDataIfExist(projectDir, ProjectMetadata.TEMP_FILE_NAME);
}
if (pm == null) {
pm = loadMetaDataIfExist(projectDir, ProjectMetadata.OLD_FILE_NAME);
}
return pm;
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class HistoryProcessTests method setUp.
@BeforeMethod
public void setUp() {
project = new Project();
projectMetadata = mock(ProjectMetadata.class);
ProjectManager.singleton.registerProject(project, projectMetadata);
AbstractOperation op = mock(AbstractOperation.class);
Change ch = mock(Change.class);
HistoryEntry entry = new HistoryEntry(1234L, project, "first operation", op, ch);
project.history.addEntry(entry);
entry = new HistoryEntry(5678L, project, "second operation", op, ch);
project.history.addEntry(entry);
}
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 {
if (!hasValidCSRFTokenAsGET(request)) {
respondCSRFError(response);
return;
}
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 {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
String name = request.getParameter("name");
ProjectMetadata pm = getProjectMetadata(request);
pm.setName(name);
respond(response, "{ \"code\" : \"ok\" }");
} catch (Exception e) {
respondException(response, e);
}
}
Aggregations