コード例 #1
0
ファイル: PhotoStore.cs プロジェクト: ermshiperete/f-spot
 public Photo [] Query(Tag [] tags, string extraCondition, DateRange range, RollSet importidrange, RatingRange ratingrange)
 {
     return(Query(OrTerm.FromTags(tags), extraCondition, range, importidrange, ratingrange));
 }
コード例 #2
0
ファイル: PhotoStore.cs プロジェクト: ermshiperete/f-spot
        public Photo [] Query(Term searchexpression, string extraCondition, DateRange range, RollSet importidrange, RatingRange ratingrange)
        {
            bool hide = (extraCondition == null);

            // The SQL query that we want to construct is:
            //
            // SELECT photos.id
            //        photos.time
            //        photos.uri,
            //        photos.description,
            //        photos.roll_id,
            //        photos.default_version_id
            //        photos.rating
            //                  FROM photos, photo_tags
            //                  WHERE photos.time >= time1 AND photos.time <= time2
            //                              AND photos.rating >= rat1 AND photos.rating <= rat2
            //                              AND photos.id NOT IN (select photo_id FROM photo_tags WHERE tag_id = HIDDEN)
            //                              AND photos.id IN (select photo_id FROM photo_tags where tag_id IN (tag1, tag2..)
            //                              AND extra_condition_string
            //                  GROUP BY photos.id

            var query_builder = new StringBuilder();
            var where_clauses = new List <string> ();

            query_builder.Append("SELECT id, " +
                                 "time, " +
                                 "base_uri, " +
                                 "filename, " +
                                 "description, " +
                                 "roll_id, " +
                                 "default_version_id, " +
                                 "rating " +
                                 "FROM photos ");

            if (range != null)
            {
                where_clauses.Add(String.Format("time >= {0} AND time <= {1}",
                                                DateTimeUtil.FromDateTime(range.Start),
                                                DateTimeUtil.FromDateTime(range.End)));
            }

            if (ratingrange != null)
            {
                where_clauses.Add(ratingrange.SqlClause());
            }

            if (importidrange != null)
            {
                where_clauses.Add(importidrange.SqlClause());
            }

            if (hide && App.Instance.Database.Tags.Hidden != null)
            {
                where_clauses.Add(String.Format("id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})",
                                                App.Instance.Database.Tags.Hidden.Id));
            }

            if (searchexpression != null)
            {
                where_clauses.Add(searchexpression.SqlCondition());
            }

            if (extraCondition != null && extraCondition.Trim() != String.Empty)
            {
                where_clauses.Add(extraCondition);
            }

            if (where_clauses.Count > 0)
            {
                query_builder.Append(" WHERE ");
                query_builder.Append(String.Join(" AND ", where_clauses.ToArray()));
            }

            query_builder.Append(" ORDER BY time");
            return(Query(query_builder.ToString()));
        }
コード例 #3
0
ファイル: PhotoStore.cs プロジェクト: neuroradiology/f-spot
 public Photo [] Query(Tag [] tags, string extra_condition, DateRange range, RollSet importidrange)
 {
     return(Query(FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, null));
 }