Skip to content

Database-based Argument Setter #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ailegion
Copy link
Contributor

@ailegion ailegion commented Jul 13, 2020

added: Database-based Argument Setter support

JIRA: https://issues.cask.co/browse/PLUGIN-173

Copy link
Member

@CuriousVini CuriousVini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments.


@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer)
throws IllegalArgumentException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: misallignment

Copy link
Contributor Author

@ailegion ailegion Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini fixed

} catch (Exception e) {
collector.addFailure(e.getMessage(), null).withStacktrace(e.getStackTrace());
}
config.validate(collector);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to call config.validate(collector) 2 times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini removed redundant call

collector.addFailure("Invalid connection string", "Connection string cannot be empty");
}
if (!containsMacro(ConnectionConfig.USER) && Strings.isNullOrEmpty(this.user)) {
collector.addFailure("Invalid username", "Username cannot be empty");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add period at the end of every failure message and its cause

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini updated all messages


collector.getOrThrowException();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini fixed

}
if (resultSet.next()) {
failureCollector
.addFailure("More than one record found",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than one records found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini fixed

if (resultSet.next()) {
failureCollector
.addFailure("More than one record found",
"The argument selection conditions return multiple rows");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the expected corrective action that needs to be taken from user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini updated

ResultSet resultSet = statement.executeQuery(config.getQuery());
boolean hasRecord = resultSet.next();
if (!hasRecord) {
failureCollector.addFailure("Ne record found",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: No records found.
Please add period to every failure message and corresponding corrective action

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini updated messages to have corrective action.

boolean hasRecord = resultSet.next();
if (!hasRecord) {
failureCollector.addFailure("Ne record found",
"No data is returned for the argument selection conditions");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no records should we return from here and not do any further processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini fixed to return and not do further processing.

.getConnection(config.getConnectionString(), connectionProperties);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(config.getQuery());
boolean hasRecord = resultSet.next();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does resultset has - hasNext() method? we should use that method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CuriousVini resulset does not have hasNext() instead it has next() which moves the cursor to next record and returns true/false based on whether record is available or not.

Copy link
Member

@CuriousVini CuriousVini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments. Fix and squash the commits

"The argument selection conditions must match only one record.");
}
} catch (SQLException e) {
throw new SQLException(e.getMessage(), e.getSQLState(), e.getErrorCode());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we catch the sqlexception and throw the same exception? It should throw same SQLException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments. Fix and squash the commits

@CuriousVini done.

collector.addFailure("Invalid password.", "Password cannot be empty.");
}
if (!containsMacro(DATABASE_NAME) && Strings.isNullOrEmpty(this.getDatabaseName())) {
collector.addFailure("Invalid database.", "Invalid database is specified.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid database is specified. -> Invalid database must be specified.

collector.addFailure("Invalid database.", "Invalid database is specified.");
}
if (!containsMacro(TABLE_NAME) && Strings.isNullOrEmpty(this.getTableName())) {
collector.addFailure("Invalid table.", "Invalid table is specified.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@ailegion ailegion force-pushed the feature/db-argument-setter branch from a6d75ad to 4d1eff1 Compare July 29, 2020 10:03
@CuriousVini CuriousVini merged commit db1afd4 into data-integrations:develop Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants