use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class HtmlExporterTests method SetUp.
@BeforeMethod
public void SetUp() {
SUT = new HtmlTableExporter();
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 XlsxExporterTests method SetUp.
@BeforeMethod
public void SetUp() {
SUT = new XlsExporter(true);
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);
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class WikidataRefineTest method createCSVProject.
protected Project createCSVProject(String projectName, String input) {
Project project = new Project();
ProjectMetadata metadata = new ProjectMetadata();
metadata.setName(projectName);
ObjectNode options = mock(ObjectNode.class);
RefineTest.prepareImportOptions(options, ",", -1, 0, 0, 1, false, false);
ImportingJob job = ImportingManager.createJob();
SeparatorBasedImporter importer = new SeparatorBasedImporter();
List<Exception> exceptions = new ArrayList<Exception>();
importer.parseOneFile(project, metadata, job, "filesource", new StringReader(input), -1, options, exceptions);
project.update();
ProjectManager.singleton.registerProject(project, metadata);
projects.add(project);
importingJobs.add(job);
return project;
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class DatabaseImportControllerTest method setUp.
@BeforeMethod
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
File dir = DBExtensionTestUtils.createTempDirectory("OR_DBExtension_Test_WorkspaceDir");
FileProjectManager.initialize(dir);
servlet = new RefineDbServletStub();
ImportingManager.initialize(servlet);
project = new Project();
metadata = new ProjectMetadata();
job = ImportingManager.createJob();
metadata.setName("Database Import Test Project");
ProjectManager.singleton.registerProject(project, metadata);
SUT = new DatabaseImportController();
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class DatabaseImportController method doCreateProject.
/**
* doCreateProject
* @param request
* @param response
* @param parameters
*/
private void doCreateProject(HttpServletRequest request, HttpServletResponse response, Properties parameters) throws ServletException, IOException {
if (logger.isDebugEnabled()) {
logger.debug("DatabaseImportController::doCreateProject:::{}", parameters.getProperty("jobID"));
}
long jobID = Long.parseLong(parameters.getProperty("jobID"));
final ImportingJob job = ImportingManager.getJob(jobID);
if (job == null) {
HttpUtilities.respond(response, "error", "No such import job");
return;
}
final DatabaseQueryInfo databaseQueryInfo = getQueryInfo(request);
if (databaseQueryInfo == null) {
HttpUtilities.respond(response, "error", "Invalid or missing Query Info");
}
job.updating = true;
try {
final ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(request.getParameter("options"));
final List<Exception> exceptions = new LinkedList<Exception>();
job.setState("creating-project");
final Project project = new Project();
new Thread() {
@Override
public void run() {
ProjectMetadata pm = new ProjectMetadata();
pm.setName(JSONUtilities.getString(optionObj, "projectName", "Untitled"));
pm.setEncoding(JSONUtilities.getString(optionObj, "encoding", "UTF-8"));
try {
parseCreate(databaseQueryInfo, project, pm, job, -1, optionObj, exceptions);
} catch (DatabaseServiceException e) {
logger.error("DatabaseImportController::doCreateProject:::run{}", e);
// throw new RuntimeException("DatabaseServiceException::", e);
}
if (!job.canceled) {
if (exceptions.size() > 0) {
job.setError(exceptions);
} else {
// update all internal models, indexes, caches, etc.
project.update();
ProjectManager.singleton.registerProject(project, pm);
job.setState("created-project");
job.setProjectID(project.id);
// logger.info("DatabaseImportController::doCreateProject:::run::projectID :{}", project.id);
}
job.touch();
job.updating = false;
}
}
}.start();
HttpUtilities.respond(response, "ok", "done");
} catch (IOException e) {
throw new ServletException(e);
}
}
Aggregations