207 {
208
209
210 if (coraltable.size()>18) throw CoraCoolException(
211 "CORAL tablename too long (max 18 chars)",
212 "CoraCoolDatabase::createFolder");
213
214
215 std::string::size_type
p1,
p2;
219 if (p1!=std::string::npos && p2!=std::string::npos) {
222 }
223
224 newdesc+="<coracool>";
225 newdesc+=coraltable;
226 newdesc+=':';
227 newdesc+=fkspec[0].name();
228 newdesc+=':';
229 newdesc+= coralfk;
230 newdesc+=':';
231 newdesc+=coralpk;
232 newdesc+="</coracool>";
233 m_log << coral::Debug <<
"Created new description: " << newdesc <<
234 coral::MessageStream::endmsg;
235
236
237
239 m_proxy->transaction().start(
false);
241 if (coralfk!=coralpk)
243
244
247 throw CoraCoolException("Cannot store payload specification",
248 "CoraCoolDatabase::createFolder");
249
250
251 try {
252 m_log << coral::Debug <<
"Generate CORAL table:" << coraltable <<
253 coral::MessageStream::endmsg;
254 coral::TableDescription tdesc("CoraCoolPayload");
255 tdesc.setName(
m_dbname+
"_"+coraltable);
256 for (
unsigned int i=0;
i<payloadspec.size();++
i) {
257 const cool::IFieldSpecification&
field=payloadspec[
i];
258 int maxsize=
field.storageType().maxSize();
259 if (
field.storageType()==cool::StorageType::Blob64k) maxsize=0;
260 const std::string typen=coral::AttributeSpecification::typeNameForId(
261 field.storageType().cppType());
262 m_log << coral::Debug <<
"Insert column " <<
field.name() <<
263 " of type " << typen << std::endl;
264 tdesc.insertColumn(
field.name(),typen,maxsize,
false);
265 }
266
267 tdesc.setPrimaryKey(coralpk);
268
269 if (coralfk!=coralpk)
270 tdesc.createIndex(
m_dbname+
"_"+coraltable+
"F",coralfk,
false);
271
272 m_proxy->nominalSchema().createTable(tdesc);
273 m_proxy->transaction().commit();
274 m_log << coral::Debug <<
"Created coral table " << coral::MessageStream::endmsg;
275
276
278 sleep(1);
280 }
281 catch (std::exception& e) {
282
283 throw CoraCoolException(
e.what(),
"CoraCoolDatabase::createFolder");
284 }
285
286
287
288
289
290
291 m_log << coral::Debug <<
"Disconnect/reconnect COOL connection" <<
292 coral::MessageStream::endmsg;
295 m_log << coral::Debug <<
"Create COOL folder" << coolpath << coral::MessageStream::endmsg;
296
298 cool::FolderSpecification(mode,fkspec),newdesc,createParents);
299 m_log << coral::Debug <<
"Created COOL folder" << coral::MessageStream::endmsg;
300
301
302
306}
boost::shared_ptr< CoraCoolFolder > CoraCoolFolderPtr
std::string encodeAttrSpec(const cool::IRecordSpecification &spec)
bool storeSpec(const std::string &tablename, const std::string &spec)
std::string description
glabal timer - how long have I taken so far?