Coverage Report - com.buckosoft.PicMan.db.DatabaseFacade
 
Classes in this File Line Coverage Branch Coverage Complexity
DatabaseFacade
N/A
N/A
1
 
 1  
 /******************************************************************************
 2  
  * DatabaseFacade.java - API into the PicMan database
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2005 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.db;
 9  
 
 10  
 import java.util.Calendar;
 11  
 import java.util.Date;
 12  
 import java.util.HashMap;
 13  
 import java.util.List;
 14  
 
 15  
 import org.springframework.dao.DataAccessException;
 16  
 
 17  
 import com.buckosoft.PicMan.business.common.PicManCommonFacade;
 18  
 import com.buckosoft.PicMan.db.logic.MetaSetFilter;
 19  
 import com.buckosoft.PicMan.domain.Chain;
 20  
 import com.buckosoft.PicMan.domain.Contact;
 21  
 import com.buckosoft.PicMan.domain.Filter;
 22  
 import com.buckosoft.PicMan.domain.FilterMicroSet;
 23  
 import com.buckosoft.PicMan.domain.MetaSet;
 24  
 import com.buckosoft.PicMan.domain.Mosaic;
 25  
 import com.buckosoft.PicMan.domain.MosaicBatch;
 26  
 import com.buckosoft.PicMan.domain.MosaicTile;
 27  
 import com.buckosoft.PicMan.domain.Pic;
 28  
 import com.buckosoft.PicMan.domain.Poster;
 29  
 import com.buckosoft.PicMan.domain.Root;
 30  
 import com.buckosoft.PicMan.domain.Set;
 31  
 import com.buckosoft.PicMan.domain.SetSize;
 32  
 import com.buckosoft.PicMan.domain.SyncClient;
 33  
 import com.buckosoft.PicMan.domain.SyncServer;
 34  
 import com.buckosoft.PicMan.domain.System;
 35  
 import com.buckosoft.PicMan.domain.User;
 36  
 import com.buckosoft.PicMan.domain.Virgin;
 37  
 import com.buckosoft.PicMan.domain.mosaic.MosaicVector;
 38  
 
 39  
 /** API into the PicMan database
 40  
  * @author Dick Balaska
 41  
  * @since 2006/07/17
 42  
  * @see <a href="http://cvs.buckosoft.com/Projects/PicMan/PicMan/src/com/buckosoft/PicMan/db/DatabaseFacade.java">DatabaseFacade.java</a>
 43  
  * @see <div><a href="http://cvs.buckosoft.com/Projects/PicMan/PicMan/src/JOCLPoolingDriver.jocl">JOCLPoolingDriver.jocl</a> Configuration file for the database</div>
 44  
  */
 45  
 public interface DatabaseFacade {
 46  
 
 47  
         /** Enable logger output on the database
 48  
          * @param debugFlag true == turn on debugging.
 49  
          */
 50  
         public void setDEBUG(boolean debugFlag);
 51  
         
 52  
         /** Set the callback to the partial main business facade.
 53  
          * We are interested in the error handler.
 54  
          * @param picManCommonFacade Where the error handler lives.
 55  
          */
 56  
         void setPicManCommonFacade(PicManCommonFacade picManCommonFacade);
 57  
         
 58  
         ///////////////////////////////////////////////////////////////////////////
 59  
         /* Contacts */
 60  
         
 61  
         /** Fetch the {@link com.buckosoft.PicMan.domain.Contact} that was built with these parameters.
 62  
          * This does not return an image, just all of the parameters needed to recreate the image.
 63  
          * Such as which Thumbnail appeared at each coordinates.
 64  
          * @param cid The {@link com.buckosoft.PicMan.domain.Chain} ID
 65  
          * @param name The qualified name of this contact.  i.e. "Gail-100-02"
 66  
          * @return The Contact
 67  
          */
 68  
         Contact                getContact(int cid, String name);
 69  
         
 70  
         /** Fetch the {@link com.buckosoft.PicMan.domain.Contact} that was built with these parameters.
 71  
          * This does not return an image, just all of the parameters needed to recreate the image.
 72  
          * Such as which Thumbnail appeared at each coordinates.
 73  
          * @param cid The {@link com.buckosoft.PicMan.domain.Chain} ID
 74  
          * @param setName The name of the {@link com.buckosoft.PicMan.domain.Set} that was used
 75  
          * @param size The Thumbnail size
 76  
          * @param index Which of this series of contacts
 77  
          * @return The Contact
 78  
          */
 79  
         Contact                getContact(int cid, String setName, int size, int index);
 80  
         
 81  
         /** Add this {@link com.buckosoft.PicMan.domain.Contact} to the database.
 82  
          * @param c The Contact
 83  
          */
 84  
         void                addContact(Contact c);
 85  
         
 86  
         /** Fetch the newest {@link com.buckosoft.PicMan.domain.Contact} made.  Basically this tells us
 87  
          * the last time Contacts were made.
 88  
          * @return The newest Contact in the database.
 89  
          */
 90  
         Contact                getNewestContact();
 91  
 
 92  
         /** Return the oldest contact in each set/size in a map
 93  
          * k = SetName i.e. "G-100" / v = Date
 94  
          * @param chain Which {@link com.buckosoft.PicMan.domain.Chain} to process 
 95  
          * @return the map
 96  
          */
 97  
         HashMap<String, Date>                getContactOldestMap(Chain chain);
 98  
 
 99  
         ///////////////////////////////////////////////////////////////////////////
 100  
         /* Chain management */
 101  
         
 102  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Chain}s in the database.
 103  
          * @return The List
 104  
          */
 105  
         List<Chain>        getChains();
 106  
         
 107  
         /** Return the number of {@link com.buckosoft.PicMan.domain.Chain}s in the Database.
 108  
          * @return The Count
 109  
          * @throws DataAccessException It broke.
 110  
          */
 111  
         int                getChainCount();
 112  
 
 113  
         /** Fetch a {@link com.buckosoft.PicMan.domain.Chain} based on its name.
 114  
          * @param chainName The name to query.
 115  
          * @return The chain or <code>null</code> if not found.
 116  
          */
 117  
         Chain        getChain(String chainName);
 118  
 
 119  
         /** Fetch a {@link com.buckosoft.PicMan.domain.Chain} based on its Chain ID.
 120  
          * @param cid The Chain ID to query.
 121  
          * @return The chain or <code>null</code> if not found.
 122  
          */
 123  
         Chain        getChain(int cid);
 124  
 
 125  
         /** Delete this {@link com.buckosoft.PicMan.domain.Chain} from the Database.
 126  
          * @param chain The Chain to delete.
 127  
          */
 128  
         void        deleteChain(Chain chain);
 129  
 
 130  
         /** Store this {@link com.buckosoft.PicMan.domain.Chain} in the Database.
 131  
          * @param chain The Chain to write.
 132  
          */
 133  
         void        storeChain(Chain chain);
 134  
 
 135  
         /** Return a list of Sets in a {@link com.buckosoft.PicMan.domain.Chain}
 136  
          * @param cid The Chain to query
 137  
          * @return A List of Set
 138  
          */
 139  
         public List<Set>        getSetsInChain(int cid);
 140  
 
 141  
         /** Return a list of SetSize for this set that are in this {@link com.buckosoft.PicMan.domain.Chain}
 142  
          * @param cid The chain id
 143  
          * @param sid The {@link com.buckosoft.PicMan.domain.Set} id
 144  
          * @return A list of SetSizes
 145  
          */
 146  
         List<SetSize>        getSetSizesInChain(int cid, int sid);
 147  
         
 148  
         ///////////////////////////////////////////////////////////////////////////
 149  
         /* Filter management */
 150  
 
 151  
         /** Get the number of {@link com.buckosoft.PicMan.domain.Filter}s in the database.
 152  
          * @return the count.
 153  
          */
 154  
         int                                getFilterCount();
 155  
 
 156  
         /** Get a list of the {@link com.buckosoft.PicMan.domain.Filter} column names from the database.
 157  
          * @return The List.
 158  
          */
 159  
         List<String>        getFilterColumns();
 160  
 
 161  
         /** Get a list of all of the {@link com.buckosoft.PicMan.domain.Filter}s in the database.
 162  
          * @return The List.
 163  
          */
 164  
         List<Filter>        getFilters();
 165  
 
 166  
         /** Get a list of all of the {@link com.buckosoft.PicMan.domain.Filter}s for this set/size.
 167  
          * @param setName The name of the Set to query.
 168  
          * @param size The thumbnail size to query.
 169  
          * @return A List of the <code>Filter</code>s that match this query
 170  
          */
 171  
         List<Filter>        getFiltersBySet(String setName, int size);
 172  
 
 173  
         /** Get a List of the Pic Names of the {@link com.buckosoft.PicMan.domain.Filter}s that match this query.
 174  
          * @param setName The name of the Set to query
 175  
          * @param size The thumbnail size to query
 176  
          * @return A List of the Pic Names that match this query
 177  
          */ 
 178  
         List<String>        getPicNamesBySet(String setName, int size);
 179  
 
 180  
         /** Get a List of the Pic Names of the {@link com.buckosoft.PicMan.domain.Filter}s that match this query.
 181  
          * @param set The Set to query
 182  
          * @param size The thumbnail size to query
 183  
          * @return A List of the Pic Names that match this query
 184  
          */
 185  
         List<String>        getPicNamesBySet(Set set, int size);
 186  
 
 187  
         /** Get a List of the Pic Names of the {@link com.buckosoft.PicMan.domain.Filter}s that match this query.
 188  
          * @param set The MetaSet to query
 189  
          * @param size The thumbnail size to query
 190  
          * @param rateOp An index into the MetaSet rateOps table.  i.e. NONE, =, !=, &lt;, &gt;.
 191  
          * @param rateVal The value to apply with the rateOp against this set
 192  
          * @return A List of the Pic Names that match this query
 193  
          */
 194  
         List<String>        getPicNamesBySet(MetaSet set, int size, int rateOp, int rateVal);
 195  
 
 196  
         /** Get a List of the Pic Names of the {@link com.buckosoft.PicMan.domain.Filter}s that match this valued query.
 197  
          * This allows to say "mlb &lt; 5".
 198  
          * @param set The Set to query.
 199  
          * @param size The thumbnail size to query.
 200  
          * @param rateOp An index into the MetaSet rateOps table.  i.e. NONE, =, !=, &lt;, &gt;.
 201  
          * @param rateVal The value to apply with the rateOp against this set
 202  
          * @return A List of the Pic Names that match this query.
 203  
          */ 
 204  
         List<String>        getPicNamesBySet(Set set, int size, int rateOp, int rateVal);
 205  
 
 206  
         /** Get a List of the Pic Names of the {@link com.buckosoft.PicMan.domain.Filter}s that match this valued query.
 207  
          * This allows to say "mlb &lt; 5".
 208  
          * @param setName The name of the Set to query.
 209  
          * @param size The thumbnail size to query.
 210  
          * @return A List of the Pic Names that match this query.
 211  
          */ 
 212  
         List<String>        getPicNamesBySet(String setName, int size, int rateOp, int rateVal);
 213  
 
 214  
         /** Get a List of the Pic Names that pass this function filter.
 215  
          * See {@link Set} for the list of valid function numbers.
 216  
          * @param func The Function number to run.
 217  
          * @param size The thumb size to run this filter on.
 218  
          * @param rateOp An index into the MetaSet rateOps table.  i.e. NONE, =, !=, &lt;, &gt;.
 219  
          * @param operand A generic operand for the func.  i.e. date (-2) takes a date here "2009-07-25"
 220  
          * @return A List of the Pic Names that match this query.
 221  
          */
 222  
         List<String>        getPicNamesByFunc(int func, int size, int rateOp, String operand);
 223  
         
 224  
         /** Return a hash of the newest filter for each set/size.
 225  
          * k = Set i.e. "G_100" / v = Date 
 226  
          * @return The Hash
 227  
          */
 228  
         HashMap<String, Date>        getSetTimestamps();
 229  
 
 230  
         /** Add a {@link com.buckosoft.PicMan.domain.Filter} to the database, overwriting any existing filter for this pic.
 231  
          * @param filter The new (or used) Filter.
 232  
          */
 233  
         void        addFilter(Filter filter);
 234  
 
 235  
         /** Get the {@link com.buckosoft.PicMan.domain.Filter} for the pic named.
 236  
          * @param picName The name of the Pic.
 237  
          * @return the Filter
 238  
          */
 239  
         Filter        getFilter(String picName);
 240  
 
 241  
         /** Get the {@link com.buckosoft.PicMan.domain.FilterMicroSet} for this pic in this set.
 242  
          * @param pid The pid the Pic.
 243  
          * @param sid The sid of the set to query.
 244  
          * @return The <code>FilterMicroSet</code> or null if not found.
 245  
          */
 246  
         FilterMicroSet        getPicFromFilterMicroSet(int pid, int sid);
 247  
 
 248  
         ///////////////////////////////////////////////////////////////////////////
 249  
         /* MetaSet management */
 250  
 
 251  
         /** Get the {@link com.buckosoft.PicMan.domain.MetaSet} that matches this Set ID.
 252  
          * @param sid The SetID to query.
 253  
          * @return The MetaSet
 254  
          */
 255  
         MetaSet        getMetaSet(int sid);
 256  
 
 257  
         /** Store this {@link com.buckosoft.PicMan.domain.MetaSet} to the database.
 258  
          * @param mset The MetaSet to write.
 259  
          */
 260  
         void                        storeMetaSet(MetaSet mset);
 261  
 
 262  
         /** Get a List of Column names for the {@link com.buckosoft.PicMan.domain.MetaSet}s.
 263  
          * @return a List of "columns" for the known metasets
 264  
          */
 265  
         List<String>        getMetaSetColumns();
 266  
 
 267  
         /** Fetch a reference to the MetaSet filter processor.
 268  
          * @return A reference to the database's MetaSet filter processor.
 269  
          */
 270  
         MetaSetFilter        getMetaSetFilter();
 271  
         
 272  
         ///////////////////////////////////////////////////////////////////////////
 273  
         /* Mosaic management */
 274  
 
 275  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Mosaic}s in the database.
 276  
          * @return The List of Mosaics
 277  
          */
 278  
         List<Mosaic>        getMosaics();
 279  
 
 280  
         /** Get a {@link com.buckosoft.PicMan.domain.Mosaic} from the database based on this Mosaic ID.
 281  
          * @param mid The Mosaic ID to query.
 282  
          * @return The Mosaic that matches this mid, or null if not found.
 283  
          */
 284  
         Mosaic                        getMosaic(int mid);
 285  
 
 286  
         /** Find the {@link com.buckosoft.PicMan.domain.Mosaic} in the database that matches these parameters.
 287  
          * @param masterPic
 288  
          * @param engine
 289  
          * @param sid
 290  
          * @param tileHeight
 291  
          * @return The mosaic that matches these parameters, or null if not found.
 292  
          */
 293  
         Mosaic                        getMosaic(String masterPic, String engine, int sid, int tileHeight);
 294  
         
 295  
         /** Return the number of tiles we have stored for this {@link com.buckosoft.PicMan.domain.Mosaic}
 296  
          * @param mid The mosaicId
 297  
          * @return The count
 298  
          */
 299  
         int                                getMosaicTileCount(int mid);
 300  
 
 301  
         /** Delete the {@link com.buckosoft.PicMan.domain.Mosaic} from the database that has this Mosaic ID.
 302  
          * @param mid The Mosaic ID to delete.
 303  
          */ 
 304  
         void                        deleteMosaic(int mid);
 305  
 
 306  
         /** Store this {@link com.buckosoft.PicMan.domain.Mosaic} in the database.
 307  
          * @param mosaic The Mosaic to store.
 308  
          */
 309  
         void                        storeMosaic(Mosaic mosaic);
 310  
         
 311  
         /** Get a List of {@link com.buckosoft.PicMan.domain.MosaicBatch}es in the database.
 312  
          * @return The List of MosaicBatches
 313  
          */
 314  
         List<MosaicBatch>        getMosaicBatches();
 315  
 
 316  
         /** Get the MosaicBatch that matches this mbid
 317  
          * @param mbid The MosaicBatch id to query.
 318  
          * @return The MosaicBatch that matches or null if not found.
 319  
          */
 320  
         MosaicBatch                getMosaicBatch(int mbid);
 321  
 
 322  
         /** Store this {@link com.buckosoft.PicMan.domain.MosaicBatch}es in the database.
 323  
          * @param mbatch The MosaicBatch to store
 324  
          */
 325  
         void                        storeMosaicBatch(MosaicBatch mbatch);
 326  
         
 327  
         ///////////////////////////////////////////////////////////////////////////
 328  
         /* MosaicTile management */
 329  
 
 330  
         /** Fetch the already built {@link com.buckosoft.PicMan.domain.MosaicTile}s for this Mosaic
 331  
          * @param mid The MosaicID to fetch
 332  
          * @return A List of MosaicTiles
 333  
          */
 334  
         List<MosaicTile>        getMosaicTiles(int mid);
 335  
 
 336  
         /** Delete the {@link com.buckosoft.PicMan.domain.MosaicTile}s for the Mosaic specified by this Mosaic ID.
 337  
          * @param mid The Mosaic ID to delete.
 338  
          */
 339  
         void                                deleteMosaicTiles(int mid);
 340  
 
 341  
         /** Store this {@link com.buckosoft.PicMan.domain.MosaicTile} in the database.
 342  
          * @param tile The MosaicTile to store.
 343  
          */
 344  
         void                                storeMosaicTile(MosaicTile tile);
 345  
 
 346  
         ///////////////////////////////////////////////////////////////////////////
 347  
         /* MosaicVector management */
 348  
 
 349  
         /** Store this {@link com.buckosoft.PicMan.domain.mosaic.MosaicVector} in the database.
 350  
          * @param mv The MosaicVector to store.
 351  
          */
 352  
         void updateMosaicVectors(MosaicVector mv);
 353  
 
 354  
         /** Get the List of {@link com.buckosoft.PicMan.domain.mosaic.MosaicVector}s that matches this picList, which probably came from a mosaic Set.
 355  
          * @param picList The List of Pics to query
 356  
          * @return The matching List of <code>MosaicVector</code>s.  The List may be empty, but not null.
 357  
          */
 358  
         List<MosaicVector>        getMosaicVectors(List<Pic> picList);
 359  
 
 360  
         ///////////////////////////////////////////////////////////////////////////
 361  
         /* Poster management */
 362  
 
 363  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Mosaic}s in the database.
 364  
          * @return The List of Mosaics
 365  
          */
 366  
         List<Poster>        getPosters();
 367  
 
 368  
         /** Get a {@link com.buckosoft.PicMan.domain.Poster} from the database based on this Poster ID.
 369  
          * @param pid The Poster ID to query.
 370  
          * @return The Poster that matches this pid, or null if not found.
 371  
          */
 372  
         Poster                        getPoster(int pid);
 373  
 
 374  
         /** Delete the {@link com.buckosoft.PicMan.domain.Poster} from the database that has this Poster ID.
 375  
          * @param pid The Poster ID to delete.
 376  
          */ 
 377  
         void                        deletePoster(int pid);
 378  
 
 379  
         /** Store this {@link com.buckosoft.PicMan.domain.Poster} in the database.
 380  
          * @param poster The Poster to store.
 381  
          */
 382  
         void                        storePoster(Poster poster);
 383  
         
 384  
         
 385  
         ///////////////////////////////////////////////////////////////////////////
 386  
         /* Pic management */
 387  
         
 388  
         /** Add this {@link com.buckosoft.PicMan.domain.Pic} to the database.
 389  
          * @param pic The Pic to add.  pid is assumed to be 0.
 390  
          */
 391  
         void                addPic(Pic pic);
 392  
 
 393  
         /** Update this {@link com.buckosoft.PicMan.domain.Pic} in the database.
 394  
          * Pic is assumed to exist and pid must not be 0.
 395  
          * @param pic The Pic to update.
 396  
          */
 397  
         void                updatePic(Pic pic);
 398  
 
 399  
         /** Get a {@link com.buckosoft.PicMan.domain.Pic} who's name matches this picName.
 400  
          * @param picName The name of the <code>Pic</code> to query.
 401  
          * @return The Pic that matches this picName or <code>null</code>.
 402  
          */
 403  
         Pic                        getPic(String picName);
 404  
 
 405  
         /** Get a {@link com.buckosoft.PicMan.domain.Pic} who's pid matches this one.
 406  
          * @param pid The pid to query
 407  
          * @return The Pic that matches this pid, or null if not found.
 408  
          */
 409  
         Pic                        getPic(int pid);
 410  
 
 411  
         /** Get the newest pic in the database.
 412  
          * @return The Pic with the newest Timestamp
 413  
          */
 414  
         Pic                        getNewestPic();
 415  
 
 416  
         /** Return a random pic from the database
 417  
          * @return Any pic from the database
 418  
          */
 419  
         Pic                        getRandomPic();
 420  
 
 421  
         
 422  
         /** Return a list of Pics that have this md5Sum
 423  
          * @param md5sum
 424  
          * @return The list, may be empty
 425  
          */
 426  
         List<Pic>        getPicsByMD5Sum(long md5sum);
 427  
 
 428  
         /** Return a random pic from the database destined to be a thumbnail on the home page
 429  
          * @param user The {@link User} who is requesting the Pic
 430  
          * @return The name of any pic from the database that matches the User's preference
 431  
          */
 432  
         String                getRandomHomePagePicName(User user);
 433  
 
 434  
         /** Get a HashMap of all of the {@link com.buckosoft.PicMan.domain.Pic} names in the database.
 435  
          * @return The map
 436  
          */
 437  
         HashMap<String, Date>                getPicsMap();
 438  
 
 439  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Pic}s in the database that match this name.  Wildcards are supported.
 440  
          * @param picName The name (or partial name) of the pics to fetch.
 441  
          * @return A List of <code>Pic</code>s.
 442  
          */
 443  
         List<Pic>        getPics(String picName);
 444  
         
 445  
         /** Get a List of all of the Pics.
 446  
          * @return A List of Pic
 447  
          */
 448  
         List<Pic>        getPics();
 449  
 
 450  
         /** Get a list of {@link com.buckosoft.PicMan.domain.Pic}s for this set at this size.
 451  
          * @param set The set to use as a filter
 452  
          * @param size The size to use as a filter
 453  
          * @return A List of Pic
 454  
          */
 455  
         List<Pic>        getPics(Set set, int size);
 456  
 
 457  
         /** Get a list of {@link com.buckosoft.PicMan.domain.Pic}s that are in this subdirectory.
 458  
          * @param rid Root id to search under
 459  
          * @param dirName The directory, i.e. "2002/20021225"
 460  
          * @return A List of Pic
 461  
          */
 462  
         List<Pic>        getPicsInDir(int rid, String dirName);
 463  
 
 464  
         /** Get a list of Pics that are newer than this date
 465  
          * @param calendar The timestamp to compare against
 466  
          * @return The List of Pics
 467  
          */
 468  
         List<Pic>        getPicsNewerThan(Calendar calendar);
 469  
         
 470  
         /** Determine the highest numbered thumb cache subdirectory used.
 471  
          * @return the highest number, or 0 if no thumbs are cached.
 472  
          */
 473  
         int                getPicMaxThumbCacheDirUsed();
 474  
 
 475  
         /** Determine the number of cached thumbs in this cache directory. <br>
 476  
          * Note that this doesn't actually check if the thumbs exist, only if they have a database entry.
 477  
          * @param cacheDir The directory to check
 478  
          * @return The Count
 479  
          */
 480  
         int                getPicThumbCacheFillCount(int cacheDir);
 481  
         
 482  
         /** Get the rating for this pic intersected by this set at this size
 483  
          * @param picName The name of the Pic whose rating we want
 484  
          * @param set The set to do the rating check against.  
 485  
          *                 If a pic is Audrey-7 and we want Carl, then this is probably not one we want. 
 486  
          * @param size The size of the pic we care about
 487  
          * @return The rate of the pic.  This is a double because we could get (6+7)/2 for a rate.
 488  
          */
 489  
         double        getPicRate(String picName, Set set, int size);
 490  
 
 491  
         /** Get the rating for this pic intersected by this MetaSet at this size
 492  
          * @param picName The Pic whose rating we want
 493  
          * @param metaSet The metaSet to do the rating check against.
 494  
          * @param size The size of the pic we care about
 495  
          * @return The rate of the pic.  This is a double because we could get (6+7)/2 for a rate.
 496  
          */
 497  
         double        getPicRate(String picName, MetaSet metaSet, int size);
 498  
         
 499  
         ///////////////////////////////////////////////////////////////////////////
 500  
         /* Roots management */
 501  
         
 502  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Root}s
 503  
          * @return A List of all of the Roots in the database
 504  
          */
 505  
         List<Root>                getRoots();
 506  
         
 507  
         /** Get the number of {@link com.buckosoft.PicMan.domain.Root}s in the database
 508  
          * @return The number of <code>Root</code>s
 509  
          */
 510  
         int                                getRootCount();
 511  
 
 512  
         /** Fetch a {@link com.buckosoft.PicMan.domain.Root}
 513  
          * @param rid The rootId to match
 514  
          * @return The Root
 515  
          */
 516  
         Root                        getRoot(int rid);
 517  
 
 518  
         /** Fetch a {@link com.buckosoft.PicMan.domain.Root}
 519  
          * @param name The Name of the Root to fetch
 520  
          * @return The Root
 521  
          */
 522  
         Root                        getRoot(String name);
 523  
         
 524  
         /** Set the {@link com.buckosoft.PicMan.domain.Root}s in the Database to be this List.
 525  
          * I'm not sure why you'd want to do this, and it is unused, but here it is.
 526  
          * @param roots A List of {@link com.buckosoft.PicMan.domain.Root}s
 527  
          */
 528  
         void                        setRoots(List<Root> roots);
 529  
         
 530  
         /** Add this {@link com.buckosoft.PicMan.domain.Root} to the Database.
 531  
          * the Root ID must be 0.
 532  
          * @param root The Root to add.
 533  
          * @throws Exception Can't do it.
 534  
          */
 535  
         void                        addRoot(Root root) throws Exception;
 536  
         
 537  
         /** Delete this {@link com.buckosoft.PicMan.domain.Root} from the database.
 538  
          * @param root The Root to delete.
 539  
          * @throws Exception Can't do it.
 540  
          */
 541  
         void                        deleteRoot(Root root) throws Exception;
 542  
         
 543  
         /** Store this existing {@link com.buckosoft.PicMan.domain.Root} in the database.
 544  
          * The Root ID must <b>NOT</b> be 0.
 545  
          * @param root The existing Root to update.
 546  
          */
 547  
         void                        storeRoot(Root root);
 548  
         
 549  
         /** Get a List of Inactive {@link com.buckosoft.PicMan.domain.Root}s.
 550  
          * Inactive <code>Root</code>s will not be scanned for new pics, or included in Sets queries.
 551  
          * @return A List of Roots that the User has disabled.
 552  
          */
 553  
         List<Root>                getInactiveRoots();
 554  
         
 555  
         /** Get a List of active {@link com.buckosoft.PicMan.domain.Root}s.
 556  
          * @return A List of Roots
 557  
          */
 558  
         List<Root>                getActiveRoots();
 559  
 
 560  
         ///////////////////////////////////////////////////////////////////////////
 561  
         /* Set management */
 562  
         
 563  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Set}s in the database.
 564  
          * <b>Note:</b> The Sets are cached in memory.  An external app writing to the database will not
 565  
          * be reflected in this running instance.
 566  
          * @return The List of {@link com.buckosoft.PicMan.domain.Set}s
 567  
          */
 568  
         List<Set>                getSets();
 569  
 
 570  
         /** Get a cloned List of all of the {@link com.buckosoft.PicMan.domain.Set}s in the database.
 571  
          * This is useful for when you want to prune the list without altering the sets cache.
 572  
          * @return The List of {@link com.buckosoft.PicMan.domain.Set}s
 573  
          */
 574  
         List<Set>                getSetsClone();
 575  
 
 576  
         /** Return the number of {@link com.buckosoft.PicMan.domain.Set}s in the Database.
 577  
          * @return The Number of {@link com.buckosoft.PicMan.domain.Set}s
 578  
          */
 579  
         int                                getSetCount();
 580  
         
 581  
         /** Get the {@link com.buckosoft.PicMan.domain.Set} that matches this Set ID
 582  
          * @param sid The SetID to query
 583  
          * @return The Set that was found or null if no match was made.
 584  
          */
 585  
         Set                                getSet(int sid);
 586  
         
 587  
         /** Get the {@link com.buckosoft.PicMan.domain.Set} that matches this Set ID
 588  
          * @param setName The name of the Set to query
 589  
          * @return The Set that was found or null if no match was made.
 590  
          */
 591  
         Set                                getSet(String setName);
 592  
 
 593  
         /** Set the {@link com.buckosoft.PicMan.domain.Set}s in the Database to be this List.
 594  
          * I'm not sure why you'd want to do this, and it is unused, but here it is.
 595  
          * @param sets A List of {@link com.buckosoft.PicMan.domain.Set}s
 596  
          */
 597  
         void                        setSets(List<Set> sets);
 598  
         
 599  
         /** Add this new {@link com.buckosoft.PicMan.domain.Set} to the database.
 600  
          * The Set ID (sid) is assumed to be 0.
 601  
          * @param set The Set to add
 602  
          * @throws Exception Can't do it
 603  
          */
 604  
         void                        addSet(Set set) throws Exception;
 605  
         
 606  
         /** Delete this {@link com.buckosoft.PicMan.domain.Set} from the database.
 607  
          * This is a very bad thing, as new Set IDs are derived from the number of Sets.
 608  
          * @param set The Set to delete.
 609  
          * @throws Exception Can't do it.
 610  
          */
 611  
         void                        deleteSet(Set set) throws Exception;
 612  
         
 613  
         /** Update this existing {@link com.buckosoft.PicMan.domain.Set} in the database.
 614  
          * @param set The Set to update
 615  
          */
 616  
         void                        storeSet(Set set);
 617  
 
 618  
         /** Rename this Set.  Includes changing references from the old setname to the new one.
 619  
          * @param oldName What is this set called?
 620  
          * @param newName What do we want it to be called?
 621  
          */
 622  
         void                        renameSet(String oldName, String newName);
 623  
 
 624  
         /** Get a List of inactive {@link com.buckosoft.PicMan.domain.Set}s
 625  
          * @return The List of {@link com.buckosoft.PicMan.domain.Set}s that the User has marked as inactive.
 626  
          */
 627  
         List<Set>                getInactiveSets();
 628  
         
 629  
         /** Get a List of active {@link com.buckosoft.PicMan.domain.Set}s
 630  
          * @return The List of {@link com.buckosoft.PicMan.domain.Set}s that are NOT marked inactive.
 631  
          */
 632  
         List<Set>                getActiveSets();
 633  
 
 634  
         /** Get an array of the number of thumbnail sizes.
 635  
          * Through the years, i have settled on 75,100,150,200,300 as the sizes that i play with and
 636  
          * these numbers are hardcoded in here.
 637  
          * @return An array of the sizes
 638  
          */
 639  
         int[]                        getSizeArray();
 640  
         
 641  
         /** Get the array of Thumbnail Sizes as a List of Integers.
 642  
          * The {@link com.buckosoft.PicMan.domain.Filter}s are keyed to the sizes.
 643  
          * A {@link com.buckosoft.PicMan.domain.Thumbnail} that looks OK as a 75, might not be worthy of a 300.
 644  
          * @return A List of Integers
 645  
          * @see #getSizeArray()
 646  
          */
 647  
         List<Integer>        getSizes();
 648  
         
 649  
         /** Return the number of sizes that we deal with.
 650  
          * @return That would be the number 5.
 651  
          */ 
 652  
         int                                getSizeCount();
 653  
         
 654  
         ///////////////////////////////////////////////////////////////////////////
 655  
         /* System */
 656  
         
 657  
         /** Fetch a reference to the {@link com.buckosoft.PicMan.domain.System} configuration.
 658  
          * <b>Note:</b> This is a cached object and changes made outside of this application will not be picked up.
 659  
          * @return The cached {@link com.buckosoft.PicMan.domain.System}.
 660  
          */
 661  
         System                        getSystem();
 662  
         
 663  
         /** Flush the {@link com.buckosoft.PicMan.domain.System} configuration back to the database.
 664  
          * @param system The System to write.
 665  
          */
 666  
         void                        saveSystem(System system);
 667  
         
 668  
         /** Get the user's preferred {@link com.buckosoft.PicMan.domain.Thumbnail} height used when running the editors.
 669  
          * @return The height of the Thumnails (I like 140 pixels).
 670  
          */
 671  
         int                                getThumbHeight();
 672  
         
 673  
         /** Return a list of file name extensions that denote pics that we are interested in. <br>
 674  
          * Originally, i expected to use <code>.png</code> in here, but basically i've settled on <code>.jpg</code>. <br>
 675  
          * This is actually convienent, because if there is a pic i want to ignore, i rename it to <code>.jpeg</code>.
 676  
          * @return A List of Extensions, typically just "jpg".
 677  
          */
 678  
         List<String>        getPicExtensions();
 679  
 
 680  
         ///////////////////////////////////////////////////////////////////////////
 681  
         /* Users */
 682  
         
 683  
         /** Get the {@link com.buckosoft.PicMan.domain.User} who has this userid.
 684  
          * @param userid The userid to query.
 685  
          * @return A PicMan User.
 686  
          */
 687  
         User        getUser(int userid) throws DataAccessException;
 688  
         
 689  
         /** Store this {@link com.buckosoft.PicMan.domain.User} in the database.  Does not affect the BSAccount settings of this User.
 690  
          * @param user The User to save.
 691  
          */
 692  
         void        storeUser(User user);
 693  
 
 694  
         ///////////////////////////////////////////////////////////////////////////
 695  
         /* Utilities */
 696  
 
 697  
         /** Make a uuid String based on a setName and a size
 698  
          * @param setName The name of the Set
 699  
          * @param size The size
 700  
          * @return The uuid String. i.e. "G_075"
 701  
          */
 702  
         String                getUuid(String setName, int size);
 703  
 
 704  
         ///////////////////////////////////////////////////////////////////////////
 705  
         /* Virgin management */
 706  
 
 707  
         /** Return the number of {@link com.buckosoft.PicMan.domain.Virgin}s in the database.
 708  
          * @return The count.
 709  
          */
 710  
         int                                getVirginCount();
 711  
 
 712  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Virgin}s in the database.
 713  
          * @return The List
 714  
          */
 715  
         List<Virgin>        getVirgins();
 716  
 
 717  
         /** Get a List of all of the {@link com.buckosoft.PicMan.domain.Virgin}s in the database up to max number. <br>
 718  
          * This is useful for the "process up to 5 virgins" page.
 719  
          * @param max The Maximum number of <code>Virgin</code>s to put in the List
 720  
          * @return The List.
 721  
          */
 722  
         List<Virgin>        getVirgins(int max);
 723  
 
 724  
         /** Is this picName a {@link com.buckosoft.PicMan.domain.Virgin}?
 725  
          * @param picName The name of the {@link com.buckosoft.PicMan.domain.Pic} to query
 726  
          * @return true if this picName is in the {@link com.buckosoft.PicMan.domain.Virgin}s table.
 727  
          */
 728  
         boolean        isVirgin(String picName);
 729  
 
 730  
         /** Add this Pic name as a {@link com.buckosoft.PicMan.domain.Virgin} in the database.
 731  
          * @param picName The name of the Pic to add.
 732  
          */
 733  
         void        addVirgin(String picName);
 734  
 
 735  
         /** Delete this Pic name from the {@link com.buckosoft.PicMan.domain.Virgin}s table.  This Pic is no longer a <code>Virgin</code>.
 736  
          * @param picName The name of the {@link com.buckosoft.PicMan.domain.Pic} to remove.
 737  
          */
 738  
         void        deleteVirgin(String picName);
 739  
         
 740  
         /** Get the last time this client sync'd.
 741  
          * @param host The host to fetch
 742  
          * @return The date/time of sync or null if never synced. 
 743  
          */
 744  
         Date        getClientSyncTimestamp(String host);
 745  
         
 746  
         /** Set the last time this client sync'd to now.
 747  
          * @param host The host to fetch
 748  
          */
 749  
         void        setClientSyncTimestamp(String host);
 750  
 
 751  
         void updateSetTimestamp(String setSize);
 752  
 
 753  
         void                                storeSyncClient(SyncClient syncClient);
 754  
         List<SyncClient>        getSyncClients();
 755  
 
 756  
         void                                storeSyncServer(SyncServer syncServer);
 757  
         List<SyncServer>        getSyncServers();
 758  
 
 759  
         /** Set the user who is accessing the database.
 760  
          * @param dbUser The database user
 761  
          */
 762  
         void        setDbUser(String dbUser);
 763  
         
 764  
         /** Get the user who is accessing the database.  This is realy a status field, as nothing outside of here accesses the database.
 765  
          * @return Usually "picman" or "picman_dev"
 766  
          */
 767  
         String        getDbUser();
 768  
         
 769  
         /** Set the database url.
 770  
          * @param dbUrl The dbUrl to set.
 771  
          */
 772  
         void        setDbUrl(String dbUrl);
 773  
         
 774  
         /** Get the url that is accessing the database.  This is realy a status field, as nothing outside of here accesses the database.
 775  
          * @return jdbc:mysql://localhost:3306/{something}
 776  
          */
 777  
         String        getDbUrl();
 778  
 }