MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / storeCVTerm_

Method storeCVTerm_

src/openms/source/FORMAT/OMSFileStore.cpp:154–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 6

execAndResetFunction · 0.85
raiseDBError_Function · 0.85
getAccessionMethod · 0.80
emptyMethod · 0.45
getNameMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected