AAVSODatabaseConnector vsxConnector = AAVSODatabaseConnector.vsxDBConnector;
Connection vsxConnection = vsxConnector.createConnection();
// TODO: this should always be populated by VSX methods below!!
// (e.g. to get period, epoch, variable/spectral type, discoverer).
StarInfo starInfo = new StarInfo(starName, auid);
// Do we need to ask for the AUID from the database before
// proceeding?
if (auid == null) {
starInfo = vsxConnector.getAUID(vsxConnection, starName);
auid = starInfo.getAuid();
if (auid == null) {
throw new UnknownStarError(starName);
}
}
// No, do we need instead to ask for the star name because
// we have an AUID but no star name?
if (starName == null) {
starInfo = vsxConnector.getStarName(vsxConnection, auid);
starName = starInfo.getDesignation();
if (starName == null) {
throw new UnknownAUIDError(auid);
}
}
updateProgress(2);
// Get a prepared statement to read a set of observations
// from the database, setting the parameters for the star
// we are targeting. We distinguish between the case where
// no JD min/max is supplied, and when one is.
// TODO:
// - Hide all this statement stuff behind a get-observations
// method.
// - Obs stmt creation and param setting should be a single
// operation to avoid possible mismatched calls! Either that
// or remove stmt parameter from parameter setting method.
AAVSODatabaseConnector obsConnector = AAVSODatabaseConnector.observationDBConnector;
Connection obsConnection = obsConnector.createConnection();
PreparedStatement obsStmt = null;
if (minJD == 0 && maxJD == Double.MAX_VALUE) {
obsStmt = obsConnector
.createObservationWithNoJDRangeQuery(obsConnection);
} else {
obsStmt = obsConnector
.createObservationWithJDRangeQuery(obsConnection);
}
updateProgress(2);
// Execute the query, passing the result set to the
// database observation retriever to give us the valid
// and observation lists and categorised valid observation
// map from which all else flows.
if (minJD == 0 && maxJD == Double.MAX_VALUE) {
obsConnector.setObservationWithNoJDRangeQueryParams(obsStmt,
auid);
} else {
obsConnector.setObservationWithJDRangeQueryParams(obsStmt,
auid, minJD, maxJD);
}
Mediator.getUI().getStatusPane().setMessage(
LocaleProps.get("STATUS_PANE_RETRIEVING_OBS"));
results = obsStmt.executeQuery();
updateProgress(2);
AAVSODatabaseObservationReader databaseObsReader = new AAVSODatabaseObservationReader(
results);
ValidObservation.reset();
databaseObsReader.retrieveObservations();
starInfo.setRetriever(databaseObsReader);
updateProgress(2);
if (databaseObsReader.getValidObservations().isEmpty()) {
throw new ObservationReadError(