store bookmarks.id value from places.sqlite into messages.sqlite placeID for sources and people tables, to maintain the link between a collection tree row in places and the corresponding record in messages db.

This commit is contained in:
alta88 2009-01-31 10:06:43 -07:00
Родитель 436d890bb7
Коммит e5e9c4da94
4 изменённых файлов: 67 добавлений и 55 удалений

Просмотреть файл

@ -412,31 +412,38 @@ this._log.info("unsubscribe: source - " + query.queryName + " : " + selectedSour
table = "sources";
break;
case "authors.id":
table = "identities";
table = "people";
break;
default:
table = null;
break;
}
for each (let group in collection.groups) {
this._log.info(table+" group.name:group.groupID - " + group.name + " : " + group.groupID);
//this._log.info(table+" group.name:group.groupID - " + group.name + " : " + group.groupID);
if (table == "sources")
value = group.groupID;
else if (table == "identities") {
else if (table == "people") {
if (!group.groupID)
// Skip null authors
continue;
// Get the sourceID that the author belongs to
value = SnowlDatastore.selectIdentitiesSourceID(group.groupID);
}
placesID = SnowlPlaces.persistPlace(table,
group.groupID,
group.name,
null, //machineURI.spec,
null, //username,
group.iconURL,
value); // aSourceID
this._log.info("Converted to places - " + group.name);
placeID = SnowlPlaces.persistPlace(table,
group.groupID,
group.name,
null, //machineURI.spec,
null, //username,
group.iconURL,
value); // aSourceID
// Store placeID back into messages for db integrity
SnowlDatastore.dbConnection.executeSimpleSQL(
"UPDATE " + table +
" SET placeID = " + placeID +
" WHERE id = " + group.groupID);
this._log.info("Converted to places - " +
group.name + " : " + group.groupID + " : " + placeID);
}
}
}

Просмотреть файл

@ -996,7 +996,7 @@ let SnowlPlaces = {
"&");
annoType = "Sources";
}
else if (aTable == "identities") {
else if (aTable == "people") {
uri = URI("snowl:authors.id=" + aId +
"&name=" + aName +
// "&externalID=" + aUsername +
@ -1008,11 +1008,11 @@ let SnowlPlaces = {
else
return null;
let placesID = PlacesUtils.bookmarks.
insertBookmark(SnowlPlaces.collectionsFlatID,
uri,
PlacesUtils.bookmarks.DEFAULT_INDEX,
aName);
let placeID = PlacesUtils.bookmarks.
insertBookmark(SnowlPlaces.collectionsFlatID,
uri,
PlacesUtils.bookmarks.DEFAULT_INDEX,
aName);
let anno = SnowlPlaces.SNOWL_COLLECTIONS_GROUPEDFOLDER_ANNO + annoType;
PlacesUtils.annotations.
@ -1027,9 +1027,9 @@ let SnowlPlaces = {
setAndLoadFaviconForPage(uri,
aIconURI,
false);
//this._log.info(aType + " name:placesID - " + aName + " : " + id);
//this._log.info(aType + " name:placeID - " + aName + " : " + id);
return placesID;
return placeID;
},
// Check for our places structure and create if not found

Просмотреть файл

@ -19,6 +19,7 @@
*
* Contributor(s):
* Myk Melez <myk@mozilla.org>
* alta88 <alta88@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -56,14 +57,19 @@ SnowlIdentity.get = function(sourceID, externalID) {
let identity;
let statement = SnowlDatastore.createStatement(
"SELECT id, personID FROM identities WHERE externalID = :externalID AND sourceID = :sourceID"
"SELECT id, personID " +
"FROM identities " +
"WHERE externalID = :externalID AND sourceID = :sourceID"
);
try {
statement.params.sourceID = sourceID;
statement.params.externalID = externalID;
if (statement.step()) {
identity = new SnowlIdentity(statement.row.id, sourceID, externalID, statement.row.personID);
identity = new SnowlIdentity(statement.row.id,
sourceID,
externalID,
statement.row.personID);
}
}
finally {
@ -77,17 +83,14 @@ SnowlIdentity.create = function(sourceID, externalID, name, homeURL, iconURL) {
let identity;
let personStatement = SnowlDatastore.createStatement(
"INSERT INTO people (name, homeURL, iconURL) VALUES (:name, :homeURL, :iconURL)"
"INSERT INTO people (name, homeURL, iconURL, placeID) " +
"VALUES (:name, :homeURL, :iconURL, :placeID)"
);
let identityStatement = SnowlDatastore.createStatement(
"INSERT INTO identities (sourceID, externalID, personID) " +
"VALUES (:sourceID, :externalID, :personID)"
"VALUES (:sourceID, :externalID, :personID)"
);
// let identityStatement = SnowlDatastore.createStatement(
// "INSERT INTO identities (sourceID, externalID, personID, placesID) " +
// "VALUES (:sourceID, :externalID, :personID, :placesID)"
// );
try {
personStatement.params.name = name;
@ -102,20 +105,24 @@ SnowlIdentity.create = function(sourceID, externalID, name, homeURL, iconURL) {
homeURL ? SnowlSource.faviconSvc.getFaviconForPage(homeURL) :
URI.get("chrome://snowl/skin/person-16.png");
// Create places record, placesID stored into people table record.
// Create places record, placeID stored into people table record.
//SnowlPlaces._log.info("Author name:iconURI.spec - " + name + " : " + iconURI.spec);
let placesID = SnowlPlaces.persistPlace("identities",
personID,
name,
null, // homeURL,
null, // externalID,
iconURI,
sourceID);
let placeID = SnowlPlaces.persistPlace("people",
personID,
name,
null, // homeURL,
null, // externalID,
iconURI,
sourceID);
// Store placeID back into messages for db integrity
SnowlDatastore.dbConnection.executeSimpleSQL(
"UPDATE people " +
"SET placeID = " + placeID +
" WHERE id = " + personID);
identityStatement.params.sourceID = sourceID;
identityStatement.params.externalID = externalID;
identityStatement.params.personID = personID;
// identityStatement.params.placesID = placesID;
identityStatement.step();
let identityID = SnowlDatastore.dbConnection.lastInsertRowID;

Просмотреть файл

@ -255,14 +255,12 @@ let SnowlSource = {
/**
* Insert a record for this source into the database, or update an existing
* record; store placesID back into sources table.
* record; store placeID back into sources table.
*
* FIXME: move this to a SnowlAccount interface.
* XXX need to make this one commitable transaction (with place db store)
* to maintain strict integrity..
*/
persist: function() {
let statement, placesID;
let statement, placeID;
if (this.id) {
statement = SnowlDatastore.createStatement(
"UPDATE sources " +
@ -295,21 +293,21 @@ let SnowlSource = {
// Extract the ID of the source from the newly-created database record.
this.id = SnowlDatastore.dbConnection.lastInsertRowID;
// Create places record
placesID = SnowlPlaces.persistPlace("sources",
this.id,
this.name,
null, // this.machineURI.spec,
null, // this.username,
this.faviconURI,
this.id); // aSourceID
// Store placedID back into messages for db integrity
// XXX uncomment once field is added..
// SnowlDatastore.dbConnection.executeSimpleSQL(
// "UPDATE sources " +
// "SET placesID = " + placesID +
// "WHERE id = " + this.id);
SnowlUtils.gListViewCollectionItemId = placesID;
this._log.info("persist newItemId - " + SnowlUtils.gListViewCollectionItemId);
placeID = SnowlPlaces.persistPlace("sources",
this.id,
this.name,
null, // this.machineURI.spec,
null, // this.username,
this.faviconURI,
this.id); // aSourceID
// Store placeID back into messages for db integrity
SnowlDatastore.dbConnection.executeSimpleSQL(
"UPDATE sources " +
"SET placeID = " + placeID +
" WHERE id = " + this.id);
SnowlUtils.gListViewCollectionItemId = placeID;
this._log.info("persist placeID:sources.id - " + placeID + " : " + this.id);
// Use 'added' here for collections observer for more specificity
Observers.notify("snowl:source:added");