[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - datasourcemanager.js:1.5

Stephan Richter srichter@cbu.edu
Fri, 21 Mar 2003 10:23:10 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv1965/moztop/content/lib

Modified Files:
	datasourcemanager.js 
Log Message:
Kept working on API for new DataSourceManager and SitesManager.

Renamed DataSourceManager to DataSourceManager2 for now to avoid conflicts.

Renamed SitesManager to SitesManager2 for now to avoid conflicts.



=== Packages/Moztop/moztop/content/lib/datasourcemanager.js 1.4 => 1.5 ===
--- Packages/Moztop/moztop/content/lib/datasourcemanager.js:1.4	Fri Mar 21 08:58:20 2003
+++ Packages/Moztop/moztop/content/lib/datasourcemanager.js	Fri Mar 21 10:23:10 2003
@@ -12,14 +12,13 @@
 *
 ******************************************************************************
 The Data Source Manager handles all navigation tree related data sources and
-makes sure they are uptodate.
-
+makes sure they are up-to-date.
 
 $Id$
 
 ******************************************************************************/
 
-function DataSourceManager() {
+function DataSourceManager2() {
     /* The term "data source" has a very specific meaning in Mozilla referring
        to an RDF data container that can be used to display information using
        XUL. However, the functionality is very low-level and it is desirable
@@ -37,80 +36,46 @@
        SitesManager (responsible for the navigation tree), LogManager and
        TasksManager.
 
+       Note: This class makes only sense as base class.
     
        This constructor defines some commonly used property URNs and other
        handy variables.
     */
 
-
-    // Properties that must be overridden by the implmenting class
-    this.treeid = null;
-
+    // the id of the XUL tree this Data Source Manager is managing
+    this.treeId = null;
+    
     // Common RDF namespaces
     this.dcns = "http://www.purl.org/dc/1.1#";
     this.oscomrdfns = "http://www.oscom.org/rdf#";
     this.ncns ="http://home.netscape.com/NC-rdf#";
     
+    // Common RDF property names
     this.titleprop = this.dcns + "title";
     this.descriptionprop = this.dcns + "description";
     this.urlprop = this.oscomrdfns + "url";
     this.subitemsprop = this.ncns + "subitems";
 
-    // XXX: So we really need this?
-    this.sourceurlprop = this.oscomrdfns + "sourceurl";
-    this.saveurlprop = this.oscomrdfns + "saveurl";  
-    this.previewurlprop = this.oscomrdfns + "previewurl"; 
-  
     var moztopurl = getProfileDirURL() + 'moztop';
 
-    // Create some default datasources
-    // XXX: Do we still need this?
-    this.datasources = new Array();
-    
     // debug message
     dump("\nfinished add datasources and rebuilding tree");
 }
 
 
-DataSourceManager.prototype.initializeProfileDir = function() {
-    /* If this is a first-time install, setup a directory in the 
-       Mozilla profile directory with the right RDF files, etc. */
-
-    // XXX: Create moztop sub-directory
-
-    // XXX: Move initial locale RDF files into directory
-    return true;
-}
-
-
-DataSourceManager.prototype.initializeDataSources = function() {
-    /* Called during startup to find needed datasources, fetch RDF, and build
-     tree */
-    tree = document.getElementById(this.treeid);
-    for (name in this.datasources) {
-	tree.database.AddDataSource(this.datasources[name].getRawDataSource());
-    }
-    tree.builder.rebuild();
-    return true;
-}
-
-
 DataSourceManager.prototype.addDataSource = function(rdfurl) {
-    /* Add a new datasource to the set. */
-    this.datasources[rdfurl] = new RDFDataSource(rdfurl);
-    return true;
-}
+    /* Add a new datasource to the tree. */
 
+    // XXX: Get the RDF from the specified URL and creata a RDFDataSource
 
-DataSourceManager.prototype.openDataSource = function(rdfurl)  {
-    /* Used during Moztop launch  */
-    // XXX: What do we need to do here?
+    // XXX: Append RDFDataSource to the tree and rebuild
+    
     return true;
 }
 
 
 DataSourceManager.prototype.removeDataSource = function(rdfurl) {
-    /*   */
+    /* Delete a data source from the tree database. */
     return true;
 }
 
@@ -118,74 +83,67 @@
     /* Given a urn, find the datasource containing that resource.  For 
        sites, the urn is the urn of the root node, whose value is the 
        URL of the rsd file on the server.  For non-remote datasources, like  
-       the sites.rdf in the profile dir, the root node urn is concocted.
-    */
+       the sites.rdf in the profile dir, the root node urn is concocted. */
     return true;
 }
 
 
-DataSourceManager.prototype.saveDataSource = 
-function reloadDataSource(rdfurl) 
-{
+DataSourceManager.prototype.saveDataSource = function(rdfurl) {
     /* Only for local datasources, should fail for remote  */
     return true;
 }
 
 
-DataSourceManager.prototype.dumpDataSources = 
-function reloadSite(rsdurl) 
-{
-    /* Iterate through all datasources on the tree and dump them 
-     somewhere meaningful, such as the log manager. */
+DataSourceManager.prototype.dumpDataSources = function() {
+    /* Dump a serialized representation of all data sources into a meaningful
+       medium, such as the LogManager */
+
+    // XXX: Iterate through all datasources in the tree database and dump
+    //      their serialized data.
     return true;
 }
 
 
-DataSourceManager.prototype.updateResource = 
-    function (resourceurn, property, value) 
-{
-    /* A quick way to grab the right RDF */
+DataSourceManager.prototype.getSelectedResource = function() {
+    /* Return the resource that is currently selected in the tree. */
     return true;
 }
 
 
-DataSourceManager.prototype.getSelectedResource = 
-function () 
-{
-    /*   */
+DataSourceManager.prototype.openSelectedResource = function() {
+    /* This function "opens
+
+       Note: This should be overridden by 
+    */
+    
     return true;
 }
 
 
-DataSourceManager.prototype.openSelectedResource = 
-function () 
-{
+DataSourceManager.prototype.addResource = function(parenturn, resourceurn) {
     /*   */
     return true;
 }
 
 
-DataSourceManager.prototype.addResource = 
-function () 
-{
-    /*   */
+DataSourceManager.prototype.updateResource = function(resourceurn, 
+						      property, value) {
+    /* A quick way to grab the right RDF */
     return true;
 }
 
 
-DataSourceManager.prototype.deleteResource = 
-function () 
-{
+DataSourceManager.prototype.deleteResource = function() {
     /*   */
     return true;
 }
 
 
 
-function SitesManager() {
+function SitesManager2() {
 
     // Overridden DataSource Manager variables
-    this.elementid = 'navigation-tree';
+    this.treeid = 'navigation-tree';
 
     // Sites-specific RDF properties
     this.resourcetypeprop = this.oscomrdfns + "resourcetypes";
@@ -193,7 +151,6 @@
     this.sitetypeprop = this.oscomrdfns + "sitetype";
     this.styleidprop = this.oscomrdfns + "styleid";
 
-
     // XXX: I do not know whether this should be here.
     var tree = document.getElementById(this.elementid);
     tree.builder.rebuild();
@@ -204,42 +161,35 @@
 SitesManager.prototype = new DataSourceManager();
 
 
+SitesManager.prototype.initializeProfileDir = function() {
+    /* If this is a first-time install, setup a directory in the 
+       Mozilla profile directory with the right RDF files, etc. */
+
+    // XXX: If non-existent, create moztop sub-directory
+
+    // XXX: Move initial local RDF files into directory
+    return true;
+}
+
+
+DataSourceManager.prototype.initializeSites = function() {
+    /* Called during startup to find needed sites, fetch RDF, and build
+     tree */
+    tree = document.getElementById(this.treeid);
+    // XXX: Iterate over all sites found in sites.rdf
+    tree.builder.rebuild();
+    return true;
+}
+
+
 SitesManager.prototype.addSite = function(title, rsdurl, rsddom) {
     /* Create a new site from the information in the DOM passed in  */
 
-    var sc = this.ds.getNode("urn:moztop:sites").getTarget(this.subitemsprop);
-    var newsite=this.ds.getNode(siteurn);
-    var siteres = this.ds.getNode("urn:moztop:resourcetypes:site");
-    sc.addChild(newsite);
-
-
-    // Now fill in the data for the new site
-    newsite.addTarget(this.titleprop, site_name);
-    newsite.addTarget(this.urlprop, contentsurl);
-    newsite.addTarget(this.usernameprop, site_username);
-    newsite.addTarget(this.passwordprop, site_password);
-    newsite.addTarget(this.resourcetypeprop, siteres);
-
-    // Prepare the area for pseudo-folders (Configurations, Content, etc.)
-
-    var subitemsurn = siteurn + ":subitems";
-    var subitems = this.ds.getNode(subitemsurn);
-    subitems.makeSeq();
-    newsite.addTarget(this.subitemsprop,subitems);
-
-
-    /* Finally, create a site datasource and load the contents for this site */
-    id = this.sitedatasources.length
-    var ds = this.sitedatasources[id];
-    if (! ds) {
-	var ds = new RDFDataSource();
-	this.sitedatasources[id] = ds;
-    }
+    // XXX: Add site to sites.rdf
 
-    dump("about to retrieve " + contentsurl);
-    this.retrieveSiteContents(contentsurl, ds);
+    // XXX: Get the resource types and content RDF sources URL
 
-    this.ds.save();
+    // XXX: Append types and content RDFDataSources to tree.
 
     return true;
 }