Browse Source

Merge pull request #4875 from wangkx/h10080

HPCC-10080 Add Activated flag to WUListQueries response

Reviewed-By: Gordon Smith <gordon.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 years ago
parent
commit
65bd6e2a1a

+ 15 - 3
common/workunit/workunit.cpp

@@ -2403,7 +2403,7 @@ public:
             StringAttr xPath;
             StringAttr sortOrder;
 
-            void populateQueryTree(const char* querySetId, IPropertyTree* querySetTree, const char *xPath, IPropertyTree* queryTree)
+            void populateQueryTree(IPropertyTree* queryRegistry, const char* querySetId, IPropertyTree* querySetTree, const char *xPath, IPropertyTree* queryTree)
             {
                 Owned<IPropertyTreeIterator> iter = querySetTree->getElements(xPath);
                 ForEach(*iter)
@@ -2411,17 +2411,29 @@ public:
                     IPropertyTree &query = iter->query();
                     IPropertyTree *queryWithSetId = queryTree->addPropTree("Query", LINK(&query));
                     queryWithSetId->addProp("@querySetId", querySetId);
+
+                    bool activated = false;
+                    const char* queryId = query.queryProp("@id");
+                    if (queryId && *queryId)
+                    {
+                        VStringBuffer xPath("Alias[@id='%s']", queryId);
+                        IPropertyTree *alias = queryRegistry->queryPropTree(xPath.str());
+                        if (alias)
+                            activated = true;
+                    }
+                    queryWithSetId->addPropBool("@activated", activated);
                 }
             }
 
             IPropertyTree* getAllQuerySetQueries(IRemoteConnection* conn, const char *querySet, const char *xPath)
             {
+                Owned<IPropertyTree> queryRegistry = getQueryRegistry(querySet, false);
                 Owned<IPropertyTree> queryTree = createPTree("Queries");
                 IPropertyTree* root = conn->queryRoot();
                 if (querySet && *querySet)
                 {
                     VStringBuffer path("QuerySet[@id='%s']/Query%s", querySet, xPath);
-                    populateQueryTree(querySet, root, path.str(), queryTree);
+                    populateQueryTree(queryRegistry, querySet, root, path.str(), queryTree);
                 }
                 else
                 {
@@ -2433,7 +2445,7 @@ public:
                         if (id && *id)
                         {
                             VStringBuffer path("Query%s", xPath);
-                            populateQueryTree(id, &querySet, path.str(), queryTree);
+                            populateQueryTree(queryRegistry, id, &querySet, path.str(), queryTree);
                         }
                     }
                 }

+ 1 - 0
esp/scm/ws_workunits.ecm

@@ -1185,6 +1185,7 @@ ESPStruct [nil_remove] QuerySetQuery
     string Comment;
     [min_ver("1.45")] string QuerySetId;
     [min_ver("1.46")] bool IsLibrary;
+    [min_ver("1.46")] bool Activated;
     [min_ver("1.46")] string PublishedBy;
 };
 

+ 2 - 1
esp/services/ws_workunits/ws_workunitsQuerySets.cpp

@@ -1049,6 +1049,7 @@ bool CWsWorkunitsEx::onWUListQueries(IEspContext &context, IEspWUListQueriesRequ
         q->setQuerySetId(query.queryProp("@querySetId"));
         q->setDll(query.queryProp("@dll"));
         q->setWuid(query.queryProp("@wuid"));
+        q->setActivated(query.getPropBool("@activated", false));
         q->setSuspended(query.getPropBool("@suspended", false));
         if (query.hasProp("@memoryLimit"))
         {
@@ -1159,7 +1160,7 @@ bool CWsWorkunitsEx::onWUQueryDetails(IEspContext &context, IEspWUQueryDetailsRe
 
     if (version >= 1.42)
     {
-        xpath.clear().appendf("Alias[@name='%s']", queryName);
+        xpath.clear().appendf("Alias[@id='%s']", queryId);
         IPropertyTree *alias = queryRegistry->queryPropTree(xpath.str());
         if (!alias)
             resp.setActivated(false);