1 /******************************************************************************
2 * PicsDao.java - Dao interface for the pics
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 com.buckosoft.PicMan.domain.Pic;
16
17 /** Dao interface for the {@link com.buckosoft.PicMan.domain.Pic}s.
18 * @author Dick Balaska
19 * @since 2005/07/31
20 * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/db/PicsDao.java">PicsDao.java</a>
21 */
22 public interface PicsDao {
23
24 /** Get a List of all of the <code>Pic</code>s in the database.
25 * @return A pretty big List
26 */
27 List<Pic> getPics();
28
29 /** Get a List of names all of the pics in the database.
30 * @return A big List of picNames
31 */
32 List<String> getPicNames();
33
34 /** Get a List of all of the <code>Pic</code>s in the database that match this name. Wildcards are supported.
35 * @param name The name (or partial name) of the pics to fetch.
36 * @return A List of <code>Pic</code>s.
37 */
38 List<Pic> getPics(String name);
39
40 /** Get a List of Pics from this List of picNames.
41 * @param list A List of picNames to fetch
42 * @return The List
43 */
44 List<Pic> getPics(List<String> list);
45
46 /** Get a list of Pics that are in this subdirectory
47 * @param rid Root id to search under
48 * @param dirName The directory, i.e. "2002/20021225"
49 * @return A List of Pic. The dirname will match any and all <code>Root</code>s
50 */
51 List<Pic> getPicsInDir(int rid, String dirName);
52
53 /** Get a list of Pics that are newer than this date
54 * @param calendar The date to compare to
55 * @return A List of <code>Pic</code>s.
56 */
57 List<Pic> getPicsNewerThan(Calendar calendar);
58
59 /** Return a list of Pics that have this md5Sum
60 * @param md5sum
61 * @return The list, may be empty
62 */
63 List<Pic> getPicsByMD5Sum(long md5sum);
64
65 /** Get a list of pic names that pass this date function.
66 * @param operator An index into the MetaSet rateOps table. i.e. = != < >
67 * @param operand the date to check. i.e. "2009-07-26"
68 * @return A List of pic names
69 */
70 List<String> getPicNamesByDateFunc(String operator, String operand);
71
72 List<String> getPicNamesByRootFunc(String operator, int rid);
73
74 /** Get a HashMap of all of the Pic names in the database.
75 * @return The map
76 */
77 HashMap<String, Date> getPicsMap();
78
79 /** Add this <code>Pic</code> to the database.
80 * @param pic The Pic to add. pid is assumed to be 0.
81 */
82 void addPic(Pic pic);
83
84 /** Update this <code>Pic</code> in the database.
85 * Pic is assumed to exist and pid must not be 0.
86 * @param pic The Pic to update.
87 */
88 void updatePic(Pic pic);
89
90 /** Get a Pic
91 * @param pid The pid to query
92 * @return The Pic
93 */
94 Pic getPic(int pid);
95
96 /** Get a Pic who's name matches this picName.
97 * @param picName The name of the <code>Pic</code> to query.
98 * @return The Pic that matches this picName or <code>null</code>.
99 */
100 Pic getPic(String picName);
101
102 /** Get the newest pic in the database.
103 * @return The Pic with the newest Timestamp
104 */
105 Pic getNewestPic();
106
107 /** Return a random pic from the database
108 * @return Any pic from the database
109 */
110 Pic getRandomPic();
111
112 /** Return a random pic from the database that lives in this root
113 * @return Any pic from the database
114 */
115 Pic getRandomPic(int rid);
116
117 /** Determine the highest numbered thumb cache subdirectory used.
118 * @return the highest number, or 0 if no thumbs are cached.
119 */
120 int getMaxThumbCacheDirUsed();
121
122 /** Determine how many thumb cache entries are in this thumb dir
123 * @param cacheDir Which thumb cache directory to check
124 * @return The Count
125 */
126 int getThumbCacheFillCount(int cacheDir);
127
128 /** Return how many pics live in this root.
129 * @param rid The root id to query.
130 * @return The number of Pics in this root.
131 */
132 int getPicCount(int rid);
133 }