| 152 | |
| 153 | |
| 154 | OMSFileStore::Key OMSFileStore::storeCVTerm_(const CVTerm& cv_term) |
| 155 | { |
| 156 | // this assumes the "CVTerm" table exists already! |
| 157 | auto& query = *prepared_queries_["CVTerm"]; |
| 158 | if (cv_term.getAccession().empty()) // use NULL for empty accessions |
| 159 | { |
| 160 | query.bind(":accession"); |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | query.bind(":accession", cv_term.getAccession()); |
| 165 | } |
| 166 | query.bind(":name", cv_term.getName()); |
| 167 | query.bind(":cv_identifier_ref", cv_term.getCVIdentifierRef()); |
| 168 | if (execAndReset(query, 1)) // one row was inserted |
| 169 | { |
| 170 | return db_->getLastInsertRowid(); |
| 171 | } |
| 172 | |
| 173 | // else: insert has failed, record must already exist - get the key: |
| 174 | auto& alt_query = *prepared_queries_["CVTerm_2"]; |
| 175 | alt_query.reset(); // get ready for a new execution |
| 176 | if (cv_term.getAccession().empty()) // use NULL for empty accessions |
| 177 | { |
| 178 | alt_query.bind(":accession"); |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | alt_query.bind(":accession", cv_term.getAccession()); |
| 183 | } |
| 184 | alt_query.bind(":name", cv_term.getName()); |
| 185 | if (!alt_query.executeStep()) |
| 186 | { |
| 187 | raiseDBError_(alt_query.getErrorMsg(), __LINE__, OPENMS_PRETTY_FUNCTION, "error querying database"); |
| 188 | } |
| 189 | |
| 190 | return Key(alt_query.getColumn(0).getInt64()); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | void OMSFileStore::createTableMetaInfo_(const String& parent_table, const String& key_column) |
nothing calls this directly
no test coverage detected