18 m_writeStmt =
nullptr;
21 m_configuration_script =
"";
22 m_configuration_script_params =
"";
29 std::cout <<
"entering clear" << std::endl;
31 m_configuration_script =
"";
32 m_configuration_script_params =
"";
42 this->checkConnection();
44 m_readStmt = m_conn->createStatement();
45 m_readStmt->setSQL(
"select ecal_ttcci_config_sq.NextVal from dual");
46 ResultSet* rset = m_readStmt->executeQuery();
47 while (rset->next()) {
50 m_conn->terminateStatement(m_readStmt);
54 throw(std::runtime_error(
std::string(
"ODTTCciConfig::fetchNextId(): ") +
e.getMessage()));
59 this->checkConnection();
61 int next_id = fetchNextId();
64 m_writeStmt = m_conn->createStatement();
66 "INSERT INTO ECAL_TTCci_CONFIGURATION (ttcci_configuration_id, ttcci_tag, " 67 " TTCCI_configuration_file, TRG_MODE, TRG_SLEEP, Configuration, configuration_script, " 68 "configuration_script_params ) " 69 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )");
70 m_writeStmt->setInt(1, next_id);
71 m_writeStmt->setString(2, getConfigTag());
72 m_writeStmt->setString(3, getTTCciConfigurationFile());
73 m_writeStmt->setString(4, getTrgMode());
74 m_writeStmt->setInt(5, getTrgSleep());
75 m_writeStmt->setString(7, getConfigurationScript());
76 m_writeStmt->setString(8, getConfigurationScriptParams());
79 oracle::occi::Clob clob(m_conn);
81 m_writeStmt->setClob(6, clob);
82 m_writeStmt->executeUpdate();
85 m_conn->terminateStatement(m_writeStmt);
86 std::cout <<
"TTCci Clob inserted into CONFIGURATION with id=" << next_id << std::endl;
89 m_writeStmt = m_conn->createStatement();
91 "SELECT Configuration FROM ECAL_TTCci_CONFIGURATION WHERE" 92 " ttcci_configuration_id=:1 FOR UPDATE");
94 std::cout <<
"updating the clob 0" << std::endl;
97 throw(std::runtime_error(
std::string(
"ODTTCciConfig::prepareWrite(): ") +
e.getMessage()));
100 std::cout <<
"updating the clob 1 " << std::endl;
107 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
108 if (ci->first ==
"TRG_MODE")
109 setTrgMode(ci->second);
110 if (ci->first ==
"TRG_SLEEP")
111 setTrgSleep(atoi(ci->second.c_str()));
112 if (ci->first ==
"TTCci_CONFIGURATION_ID")
113 setConfigTag(ci->second);
114 if (ci->first ==
"CONFIGURATION_SCRIPT")
115 setConfigurationScript(ci->second);
116 if (ci->first ==
"CONFIGURATION_SCRIPT_PARAMS")
117 setConfigurationScriptParams(ci->second);
118 if (ci->first ==
"CONFIGURATION_SCRIPT_PARAMETERS")
119 setConfigurationScriptParams(ci->second);
120 if (ci->first ==
"Configuration") {
129 cout <<
"fname=" <<
fname <<
" and reduced is: " << str3 << endl;
130 setTTCciConfigurationFile(str3);
133 std::cout <<
"Going to read file: " << str3 << endl;
136 inpFile.open(str3.c_str());
141 bufsize = inpFile.tellg();
142 std::cout <<
" bufsize =" << bufsize << std::endl;
144 inpFile.seekg(0, ios::beg);
153 std::cout <<
"updating the clob 2" << std::endl;
156 m_writeStmt->setInt(1, m_ID);
157 ResultSet* rset = m_writeStmt->executeQuery();
159 while (rset->next()) {
160 oracle::occi::Clob clob = rset->getClob(1);
161 cout <<
"Opening the clob in read write mode" << endl;
162 cout <<
"Populating the clob" << endl;
163 populateClob(clob, getTTCciConfigurationFile(), m_size);
164 int clobLength = clob.length();
165 cout <<
"Length of the clob is: " << clobLength << endl;
169 m_writeStmt->executeUpdate();
171 m_writeStmt->closeResultSet(rset);
174 throw(std::runtime_error(
std::string(
"ODTTCciConfig::writeDB(): ") +
e.getMessage()));
177 if (!this->fetchID()) {
178 throw(std::runtime_error(
"ODTTCciConfig::writeDB: Failed to write"));
183 this->checkConnection();
185 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
186 throw(std::runtime_error(
"ODTTCciConfig::fetchData(): no Id defined for this ODTTCciConfig "));
192 "FROM ECAL_TTCci_CONFIGURATION " 193 " where ( ttcci_configuration_id = :1 or ttcci_tag=:2 )");
194 m_readStmt->setInt(1,
result->getId());
195 m_readStmt->setString(2,
result->getConfigTag());
196 ResultSet* rset = m_readStmt->executeQuery();
201 result->setId(rset->getInt(1));
202 result->setConfigTag(rset->getString(2));
204 result->setTTCciConfigurationFile(rset->getString(3));
205 result->setTrgMode(rset->getString(4));
206 result->setTrgSleep(rset->getInt(5));
208 result->setConfigurationScript(rset->getString(7));
209 result->setConfigurationScriptParams(rset->getString(8));
211 Clob clob = rset->getClob(6);
212 cout <<
"Opening the clob in Read only mode" << endl;
213 clob.open(OCCI_LOB_READONLY);
214 int clobLength = clob.length();
215 cout <<
"Length of the clob is: " << clobLength << endl;
217 unsigned char*
buffer = readClob(clob, m_size);
219 cout <<
"the clob buffer is:" << endl;
220 for (
int i = 0;
i < clobLength; ++
i)
227 throw(std::runtime_error(
std::string(
"ODTTCciConfig::fetchData(): ") +
e.getMessage()));
236 this->checkConnection();
239 Statement* stmt = m_conn->createStatement();
241 "SELECT ttcci_configuration_id FROM ecal_ttcci_configuration " 242 "WHERE ttcci_tag=:ttcci_tag ");
244 stmt->setString(1, getConfigTag());
246 ResultSet* rset = stmt->executeQuery();
249 m_ID = rset->getInt(1);
253 m_conn->terminateStatement(stmt);
255 throw(std::runtime_error(
std::string(
"ODTTCciConfig::fetchID: ") +
e.getMessage()));
~ODTTCciConfig() override
void fetchData(ODTTCciConfig *result) noexcept(false)
void setParameters(const std::map< std::string, std::string > &my_keys_map)
void writeDB() noexcept(false)
int fetchID() noexcept(false)
void prepareWrite() noexcept(false) override
oracle::occi::Statement Statement
int fetchNextId() noexcept(false)
oracle::occi::SQLException SQLException
void clear(HadCaloObj &c)