/** * Returns the password associated with the specified dbms. * This is equivalent to calling {@code get(dbms.getName())}. * * @param dbms the dbms used as a key * @return the associated password or empty */ default Optional<char[]> get(Dbms dbms) { requireNonNull(dbms); return get(dbms.getId()); } }
public static Dbms referencedDbms(Project project, String dbmsId) { return project .dbmses().filter(dbms -> dbmsId.equals(dbms.getId())) .findAny().orElseThrow(() -> new SpeedmentConfigException( "Could not find referenced " + Dbms.class.getSimpleName() + " with name '" + dbmsId + "'." )); }
public static Optional<? extends Dbms> referencedDbmsIfPresent(Project project, String dbmsId) { return project.dbmses().filter(dbms -> dbmsId.equals(dbms.getId())).findAny(); }
/** * Stores the specified password for the specified dbmsName. This * is equivalent to calling {@code put(dbms.getName(), password)}. * If the dbmsName already had a stored password, that password * is removed and will no longer exist in memory. * <p> * <b>Warning:</b> Note that the password might still be stored * in the String cache somewhere else in the JVM memory. * * @param dbms the dbms used as a key * @param password the password associated with that dbms */ default void put(Dbms dbms, char[] password) { requireNonNull(dbms); // password is nullable put(dbms.getId(), password); }
/** * Returns {@code true} if the two specified documents represents the same * element in the database. Two documents are considered same if they have * the same name and type and their parents are considered same. * * @param first the first document * @param second the second document * @return {@code true} if same, else {@code false} */ public static boolean isSame(Dbms first, Dbms second) { if (first.getId().equals(second.getId())) { final Project firstParent = first.getParentOrThrow(); final Project secondParent = second.getParentOrThrow(); return isSame(firstParent, secondParent); } else { return false; } }
/** * Counts the number of elements in the current table by querying the * database. * * @param dbmsOperationHandler the operation handler * @param naming the naming convention in use * @param dbms the dbms * @param table the table * * @return the number of elements in the table */ public static long sqlCount(DbmsOperationHandler dbmsOperationHandler, DatabaseNamingConvention naming, Dbms dbms, Table table) { return dbmsOperationHandler.executeQuery(dbms, "SELECT COUNT(*) FROM " + sqlTableReference(naming, table), Collections.emptyList(), rs -> rs.getLong(1) ).findAny().orElseThrow(() -> new NoSuchElementException("Unable to get sql count for table " + table.getId() + " in dbms " + dbms.getId())); }
.filter(d -> dbmsId.equals(d.getId())) .findAny() .orElseThrow(() -> new IllegalArgumentException(
ImmutableDbms(ImmutableProject parent, Map<String, Object> dbms) { super(parent, requireKeys(dbms, Dbms.TYPE_NAME)); final Dbms prototype = new DbmsImpl(parent, dbms); this.enabled = prototype.isEnabled(); this.id = prototype.getId(); this.name = prototype.getName(); this.alias = prototype.getAlias(); this.typeName = prototype.getTypeName(); this.ipAddress = prototype.getIpAddress(); this.port = prototype.getPort(); this.username = prototype.getUsername(); this.schemas = unmodifiableList(super.children(SCHEMAS, ImmutableSchema::new).collect(toList())); }
fkcMutator.setForeignDatabaseName(schema.getParentOrThrow().getId()); fkcMutator.setForeignSchemaName("schema"); };
fkcMutator.setForeignDatabaseName(schema.getParentOrThrow().getId());
.add(Constructor.of().protected_() .add("this.tableIdentifier = " + TableIdentifier.class.getSimpleName() + ".of(" + Stream.of(getSupport().dbmsOrThrow().getId(), getSupport().schemaOrThrow().getId(), getSupport().tableOrThrow().getId()) .map(s -> "\"" + s + "\"").collect(joining(", ")) + ");")
+ TableIdentifier.class.getSimpleName() + ".of(" + Stream.of( getSupport().dbmsOrThrow().getId(), getSupport().schemaOrThrow().getId(), getSupport().tableOrThrow().getId()
.add(returnString(getSupport().dbmsOrThrow().getId()))
/** * Returns the password associated with the specified dbms. * This is equivalent to calling {@code get(dbms.getName())}. * * @param dbms the dbms used as a key * @return the associated password or empty */ default Optional<char[]> get(Dbms dbms) { requireNonNull(dbms); return get(dbms.getId()); } }
/** * Stores the specified password for the specified dbmsName. This * is equivalent to calling {@code put(dbms.getName(), password)}. * If the dbmsName already had a stored password, that password * is removed and will no longer exist in memory. * <p> * <b>Warning:</b> Note that the password might still be stored * in the String cache somewhere else in the JVM memory. * * @param dbms the dbms used as a key * @param password the password associated with that dbms */ default void put(Dbms dbms, char[] password) { requireNonNull(dbms); // password is nullable put(dbms.getId(), password); }
/** * Counts the number of elements in the current table by querying the * database. * * @param dbmsOperationHandler the operation handler * @param naming the naming convention in use * @param dbms the dbms * @param table the table * * @return the number of elements in the table */ public static long sqlCount(DbmsOperationHandler dbmsOperationHandler, DatabaseNamingConvention naming, Dbms dbms, Table table) { return dbmsOperationHandler.executeQuery(dbms, "SELECT COUNT(*) FROM " + sqlTableReference(naming, table), Collections.emptyList(), rs -> rs.getLong(1) ).findAny().orElseThrow(() -> new NoSuchElementException("Unable to get sql count for table " + table.getId() + " in dbms " + dbms.getId())); }
fkcMutator.setForeignDatabaseName(schema.getParentOrThrow().getId());