Jelajahi Sumber

HPCC-16822 Extract query archive from DLL in WsWorkunits

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 8 tahun lalu
induk
melakukan
6be6215b10

+ 14 - 0
common/wuwebview/wuwebview.cpp

@@ -337,6 +337,7 @@ public:
     void getResource(const char *name, StringBuffer &content, StringBuffer &abspath, const char *type);
     bool getResourceByPath(const char *path, MemoryBuffer &mb);
     StringBuffer &getManifest(StringBuffer &mf){return toXML(ensureManifest(), mf);}
+    IConstWUQuery* getEmbeddedQuery();
 
     void calculateResourceIncludePaths();
     virtual bool getInclude(const char *includename, MemoryBuffer &includebuf, bool &pathOnly);
@@ -921,6 +922,19 @@ void WuWebView::addInputsFromXml(const char *xml)
     addInputsFromPTree(pt.get());
 }
 
+IConstWUQuery* WuWebView::getEmbeddedQuery()
+{
+    if (!loadDll())
+        return NULL;
+
+    StringBuffer dllXML;
+    if (!getEmbeddedWorkUnitXML(dll, dllXML))
+        return NULL;
+
+    Owned<ILocalWorkUnit> embeddedWU = createLocalWorkUnit(dllXML.str());
+    return embeddedWU->getQuery();
+}
+
 extern WUWEBVIEW_API IWuWebView *createWuWebView(IConstWorkUnit &wu, const char *target, const char *queryname, const char *dir, bool mapEspDirectories)
 {
     try

+ 1 - 0
common/wuwebview/wuwebview.hpp

@@ -58,6 +58,7 @@ interface IWuWebView : extends IInterface
     virtual void createWuidResponse(StringBuffer &out, unsigned flags)=0;
     virtual bool getResourceByPath(const char *path, MemoryBuffer &mb)=0;
     virtual StringBuffer &getManifest(StringBuffer &mf)=0;
+    virtual IConstWUQuery* getEmbeddedQuery()=0;
 
 };
 

+ 22 - 2
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -508,7 +508,7 @@ void WsWuInfo::getHelpers(IEspECLWorkunit &info, unsigned flags)
 
             if (version > 1.30)
             {
-                info.setHasArchiveQuery(query->isArchive());
+                info.setHasArchiveQuery(query->hasArchive());
             }
 
             for (unsigned i = 0; i < FileTypeSize; i++)
@@ -2085,6 +2085,15 @@ void WsWuInfo::getWorkunitResTxt(MemoryBuffer& buf)
     queryDllServer().getDll(query->getQueryResTxtName(resname).str(), buf);
 }
 
+IConstWUQuery* WsWuInfo::getEmbeddedQuery()
+{
+    Owned<IWuWebView> wv = createWuWebView(*cw, NULL, NULL, NULL, false);
+    if (wv)
+        return wv->getEmbeddedQuery();
+
+    return NULL;
+}
+
 void WsWuInfo::getWorkunitArchiveQuery(MemoryBuffer& buf)
 {
     Owned<IConstWUQuery> query = cw->getQuery();
@@ -2094,7 +2103,18 @@ void WsWuInfo::getWorkunitArchiveQuery(MemoryBuffer& buf)
     SCMStringBuffer queryText;
     query->getQueryText(queryText);
     if ((queryText.length() < 1) || !isArchiveQuery(queryText.str()))
-        throw MakeStringException(ECLWATCH_CANNOT_GET_WORKUNIT, "Archive Query not found for workunit %s.", wuid.str());
+    {
+        if (!query->hasArchive())
+            throw MakeStringException(ECLWATCH_CANNOT_GET_WORKUNIT, "Archive query not found for workunit %s.", wuid.str());
+
+        Owned<IConstWUQuery> embeddedQuery = getEmbeddedQuery();
+        if (!embeddedQuery)
+            throw MakeStringException(ECLWATCH_CANNOT_GET_WORKUNIT, "Embedded query not found for workunit %s.", wuid.str());
+
+        embeddedQuery->getQueryText(queryText);
+        if ((queryText.length() < 1) || !isArchiveQuery(queryText.str()))
+            throw MakeStringException(ECLWATCH_CANNOT_GET_WORKUNIT, "Archive query not found for workunit %s.", wuid.str());
+    }
     buf.append(queryText.length(), queryText.str());
 }
 

+ 1 - 0
esp/services/ws_workunits/ws_workunitsHelpers.hpp

@@ -201,6 +201,7 @@ public:
     void listArchiveFiles(IPropertyTree* archive, const char* path, IArrayOf<IEspWUArchiveModule>& modules, IArrayOf<IEspWUArchiveFile>& files);
     void getArchiveFile(IPropertyTree* archive, const char* moduleName, const char* attrName, const char* path, StringBuffer& file);
     void setWUAbortTime(IEspECLWorkunit &info, unsigned __int64 abortTS);
+    IConstWUQuery* getEmbeddedQuery();
 
 protected:
     void addTimerToList(SCMStringBuffer& name, const char * scope, IConstWUStatistic & stat, IArrayOf<IEspECLTimer>& timers);