com.xmlserv.app.basket
Class Basket

java.lang.Object
  |
  +--com.xmlserv.app.basket.Basket

public class Basket
extends java.lang.Object

Basket abstraction. The XMLServ Applications Basket* just interact with instances of this class.


Constructor Summary
Basket(java.sql.Connection con, int id)
          Constructor used by BasketReceipt.
Basket(java.sql.Connection con, int userid, int id)
          Load an existing basket.
Basket(java.sql.Connection con, int userid, java.lang.String basketid)
          Create object by loading data associated with given basketid.
Basket(java.sql.Connection con, java.lang.String basketid)
          Constructor used by BasketReceipt.
Basket(java.sql.Connection con, java.lang.String name, int userid)
          Create a new Basket.
 
Method Summary
 void add(java.sql.Connection con, int image)
          Add an Image to the basket.
static void cleanup(java.sql.Connection con, int userid, Basket currentBasket, boolean radicalCleanup)
          Forward to cleanup(Connection, int, int). currentBasket can be null.
static void cleanup(java.sql.Connection con, int userid, int currentBasket, boolean radicalCleanup)
          Remove any empty baskets without a name that are still open and older than one day except the current basket.
 void clear(java.sql.Connection con)
          Clear basket contents.
 Basket clone(java.sql.Connection con, java.lang.String name)
          Create a fresh deep copy of this basket.
 void close(java.sql.Connection con)
           
 void del(java.sql.Connection con, int image)
          Delete an Image from the basket.
static void drop(java.sql.Connection con, int userid, int id)
          Delete the basket itself.
static void drop(java.sql.Connection con, int userid, java.lang.String basketid)
          Delete the basket itself.
 java.lang.String getBasketid()
           
 java.lang.String getCompleted()
           
 int getContentID(java.sql.Connection con, int image)
          Return the id from basket_contents associated with the given image and this basket.
 java.lang.String getCtime()
           
 int getId()
           
 java.lang.String getName()
           
 BasketRecipient getRecipient(java.sql.Connection con)
          Get the recipient for this basket.
 int getUserid()
           
 boolean isBasketClosed()
           
 boolean isMailinglistRecipient(java.sql.Connection con)
           
 java.util.Vector list(java.sql.Connection con)
          Return list of basket contents (image ids in a Vector).
static org.jdom.Element listBaskets(java.sql.Connection con, int userid)
          List users baskets.
static org.jdom.Element listBaskets(java.sql.Connection con, int userid, boolean closed)
          List users baskets.
 void setName(java.sql.Connection con, java.lang.String name)
           
 void setRecipient(java.sql.Connection con, Mailinglist mailinglist)
          Set a mailinglist recipient for this basket.
 void setRecipient(java.sql.Connection con, PhoneBook.Entry recipient)
          Set recipient of this basket.
 void setRecipient(java.sql.Connection con, User recipient)
          Set recipient rof this basket.
 org.jdom.Element toElement(java.sql.Connection con, SecurityManager securityManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Basket

public Basket(java.sql.Connection con,
              java.lang.String name,
              int userid)
       throws XMLServException
Create a new Basket.
Parameters:
con - The DB Connection
name - The name of this basket. May be null or empty.

Basket

public Basket(java.sql.Connection con,
              int userid,
              int id)
       throws XMLServException
Load an existing basket.
Parameters:
con - A DB connection used to load basket data.
userid - The numeric user id.
id - The unique (numeric) id.

Basket

public Basket(java.sql.Connection con,
              int userid,
              java.lang.String basketid)
       throws XMLServException
Create object by loading data associated with given basketid.
Parameters:
con - The DB connection.
userid - The numeric user id.
basketid - The unique 'random' basketid (referencing the field basketid in the DB)

Basket

public Basket(java.sql.Connection con,
              int id)
       throws XMLServException
Constructor used by BasketReceipt. Enforces the called basket to be closed already.

Basket

public Basket(java.sql.Connection con,
              java.lang.String basketid)
       throws XMLServException
Constructor used by BasketReceipt. Enforces the called basket to be closed already.
Method Detail

clone

public Basket clone(java.sql.Connection con,
                    java.lang.String name)
             throws XMLServException
Create a fresh deep copy of this basket. This includes content and selected formats, but not the recipients.

listBaskets

public static org.jdom.Element listBaskets(java.sql.Connection con,
                                           int userid)
                                    throws XMLServException
List users baskets.
Parameters:
con - The DB connection.
userid - The users numeric id.

listBaskets

public static org.jdom.Element listBaskets(java.sql.Connection con,
                                           int userid,
                                           boolean closed)
                                    throws XMLServException
List users baskets.
Parameters:
con - The DB connection.
userid - The users numeric id.
closed - If true, show only closed baskets. Show all otherwise.

add

public void add(java.sql.Connection con,
                int image)
         throws XMLServException
Add an Image to the basket.
Parameters:
con - The DB Connection to use.
image - The Image ID.

del

public void del(java.sql.Connection con,
                int image)
         throws XMLServException
Delete an Image from the basket.
Parameters:
con - The DB Connection.
image - The Image ID to remove.

list

public java.util.Vector list(java.sql.Connection con)
                      throws XMLServException
Return list of basket contents (image ids in a Vector).
Parameters:
con - The DB connection.
Returns:
A Vector of image IDs.

getContentID

public int getContentID(java.sql.Connection con,
                        int image)
                 throws java.sql.SQLException
Return the id from basket_contents associated with the given image and this basket.
Returns:
Said ID or -1 if not found.

clear

public void clear(java.sql.Connection con)
           throws XMLServException
Clear basket contents.

close

public void close(java.sql.Connection con)
           throws XMLServException

drop

public static void drop(java.sql.Connection con,
                        int userid,
                        java.lang.String basketid)
                 throws XMLServException
Delete the basket itself. Only possible on open baskets.
Parameters:
basketid - The String Basket ID.

drop

public static void drop(java.sql.Connection con,
                        int userid,
                        int id)
                 throws XMLServException
Delete the basket itself. Only possible on open baskets.
Parameters:
basketid - The String Basket ID.

toElement

public org.jdom.Element toElement(java.sql.Connection con,
                                  SecurityManager securityManager)
                           throws XMLServException

cleanup

public static void cleanup(java.sql.Connection con,
                           int userid,
                           Basket currentBasket,
                           boolean radicalCleanup)
                    throws XMLServException
Forward to cleanup(Connection, int, int). currentBasket can be null.
Parameters:
radicalDelete - If false, delete only 'old' empty baskets without a name. Delete all open baskets except the current one otherwise.

cleanup

public static void cleanup(java.sql.Connection con,
                           int userid,
                           int currentBasket,
                           boolean radicalCleanup)
                    throws XMLServException
Remove any empty baskets without a name that are still open and older than one day except the current basket.
Parameters:
radicalDelete - If false, delete only 'old' empty baskets without a name. Delete all open baskets except the current one otherwise.

getId

public int getId()

getBasketid

public java.lang.String getBasketid()

getName

public java.lang.String getName()

setName

public void setName(java.sql.Connection con,
                    java.lang.String name)
             throws XMLServException

isMailinglistRecipient

public boolean isMailinglistRecipient(java.sql.Connection con)
                               throws XMLServException

getRecipient

public BasketRecipient getRecipient(java.sql.Connection con)
                             throws XMLServException
Get the recipient for this basket. Currently only one recipient can be read.

setRecipient

public void setRecipient(java.sql.Connection con,
                         PhoneBook.Entry recipient)
                  throws XMLServException
Set recipient of this basket.

setRecipient

public void setRecipient(java.sql.Connection con,
                         User recipient)
                  throws XMLServException
Set recipient rof this basket.

setRecipient

public void setRecipient(java.sql.Connection con,
                         Mailinglist mailinglist)
                  throws XMLServException
Set a mailinglist recipient for this basket.

getUserid

public int getUserid()

getCtime

public java.lang.String getCtime()

getCompleted

public java.lang.String getCompleted()

isBasketClosed

public boolean isBasketClosed()