소스 검색

HPCC-13714 Option for #Webservice(Fields()) to include unspecified fields

The following syntax:
#WEBSERVICE(FIELDS('field1','field2','*'));

The addition of the name '*' would cause the form to show
first field1 and field2 and then all additional stored inputs
(unless noinput is specified for that stored).

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 8 년 전
부모
커밋
4a06d24388
1개의 변경된 파일31개의 추가작업 그리고 3개의 파일을 삭제
  1. 31 3
      esp/services/ws_ecl/ws_ecl_wuinfo.cpp

+ 31 - 3
esp/services/ws_ecl/ws_ecl_wuinfo.cpp

@@ -209,11 +209,39 @@ bool WsEclWuInfo::getWsResource(const char *name, StringBuffer &out)
         IArrayOf<IPropertyTree> parts;
         if (fields.length())
         {
+            bool addedAdditionalFields = false;
+            unsigned offset = 1;
             ForEachItemIn(i, fields)
             {
-                Owned<IConstWUResult> var = wu->getVariableByName(fields.item(i));
-                if (var)
-                    appendVariableParmInfo(parts, resultSetFactory, *var, i+1);
+                const char *name = fields.item(i);
+                if (!addedAdditionalFields && streq(name, "*")) //name of '*' means insert all unspecified fields here, can only be used once
+                {
+                    addedAdditionalFields=true;
+                    Owned<IConstWUResultIterator> vars = &ensureWorkUnit()->getVariables();
+                    ForEach(*vars)
+                    {
+                        SCMStringBuffer s;
+                        IConstWUResult &var = vars->query();
+                        if (NotFound == fields.find(var.getResultName(s).str()))
+                        {
+                            SCMStringBuffer fieldSeq;
+                            var.getResultFieldOpt("sequence", fieldSeq);
+                            int seq = fieldSeq.length() ? atoi(fieldSeq.str()) : 0;
+                            if (seq < 0)
+                                seq = 0;
+                            seq = seq + i + 1;
+                            if (seq > offset) //track where we need to resume with specified fields
+                                offset = seq;
+                            appendVariableParmInfo(parts, resultSetFactory, vars->query(), seq);
+                        }
+                    }
+                }
+                else
+                {
+                    Owned<IConstWUResult> var = wu->getVariableByName(name);
+                    if (var)
+                        appendVariableParmInfo(parts, resultSetFactory, *var, i+offset);
+                }
             }
         }
         else