~ubuntu-branches/ubuntu/quantal/shotwell/quantal

« back to all changes in this revision

Viewing changes to src/alien_db/f_spot/FSpotDatabaseBehavior.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: package-import@ubuntu.com-20120221135258-ao9jiib5qicomq7q
Tags: upstream-0.11.92
ImportĀ upstreamĀ versionĀ 0.11.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2011 Yorba Foundation
2
 
 *
3
 
 * This software is licensed under the GNU Lesser General Public License
4
 
 * (version 2.1 or later).  See the COPYING file in this distribution. 
5
 
 */
6
 
 
7
 
namespace AlienDb.FSpot {
8
 
 
9
 
/**
10
 
 * A class that consolidates the behavior of all F-Spot tables (apart from meta)
11
 
 * and is the one place to check whether the database version is supported.
12
 
 */
13
 
public class FSpotDatabaseBehavior : Object {
14
 
    // Minimum unsupported version: any database from that version and above
15
 
    // is not supported as it's too new and support has not been provided
16
 
    // In practice, the code may work with future versions but this cannot be
17
 
    // guaranteed as it hasn't been tested so it's probably better to just
18
 
    // bomb out at that point rather than risk importing incorrect data
19
 
    public static AlienDatabaseVersion MIN_UNSUPPORTED_VERSION =
20
 
        new AlienDatabaseVersion({ 19 });
21
 
    
22
 
    private FSpotTableBehavior<FSpotPhotoRow> photos_behavior;
23
 
    private FSpotTableBehavior<FSpotTagRow> tags_behavior;
24
 
    private FSpotTableBehavior<FSpotPhotoTagRow> photo_tags_behavior;
25
 
    private FSpotTableBehavior<FSpotPhotoVersionRow> photo_versions_behavior;
26
 
    private FSpotTableBehavior<FSpotRollRow> rolls_behavior;
27
 
    
28
 
    public FSpotDatabaseBehavior(
29
 
        FSpotDatabaseDriver driver, AlienDatabaseVersion version
30
 
    ) throws AlienDatabaseError {
31
 
        if (version.compare_to(MIN_UNSUPPORTED_VERSION) >= 0)
32
 
            throw new AlienDatabaseError.UNSUPPORTED_VERSION("Version %s is not yet supported", version.to_string());
33
 
        
34
 
        FSpotTableBehavior? photos_generic_behavior = driver.find_behavior(FSpotPhotosTable.TABLE_NAME, version);
35
 
        if (photos_generic_behavior != null)
36
 
            photos_behavior = photos_generic_behavior as FSpotTableBehavior<FSpotPhotoRow>;
37
 
        FSpotTableBehavior? tags_generic_behavior = driver.find_behavior(FSpotTagsTable.TABLE_NAME, version);
38
 
        if (tags_generic_behavior != null)
39
 
            tags_behavior = tags_generic_behavior as FSpotTableBehavior<FSpotTagRow>;
40
 
        FSpotTableBehavior? photo_tags_generic_behavior = driver.find_behavior(FSpotPhotoTagsTable.TABLE_NAME, version);
41
 
        if (photo_tags_generic_behavior != null)
42
 
            photo_tags_behavior = photo_tags_generic_behavior as FSpotTableBehavior<FSpotPhotoTagRow>;
43
 
        FSpotTableBehavior? photo_versions_generic_behavior = driver.find_behavior(FSpotPhotoVersionsTable.TABLE_NAME, version);
44
 
        if (photo_versions_generic_behavior != null)
45
 
            photo_versions_behavior = photo_versions_generic_behavior as FSpotTableBehavior<FSpotPhotoVersionRow>;
46
 
        FSpotTableBehavior? rolls_generic_behavior = driver.find_behavior(FSpotRollsTable.TABLE_NAME, version);
47
 
        if (rolls_generic_behavior != null)
48
 
            rolls_behavior = rolls_generic_behavior as FSpotTableBehavior<FSpotRollRow>;
49
 
        
50
 
        if (photos_behavior == null || tags_behavior == null ||
51
 
            photo_tags_behavior == null || photo_versions_behavior == null ||
52
 
            rolls_behavior == null
53
 
        )
54
 
            throw new AlienDatabaseError.UNSUPPORTED_VERSION("Version %s is not supported", version.to_string());
55
 
    }
56
 
    
57
 
    public FSpotTableBehavior<FSpotPhotoRow> get_photos_behavior() {
58
 
        return photos_behavior;
59
 
    }
60
 
    
61
 
    public FSpotTableBehavior<FSpotTagRow> get_tags_behavior() {
62
 
        return tags_behavior;
63
 
    }
64
 
    
65
 
    public FSpotTableBehavior<FSpotPhotoTagRow> get_photo_tags_behavior() {
66
 
        return photo_tags_behavior;
67
 
    }
68
 
    
69
 
    public FSpotTableBehavior<FSpotPhotoVersionRow> get_photo_versions_behavior() {
70
 
        return photo_versions_behavior;
71
 
    }
72
 
    
73
 
    public FSpotTableBehavior<FSpotRollRow> get_rolls_behavior() {
74
 
        return rolls_behavior;
75
 
    }
76
 
}
77
 
 
78
 
}
79