|
@@ -1894,6 +1894,7 @@ mapEnums querySortFields[] =
|
|
|
{ WUQSFpriority, "@priority" },
|
|
|
{ WUQSFpriorityHi, "@priority" },
|
|
|
{ WUQSFQuerySet, "../@id" },
|
|
|
+ { WUQSFLibrary, "Library"},
|
|
|
{ WUQSFterm, NULL }
|
|
|
};
|
|
|
|
|
@@ -2388,6 +2389,28 @@ public:
|
|
|
return getWorkUnitsSorted(sortorder,filters,filterbuf,startoffset,maxnum,queryowner,cachehint, NULL, NULL, total);
|
|
|
}
|
|
|
|
|
|
+ static void checkUpdateQuerysetLibraries(IPropertyTree *querySet)
|
|
|
+ {
|
|
|
+ if (querySet->hasProp("@updatedLibraries")) //only need to do this once, then publish and copy will keep up to date
|
|
|
+ return;
|
|
|
+ Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
|
|
|
+ Owned<IPropertyTreeIterator> queries = querySet->getElements("Query");
|
|
|
+ ForEach(*queries)
|
|
|
+ {
|
|
|
+ IPropertyTree &query = queries->query();
|
|
|
+ if (query.hasProp("@libCount"))
|
|
|
+ continue;
|
|
|
+ const char *wuid = query.queryProp("@wuid");
|
|
|
+ if (!wuid || !*wuid)
|
|
|
+ continue;
|
|
|
+ Owned<IConstWorkUnit> cw = factory->openWorkUnit(wuid, false);
|
|
|
+ if (!cw)
|
|
|
+ continue;
|
|
|
+ addLibrariesToQueryEntry(&query, cw);
|
|
|
+ }
|
|
|
+ querySet->setPropBool("@updatedLibraries", true);
|
|
|
+ }
|
|
|
+
|
|
|
IConstQuerySetQueryIterator* getQuerySetQueriesSorted( WUQuerySortField *sortorder, // list of fields to sort by (terminated by WUSFterm)
|
|
|
WUQuerySortField *filters, // NULL or list of fields to folteron (terminated by WUSFterm)
|
|
|
const void *filterbuf, // (appended) string values for filters
|
|
@@ -2401,6 +2424,7 @@ public:
|
|
|
StringAttr querySet;
|
|
|
StringAttr xPath;
|
|
|
StringAttr sortOrder;
|
|
|
+ bool checkLibraries;
|
|
|
|
|
|
void populateQueryTree(IPropertyTree* queryRegistry, const char* querySetId, IPropertyTree* querySetTree, const char *xPath, IPropertyTree* queryTree)
|
|
|
{
|
|
@@ -2431,6 +2455,8 @@ public:
|
|
|
if (querySet && *querySet)
|
|
|
{
|
|
|
Owned<IPropertyTree> queryRegistry = getQueryRegistry(querySet, false);
|
|
|
+ if (checkLibraries)
|
|
|
+ checkUpdateQuerysetLibraries(queryRegistry); //only actually happens once per queryset
|
|
|
VStringBuffer path("QuerySet[@id='%s']/Query%s", querySet, xPath);
|
|
|
populateQueryTree(queryRegistry, querySet, root, path.str(), queryTree);
|
|
|
}
|
|
@@ -2444,6 +2470,8 @@ public:
|
|
|
if (id && *id)
|
|
|
{
|
|
|
Owned<IPropertyTree> queryRegistry = getQueryRegistry(id, false);
|
|
|
+ if (checkLibraries)
|
|
|
+ checkUpdateQuerysetLibraries(queryRegistry); //only actually happens once per queryset
|
|
|
VStringBuffer path("Query%s", xPath);
|
|
|
populateQueryTree(queryRegistry, id, &querySetTree, path.str(), queryTree);
|
|
|
}
|
|
@@ -2455,8 +2483,8 @@ public:
|
|
|
public:
|
|
|
IMPLEMENT_IINTERFACE_USING(CSimpleInterface);
|
|
|
|
|
|
- CQuerySetQueriesPager(const char* _querySet, const char* _xPath, const char *_sortOrder)
|
|
|
- : querySet(_querySet), xPath(_xPath), sortOrder(_sortOrder)
|
|
|
+ CQuerySetQueriesPager(const char* _querySet, const char* _xPath, const char *_sortOrder, bool _checkLibraries)
|
|
|
+ : querySet(_querySet), xPath(_xPath), sortOrder(_sortOrder), checkLibraries(_checkLibraries)
|
|
|
{
|
|
|
}
|
|
|
virtual IRemoteConnection* getElements(IArrayOf<IPropertyTree> &elements)
|
|
@@ -2477,6 +2505,7 @@ public:
|
|
|
StringAttr querySet;
|
|
|
StringBuffer xPath;
|
|
|
StringBuffer so;
|
|
|
+ bool checkLibraries = false;
|
|
|
if (filters)
|
|
|
{
|
|
|
const char *fv = (const char *)filterbuf;
|
|
@@ -2499,6 +2528,8 @@ public:
|
|
|
xPath.append('~');
|
|
|
xPath.append('"').append(fv).append("\"]");
|
|
|
}
|
|
|
+ if (subfmt==WUQSFLibrary)
|
|
|
+ checkLibraries = true;
|
|
|
fv = fv + strlen(fv)+1;
|
|
|
}
|
|
|
}
|
|
@@ -2519,7 +2550,7 @@ public:
|
|
|
}
|
|
|
}
|
|
|
IArrayOf<IPropertyTree> results;
|
|
|
- Owned<IElementsPager> elementsPager = new CQuerySetQueriesPager(querySet.get(), xPath.str(), so.length()?so.str():NULL);
|
|
|
+ Owned<IElementsPager> elementsPager = new CQuerySetQueriesPager(querySet.get(), xPath.str(), so.length()?so.str():NULL, checkLibraries);
|
|
|
Owned<IRemoteConnection> conn=getElementsPaged(elementsPager,startoffset,maxnum,NULL,"",cachehint,results,total);
|
|
|
return new CConstQuerySetQueryIterator(results);
|
|
|
}
|
|
@@ -9703,7 +9734,30 @@ extern WORKUNIT_API IPropertyTree * getQueryRegistryRoot()
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+extern WORKUNIT_API void addLibrariesToQueryEntry(IPropertyTree *queryTree, IConstWULibraryIterator *libraries)
|
|
|
+{
|
|
|
+ if (!queryTree || !libraries)
|
|
|
+ return;
|
|
|
+ if (queryTree->hasProp("@libCount")) //already added
|
|
|
+ return;
|
|
|
+ unsigned libCount=0;
|
|
|
+ ForEach(*libraries)
|
|
|
+ {
|
|
|
+ IConstWULibrary &library = libraries->query();
|
|
|
+ SCMStringBuffer libname;
|
|
|
+ if (!library.getName(libname).length())
|
|
|
+ continue;
|
|
|
+ queryTree->addProp("Library", libname.str());
|
|
|
+ libCount++;
|
|
|
+ }
|
|
|
+ queryTree->setPropInt("@libCount", libCount);
|
|
|
+}
|
|
|
|
|
|
+extern WORKUNIT_API void addLibrariesToQueryEntry(IPropertyTree *queryTree, IConstWorkUnit *cw)
|
|
|
+{
|
|
|
+ Owned<IConstWULibraryIterator> libraries = &cw->getLibraries();
|
|
|
+ addLibrariesToQueryEntry(queryTree, libraries);
|
|
|
+}
|
|
|
|
|
|
extern WORKUNIT_API IPropertyTree * getQueryRegistry(const char * wsEclId, bool readonly)
|
|
|
{
|