banshee r2990 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena src/Core/Hyena/Hyena.Data.Sqlite
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r2990 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena src/Core/Hyena/Hyena.Data.Sqlite
- Date: Sat, 19 Jan 2008 00:50:21 +0000 (GMT)
Author: scottp
Date: Sat Jan 19 00:50:21 2008
New Revision: 2990
URL: http://svn.gnome.org/viewvc/banshee?rev=2990&view=rev
Log:
* src/Core/Hyena/Hyena.Data.Sqlite/DatabaseAttributes.cs,
* src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelProvider.cs,
* src/Core/Hyena/Hyena.Data.Sqlite/DatabaseColumnAttribute.cs,
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs,
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs,
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs,
* src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs:
Got rid of DatabaseTableAttribute
Added:
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseColumnAttribute.cs
- copied, changed from r2989, /trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseAttributes.cs
Removed:
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseAttributes.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelProvider.cs
trunk/banshee/src/Core/Hyena/Hyena.mdp
trunk/banshee/src/Core/Hyena/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs Sat Jan 19 00:50:21 2008
@@ -37,12 +37,11 @@
using Banshee.ServiceStack;
namespace Banshee.Collection.Database
-{
- [DatabaseTable("CoreAlbums", 1)]
+{
public class LibraryAlbumInfo : AlbumInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryAlbumInfo> provider = new BansheeModelProvider<LibraryAlbumInfo> (
- ServiceManager.DbConnection
+ ServiceManager.DbConnection, "CoreAlbums"
);
public static BansheeModelProvider<LibraryAlbumInfo> Provider {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs Sat Jan 19 00:50:21 2008
@@ -37,12 +37,11 @@
using Banshee.ServiceStack;
namespace Banshee.Collection.Database
-{
- [DatabaseTable("CoreArtists", 1)]
+{
public class LibraryArtistInfo : ArtistInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryArtistInfo> provider = new BansheeModelProvider<LibraryArtistInfo> (
- ServiceManager.DbConnection
+ ServiceManager.DbConnection, "CoreArtists"
);
public static BansheeModelProvider<LibraryArtistInfo> Provider {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs Sat Jan 19 00:50:21 2008
@@ -37,11 +37,10 @@
namespace Banshee.Collection.Database
{
- [DatabaseTable("CoreTracks", 1)]
public class LibraryTrackInfo : TrackInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryTrackInfo> provider = new BansheeModelProvider<LibraryTrackInfo> (
- ServiceManager.DbConnection
+ ServiceManager.DbConnection, "CoreTracks"
);
public static BansheeModelProvider<LibraryTrackInfo> Provider {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs Sat Jan 19 00:50:21 2008
@@ -42,14 +42,24 @@
public class BansheeModelProvider<T> : SqliteModelProvider<T> where T : IDatabaseItem, new ()
{
private BansheeDbConnection connection;
+ private string table_name;
- public BansheeModelProvider (BansheeDbConnection connection)
+ public BansheeModelProvider (BansheeDbConnection connection, string table_name)
: base (connection)
{
this.connection = connection;
+ this.table_name = table_name;
Init ();
}
+ protected override sealed string TableName {
+ get { return table_name; }
+ }
+
+ protected override int ModelVersion {
+ get { return 1; }
+ }
+
protected override sealed int DatabaseVersion {
get { return 1; }
}
Copied: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseColumnAttribute.cs (from r2989, /trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseAttributes.cs)
==============================================================================
--- /trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseAttributes.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseColumnAttribute.cs Sat Jan 19 00:50:21 2008
@@ -34,19 +34,6 @@
namespace Hyena.Data.Sqlite
{
- [AttributeUsage(AttributeTargets.Class)]
- public sealed class DatabaseTableAttribute : Attribute
- {
- public readonly string Name;
- public readonly int Version;
-
- public DatabaseTableAttribute(string name, int version)
- {
- Name = name;
- Version = version;
- }
- }
-
[Flags]
public enum DatabaseColumnConstraints
{
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelProvider.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelProvider.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelProvider.cs Sat Jan 19 00:50:21 2008
@@ -48,9 +48,7 @@
private HyenaSqliteCommand select_command;
private HyenaSqliteCommand select_range_command;
private HyenaSqliteCommand select_single_command;
-
- private string table_name;
- private int model_version;
+
private string primary_key;
private string select;
@@ -59,6 +57,8 @@
private const string HYENA_DATABASE_NAME = "hyena_database_master";
+ protected abstract string TableName { get; }
+ protected abstract int ModelVersion { get; }
protected abstract int DatabaseVersion { get; }
protected abstract void MigrateTable (int old_version);
protected abstract void MigrateDatabase (int old_version);
@@ -70,27 +70,8 @@
protected SqliteModelProvider (HyenaSqliteConnection connection)
{
- foreach (DatabaseTableAttribute attribute in typeof (T).GetCustomAttributes (typeof (DatabaseTableAttribute), true)) {
- table_name = attribute.Name;
- model_version = attribute.Version;
- }
-
- if (TableName == null) {
- throw new Exception (String.Format (
- "The type {0} does not have a DatabaseTable attribute",
- typeof (T).Name));
- }
-
this.connection = connection;
}
-
- protected string TableName {
- get { return table_name; }
- }
-
- protected int ModelVersion {
- get { return model_version; }
- }
protected void Init ()
{
Modified: trunk/banshee/src/Core/Hyena/Hyena.mdp
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.mdp (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.mdp Sat Jan 19 00:50:21 2008
@@ -41,13 +41,13 @@
<File name="Hyena.Data.Query/XmlQueryParser.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Query/QueryFieldSet.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Sqlite/DatabaseColumn.cs" subtype="Code" buildaction="Compile" />
- <File name="Hyena.Data.Sqlite/DatabaseAttributes.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Data.Sqlite/DatabaseColumnAttribute.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Sqlite/SqliteModelProvider.cs" subtype="Code" buildaction="Compile" />
- <File name="Hyena.Data.Sqlite/SqilteModelCache.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Sqlite/HyenaSqliteCommand.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Sqlite/HyenaSqliteConnection.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Sqlite/ICacheableDatabaseModel.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data/ModelCache.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Data.Sqlite/SqliteModelCache.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/banshee/src/Core/Hyena/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Hyena/Makefile.am (original)
+++ trunk/banshee/src/Core/Hyena/Makefile.am Sat Jan 19 00:50:21 2008
@@ -21,8 +21,8 @@
Hyena.Data.Query/QueryToken.cs \
Hyena.Data.Query/UserQueryParser.cs \
Hyena.Data.Query/XmlQueryParser.cs \
- Hyena.Data.Sqlite/DatabaseAttributes.cs \
Hyena.Data.Sqlite/DatabaseColumn.cs \
+ Hyena.Data.Sqlite/DatabaseColumnAttribute.cs \
Hyena.Data.Sqlite/HyenaSqliteCommand.cs \
Hyena.Data.Sqlite/HyenaSqliteConnection.cs \
Hyena.Data.Sqlite/ICacheableDatabaseModel.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]