DakotaAlgorithmRecord DakotaAlgorithmRecord::factoryFromDakotaAlgorithm( const analysis::DakotaAlgorithm& dakotaAlgorithm, AnalysisRecord& analysisRecord) { if (dakotaAlgorithm.optionalCast<analysis::DDACEAlgorithm>()) { return DDACEAlgorithmRecord(dakotaAlgorithm.cast<analysis::DDACEAlgorithm>(), analysisRecord); } if (dakotaAlgorithm.optionalCast<analysis::FSUDaceAlgorithm>()) { return FSUDaceAlgorithmRecord(dakotaAlgorithm.cast<analysis::FSUDaceAlgorithm>(), analysisRecord); } if (dakotaAlgorithm.optionalCast<analysis::PSUADEDaceAlgorithm>()) { return PSUADEDaceAlgorithmRecord(dakotaAlgorithm.cast<analysis::PSUADEDaceAlgorithm>(), analysisRecord); } if (dakotaAlgorithm.optionalCast<analysis::ParameterStudyAlgorithm>()) { return ParameterStudyAlgorithmRecord(dakotaAlgorithm.cast<analysis::ParameterStudyAlgorithm>(), analysisRecord); } if (dakotaAlgorithm.optionalCast<analysis::SamplingAlgorithm>()) { return SamplingAlgorithmRecord(dakotaAlgorithm.cast<analysis::SamplingAlgorithm>(), analysisRecord); } OS_ASSERT(false); return DakotaAlgorithmRecord(std::shared_ptr<detail::DakotaAlgorithmRecord_Impl>()); }
boost::optional<DakotaAlgorithmRecord> DakotaAlgorithmRecord::factoryFromQuery( const QSqlQuery& query, ProjectDatabase& database) { OptionalDakotaAlgorithmRecord result; int dakotaAlgorithmRecordType = query.value(AlgorithmRecordColumns::dakotaAlgorithmRecordType).toInt(); switch (dakotaAlgorithmRecordType) { case DakotaAlgorithmRecordType::DDACEAlgorithmRecord : result = DDACEAlgorithmRecord(query, database).cast<DakotaAlgorithmRecord>(); break; case DakotaAlgorithmRecordType::FSUDaceAlgorithmRecord : result = FSUDaceAlgorithmRecord(query, database).cast<DakotaAlgorithmRecord>(); break; case DakotaAlgorithmRecordType::PSUADEDaceAlgorithmRecord : result = PSUADEDaceAlgorithmRecord(query, database).cast<DakotaAlgorithmRecord>(); break; case DakotaAlgorithmRecordType::ParameterStudyAlgorithmRecord : result = ParameterStudyAlgorithmRecord(query, database).cast<DakotaAlgorithmRecord>(); break; case DakotaAlgorithmRecordType::SamplingAlgorithmRecord : result = SamplingAlgorithmRecord(query, database).cast<DakotaAlgorithmRecord>(); break; default : LOG(Error,"Unknown DakotaAlgorithmRecordType " << dakotaAlgorithmRecordType); return boost::none; } return result; }
std::vector<FSUDaceAlgorithmRecord> FSUDaceAlgorithmRecord::getFSUDaceAlgorithmRecords(ProjectDatabase& database) { std::vector<FSUDaceAlgorithmRecord> result; QSqlQuery query(*(database.qSqlDatabase())); query.prepare(toQString("SELECT * FROM " + AlgorithmRecord::databaseTableName() + " WHERE algorithmRecordType=:algorithmRecordType AND " + "dakotaAlgorithmRecordType=:dakotaAlgorithmRecordType")); query.bindValue(":dakotaAlgorithmRecordType", DakotaAlgorithmRecordType::FSUDaceAlgorithmRecord); assertExec(query); while (query.next()) { result.push_back(FSUDaceAlgorithmRecord(query, database)); } return result; }
boost::optional<FSUDaceAlgorithmRecord> FSUDaceAlgorithmRecord::factoryFromQuery( const QSqlQuery& query, ProjectDatabase& database) { OptionalFSUDaceAlgorithmRecord result; try { result = FSUDaceAlgorithmRecord(query,database); } catch (const std::exception& e) { LOG(Error,"Unable to construct FSUDaceAlgorithmRecord from query, because '" << e.what() << "'."); } return result; }
boost::optional<FSUDaceAlgorithmRecord> FSUDaceAlgorithmRecord::getFSUDaceAlgorithmRecord( int id, ProjectDatabase& database) { boost::optional<FSUDaceAlgorithmRecord> result; QSqlQuery query(*(database.qSqlDatabase())); query.prepare(toQString("SELECT * FROM " + AlgorithmRecord::databaseTableName() + " WHERE algorithmRecordType=:algorithmRecordType AND " + "dakotaAlgorithmRecordType=:dakotaAlgorithmRecordType AND " + "id=:id")); query.bindValue(":dakotaAlgorithmRecordType", DakotaAlgorithmRecordType::FSUDaceAlgorithmRecord); query.bindValue(":id",id); assertExec(query); if (query.first()) { result = FSUDaceAlgorithmRecord(query, database); } return result; }