Bläddra i källkod

Merge pull request #7056 from afishbeck/eclWebserviceFieldSorting

HPCC-12508 WsEcl unsequenced fields should be alphabetica

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com> l
Richard Chapman 10 år sedan
förälder
incheckning
b1c9c7b2f2
1 ändrade filer med 27 tillägg och 12 borttagningar
  1. 27 12
      esp/services/ws_ecl/ws_ecl_wuinfo.cpp

+ 27 - 12
esp/services/ws_ecl/ws_ecl_wuinfo.cpp

@@ -47,6 +47,11 @@ IConstWorkUnit *WsEclWuInfo::ensureWorkUnit()
 
 void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *resultSetFactory, IConstWUResult &var, unsigned hashWebserviceSeq=0)
 {
+    Owned<IResultSetMetaData> meta = resultSetFactory->createResultSetMeta(&var);
+    StringAttr noinput;
+    if (var.getResultFieldOpt("noinput", StringAttrAdaptor(noinput)).length() && strToBool(noinput.length(), noinput.get()))  //developer specified not to show field on form
+        return;
+
     SCMStringBuffer varname;
     var.getResultName(varname);
     int seq = var.getResultSequence();
@@ -56,8 +61,6 @@ void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *r
     SCMStringBuffer eclschema;
     var.getResultEclSchema(eclschema);
 
-    SCMStringBuffer s;
-    Owned<IResultSetMetaData> meta = resultSetFactory->createResultSetMeta(&var);
     StringBuffer width, height, fieldSeq;
     var.getResultFieldOpt("fieldwidth", StringBufferAdaptor(width));
     var.getResultFieldOpt("fieldheight", StringBufferAdaptor(height));
@@ -66,6 +69,7 @@ void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *r
     else
         var.getResultFieldOpt("sequence", StringBufferAdaptor(fieldSeq));
 
+    SCMStringBuffer s;
     Owned<IPropertyTree> part = createPTree("part");
     if (!var.isResultScalar())
     {
@@ -125,23 +129,34 @@ void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *r
     parts.append(*part.getClear());
 }
 
+int orderMatchingSequence(IPropertyTree * left, IPropertyTree * right)
+{
+    if (!right->hasProp("@name"))
+        return -1;
+    if (!left->hasProp("@name"))
+        return 1;
+    return stricmp(left->queryProp("@name"), right->queryProp("@name"));
+}
+
 int orderParts(IInterface * const * pLeft, IInterface * const * pRight)
 {
-    IPropertyTree * right = (IPropertyTree *)*pRight;
     IPropertyTree * left = (IPropertyTree *)*pLeft;
-    bool hasRightSeq = right->hasProp("@sequence");
+    IPropertyTree * right = (IPropertyTree *)*pRight;
     bool hasLeftSeq = left->hasProp("@sequence");
-    if (hasRightSeq && hasLeftSeq)
-        return left->getPropInt("@sequence") - right->getPropInt("@sequence");
+    bool hasRightSeq = right->hasProp("@sequence");
+    if (hasLeftSeq && hasRightSeq)
+    {
+        int rightSeq = right->getPropInt("@sequence");
+        int leftSeq = left->getPropInt("@sequence");
+        if (rightSeq == leftSeq)
+            return orderMatchingSequence(left, right);  //fields with same sequence alphabetical within sequence
+        return leftSeq - rightSeq;
+    }
     if (hasRightSeq)
-        return -1;
-    if (hasLeftSeq)
         return 1;
-    if (!right->hasProp("@name"))
+    if (hasLeftSeq)
         return -1;
-    if (!left->hasProp("@name"))
-        return 1;
-    return stricmp(right->queryProp("@name"), left->queryProp("@name"));  //fields without sequence alphabetical AFTER sequenced fields
+    return orderMatchingSequence(left, right);  //fields without sequence alphabetical AFTER sequenced fields
 }
 
 bool WsEclWuInfo::getWsResource(const char *name, StringBuffer &out)