Query classes for common property = get value; Variable sort
If you can, please help me with this XWiki query. The languages in XWiki are ALL new to me: Java, SQL, Velocity, Hibernate, etc. The complete page code is at the end, for reference. GENERAL APPLICATION GOAL To dynamically sort XWiki content through navigation by custom "categories" (slightly similar to XWiki's News/Blog/Articles classification model). THE PROBLEM Construct a query for a page where: - Class name must begin with "XYZ" (e.g., "XYZ.PROClass") - all ClassTemplates are excluded - there is a common class property called "category" (which does NOT exist for ALL "XYZ*" Classes) which is equivalent to the value of a temporary variable "category1" obtained from the current URL (i.e., getParameter from a URL Get posted by the previous page) - results are sortable by standard document properties (and eventually, also sort by custom Class properties, too) CURRENT QUERY ATTEMPT sql=(", BaseObject as obj where obj.name=doc.fullName and obj.className like 'XYZ%' and obj.name not like '%ClassTemplate' and obj.category like '${category1}' order by '${mrsorter}'"); TROUBLESHOOTING The present query, upon repeatedly splicing it, is apparently not working for either of these components: * obj.category like '${category1}' - returns page error: "java.lang.ClassCastException" * order by '${mrsorter}' - returns page error: "com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while searching documents with sql ,BaseObject as obj where obj.name=doc.fullName and obj.className like 'XYZ%' order by 'doc.name' Wrapped Exception: could not execute query " ABOUT XYZ* CLASSES & CATEGORY PROPERTY Right now, in my XWiki there exists one "XYZ*" custom class (as a document template) which contains a property called "category" among other XYZ* classes which do not. The goal is to add more classes with names beginning with "XYZ*" that this query will need to explore in order to find matching "category" property results. I modeled the category property after the classification system in XWiki's Blog/ArticleClass, such that: Name: category Pretty Name: Category Unmodifiable: No Number: 2 Display Type: select Multiple Select: Yes Relational Storage: Yes Size: 5 Hibernate Query: select prop.value from BaseObject as obj, StringProperty as prop where obj.className='XYZ.Catsv02Class' and prop.id.id = obj.id and prop.id.name='name' FYI, XYZ.Catsv02Class exists as the class of all categories for content. When context= inline, I need a select list of these (similar to editing an XWiki Article) - but I can't get one to display on the page. But that's another story ... back to the query! COMPLETE PAGE CODE <% title1=request.getParameter("title"); category1=request.getParameter("category"); if (!title1) { title1 = "Unspecified" } if (!category1) { category1 = "Unspecified" } mrsorter=request.getParameter("orderby"); if(!mrsorter) { #set ($mrsorter = "doc.name") mrsorter = xwikidocument.getName(); } sql=(", BaseObject as obj where obj.name=doc.fullName and obj.className like 'XYZ%' and obj.name <> '%ClassTemplate' and obj.category like '${category1}' order by '${mrsorter}'"); %> [XYZ Home>XYZ.nav] : [${title1}>XYZ.subnav] : 1 ${category1} <br> Sort by: [Document No.>XYZ.catdoc?category=&orderby=doc.name] / [Date>XYZ.catdoc?category=&orderby=doc.date] / [Title>XYZ.catdoc?category=&orderby=doc.title] [+ Add New>apps.AddNew?category=${category1}] <% def formatdate(arg) { rd=arg.toString() a=rd.split(" "); return a[0] } println "1.1 Controlled Documentation"; println "<table border=0 cellpadding=0 cellspacing=12>"; println "<tr> <td>*Title*</td> <td>*Document No.*</td> <td>*Version*</td> <td>*Released*</td> <td>*<nobr>Previous No.</nobr>*</td> </tr>"; for (item in xwiki.searchDocuments(sql)) { d=xwiki.getDocument(item) rd=xwiki.formatDate(d.date,"MM/dd/yyyy") println "<tr><td>[${d.title}>${d.fullName}]</td><td><nobr>${d.name}</nobr></td><td>${d.version}</td><td>${rd}</td><td>${d.orig_doc_no}</td> </tr>"; } println "</table>"; %> END PAGE CODE I would greatly appreciate any assistance you are able to provide. Thank you, eBox _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
participants (1)
-
e Box