17 m_version =
"default";
18 m_dataType =
"default";
38 if (genTag != m_genTag) {
55 if (locDef != m_locDef) {
72 if (method != m_method) {
89 if (version != m_version) {
106 if (dataType != m_dataType) {
122 this->checkConnection();
126 this->fetchParentIDs(&locID);
130 Statement* stmt = m_conn->createStatement();
131 stmt->setSQL(
"SELECT tag_id FROM cali_tag WHERE " 133 "location_id = :2 AND " 137 stmt->setString(1, m_genTag);
138 stmt->setInt(2, locID);
139 stmt->setString(3, m_method);
140 stmt->setString(4, m_version);
141 stmt->setString(5, m_dataType);
143 ResultSet* rset = stmt->executeQuery();
146 m_ID = rset->getInt(1);
150 m_conn->terminateStatement(stmt);
151 }
catch (SQLException &
e) {
152 throw(std::runtime_error(
"CaliTag::fetchID: "+e.getMessage()));
163 this->checkConnection();
166 Statement* stmt = m_conn->createStatement();
168 stmt->setSQL(
"SELECT gen_tag, location_id, method, version, data_type " 169 "FROM cali_tag WHERE tag_id = :1");
172 ResultSet* rset = stmt->executeQuery();
174 m_genTag = rset->getString(1);
175 int locID = rset->getInt(2);
176 m_locDef.setConnection(m_env, m_conn);
177 m_locDef.setByID(locID);
178 m_method = rset->getString(3);
179 m_version = rset->getString(4);
180 m_dataType = rset->getString(5);
184 throw(std::runtime_error(
"CaliTag::setByID: Given tag_id is not in the database"));
187 m_conn->terminateStatement(stmt);
188 }
catch (SQLException &
e) {
189 throw(std::runtime_error(
"CaliTag::setByID: "+e.getMessage()));
198 if (this->fetchID()) {
203 this->checkConnection();
207 this->fetchParentIDs(&locID);
211 Statement* stmt = m_conn->createStatement();
213 stmt->setSQL(
"INSERT INTO cali_tag (tag_id, gen_tag, location_id, method, version, data_type) " 214 "VALUES (cali_tag_sq.NextVal, :1, :2, :3, :4, :5)");
215 stmt->setString(1, m_genTag);
216 stmt->setInt(2, locID);
217 stmt->setString(3, m_method);
218 stmt->setString(4, m_version);
219 stmt->setString(5, m_dataType);
221 stmt->executeUpdate();
223 m_conn->terminateStatement(stmt);
224 }
catch (SQLException &
e) {
225 throw(std::runtime_error(
"CaliTag::writeDB: "+e.getMessage()));
229 if (!this->fetchID()) {
230 throw(std::runtime_error(
"CaliTag::writeDB: Failed to write"));
241 this->checkConnection();
243 Statement* stmt = m_conn->createStatement();
244 stmt->setSQL(
"SELECT tag_id FROM cali_tag ORDER BY tag_id");
245 ResultSet* rset = stmt->executeQuery();
249 while(rset->next()) {
250 dcutag.
setByID( rset->getInt(1) );
251 fillVec->push_back( dcutag );
253 m_conn->terminateStatement(stmt);
254 }
catch (SQLException &
e) {
255 throw(std::runtime_error(
"CaliTag::fetchAllTags: "+e.getMessage()));
265 m_locDef.setConnection(m_env, m_conn);
266 *locID = m_locDef.fetchID();
269 throw(std::runtime_error(
"CaliTag::writeDB: Given location does not exist in DB"));
void setMethod(std::string method)
LocationDef getLocationDef() const
void setLocationDef(const LocationDef &locDef)
std::string getGeneralTag() const
void setByID(int id) noexcept(false) override
std::string getVersion() const
int writeDB() noexcept(false)
void fetchParentIDs(int *locId) noexcept(false)
int fetchID() noexcept(false) override
void setVersion(std::string version)
void fetchAllTags(std::vector< CaliTag > *fillVec) noexcept(false)
std::string getDataType() const
void setDataType(std::string dataType)
std::string getMethod() const
void setGeneralTag(std::string tag)
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)