Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 1286:b4acdb37e43b
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 16:51:19 +0100 |
parents | 83d8b3eacf49 |
children | 6e7e5ed91c2d |
comparison
equal
deleted
inserted
replaced
1285:5730f374e4e6 | 1286:b4acdb37e43b |
---|---|
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 | 473 |
474 void ServerIndex::SetMainDicomTags(int64_t resource, | |
475 const DicomMap& tags) | |
476 { | |
477 DicomArray flattened(tags); | |
478 for (size_t i = 0; i < flattened.GetSize(); i++) | |
479 { | |
480 const DicomElement& element = flattened.GetElement(i); | |
481 db_.SetMainDicomTag(resource, element.GetTag(), element.GetValue().AsString()); | |
482 } | |
483 } | |
484 | |
485 | |
486 | |
474 ServerIndex::ServerIndex(ServerContext& context, | 487 ServerIndex::ServerIndex(ServerContext& context, |
475 IDatabaseWrapper& db) : | 488 IDatabaseWrapper& db) : |
476 done_(false), | 489 done_(false), |
477 db_(db), | 490 db_(db), |
478 maximumStorageSize_(0), | 491 maximumStorageSize_(0), |
549 // Create the instance | 562 // Create the instance |
550 int64_t instance = db_.CreateResource(hasher.HashInstance(), ResourceType_Instance); | 563 int64_t instance = db_.CreateResource(hasher.HashInstance(), ResourceType_Instance); |
551 | 564 |
552 DicomMap dicom; | 565 DicomMap dicom; |
553 dicomSummary.ExtractInstanceInformation(dicom); | 566 dicomSummary.ExtractInstanceInformation(dicom); |
554 db_.SetMainDicomTags(instance, dicom); | 567 SetMainDicomTags(instance, dicom); |
555 | 568 |
556 // Detect up to which level the patient/study/series/instance | 569 // Detect up to which level the patient/study/series/instance |
557 // hierarchy must be created | 570 // hierarchy must be created |
558 int64_t patient = -1, study = -1, series = -1; | 571 int64_t patient = -1, study = -1, series = -1; |
559 bool isNewPatient = false; | 572 bool isNewPatient = false; |
602 // Create the series if needed | 615 // Create the series if needed |
603 if (isNewSeries) | 616 if (isNewSeries) |
604 { | 617 { |
605 series = db_.CreateResource(hasher.HashSeries(), ResourceType_Series); | 618 series = db_.CreateResource(hasher.HashSeries(), ResourceType_Series); |
606 dicomSummary.ExtractSeriesInformation(dicom); | 619 dicomSummary.ExtractSeriesInformation(dicom); |
607 db_.SetMainDicomTags(series, dicom); | 620 SetMainDicomTags(series, dicom); |
608 } | 621 } |
609 | 622 |
610 // Create the study if needed | 623 // Create the study if needed |
611 if (isNewStudy) | 624 if (isNewStudy) |
612 { | 625 { |
613 study = db_.CreateResource(hasher.HashStudy(), ResourceType_Study); | 626 study = db_.CreateResource(hasher.HashStudy(), ResourceType_Study); |
614 dicomSummary.ExtractStudyInformation(dicom); | 627 dicomSummary.ExtractStudyInformation(dicom); |
615 db_.SetMainDicomTags(study, dicom); | 628 SetMainDicomTags(study, dicom); |
616 } | 629 } |
617 | 630 |
618 // Create the patient if needed | 631 // Create the patient if needed |
619 if (isNewPatient) | 632 if (isNewPatient) |
620 { | 633 { |
621 patient = db_.CreateResource(hasher.HashPatient(), ResourceType_Patient); | 634 patient = db_.CreateResource(hasher.HashPatient(), ResourceType_Patient); |
622 dicomSummary.ExtractPatientInformation(dicom); | 635 dicomSummary.ExtractPatientInformation(dicom); |
623 db_.SetMainDicomTags(patient, dicom); | 636 SetMainDicomTags(patient, dicom); |
624 } | 637 } |
625 | 638 |
626 // Create the parent-to-child links | 639 // Create the parent-to-child links |
627 db_.AttachChild(series, instance); | 640 db_.AttachChild(series, instance); |
628 | 641 |
1559 | 1572 |
1560 | 1573 |
1561 void ServerIndex::DeleteChanges() | 1574 void ServerIndex::DeleteChanges() |
1562 { | 1575 { |
1563 boost::mutex::scoped_lock lock(mutex_); | 1576 boost::mutex::scoped_lock lock(mutex_); |
1564 db_.ClearTable("Changes"); | 1577 db_.ClearChanges(); |
1565 } | 1578 } |
1566 | 1579 |
1567 void ServerIndex::DeleteExportedResources() | 1580 void ServerIndex::DeleteExportedResources() |
1568 { | 1581 { |
1569 boost::mutex::scoped_lock lock(mutex_); | 1582 boost::mutex::scoped_lock lock(mutex_); |
1570 db_.ClearTable("ExportedResources"); | 1583 db_.ClearExportedResources(); |
1571 } | 1584 } |
1572 | 1585 |
1573 | 1586 |
1574 void ServerIndex::GetStatisticsInternal(/* out */ uint64_t& compressedSize, | 1587 void ServerIndex::GetStatisticsInternal(/* out */ uint64_t& compressedSize, |
1575 /* out */ uint64_t& uncompressedSize, | 1588 /* out */ uint64_t& uncompressedSize, |