diff --git a/applications/whatithink.com/db/xmlss/whatithink.com/format-xml-as-html.xslt b/applications/whatithink.com/db/xmlss/whatithink.com/format-xml-as-html.xslt
index 3b94bdd..a35ab7e 100644
--- a/applications/whatithink.com/db/xmlss/whatithink.com/format-xml-as-html.xslt
+++ b/applications/whatithink.com/db/xmlss/whatithink.com/format-xml-as-html.xslt
@@ -1 +1,30 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/applications/whatithink.com/db/xmlss/whatithink.com/mylist-to-fo.xslt b/applications/whatithink.com/db/xmlss/whatithink.com/mylist-to-fo.xslt
index d0c546f..8fe25a4 100644
--- a/applications/whatithink.com/db/xmlss/whatithink.com/mylist-to-fo.xslt
+++ b/applications/whatithink.com/db/xmlss/whatithink.com/mylist-to-fo.xslt
@@ -1,4 +1,79 @@
-Created on: June 2, 2011Author: Adam Retteradam.retter@google.comhttp://www.adamretter.org.uk
- 's List
-
- Page
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 's List
+
+
+
+
+ Page
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/applications/whatithink.com/db/xmlss/whatithink.com/mylist.xqm b/applications/whatithink.com/db/xmlss/whatithink.com/mylist.xqm
index 1a1d0b6..6e4f8d6 100644
--- a/applications/whatithink.com/db/xmlss/whatithink.com/mylist.xqm
+++ b/applications/whatithink.com/db/xmlss/whatithink.com/mylist.xqm
@@ -1,3 +1,27 @@
+(:
+ Copyright 2011 Adam Retter
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+:)
+
+(:~
+: This module manages a logged in Users list of
+: atom entries that they want to order as a book
+: and/or send to the printers
+:
+: @author Adam Retter
+: @version 201109122029
+:)
xquery version "1.0";
module namespace mylist = "http://whatithink.com/xquery/mylist";
@@ -18,6 +42,15 @@ import module namespace security = "http://whatithink.com/xquery/security" at "s
declare variable $mylist:mylist-filename := "mylist.xml";
+(:~
+: Adds an atom entry to the users list
+:
+: @param entry
+: The atom entry to add to the list
+:
+: @return
+: true() if the entry was added to the list, false() otherwise
+:)
declare function mylist:add($entry as document-node()) as xs:boolean {
let $mylist := mylist:get-or-create() return
if($mylist/mylist:list/mylist:entry/@ref = $entry/atom:entry/atom:id/text())then
@@ -28,6 +61,13 @@ declare function mylist:add($entry as document-node()) as xs:boolean {
)
};
+(:~
+: Generates an XHTML list of the current logged in users atom entries
+:
+: @return
+: An XHTML list of the current logged in users atom entries,
+: complete with hyperlinks to retrieve each entry
+:)
declare function mylist:browse-all-entries() as element(xh:ul) {
{
@@ -37,14 +77,22 @@ declare function mylist:browse-all-entries() as element(xh:ul) {
};
+(:~
+: Gets the current logged in users atom:entries from their list
+:
+: @return
+: The current logged in users atom:entries from their list
+:)
declare function mylist:get-entries() as element(atom:entry)* {
for $list-entry in mylist:get-or-create()/mylist:list/mylist:entry return
entry:get-entry-from-id($list-entry/@ref)/atom:entry
};
-(:
-TODO -
- declare function mylist:as-atom-feed() as document-node(element(atom:feed))
+(:~
+: Gets the current logged in users list of atom:entries as an atom feed
+:
+: @return
+: An atom feed of the currently logged in users atom:entries
:)
declare function mylist:as-atom-feed() as document-node() {
document {
@@ -63,6 +111,13 @@ declare function mylist:as-atom-feed() as document-node() {
}
};
+(:~
+: Gets the document that holds the currently logged in users list.
+: If the document does not exist it will be created.
+:
+: @return
+: The document which holds the users personal list of atom entries
+:)
declare function mylist:get-or-create() as document-node() {
let $mylist-uri := fn:concat(security:get-user-collection-path(), "/", $mylist:mylist-filename) return
@@ -75,15 +130,41 @@ declare function mylist:get-or-create() as document-node() {
fn:doc($mylist-uri)
};
+(:~
+: Clears all entries from the currently logged in users list
+:)
declare function mylist:clear() as empty() {
let $mylist := mylist:get-or-create() return
update delete $mylist/mylist:list/mylist:entry
};
+(:~
+: Places an order with the Printers for
+: the contents of a list
+:
+: The list is uploaded by an admin
+: whom specifies the user. The list is
+: then ordered for that user.
+:
+: @param order-upload
+: The Order wrapped in an order-upload element,
+: with the following format -
+:
+:
+:
+:
+:
+:
+:
+: @return
+: true() if we could order the list, false() otherwise
+:)
declare function mylist:order-from-xml($order-upload as element(order-upload)) as xs:boolean {
(: decode the base64 uploaded file :)
let $order := util:parse(util:base64-decode($order-upload/file)),
+
+ (: get the username of whom this order is for :)
$for-username := $order-upload/for/username return
let $order-for-user := mylist:replace-element($order/order:Order, {$for-username}) return
@@ -92,6 +173,23 @@ declare function mylist:order-from-xml($order-upload as element(order-upload)) a
};
+(:~
+: Replaces one element with another.
+:
+: The function looks at the given $src element
+: and all child elements recursively
+: if the QName of the $replacement element
+: matches the element under comparisson then
+: it is replaced.
+:
+: @param src
+: The element to replace or a container of the element to replace
+:
+: @param replacement
+: The element to substitute
+:
+: @return the src with any replacements made
+:)
declare function mylist:replace-element($src as element(), $replacement as element()) as element() {
if(node-name($src) eq node-name($replacement))then
$replacement
@@ -105,6 +203,15 @@ declare function mylist:replace-element($src as element(), $replacement as eleme
}
};
+(:~
+: Sends an Order to the Printers via REST
+:
+: @param order
+: The order to send to the printers
+:
+: @return
+: true() if the order was sent, false() otherwise
+:)
declare function mylist:order($order as element(order:Order)) as xs:boolean {
let $result := httpclient:post(
$config:printer-webapp-restful-order-uri,
@@ -117,7 +224,13 @@ declare function mylist:order($order as element(order:Order)) as xs:boolean {
$result/@statusCode eq "200"
};
-declare function mylist:browse-all-orders() as element(xh:table) {
+(:~
+: Gets a list of all Orders for the currently logged in user
+: via REST from the Printers.
+:
+: @return an XHTML snippet describing the Orders from the Printers
+:)
+declare function mylist:browse-all-orders() as element() {
let $my-orders := httpclient:get(
xs:anyURI(fn:concat($config:printer-webapp-restful-order-status-uri, "?requestId=", security:get-username())),
false(),