Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 3091:476cba12c2b0 db-changes
IDatabaseWrapper::GetChildrenMetadata()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 05 Jan 2019 15:08:53 +0100 |
parents | 31244604f617 |
children | 2e1808b6146a |
comparison
equal
deleted
inserted
replaced
3090:31244604f617 | 3091:476cba12c2b0 |
---|---|
991 | 991 |
992 | 992 |
993 SeriesStatus ServerIndex::GetSeriesStatus(int64_t id, | 993 SeriesStatus ServerIndex::GetSeriesStatus(int64_t id, |
994 int64_t expectedNumberOfInstances) | 994 int64_t expectedNumberOfInstances) |
995 { | 995 { |
996 // Loop over the instances of this series | 996 std::list<std::string> values; |
997 std::list<int64_t> children; | 997 db_.GetChildrenMetadata(values, id, MetadataType_Instance_IndexInSeries); |
998 db_.GetChildrenInternalId(children, id); | |
999 | 998 |
1000 std::set<int64_t> instances; | 999 std::set<int64_t> instances; |
1001 for (std::list<int64_t>::const_iterator | 1000 |
1002 it = children.begin(); it != children.end(); ++it) | 1001 for (std::list<std::string>::const_iterator |
1003 { | 1002 it = values.begin(); it != values.end(); ++it) |
1004 // Get the index of this instance in the series | 1003 { |
1005 int64_t index; | 1004 int64_t index; |
1006 if (!GetMetadataAsInteger(index, *it, MetadataType_Instance_IndexInSeries)) | 1005 |
1006 try | |
1007 { | |
1008 index = boost::lexical_cast<int64_t>(*it); | |
1009 } | |
1010 catch (boost::bad_lexical_cast&) | |
1007 { | 1011 { |
1008 return SeriesStatus_Unknown; | 1012 return SeriesStatus_Unknown; |
1009 } | 1013 } |
1010 | 1014 |
1011 if (!(index > 0 && index <= expectedNumberOfInstances)) | 1015 if (!(index > 0 && index <= expectedNumberOfInstances)) |
1012 { | 1016 { |
1013 // Out-of-range instance index | 1017 // Out-of-range instance index |
1014 return SeriesStatus_Inconsistent; | 1018 return SeriesStatus_Inconsistent; |
1015 } | 1019 } |
1198 result["FileSize"] = static_cast<unsigned int>(attachment.GetUncompressedSize()); | 1202 result["FileSize"] = static_cast<unsigned int>(attachment.GetUncompressedSize()); |
1199 result["FileUuid"] = attachment.GetUuid(); | 1203 result["FileUuid"] = attachment.GetUuid(); |
1200 | 1204 |
1201 int64_t i; | 1205 int64_t i; |
1202 if (GetMetadataAsInteger(i, id, MetadataType_Instance_IndexInSeries)) | 1206 if (GetMetadataAsInteger(i, id, MetadataType_Instance_IndexInSeries)) |
1207 { | |
1203 result["IndexInSeries"] = static_cast<int>(i); | 1208 result["IndexInSeries"] = static_cast<int>(i); |
1209 } | |
1204 else | 1210 else |
1211 { | |
1205 result["IndexInSeries"] = Json::nullValue; | 1212 result["IndexInSeries"] = Json::nullValue; |
1213 } | |
1206 | 1214 |
1207 break; | 1215 break; |
1208 } | 1216 } |
1209 | 1217 |
1210 default: | 1218 default: |