@Override public String toString() { String message = _writtenRowCount + " inserts executed"; if (_updatesCount > 0) { message = message + "\n" + _updatesCount + " updates executed"; } if (_errorRowCount > 0) { if (_errorDatastore == null) { message = message + "\n - WARNING! " + _errorRowCount + " record failed"; } else { message = message + "\n - WARNING! " + _errorRowCount + " record failed, written to file: " + _errorDatastore.getFilename(); } } return message; } }
private String getFilename(Datastore ds) { if (ds instanceof ResourceDatastore) { final Resource resource = ((ResourceDatastore) ds).getResource(); return resource.getName(); } else if (ds instanceof FileDatastore) { final String filename = ((FileDatastore) ds).getFilename(); return new File(filename).getName(); } return ds.getName(); }
public String getFilename() { if (_datastore instanceof FileDatastore) { if (_datastore instanceof CsvDatastore || _datastore instanceof JsonDatastore) { final Resource resource = ((ResourceDatastore) _datastore).getResource(); if (resource instanceof HadoopResource) { return resource.getQualifiedPath(); } } final String filename = ((FileDatastore) _datastore).getFilename(); return filename; } else { return null; } }
private InputStream getInputStream(Datastore ds, HttpServletResponse response) throws IOException { if (ds instanceof ResourceDatastore) { final Resource resource = ((ResourceDatastore) ds).getResource(); if (resource == null || !resource.isExists()) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Datastore resource not found: " + ds); return null; } String username = getUsername(); logger.info("Serving datastore resource {} to user: {}", resource, username); return resource.read(); } else if (ds instanceof FileDatastore) { final FileDatastore fileDatastore = (FileDatastore) ds; final String filename = fileDatastore.getFilename(); final File file = new File(filename); if (!file.exists() || !file.isFile()) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Datastore file not found: " + filename); return null; } String username = getUsername(); logger.info("Serving datastore file {} to user: {}", filename, username); return new FileInputStream(file); } response.sendError(HttpServletResponse.SC_NO_CONTENT, "Datastore is not file based: " + ds.getName()); return null; }
/** * Validates a job before loading it with a concrete datastore. * * @param context * @param job * * @throws FileNotFoundException */ private void preLoadJob(DataCleanerConfiguration configuration, DataCleanerJobContext job) throws FileNotFoundException, ResourceException { final String sourceDatastoreName = job.getSourceDatastoreName(); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(sourceDatastoreName); if (datastore instanceof ResourceDatastore) { Resource resource = ((ResourceDatastore) datastore).getResource(); if (resource == null || !resource.isExists()) { logger.warn("Raising ResourceException from datastore: {}", datastore); throw new ResourceException(resource, "Resource does not exist: " + resource); } } else if (datastore instanceof FileDatastore) { final String filename = ((FileDatastore) datastore).getFilename(); final File file = new File(filename); if (!file.exists()) { logger.warn("Raising FileNotFound exception from datastore: {}", datastore); throw new FileNotFoundException(filename); } } }
if (existingDatastore instanceof FileDatastore) { final FileDatastore fileDatastore = (FileDatastore) existingDatastore; final String datastoreFilename = fileDatastore.getFilename(); if (filename.equals(datastoreFilename) || filePath.equals(datastoreFilename)) { datastore = _datastoreCatalog.getDatastore(filename);
return ((ResourceDatastore) datastore).getResource().getQualifiedPath(); } else if (datastore instanceof FileDatastore) { return ((FileDatastore) datastore).getFilename(); } else if (datastore instanceof JdbcDatastore) { final JdbcDatastore jdbcDatastore = (JdbcDatastore) datastore;
+ " records</b> could <i>not</i> be written to the table!<br/>" + "The records were written to <a href=\"https://datacleaner.org/preview_datastore\">" + errorDatastore.getFilename() + "</a> (<a href=\"https://datacleaner.org/register_datastore\">Register as datastore</a>)."); editorPane.setEditable(false);
final String filename = fileDatastore.getFilename(); _filenameField.setFilename(filename);