comparison OrthancServer/DatabaseWrapper.cpp @ 1286:b4acdb37e43b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Feb 2015 16:51:19 +0100
parents 32fcc5dc7562
children 6e7e5ed91c2d
comparison
equal deleted inserted replaced
1285:5730f374e4e6 1286:b4acdb37e43b
492 } 492 }
493 493
494 494
495 static void SetMainDicomTagsInternal(SQLite::Statement& s, 495 static void SetMainDicomTagsInternal(SQLite::Statement& s,
496 int64_t id, 496 int64_t id,
497 const DicomElement& element) 497 const DicomTag& tag,
498 { 498 const std::string& value)
499 s.BindInt64(0, id); 499 {
500 s.BindInt(1, element.GetTag().GetGroup()); 500 s.BindInt64(0, id);
501 s.BindInt(2, element.GetTag().GetElement()); 501 s.BindInt(1, tag.GetGroup());
502 s.BindString(3, element.GetValue().AsString()); 502 s.BindInt(2, tag.GetElement());
503 s.BindString(3, value);
503 s.Run(); 504 s.Run();
504 } 505 }
505 506
506 507
507 void DatabaseWrapper::SetMainDicomTags(int64_t id, 508 void DatabaseWrapper::SetMainDicomTag(int64_t id,
508 const DicomMap& tags) 509 const DicomTag& tag,
509 { 510 const std::string& value)
510 DicomArray flattened(tags); 511 {
511 for (size_t i = 0; i < flattened.GetSize(); i++) 512 if (tag.IsIdentifier())
512 { 513 {
513 if (flattened.GetElement(i).GetTag().IsIdentifier()) 514 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers VALUES(?, ?, ?, ?)");
514 { 515 SetMainDicomTagsInternal(s, id, tag, value);
515 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers VALUES(?, ?, ?, ?)"); 516 }
516 SetMainDicomTagsInternal(s, id, flattened.GetElement(i)); 517 else
517 } 518 {
518 else 519 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)");
519 { 520 SetMainDicomTagsInternal(s, id, tag, value);
520 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)");
521 SetMainDicomTagsInternal(s, id, flattened.GetElement(i));
522 }
523 } 521 }
524 } 522 }
525 523
526 void DatabaseWrapper::GetMainDicomTags(DicomMap& map, 524 void DatabaseWrapper::GetMainDicomTags(DicomMap& map,
527 int64_t id) 525 int64_t id)