# HG changeset patch # User Sebastien Jodogne # Date 1526393403 -7200 # Node ID a3fdfb6979eddb84be4578aea3ff9d364255aa4c # Parent bf14b037731f280eee23211ee3414f5c0e599b34 getting rid of ReusableDicomConnection in REST API diff -r bf14b037731f -r a3fdfb6979ed Core/JobsEngine/JobInfo.cpp --- a/Core/JobsEngine/JobInfo.cpp Mon May 14 21:44:41 2018 +0200 +++ b/Core/JobsEngine/JobInfo.cpp Tue May 15 16:10:03 2018 +0200 @@ -116,7 +116,8 @@ } - void JobInfo::Serialize(Json::Value& target) const + void JobInfo::Serialize(Json::Value& target, + bool includeInternalContent) const { target = Json::objectValue; target["ID"] = id_; @@ -131,7 +132,11 @@ target["Type"] = status_.GetJobType(); target["PublicContent"] = status_.GetPublicContent(); - target["InternalContent"] = status_.GetInternalContent(); + + if (includeInternalContent) + { + target["InternalContent"] = status_.GetInternalContent(); + } if (HasEstimatedTimeOfArrival()) { diff -r bf14b037731f -r a3fdfb6979ed Core/JobsEngine/JobInfo.h --- a/Core/JobsEngine/JobInfo.h Mon May 14 21:44:41 2018 +0200 +++ b/Core/JobsEngine/JobInfo.h Tue May 15 16:10:03 2018 +0200 @@ -115,6 +115,7 @@ return status_; } - void Serialize(Json::Value& target) const; + void Serialize(Json::Value& target, + bool includeInternalContent) const; }; } diff -r bf14b037731f -r a3fdfb6979ed OrthancExplorer/explorer.js --- a/OrthancExplorer/explorer.js Mon May 14 21:44:41 2018 +0200 +++ b/OrthancExplorer/explorer.js Tue May 15 16:10:03 2018 +0200 @@ -1181,8 +1181,14 @@ AddJobDateField(item, 'Completion time: ', job.CompletionTime); AddJobDateField(item, 'ETA: ', job.EstimatedTimeOfArrival); + if (job.State == 'Running' || + job.State == 'Pending' || + job.State == 'Paused') { + AddJobField(item, 'Priority: ', job.Priority); + AddJobField(item, 'Progress: ', job.Progress); + } + if (job.State == 'Running') { - AddJobField(item, 'Progress: ', job.Progress); li.insertAfter(running); } else if (job.State == 'Pending' || job.State == 'Paused') { diff -r bf14b037731f -r a3fdfb6979ed OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon May 14 21:44:41 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Tue May 15 16:10:03 2018 +0200 @@ -304,12 +304,15 @@ ServerContext& context = OrthancRestApi::GetContext(call); const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); try { - if (locker.GetConnection().Echo()) + DicomUserConnection connection(localAet, remote); + connection.Open(); + + if (connection.Echo()) { // Echo has succeeded call.GetOutput().AnswerBuffer("{}", "application/json"); @@ -425,11 +428,16 @@ } const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); + + DicomFindAnswers answers(false); - DicomFindAnswers answers(false); - FindPatient(answers, locker.GetConnection(), fields); + { + DicomUserConnection connection(localAet, remote); + connection.Open(); + FindPatient(answers, connection, fields); + } Json::Value result; answers.ToJson(result, true); @@ -455,11 +463,16 @@ } const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); DicomFindAnswers answers(false); - FindStudy(answers, locker.GetConnection(), fields); + + { + DicomUserConnection connection(localAet, remote); + connection.Open(); + FindStudy(answers, connection, fields); + } Json::Value result; answers.ToJson(result, true); @@ -486,11 +499,16 @@ } const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); DicomFindAnswers answers(false); - FindSeries(answers, locker.GetConnection(), fields); + + { + DicomUserConnection connection(localAet, remote); + connection.Open(); + FindSeries(answers, connection, fields); + } Json::Value result; answers.ToJson(result, true); @@ -518,11 +536,16 @@ } const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); DicomFindAnswers answers(false); - FindInstance(answers, locker.GetConnection(), fields); + + { + DicomUserConnection connection(localAet, remote); + connection.Open(); + FindInstance(answers, connection, fields); + } Json::Value result; answers.ToJson(result, true); @@ -555,11 +578,14 @@ } const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); + DicomUserConnection connection(localAet, remote); + connection.Open(); + DicomFindAnswers patients(false); - FindPatient(patients, locker.GetConnection(), m); + FindPatient(patients, connection, m); // Loop over the found patients Json::Value result = Json::arrayValue; @@ -577,7 +603,7 @@ CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID); DicomFindAnswers studies(false); - FindStudy(studies, locker.GetConnection(), m); + FindStudy(studies, connection, m); patient["Studies"] = Json::arrayValue; @@ -597,7 +623,7 @@ CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID); DicomFindAnswers series(false); - FindSeries(series, locker.GetConnection(), m); + FindSeries(series, connection, m); // Loop over the found series study["Series"] = Json::arrayValue; @@ -1034,15 +1060,18 @@ std::string targetAet = Toolbox::GetJsonStringField (request, "TargetAet", context.GetDefaultLocalApplicationEntityTitle()); - const RemoteModalityParameters source = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - + const RemoteModalityParameters source = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); + + DicomUserConnection connection(localAet, source); + connection.Open(); + for (Json::Value::ArrayIndex i = 0; i < request[RESOURCES].size(); i++) { DicomMap resource; FromDcmtkBridge::FromJson(resource, request[RESOURCES][i]); - - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, source); - locker.GetConnection().Move(targetAet, level, resource); + + connection.Move(targetAet, level, resource); } // Move has succeeded @@ -1236,15 +1265,17 @@ if (call.ParseJsonRequest(json)) { const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); - RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); + RemoteModalityParameters remote = + Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", "")); std::auto_ptr query(ParsedDicomFile::CreateFromJson(json, static_cast(0))); DicomFindAnswers answers(true); { - ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote); - locker.GetConnection().FindWorklist(answers, *query); + DicomUserConnection connection(localAet, remote); + connection.Open(); + connection.FindWorklist(answers, *query); } Json::Value result; diff -r bf14b037731f -r a3fdfb6979ed OrthancServer/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Mon May 14 21:44:41 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Tue May 15 16:10:03 2018 +0200 @@ -291,7 +291,7 @@ if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, *it)) { Json::Value tmp; - info.Serialize(tmp); + info.Serialize(tmp, false); v.append(tmp); } } @@ -312,7 +312,7 @@ if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, id)) { Json::Value json; - info.Serialize(json); + info.Serialize(json, false); call.GetOutput().AnswerJson(json); } } diff -r bf14b037731f -r a3fdfb6979ed UnitTestsSources/MultiThreadingTests.cpp --- a/UnitTestsSources/MultiThreadingTests.cpp Mon May 14 21:44:41 2018 +0200 +++ b/UnitTestsSources/MultiThreadingTests.cpp Tue May 15 16:10:03 2018 +0200 @@ -754,7 +754,7 @@ if (engine.GetRegistry().GetJobInfo(info, *it)) { Json::Value vv; - info.Serialize(vv); + info.Serialize(vv, true); v.append(vv); } } @@ -790,7 +790,7 @@ if (engine.GetRegistry().GetJobInfo(info, *it)) { Json::Value vv; - info.Serialize(vv); + info.Serialize(vv, true); v.append(vv); } }