コード例 #1
0
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>());
}
コード例 #2
0
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;
}
コード例 #3
0
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;
}
コード例 #4
0
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;
}
コード例 #5
0
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;
}