> There is no supporting code for multilevels in Dove as far as I can see,
> but it could easily be added here. For instance by using syntax like:
>
>   /[EMAIL PROTECTED]/related/newstypes

I've hacked a bit and got it working, a patch is attached. I had to change
a tiny bit of code dealing with 'field' definitions, of which I'm not sure
if it is backward compatible, and whether or not that matters.

The syntax now is
  /[EMAIL PROTECTED],related,newstypes
(saves a bit of '/'-to-','-conversion)

Furthermore, '{$origin}' and such are filled in in the query, if you need
them.

Could any one of the editwizard-wizards take a look?

Johannes
? dove/build
Index: dove/src/org/mmbase/applications/dove/Dove.java
===================================================================
RCS file: /usr/local/cvs/applications/dove/src/org/mmbase/applications/dove/Dove.java,v
retrieving revision 1.52
diff -u -r1.52 Dove.java
--- dove/src/org/mmbase/applications/dove/Dove.java     23 Feb 2004 18:59:35 -0000     
 1.52
+++ dove/src/org/mmbase/applications/dove/Dove.java     5 May 2004 13:45:33 -0000
@@ -697,22 +697,40 @@
                         querydata.setAttribute(ELM_DIRECTIONS, directions);
                     }
                     out.appendChild(querydata);
-                    // get node template
-                    Element node=getFirstElement(query);
 
                     if (xpath.indexOf("/*@")!=0) {
                         Element err = addContentElement(ERROR,"invalid xpath",out);
                         err.setAttribute(ELM_TYPE, IS_CLIENT);
                     } else {
-                        //get node data, bit stupid
+                        String nodepath = xpath.substring(3);
                         try {
-                            NodeManager nm = cloud.getNodeManager(xpath.substring(3));
-                            for(NodeIterator i 
=nm.getList(where,orderby,directions).nodeIterator(); i.hasNext(); ) {
+                            NodeIterator i = null;
+
+                            if (nodepath.indexOf(",") == -1) {
+                                // If there is no ',' seperator, we only get fields 
from one nodemanager. This is the fastest
+                                // way of getting those.
+                                i = 
cloud.getNodeManager(xpath.substring(3)).getList(where,orderby,directions).nodeIterator();
+                            } else {
+                                // If there are ',' seperators, we need to do a 
multilevel search. Therefore we first need to
+                                // get a list of all the fields (as subnodes) to 
query.
+                                String fields = "";
+                                Element field = getFirstElement(query, FIELD);
+                                while (field != null) {
+                                    String fname=(String)field.getAttribute(ELM_NAME);
+                                    if (!fields.equals(""))
+                                        fields += ",";
+                                    fields += fname;
+                                    field = getNextElement(field, FIELD);    
+                                }
+                                i = cloud.getList("", nodepath, fields, where, 
orderby, directions, null, true).nodeIterator();
+                            }
+
+                            for(; i.hasNext(); ) {
                                 org.mmbase.bridge.Node n=i.nextNode();
                                 Element data=doc.createElement(OBJECT);
                                 data.setAttribute(ELM_NUMBER, ""+n.getNumber());
                                 querydata.appendChild(data);
-                                getDataNode(node,data,n);
+                                getDataNode(query,data,n);
                             }
                         } catch(RuntimeException e) {
                             Element err = addContentElement(ERROR,"node type " + 
xpath.substring(3) + " does not exist(" + e.toString() + ")",out);
Index: editwizard/src/org/mmbase/applications/editwizard/Wizard.java
===================================================================
RCS file: 
/usr/local/cvs/applications/editwizard/src/org/mmbase/applications/editwizard/Wizard.java,v
retrieving revision 1.121
diff -u -r1.121 Wizard.java
--- editwizard/src/org/mmbase/applications/editwizard/Wizard.java       7 Apr 2004 
17:04:26 -0000       1.121
+++ editwizard/src/org/mmbase/applications/editwizard/Wizard.java       5 May 2004 
13:45:33 -0000
@@ -788,6 +788,9 @@
                 Node queryresult = null;
 
                 try {
+                    // replace {$origin} and such
+                    String newWhere = Utils.fillInParams(Utils.getAttribute(query, 
"where"), variables);
+                    Utils.setAttribute(query, "where", newWhere);
                     queryresult = databaseConnector.getList(query);
                     queryresult = Utils.selectSingleNode(queryresult, 
"/getlist/query");
                 } catch (Exception e) {
Index: 
editwizard/src/org/mmbase/applications/editwizard/resources/wizard-schema_1_0.dtd
===================================================================
RCS file: 
/usr/local/cvs/applications/editwizard/src/org/mmbase/applications/editwizard/resources/wizard-schema_1_0.dtd,v
retrieving revision 1.23
diff -u -r1.23 wizard-schema_1_0.dtd
--- editwizard/src/org/mmbase/applications/editwizard/resources/wizard-schema_1_0.dtd  
 19 Dec 2003 11:10:10 -0000      1.23
+++ editwizard/src/org/mmbase/applications/editwizard/resources/wizard-schema_1_0.dtd  
 5 May 2004 13:45:33 -0000
@@ -33,7 +33,7 @@
 <!ELEMENT option ( #PCDATA ) >
 <!ATTLIST option id CDATA  #REQUIRED >
 
-<!ELEMENT query EMPTY >
+<!ELEMENT query ( field* ) >
 <!ATTLIST query xpath CDATA #REQUIRED >
 <!ATTLIST query where CDATA #IMPLIED >
 <!ATTLIST query orderby CDATA #IMPLIED >

Reply via email to