public WriteDataResultImpl(final int writtenRowCount, final int updatesCount, final String datastoreName, final String schemaName, final String tableName) { _writtenRowCount = writtenRowCount; _updatesCount = updatesCount; _schemaName = schemaName; _tableName = tableName; _datastoreName = datastoreName; _datastoreFunc = catalog -> catalog.getDatastore(datastoreName); _errorRowCount = 0; _errorDatastore = null; }
public static Datastore createUniqueDatastoreFromResource(final DatastoreCatalog catalog, final Resource resource) { String name = resource.getName(); if (catalog.containsDatastore(name)) { final String originalName = name; int prefix = 1; do { name = originalName + "_" + prefix++; } while (catalog.containsDatastore(name)); } return createDatastoreFromResource(resource, name); }
private DatastoreBeanWrapper[] prepareDatastoreWrappers(DatastoreCatalog datastoreCatalog) { final String[] datastoreNames = datastoreCatalog.getDatastoreNames(); final DatastoreBeanWrapper[] beanWrapperArray = new DatastoreBeanWrapper[datastoreNames.length]; for (int i = 0; i < beanWrapperArray.length; i++) { final String datastoreName = datastoreNames[i]; final Datastore datastore = datastoreCatalog.getDatastore(datastoreName); beanWrapperArray[i] = new DatastoreBeanWrapper(datastore); } return beanWrapperArray; } }
private JComboBox<String> createDatastoreCombobox() { final String[] comboBoxModel = CollectionUtils.array(new String[1], _datastoreCatalog.getDatastoreNames()); final JComboBox<String> comboBox = new JComboBox<>(comboBoxModel); comboBox.setEditable(false); final JDialog parent = this; comboBox.addActionListener(e -> { try { final ComboBoxUpdater comboBoxUpdater = new ComboBoxUpdater(parent); comboBoxUpdater.execute(); } catch (final Exception exception) { final String exceptionMessage = "An unexpected error occurred while updating combo boxes:\n" + exception.getMessage(); logger.error(exceptionMessage); WidgetUtils.showErrorMessage("Unexpected error", exceptionMessage); } }); return comboBox; }
private void printDatastores(final DataCleanerConfiguration configuration) { final String[] datastoreNames = configuration.getDatastoreCatalog().getDatastoreNames(); if (datastoreNames == null || datastoreNames.length == 0) { write("No datastores configured!"); } else { write("Datastores:"); write("-----------"); for (final String datastoreName : datastoreNames) { write(datastoreName); } } }
/** * Determines if a datastore by a specific name is contained in the * {@link DatastoreCatalog}. * * @param name * @return */ default boolean containsDatastore(final String name) { return getDatastore(name) != null; }
@RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseBody public List<Map<String, String>> datastoresFolderJson(@PathVariable("tenant") String tenant) { final TenantContext context = _contextFactory.getContext(tenant); final DatastoreCatalog datastoreCatalog = context.getConfiguration().getDatastoreCatalog(); final String[] names = datastoreCatalog.getDatastoreNames(); final List<Map<String, String>> result = new ArrayList<Map<String, String>>(); for (String name : names) { final Datastore datastore = datastoreCatalog.getDatastore(name); final Map<String, String> map = new LinkedHashMap<String, String>(); map.put("name", name); map.put("description", datastore.getDescription()); map.put("type", datastore.getClass().getSimpleName()); result.add(map); } return result; }
String[] datastoreNames = datastoreCatalog.getDatastoreNames(); try { datastoreName = datastoreNames[datastoreIndex];
@Override public void createDatastore(final Datastore datastore) { final String name = datastore.getName(); synchronized (_datastoreCatalog) { if (_datastoreCatalog.containsDatastore(name)) { logger.warn("Datastore '{}' already exists. No new datastore will be created!", name); } else { if (_datastoreCatalog instanceof MutableDatastoreCatalog) { ((MutableDatastoreCatalog) _datastoreCatalog).addDatastore(datastore); } else { throw new IllegalStateException( "Tried to create datastore '" + name + "', but the datastore catalog is not mutable"); } } } } }
public ComboBoxUpdater(final JDialog parent) { final String datastoreName = (String) _datastoreCombobox.getSelectedItem(); _datastore = _datastoreCatalog.getDatastore(datastoreName); }
private PopupButton createExistingDatastoresButton() { final PopupButton existingDatastoresButton = WidgetFactory.createDefaultPopupButton("Existing datastores", IconUtils.FILE_FOLDER); final JPopupMenu menu = existingDatastoresButton.getMenu(); final String[] datastoreNames = _datastoreCatalog.getDatastoreNames(); for (final String datastoreName : datastoreNames) { final Datastore datastore = _datastoreCatalog.getDatastore(datastoreName); final JMenuItem menuItem = WidgetFactory.createMenuItem(datastoreName, IconUtils.getDatastoreIcon(datastore, IconUtils.ICON_SIZE_MENU_ITEM)); menuItem.addActionListener(e -> _datastoreSelectedListener.datastoreSelected(datastore)); menu.add(menuItem); } return existingDatastoresButton; }
@Override public Datastore getDatastore(final DatastoreCatalog datastoreCatalog) { if (_datastoreFunc == null) { if (_datastoreName == null) { return null; } return datastoreCatalog.getDatastore(_datastoreName); } return _datastoreFunc.apply(datastoreCatalog); }
public MutableDatastoreCatalog(final DatastoreCatalog immutableDelegate, final DomConfigurationWriter configurationWriter, final UserPreferences userPreferences) { _configurationWriter = configurationWriter; _userPreferences = userPreferences; final String[] datastoreNames = immutableDelegate.getDatastoreNames(); for (final String name : datastoreNames) { if (containsDatastore(name)) { // remove any copies of the datastore - the immutable (XML) // version should always win removeDatastore(getDatastore(name), false); } addDatastore(immutableDelegate.getDatastore(name), false); } }
@Override public Datastore getSingleDatastore(final DatastoreCatalog datastoreCatalog) { final String ds = _arguments.getDatastoreName(); return datastoreCatalog.getDatastore(ds); }
@Inject protected DatabaseDriversPanel(final DataCleanerConfiguration configuration, final WindowContext windowContext, final UserPreferences userPreferences, final DatabaseDriverCatalog databaseDriverCatalog, final CloseableHttpClient httpClient) { super(WidgetUtils.COLOR_DEFAULT_BACKGROUND); _windowContext = windowContext; _userPreferences = userPreferences; _databaseDriverCatalog = databaseDriverCatalog; _httpClient = httpClient; setLayout(new BorderLayout()); final DatastoreCatalog datastoreCatalog = configuration.getDatastoreCatalog(); final String[] datastoreNames = datastoreCatalog.getDatastoreNames(); for (final String name : datastoreNames) { final Datastore datastore = datastoreCatalog.getDatastore(name); if (datastore instanceof JdbcDatastore) { final String driverClass = ((JdbcDatastore) datastore).getDriverClass(); if (driverClass != null) { _usedDriverClassNames.add(driverClass); } } } for (final UserDatabaseDriver driver : _userPreferences.getDatabaseDrivers()) { _usedDriverClassNames.add(driver.getDriverClassName()); } updateComponents(); }
public AnalysisJobBuilder setDatastore(final String datastoreName) { final Datastore datastore = _configuration.getDatastoreCatalog().getDatastore(datastoreName); if (datastore == null) { throw new IllegalArgumentException("No such datastore: " + datastoreName); } return setDatastore(datastore); }
final String filename = file.getName(); final String filePath = file.getAbsolutePath(); final String[] datastoreNames = _datastoreCatalog.getDatastoreNames(); for (int i = 0; i < datastoreNames.length; i++) { final Datastore existingDatastore = _datastoreCatalog.getDatastore(datastoreNames[i]); 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);
@RequestMapping(method = RequestMethod.POST, produces = "application/json") @ResponseBody @RolesAllowed({ SecurityRoles.CONFIGURATION_EDITOR }) public Map<String, String> removeDatastore(@PathVariable("tenant") final String tenant, @PathVariable("datastore") String datastoreName) { logger.info("Request payload: {} - {}", tenant, datastoreName); datastoreName = datastoreName.replaceAll("\\+", " "); final Map<String, String> response = new TreeMap<String, String>(); response.put("datastore", datastoreName); response.put("action", "remove"); final TenantContext tenantContext = _contextFactory.getContext(tenant); if (tenantContext.getConfiguration().getDatastoreCatalog().getDatastore(datastoreName) == null) { response.put("status", "FAILURE"); response.put("message", "No such datastore: " + datastoreName); return response; } try { datastoreDao.removeDatastore(tenantContext, datastoreName); } catch (Exception e) { logger.error("Removing datastore '" + datastoreName + "' from tenant '" + tenant + "'s configuration failed", e); response.put("status", "FAILURE"); response.put("message", e.getMessage()); return response; } response.put("status", "SUCCESS"); response.put("message", "Datastore was removed succesfully"); logger.debug("Response payload: {}", response); return response; }
public void updateDatastores() { removeAll(); final String[] datastoreNames = _datastoreCatalog.getDatastoreNames(); for (int i = 0; i < datastoreNames.length; i++) { final Datastore datastore = _datastoreCatalog.getDatastore(datastoreNames[i]); final DetailedListItemPanel datastorePanel = new DetailedListItemPanel(IconUtils.getDatastoreIcon(datastore, IconUtils.ICON_SIZE_LARGE), "<html><b>" + datastore.getName() + "</b></html>", DatastorePanel.getDescription(datastore)); datastorePanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { _datastoreSelectListener.datastoreSelected(datastore); } }); add(datastorePanel); } } }
@RolesAllowed(SecurityRoles.JOB_EDITOR) @RequestMapping(value = "/{tenant}/datastores/{datastore}.analyze.jnlp", method = RequestMethod.GET) @ResponseBody public void launchDataCleanerForDatastore(HttpServletRequest request, HttpServletResponse response, @PathVariable("tenant") final String tenant, @PathVariable("datastore") String datastoreName) throws IOException { datastoreName = datastoreName.replaceAll("\\+", " "); final DataCleanerConfiguration configuration = _contextFactory.getContext(tenant).getConfiguration(); final Datastore ds = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (ds == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such datastore: " + datastoreName); return; } final String scheme = request.getScheme(); final String hostname = request.getServerName(); final int port = getPort(request, scheme); final String contextPath = request.getContextPath(); final String encodedDatastoreName = URLEncoder.encode(datastoreName, FileHelper.UTF_8_ENCODING); final String jnlpHref = "datastores/" + encodedDatastoreName + ".analyze.jnlp"; final String confPath = '/' + RESOURCES_FOLDER + "conf.xml?datastore=" + encodedDatastoreName; writeJnlpResponse(request, tenant, response, scheme, hostname, port, contextPath, jnlpHref, null, datastoreName, confPath); }