banshee r2980 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena/Hyena.Data.Sqlite
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r2980 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena/Hyena.Data.Sqlite
- Date: Thu, 17 Jan 2008 21:26:35 +0000 (GMT)
Author: scottp
Date: Thu Jan 17 21:26:35 2008
New Revision: 2980
URL: http://svn.gnome.org/viewvc/banshee?rev=2980&view=rev
Log:
* src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModel.cs: Added new Load
overload, uncommendted some methods
* src/Core/Hyena/Hyena.Data.Sqlite/ICacheableDatabaseModel.cs,
src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs,
src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs,
src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs,
src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs:
Changed GetItemFromReader to Load
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryAlbumInfo.cs,
src/Core/Banshee.Services/Banshee.Collection.Database/LibraryArtistInfo.cs:
Inherited from IDatabaseItem and added DbIndex { set; }
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs:
Inherited from IDatabaseItem and made DbIndex { set; } public
* src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModel.cs:
Implemented MakeNewObject
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs
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.Collection.Database/TrackListDatabaseModel.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModel.cs
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModel.cs
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/ICacheableDatabaseModel.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -130,11 +130,9 @@
}
// Implement IDatabaseModel
- public LibraryAlbumInfo GetItemFromReader (IDataReader reader, int index)
+ public LibraryAlbumInfo Load (IDataReader reader, int index)
{
- LibraryAlbumInfo album = new LibraryAlbumInfo ();
- provider.Load (album, reader);
- return album;
+ return provider.Load (reader, index);
}
public BansheeModelProvider<LibraryAlbumInfo> Provider {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -104,9 +104,9 @@
}
// Implement IDatabaseModel
- public LibraryArtistInfo GetItemFromReader (IDataReader reader, int index)
+ public LibraryArtistInfo Load (IDataReader reader, int index)
{
- return new LibraryArtistInfo (reader);
+ return provider.Load (reader, index);
}
public BansheeModelProvider<LibraryArtistInfo> Provider {
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 Thu Jan 17 21:26:35 2008
@@ -39,7 +39,7 @@
namespace Banshee.Collection.Database
{
- public class LibraryAlbumInfo : AlbumInfo
+ public class LibraryAlbumInfo : AlbumInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryAlbumInfo> provider = new BansheeModelProvider<LibraryAlbumInfo> (
"CoreAlbums", ServiceManager.DbConnection
@@ -117,5 +117,11 @@
get { return base.ArtistName; }
set { base.ArtistName = value; }
}
+
+ private int db_index;
+ public int DbIndex {
+ get { return db_index; }
+ set { db_index = value; }
+ }
}
}
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 Thu Jan 17 21:26:35 2008
@@ -38,7 +38,7 @@
namespace Banshee.Collection.Database
{
- public class LibraryArtistInfo : ArtistInfo
+ public class LibraryArtistInfo : ArtistInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryArtistInfo> provider = new BansheeModelProvider<LibraryArtistInfo> (
"CoreArtists", ServiceManager.DbConnection
@@ -58,6 +58,10 @@
ArtistID,
Name
}
+
+ public LibraryArtistInfo () : base (null)
+ {
+ }
public LibraryArtistInfo (string artistName) : base (null)
{
@@ -108,5 +112,11 @@
get { return base.Name; }
set { base.Name = value; }
}
+
+ private int db_index;
+ public int DbIndex {
+ get { return db_index; }
+ set { db_index = value; }
+ }
}
}
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 Thu Jan 17 21:26:35 2008
@@ -38,7 +38,7 @@
namespace Banshee.Collection.Database
{
- public class LibraryTrackInfo : TrackInfo
+ public class LibraryTrackInfo : TrackInfo, IDatabaseItem
{
private static BansheeModelProvider<LibraryTrackInfo> provider = new BansheeModelProvider<LibraryTrackInfo> (
"CoreTracks", ServiceManager.DbConnection
@@ -58,6 +58,7 @@
public LibraryTrackInfo () : base ()
{
+ Attributes |= TrackAttributes.CanPlay;
}
public LibraryTrackInfo (int index) : base ()
@@ -84,7 +85,7 @@
private int db_index;
public int DbIndex {
get { return db_index; }
- internal set { db_index = value; }
+ set { db_index = value; }
}
[DatabaseColumn("ArtistID", Index = "CoreTracksArtistIndex")]
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -382,11 +382,9 @@
}
// Implement IDatabaseModel
- public LibraryTrackInfo GetItemFromReader (IDataReader reader, int index)
+ public LibraryTrackInfo Load (IDataReader reader, int index)
{
- LibraryTrackInfo track = new LibraryTrackInfo (index);
- Provider.Load (track, reader);
- return track;
+ return provider.Load (reader, index);
}
public string PrimaryKey {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -27,6 +27,7 @@
//
using System;
+using System.Collections.Generic;
using System.Data;
using Hyena.Data;
@@ -34,7 +35,12 @@
namespace Banshee.Database
{
- public class BansheeModelProvider<T> : DatabaseModel<T>
+ public interface IDatabaseItem
+ {
+ int DbIndex { set; }
+ }
+
+ public class BansheeModelProvider<T> : DatabaseModel<T> where T : IDatabaseItem, new ()
{
protected string table_name;
@@ -103,5 +109,12 @@
protected override void MigrateTable(int old_version)
{
}
+
+ protected override T MakeNewObject (int index)
+ {
+ T item = new T ();
+ item.DbIndex = index;
+ return item;
+ }
}
}
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -61,7 +61,7 @@
protected abstract int DatabaseVersion { get; }
protected abstract void MigrateTable (int old_version);
protected abstract void MigrateDatabase (int old_version);
- //protected abstract T MakeNewObject (int offset);
+ protected abstract T MakeNewObject (int offset);
protected virtual string HyenaTableName {
get { return "HyenaModelVersions"; }
@@ -265,7 +265,14 @@
connection.Execute (UpdateCommand);
}
- public void Load (T target, IDataReader reader)
+ public T Load (IDataReader reader, int index)
+ {
+ T item = MakeNewObject (index);
+ Load (reader, item);
+ return item;
+ }
+
+ public void Load (IDataReader reader, T target)
{
int i = 0;
@@ -282,53 +289,47 @@
{
}
- /*public IEnumerable<T> FetchAll ()
+ public IEnumerable<T> FetchAll ()
{
PrepareSelectCommand ();
int i = 1;
using (IDataReader reader = connection.ExecuteReader (SelectCommand)) {
while (reader.Read ()) {
- T new_object = MakeNewObject (i);
- Load (new_object, reader);
- yield return new_object;
+ yield return Load (reader, i++);
}
}
- }*/
+ }
protected virtual void PrepareSelectRangeCommand (int offset, int limit)
{
SelectRangeCommand.ApplyValues (offset, limit);
}
- /*public IEnumerable<T> FetchRange (int offset, int limit)
+ public IEnumerable<T> FetchRange (int offset, int limit)
{
PrepareSelectRangeCommand (offset, limit);
using (IDataReader reader = connection.ExecuteReader (SelectRangeCommand)) {
while (reader.Read ()) {
- T new_object = MakeNewObject (offset++);
- Load (new_object, reader);
- yield return new_object;
+ yield return Load (reader, offset++);
}
}
- }*/
+ }
protected virtual void PrepareSelectSingleCommand (object id)
{
SelectSingleCommand.ApplyValues (id);
}
- /*public T FetchSingle (int id)
+ public T FetchSingle (int id)
{
PrepareSelectSingleCommand (id);
using (IDataReader reader = connection.ExecuteReader (SelectSingleCommand)) {
if (reader.Read ()) {
- T new_object = MakeNewObject (id);
- Load (new_object, reader);
- return new_object;
+ return Load (reader, id);
}
}
return default(T);
- }*/
+ }
protected virtual HyenaSqliteCommand CreateCommand {
get {
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs Thu Jan 17 21:26:35 2008
@@ -121,7 +121,7 @@
T item;
while (reader.Read ()) {
if (!Contains (i)) {
- item = db_model.GetItemFromReader (reader, i);
+ item = db_model.Load (reader, i);
Add (i, item);
}
i++;
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/ICacheableDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/ICacheableDatabaseModel.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/ICacheableDatabaseModel.cs Thu Jan 17 21:26:35 2008
@@ -34,7 +34,7 @@
{
public interface ICacheableDatabaseModel<T> : ICacheableModel
{
- T GetItemFromReader (IDataReader reader, int index);
+ T Load (IDataReader reader, int index);
string PrimaryKey { get; }
string ReloadFragment { get; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]