From 1b768211bd5be80d84b183e4a3eec5c5bbe270d4 Mon Sep 17 00:00:00 2001
From: Owen Arnold <owen.arnold@stfc.ac.uk>
Date: Sun, 25 Oct 2015 20:42:00 +0000
Subject: [PATCH] refs #13989. Load Logs Rather than LoadISISNexus.

We only need to load the logs for the measurement information.
---
 Framework/DataHandling/src/LoadISISNexus2.cpp | 48 ------------------
 Framework/DataHandling/src/LoadNexusLogs.cpp  | 49 +++++++++++++++++++
 .../src/ReflLegacyTransferStrategy.cpp        |  4 +-
 .../src/ReflMeasureTransferStrategy.cpp       |  8 ++-
 4 files changed, 54 insertions(+), 55 deletions(-)

diff --git a/Framework/DataHandling/src/LoadISISNexus2.cpp b/Framework/DataHandling/src/LoadISISNexus2.cpp
index fbf9e489746..32742e3cffd 100644
--- a/Framework/DataHandling/src/LoadISISNexus2.cpp
+++ b/Framework/DataHandling/src/LoadISISNexus2.cpp
@@ -39,52 +39,6 @@
 namespace Mantid {
 namespace DataHandling {
 
-namespace {
-
-/**
- * @brief loadAndApplyMeasurementInfo
- * @param file : Nexus::File pointer
- * @param workspace : Pointer to the workspace to set logs on
- * @return True only if reading and execution successful.
- */
-bool loadAndApplyMeasurementInfo(::NeXus::File *const file,
-                                 DataObjects::Workspace2D &workspace) {
-
-  bool successfullyApplied = false;
-  try {
-    file->openGroup("measurement", "NXcollection");
-
-    // If we can open the measurement group. We assume that the following will
-    // be avaliable.
-    file->openData("id");
-    workspace.mutableRun().addLogData(
-        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_id",
-                                                           file->getStrData()));
-    file->closeData();
-    file->openData("label");
-    workspace.mutableRun().addLogData(
-        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_label",
-                                                           file->getStrData()));
-    file->closeData();
-    file->openData("subid");
-    workspace.mutableRun().addLogData(
-        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_subid",
-                                                           file->getStrData()));
-    file->closeData();
-    file->openData("type");
-    workspace.mutableRun().addLogData(
-        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_type",
-                                                           file->getStrData()));
-    file->closeData();
-    file->closeGroup();
-    successfullyApplied = true;
-  } catch (::NeXus::Exception &) {
-    successfullyApplied = false;
-  }
-  return successfullyApplied;
-}
-}
-
 DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadISISNexus2)
 
 using namespace Kernel;
@@ -298,8 +252,6 @@ void LoadISISNexus2::exec() {
   m_cppFile->openPath(entry.path());
   local_workspace->loadSampleAndLogInfoNexus(m_cppFile.get());
 
-  loadAndApplyMeasurementInfo(m_cppFile.get(), *local_workspace);
-
   // Load logs and sample information further information... See maintenance
   // ticket #8697
   loadSampleData(local_workspace, entry);
diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp
index 927184c5f64..278e8761ba9 100644
--- a/Framework/DataHandling/src/LoadNexusLogs.cpp
+++ b/Framework/DataHandling/src/LoadNexusLogs.cpp
@@ -28,6 +28,52 @@ using API::MatrixWorkspace_sptr;
 using API::FileProperty;
 using std::size_t;
 
+namespace {
+
+/**
+ * @brief loadAndApplyMeasurementInfo
+ * @param file : Nexus::File pointer
+ * @param workspace : Pointer to the workspace to set logs on
+ * @return True only if reading and execution successful.
+ */
+bool loadAndApplyMeasurementInfo(::NeXus::File *const file,
+                                 API::MatrixWorkspace &workspace) {
+
+  bool successfullyApplied = false;
+  try {
+    file->openGroup("measurement", "NXcollection");
+
+    // If we can open the measurement group. We assume that the following will
+    // be avaliable.
+    file->openData("id");
+    workspace.mutableRun().addLogData(
+        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_id",
+                                                           file->getStrData()));
+    file->closeData();
+    file->openData("label");
+    workspace.mutableRun().addLogData(
+        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_label",
+                                                           file->getStrData()));
+    file->closeData();
+    file->openData("subid");
+    workspace.mutableRun().addLogData(
+        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_subid",
+                                                           file->getStrData()));
+    file->closeData();
+    file->openData("type");
+    workspace.mutableRun().addLogData(
+        new Mantid::Kernel::PropertyWithValue<std::string>("measurement_type",
+                                                           file->getStrData()));
+    file->closeData();
+    file->closeGroup();
+    successfullyApplied = true;
+  } catch (::NeXus::Exception &) {
+    successfullyApplied = false;
+  }
+  return successfullyApplied;
+}
+}
+
 /// Empty default constructor
 LoadNexusLogs::LoadNexusLogs() {}
 
@@ -124,6 +170,9 @@ void LoadNexusLogs::exec() {
     }
   }
 
+  // If there's measurement information, load that info as logs.
+  loadAndApplyMeasurementInfo(&file, *workspace);
+
   // Freddie Akeroyd 12/10/2011
   // current ISIS implementation contains an additional indirection between
   // collected frames via an
diff --git a/MantidQt/CustomInterfaces/src/ReflLegacyTransferStrategy.cpp b/MantidQt/CustomInterfaces/src/ReflLegacyTransferStrategy.cpp
index 00ae00f823f..ca5d75ac419 100644
--- a/MantidQt/CustomInterfaces/src/ReflLegacyTransferStrategy.cpp
+++ b/MantidQt/CustomInterfaces/src/ReflLegacyTransferStrategy.cpp
@@ -10,8 +10,8 @@ namespace MantidQt
   namespace CustomInterfaces
   {
   std::vector<std::map<std::string, std::string>>
-  ReflLegacyTransferStrategy::transferRuns(SearchResultMap &searchResults,
-      Mantid::Kernel::ProgressBase &progress) {
+  ReflLegacyTransferStrategy::transferRuns(
+      SearchResultMap &searchResults, Mantid::Kernel::ProgressBase &progress) {
       /*
        * If the descriptions are the same except for theta: same group, different rows.
        * If the descriptions are the same including theta: same row with runs separated by '+'
diff --git a/MantidQt/CustomInterfaces/src/ReflMeasureTransferStrategy.cpp b/MantidQt/CustomInterfaces/src/ReflMeasureTransferStrategy.cpp
index 9254ac0cb87..6976db501c0 100644
--- a/MantidQt/CustomInterfaces/src/ReflMeasureTransferStrategy.cpp
+++ b/MantidQt/CustomInterfaces/src/ReflMeasureTransferStrategy.cpp
@@ -40,8 +40,7 @@ ReflMeasureTransferStrategy::~ReflMeasureTransferStrategy() {}
 
 std::vector<std::map<std::string, std::string>>
 MantidQt::CustomInterfaces::ReflMeasureTransferStrategy::transferRuns(
-    SearchResultMap &searchResults,
-    Mantid::Kernel::ProgressBase &progress) {
+    SearchResultMap &searchResults, Mantid::Kernel::ProgressBase &progress) {
 
   typedef std::vector<Measurement> VecSameMeasurement;
   typedef std::map<Measurement::IDType, VecSameMeasurement>
@@ -68,9 +67,8 @@ MantidQt::CustomInterfaces::ReflMeasureTransferStrategy::transferRuns(
         // Add to existing group
         mapOfMeasurements[metaData.id()].push_back(metaData);
       }
-    }
-    else{
-        it->second.issues = metaData.whyUnuseable();
+    } else {
+      it->second.issues = metaData.whyUnuseable();
     }
 
     // Obtaining metadata could take time.
-- 
GitLab