From 7905926c413e843d9497948cb824059f2c017f6a Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 26 Aug 2013 03:04:23 +0000 Subject: Support sorting database search results by rank, and add a rank attribute to ATOM entries. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1517412 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/atom/atom.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sca-cpp/trunk/modules/atom/atom.hpp') diff --git a/sca-cpp/trunk/modules/atom/atom.hpp b/sca-cpp/trunk/modules/atom/atom.hpp index b6f2788b1e..49763a4b38 100644 --- a/sca-cpp/trunk/modules/atom/atom.hpp +++ b/sca-cpp/trunk/modules/atom/atom.hpp @@ -46,7 +46,7 @@ const value entry("entry"); */ const list entryElementValues(const list& e) { const list lt = elementChildren("title", e); - const list t = nilListValue + element + value("title") + (isNull(lt)? value(emptyString) : elementValue(car(lt))); + const list t = nilListValue + element + value("title") + (isNull(lt) || !elementHasValue(car(lt))? value(emptyString) : elementValue(car(lt))); const list li = elementChildren("id", e); const list i = nilListValue + element + value("id") + (isNull(li)? value(emptyString) : elementValue(car(li))); @@ -60,11 +60,14 @@ const list entryElementValues(const list& e) { const list lu = elementChildren("updated", e); const list u = isNull(lu)? nilListValue : mklist(nilListValue + element + value("updated") + elementValue(car(lu))); + const list lr = elementChildren("rank", e); + const list r = isNull(lr)? nilListValue : mklist(nilListValue + element + value("rank") + elementValue(car(lr))); + const list lc = elementChildren("content", e); const list c = isNull(lc)? nilListValue : isAttribute(elementValue(car(lc)))? nilListValue : mklist(nilListValue + element + value("content") + elementValue(car(lc))); - return append(append(append(nilListValue + element + entry + value(t) + value(i), a), u), c); + return append(append(append(append(nilListValue + element + entry + value(t) + value(i), a), u), r), c); } /** @@ -138,15 +141,17 @@ const list entryElement(const list& l) { const value author = elementChild("author", l); const bool email = isNull(author)? false : contains(elementValue(author), "@"); const value updated = elementChild("updated", l); + const value rank = elementChild("rank", l); const value content = elementChild("content", l); const bool text = isNull(content)? false : elementHasValue(content); return nilListValue + element + entry + (nilListValue + attribute + "xmlns" + "http://www.w3.org/2005/Atom") - + (nilListValue + element + "title" + (nilListValue + attribute + "type" + "text") + elementValue(title)) + + (nilListValue + element + "title" + (nilListValue + attribute + "type" + "text") + (elementHasValue(title)? elementValue(title) : value(""))) + (nilListValue + element + "id" + elementValue(id)) + (isNull(author)? nilListValue : (nilListValue + element + "author" + (email? (nilListValue + element + "email" + elementValue(author)) : (nilListValue + element + "name" + elementValue(author))))) + (isNull(updated)? nilListValue : (nilListValue + element + "updated" + elementValue(updated))) + + (isNull(rank)? nilListValue : (nilListValue + element + "rank" + elementValue(rank))) + (isNull(content)? nilListValue : append(nilListValue + element + "content" + (nilListValue + attribute + "type" + (text? "text" : "application/xml")), -- cgit v1.2.3