incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r481193 - in /incubator/xap/trunk/src/xap/data: bridge/ controller/ datasource/ events/
Date Fri, 01 Dec 2006 09:14:14 GMT
Author: jmargaris
Date: Fri Dec  1 01:14:08 2006
New Revision: 481193

URL: http://svn.apache.org/viewvc?view=rev&rev=481193
Log:
Mess of changes to improve documentDataSource

Removed:
    incubator/xap/trunk/src/xap/data/controller/ContextFrame.java
    incubator/xap/trunk/src/xap/data/events/GenericPropertyChangeListener.js
Modified:
    incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
    incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js
    incubator/xap/trunk/src/xap/data/controller/Iterator.js
    incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
    incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js

Modified: incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js Fri Dec  1 01:14:08 2006
@@ -16,55 +16,29 @@
  *
  */
 Xap.provide("xap.data.bridge.DataSourceBridge");
-// Superclass:
+
 Xap.require("xap.data.bridge.DataFrameworkBridge");
 Xap.require("xap.session.ClientEvent"); 
 Xap.require("xap.taghandling.AttributeConversionException");
-//Xap.require("xap.data.DataServiceImpl") ;
-//Xap.require("xap.data.InitializationException") ;
-//Xap.require("xap.data.datasource.AsynchronousDataSource") ;
-//Xap.require("xap.data.datasource.AsynchronousDataSourceListener") ;
-//Xap.require("xap.data.datasource.ChangeAwareDataSource") ;
-//Xap.require("xap.data.datasource.DataChangeListener") ;
-//Xap.require("xap.data.datasource.DataSource") ; 
-Xap.require("xap.util.LogFactory"); 
-//Xap.require("xap.util.ResourceDictionary") ; 
+Xap.require("xap.util.LogFactory");  
 Xap.require("xap.util.UidProvider");
 Xap.require("xap.data.bridge.XmlDataTokens") ;
+Xap.require("xap.xml.dom.XapElement");
+Xap.require("xap.util.Exception");
+
 
 
-/**
- * The generic data source bridge, it uses the <code>class</code> 
- * attribute to look up an implementation of 
- * <code>xap.data.DataSource</code>.
- * initializes the data source and registers the data source in the 
- * data source container with the specified <code>id</code> attribute.
- * <br><br>
- * As of 4.5/jRex1.1 this implements <code>DataChangeListener</code>
- * and <code>AsynchronousDataSourceListener</code> in order to implement
- * data notification events via XML.
- * 
- * 
- * @author dgennaco
- */
 xap.data.bridge.DataSourceBridge = function () {
 	xap.data.bridge.DataFrameworkBridge.call(this);
 };
+
 Xap.setupClassAsSubclassOf("xap.data.bridge.DataSourceBridge", "xap.data.bridge.DataFrameworkBridge");
+
 xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE = "source";
 xap.data.bridge.DataSourceBridge.PATH_ATTRIBUTE = "path";
 xap.data.bridge.DataSourceBridge.NULL_SOURCE_MSGID = "nullSourceObject";
-xap.data.bridge.DataSourceBridge.ID_IS_NOT_SPECIFIED_MSGID = "idNotSpecified";
 
-//-----------------------------------------------------------------------
-// Instance Variables.
-//-----------------------------------------------------------------------
-/* private */
-xap.data.bridge.DataSourceBridge.prototype._dataSource = null;
-	
-//-----------------------------------------------------------------------
-// Public Methods.
-//-----------------------------------------------------------------------
+
 /**
  * @public 
  * @return {DataSource}
@@ -89,12 +63,10 @@
  */
 /*public void*/
 xap.data.bridge.DataSourceBridge.prototype.onDataRequestFailed = function (source, failureCause)
{
-	/*ClientEvent*/
 	var e = new xap.session.ClientEvent(this.getElement());
 		
-	//TODO document this
-	e.setFailureCause(failureCause);
-	this.fireEvent("onDataRequestFailed", e, null, null);
+	//TODO we need to include the failure reason here if we can
+	this.fireEvent("onDataRequestFailed");
 };
 /**
  * Implementation of the AsynchronousDataSourceListener interface,
@@ -103,7 +75,7 @@
  */
 /*public void*/
 xap.data.bridge.DataSourceBridge.prototype.onDataRequestCompleted = function (source) {
-	this.fireEvent( "onDataRequestCompleted", null, null, null) 
+	this.fireEvent( "onDataRequestCompleted") 
 };
 /**
  * Returns a log appropriate for DataSource bridges.
@@ -124,19 +96,13 @@
  * @throws InitializationException
  */
 xap.data.bridge.DataSourceBridge.prototype.initializeDataSource = function () {
-	//							   xap.data.bridge.XmlDataTokens.ID
 	var id = this.getElement().getAttribute("id");
 	
-//	if ( id.startsWith( xap.util.UidProvider.XAP_ID_PREFIX )) {
-//			this.getLog().info( ResourceDictionary.getMessage(
-//									 ID_IS_NOT_SPECIFIED_MSGID,
-//									 xap.data.bridge.DataSourceBridge,
-//									 [this._dataSource.getClass().getName(),
-//									  this.getElement().toXml( true )
-//									 ]
-//								 )
-//								);
-//	}
+	//TODO test this logic
+	if (!id || xap.xml.dom.XapElement.isGeneratedId(id)){
+		throw new xap.util.Exception("Data source did not have an id: "+ this.getElement().toXml());
+	}
+
 	this._dataSource.initialize(id, this.getSession(), this.getElement());
 	this.getDataSourceContainer().addDataSource(id, this._dataSource);
 };
@@ -150,20 +116,9 @@
 	var className = this.getElement().getAttribute( xap.data.bridge.XmlDataTokens.CLASS );
 	/*DataSource*/
 	var dataSource = null;
-	try {
-		
-		//IMPORTANT what does DataSourceImpl do here?
-		//why aren't we doing the toClassInstance??
-	//	dataSource = new xap.data.datasource.DataSourceImpl();
-		//				 xap.data.bridge.DataAttributeConverter.toClassInstance(
-		//									 className, DataSource.class)
-	}
-	catch (e) {
-	//		AttributeConversionException
-	//		reportInvalidXmlException(xap.data.bridge.XmlDataTokens.CLASS,
-	//		className,getElement(),e);
-		throw new xap.util.Exception(e);
-	}
+	
+	//IMPORTANT reading the CLASS name/src for you own data source class
+	//should work
 	return dataSource;
 };
 /**
@@ -173,26 +128,14 @@
 xap.data.bridge.DataSourceBridge.prototype.init = function () {
 	xap.data.bridge.DataFrameworkBridge.prototype.init.call(this);
 	this._dataSource = this.createDataSource();
-	if (this._dataSource == null) {
+	if (!this._dataSource) {
 		return;
 	}
-	// TODO:  make this really work:
-	if (true) {
-		/*this._dataSource instanceof AsynchronousDataSource*/
-		this._dataSource.addAsynchronousDataSourceListener(this);
-	}
-	// TODO:  make this really work:
-	if (false) {
-		/*this._dataSource instanceof ChangeAwareDataSource*/
-		this._dataSource.addDataChangeListener(this);
-	}
-	try {
-		this.initializeDataSource();
-	}
-	catch (e) { 
-		// This should be an InitializationException instance
-		this.getSession().handleException(xap.data.DataFramework.DATA_FRAMEWORK_EXCEPTION_TYPE+e,
e);
-	}
+	
+	this._dataSource.addAsynchronousDataSourceListener(this);
+	this._dataSource.addDataChangeListener(this);
+	this.initializeDataSource();
+	
 };
 
 

Modified: incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js Fri Dec  1 01:14:08
2006
@@ -15,17 +15,11 @@
  *
  */
  
-//import java.net.MalformedURLException;
 Xap.provide("xap.data.bridge.SimpleDocumentDataSourceBridge");
-//superclass:
-Xap.require("xap.data.bridge.JavascriptDataSourceBridge");
-Xap.require("xap.session.EventHandler");
-Xap.require("xap.taghandling.AttributeConversionException");
-Xap.require("xap.data.datasource.AbstractDataSource");
+
 Xap.require("xap.data.datasource.SimpleDocumentDataSource");
-Xap.require("xap.xml.dom.XapElement");
 Xap.require("xap.data.bridge.DataSourceBridge");
-Xap.require("xap.data.bridge.XmlDataTokens");
+
 /**
  * SimpleDocumentDataSourceBridge is a simplified bridge class for the 
  * documentDataSource tag,
@@ -34,9 +28,9 @@
  * @author mturyn 
  */
 xap.data.bridge.SimpleDocumentDataSourceBridge = function () {
-	xap.data.bridge.JavascriptDataSourceBridge.call(this);
+	xap.data.bridge.DataSourceBridge.call(this);
 };
-Xap.setupClassAsSubclassOf("xap.data.bridge.SimpleDocumentDataSourceBridge", "xap.data.bridge.JavascriptDataSourceBridge");
+Xap.setupClassAsSubclassOf("xap.data.bridge.SimpleDocumentDataSourceBridge", "xap.data.bridge.DataSourceBridge");
 
 //-----------------------------------------------------------------------
 // Protected Methods.
@@ -44,26 +38,11 @@
 	
 //protected DataSource
 xap.data.bridge.SimpleDocumentDataSourceBridge.prototype.createDataSource = function () {
-	/*DataSource*/
-	var dataSource = null;
-	try {
-		dataSource = new xap.data.datasource.SimpleDocumentDataSource(this);
-	}
-	catch (e) { //AttributeConversionException
-//		this.reportInvalidXmlException( xap.data.bridge.XmlDataTokens.CLASS, className,
-//								  this.getElement(), e );
-			// TODO: Restore better exception handling
-		throw new xap.util.XapException("Error creating a SimpleDocumentDataSource instance:\n"
+ e);
-	}
-	return dataSource;
+	return new xap.data.datasource.SimpleDocumentDataSource();
 };
 
-xap.data.bridge.SimpleDocumentDataSourceBridge.prototype.processConfigurationElement = function(){
-	//IMPORTANT overridden for now because superclass logic is strange
-}
-
 xap.data.bridge.SimpleDocumentDataSourceBridge.prototype.initializeDataSource = function
() {
-	xap.data.bridge.JavascriptDataSourceBridge.prototype.initializeDataSource.call(this);
+	xap.data.bridge.DataSourceBridge.prototype.initializeDataSource.call(this);
 	var uri = this.getElement().getAttribute(xap.data.bridge.DataSourceBridge.SOURCE_ATTRIBUTE);
 	if (uri){
 		this._dataSource.loadSourceFromServer(uri);

Modified: incubator/xap/trunk/src/xap/data/controller/Iterator.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/Iterator.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Iterator.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/Iterator.js Fri Dec  1 01:14:08 2006
@@ -286,7 +286,7 @@
     }
     catch (e) { //NexawebException
         source.removeListener(this);
-        this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE
+ ": can't get data set from given source.", e);
+        this._session.handleException(e);
     }
 };
 /**

Modified: incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/AbstractDataSource.js Fri Dec  1 01:14:08
2006
@@ -28,13 +28,13 @@
 /**
 * An ease-of-use base class for DataSource implementations. 
 * 
-* <p/>
+* <br><br>
 * 
 * This class persists bound queries (i.e. queries whose binding type != 
 * BindingType.ONE_WAY) so that they can be later requeried when the data 
 * changes.
 * 
-* <p/>
+* <br><br>
 * 
 * This base class can also keep track of any queries that need to be postponed 
 * and executed later if the data is being retrieved at the time of the original
@@ -43,99 +43,17 @@
 * clean them up later (the queries are automatically cleaned up after the 
 * execution).
 * 
-* <br><br>
-* As of 4.5/jRex1.1 this implements NetServiceListener in order
-* to work well with the DataRequest plugin.
-* 
-* @see #addPostponedQuery(String, Context, RetrievalListener)
-* @see #executePostponedQueries()
-* @see #clearPostponedQueries()
-* 
 * @author Igor Kaplansky
-* @abstract
+* @author James Margaris
 */
 xap.data.datasource.AbstractDataSource = function () {
-};
-Xap.setupClassAsSubclassOf("xap.data.datasource.AbstractDataSource", "Object");
+	this._boundQueries = new xap.util.Vector();
+	this._postponedQueries = new xap.util.Vector();
+	this._asynchronousDataSourceListeners = new xap.util.Vector();
+	this._dataChangeListeners = new xap.util.Vector();
+}
 
 
-//-----------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------
-/**
- * Loading source from server URL: {0}, DataSource class: {1}
- * <br/>
- * Args:
- * <ul>
- * <li>{0} - the source URL.</li>
- * <li>{1} - the DataSource class name.</li>
- * </ul>
- */
-/*private static final String*/
-xap.data.datasource.AbstractDataSource.LOADING_SOURCE_FROM_SERVER_MSGID = "loadSourceFromServer";
-/**
- * Refresh got called on the datasource: {0}.
- * <br/>
- * Args:
- * <ul>
- * <li>{0} - the class name of the datasource. </li>
- * </ul>
- */
-/*private static final String*/
-xap.data.datasource.AbstractDataSource.REFRESH_MSGID = "refresh";
-/**
- * Setting null as the source object is not allowed for datasource {0}
- * <br/>
- * Args:
- * <ul>
- * <li>{0} - the DataSource class name.</li>
- * </ul>
- */
-/*protected static final String*/
-xap.data.datasource.AbstractDataSource.NULL_SOURCE_MSGID = "nullSource";
-   
-	
-//-----------------------------------------------------------------------
-// Instance Variables.
-//-----------------------------------------------------------------------
-/**
- * @private Element
- **/
-xap.data.datasource.AbstractDataSource.prototype._dataSourceElement = null;
-/**
- * @private ClientSession
- **/
-xap.data.datasource.AbstractDataSource.prototype._clientSession = null;
-/**
- * @private String
- **/
-xap.data.datasource.AbstractDataSource.prototype._id = null;
-/**
- * @private Object
- **/
-xap.data.datasource.AbstractDataSource.prototype._source = null;
-// vector of QueryRecords for all bound queries (binding type != ONE_TIME)
-/**
- * @private Vector
- **/
-xap.data.datasource.AbstractDataSource.prototype._boundQueries = null;
-// vector of QueryRecords for all postponed queries.
-/**
- * @private Vector
- **/
-xap.data.datasource.AbstractDataSource.prototype._postponedQueries = null;
-/**
- * @private Vector
-**/
-xap.data.datasource.AbstractDataSource.prototype._dataChangeListeners = new xap.util.Vector();
-/**
- * @private Vector
-**/
-xap.data.datasource.AbstractDataSource.prototype._asynchronouseDataSourceListeners = new
xap.util.Vector();
-	
-//-----------------------------------------------------------------------
-// DataSource Interface.
-//-----------------------------------------------------------------------
 /**
  * @see DataSource#initialize(String, ClientSession, Element)
  * <p/>
@@ -154,54 +72,15 @@
 	this._id = id;
 	this._clientSession = session;
 	this._dataSourceElement = dataSourceElement;
-	this._boundQueries = new xap.util.Vector();
-	this._postponedQueries = new xap.util.Vector();
-};
-/**
- * @see DataSource#destroy()
- * <p/>
- * Subclasses have to call <code>super.destroy()</code> if they override
- * this method.
- */
-/**
- * @public
- * @return {void}
- **/
+}
+
+
 xap.data.datasource.AbstractDataSource.prototype.destroy = function () {
-	/**/
 	this._boundQueries = new xap.util.Vector();
-	/**/
 	this._postponedQueries = new xap.util.Vector();
-};
-/**
- * @see DataSource#getId()
- */
-/**
- * @public
- * @return {String}
- **/
-xap.data.datasource.AbstractDataSource.prototype.getId = function () {
-	return this._id;
-};
-/**
- * @see DataSource#isSupported(BindingType)
- */
-/**
- * @public
- * @param type{BindingType }
- * @return {boolean}
- **/
-xap.data.datasource.AbstractDataSource.prototype.isSupported = function (type) {
-	//return type === xap.data.controller.BindingType.ONE_TIME || type === xap.data.controller.BindingType.ONE_WAY;
-	//TODO:  See why the above didn't work properly--- is, probably, find
-	//out where we introduced another another BindingType instance without meaning to do...but
for now:
-	return type 
-			&& (type.getTypeId() == xap.data.controller.BindingType.ONE_WAY.getTypeId()
-				|| type.getTypeId() == xap.data.controller.BindingType.ONE_TIME.getTypeId()
-				) ;
-};
-
-
+	this._asynchronousDataSourceListeners = new xap.util.Vector();
+	this._dataChangeListeners = new xap.util.Vector();
+}
 /**
  * @see DataSource#getDataSet(String, DataSetRetrievalListener)
  * @public
@@ -211,11 +90,7 @@
  * @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException 
  * @return {void}
  **/
-xap.data.datasource.AbstractDataSource.prototype.getDataSet = function (query, listener,ctx)
{
-	var context = null ;
-	if (typeof ctx != "undefined"){
-		context = ctx ;
-	}
+xap.data.datasource.AbstractDataSource.prototype.getDataSet = function (query, listener,context)
{
 	this.handleGenericQuery(query, context, listener);
 };
 /**
@@ -229,57 +104,7 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.getData = function (query, listener, context)
{
 	this.handleGenericQuery(query, context, listener);
-};
-/**
- * @see DataSource#removeListener(String, RetrievalListener, Context)
- */
-/**
- * @public
- * @return {void}
- * @param query{String}
- * @param listener{RetrievalListener}
- * @param context{ContextFrame  }
- **/
-xap.data.datasource.AbstractDataSource.prototype.removeListener = function (query, listener,
context) {
-	for (var i = 0; i < this._boundQueries.size(); i++) {
-		/*QueryRecord*/
-		var record = this._boundQueries.elementAt(i);
-		if (record.getQuery().equals(query) && record.getListener() == listener &&
record.getContext() == context) {
-			this._boundQueries.removeElementAt(i--);
-		}
-	}
-	for (var i = 0; i < this._postponedQueries.size(); i++) {
-		/*QueryRecord*/
-		var record = this._postponedQueries.elementAt(i);
-		if (record.getQuery().equals(query) && record.getListener() == listener &&
record.getContext() == context) {
-			this._postponedQueries.removeElementAt(i--);
-		}
-	}
-};
-/**
- * @see DataSource#removeListener(String, RetrievalListener)
- * @public
- * @return {void}
- * @param query{String}
- * @param listener{RetrievalListener}
- **/
-xap.data.datasource.AbstractDataSource.prototype.removeListener = function (query, listener)
{
-	for (var i = 0; i < this._boundQueries.size(); i++) {
-		/*QueryRecord*/
-		var record = this._boundQueries.elementAt(i);
-		if (record.getQuery().equals(query) && record.getListener() == listener) {
-			this._boundQueries.removeElementAt(i--);
-		}
-	}
-	for (var i = 0; i < this._postponedQueries.size(); i++) {
-		/*QueryRecord*/
-		var record = this._postponedQueries.elementAt(i);
-		if (record.getQuery().equals(query) && record.getListener() == listener) {
-			this._postponedQueries.removeElementAt(i--);
-		}
-	}
-};
-
+}
 
 /**
  * @see DataSource#removeListener(RetrievalListener)
@@ -334,8 +159,8 @@
  * @return {void}
  **/
 xap.data.datasource.AbstractDataSource.prototype.addAsynchronousDataSourceListener = function
(l) {
-	if (!this._asynchronouseDataSourceListeners.contains(l)) {
-		this._asynchronouseDataSourceListeners.addElement(l);
+	if (!this._asynchronousDataSourceListeners.contains(l)) {
+		this._asynchronousDataSourceListeners.addElement(l);
 	}
 };
 /**
@@ -344,7 +169,7 @@
  * @param l{AsynchronousDataSourceListener}
  **/
 xap.data.datasource.AbstractDataSource.prototype.removeAsynchronousDataSourceListener = function
(l) {
-	this._asynchronouseDataSourceListeners.removeElement(l);
+	this._asynchronousDataSourceListeners.removeElement(l);
 };
 /**
  * @protected
@@ -352,8 +177,8 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveSucess = function () {
 	/*for (int*/
-	for (var i = 0; i < this._asynchronouseDataSourceListeners.size(); i++) {
-		this._asynchronouseDataSourceListeners.elementAt(i).onDataRequestCompleted(this);
+	for (var i = 0; i < this._asynchronousDataSourceListeners.size(); i++) {
+		this._asynchronousDataSourceListeners.elementAt(i).onDataRequestCompleted(this);
 	}
 };
 /**
@@ -363,8 +188,8 @@
  **/
 xap.data.datasource.AbstractDataSource.prototype.fireOnDataRetrieveFailure = function (failureCause)
{
 	/*for (int*/
-	for (var i = 0; i < this._asynchronouseDataSourceListeners.size(); i++) {
-		(this._asynchronouseDataSourceListeners.elementAt(i)).onDataRequestFailed(this, failureCause);
+	for (var i = 0; i < this._asynchronousDataSourceListeners.size(); i++) {
+		(this._asynchronousDataSourceListeners.elementAt(i)).onDataRequestFailed(this, failureCause);
 	}
 };
 
@@ -386,10 +211,8 @@
 xap.data.datasource.AbstractDataSource.prototype.addedToContainer = function (container,
name) {
 	//NOOP
 };
-/**
- * @see ContainerLifecycleObject#removedFromContainer(
- *					  com.nexaweb.client.mco.Container, java.lang.String )
- */
+
+
 /**
  * @public
  * @return {void}
@@ -486,14 +309,14 @@
     	//this sucess message. But we probably want them
     	//to be able to get the new source their listener
    		this.fireOnDataRetrieveSucess();
-    	//this.executePostponedQueries();
+    	this.executePostponedQueries();
 	}
 	catch(e){
 		this.getClientSession().handleException(e);
 		this.fireOnDataRetrieveFailure(e);
 	}
     finally {
-      //  this.clearPostponedQueries();
+        this.clearPostponedQueries();
     }    
 };
 /**
@@ -503,22 +326,17 @@
  * @param e{NetServiceException}
  **/
 xap.data.datasource.AbstractDataSource.prototype.requestFailed = function (a, e) {
-	alert("requestFailed to load source:" + a);
 	try {
 		this.getClientSession().handleException(e);
 		this.fireOnDataRetrieveFailure(e);
 	}
 	finally {
-	//	this.clearPostponedQueries();
+		this.clearPostponedQueries();
 	}
 
 };
 
 
-	
-//----------------------------------------------------------------------
-// Protected Methods.
-//----------------------------------------------------------------------
 /**
  * @return the ClientSession this DataSource is associated with
  */
@@ -529,14 +347,8 @@
 xap.data.datasource.AbstractDataSource.prototype.getClientSession = function () {
 	return this._clientSession;
 };
-/**
- * @return the DataSource declaration element
- * @protected
- * @return {Element}
- **/
-xap.data.datasource.AbstractDataSource.prototype.getDataSourceElement = function () {
-	return this._dataSourceElement;
-};
+
+
 /**
  * @return the source object of the DataSource
  * @protected
@@ -574,19 +386,6 @@
 };
 
 
-/**
- * Sets the path urifor this DataSource
- * 
- * @param sourceObject The new source object
- * @protected
- * @param pathString{String}
- * @return {void}
- **/
-xap.data.datasource.AbstractDataSource.prototype.setPath = function (pathString) {
-	this._path = pathString ;
-};
-
-
 
 /**
  * Adds a postponed query to this DataSource. This method can be used to
@@ -605,12 +404,10 @@
  * @param context{ContextFrame}
  * @param listener{RetrievalListener  }
  **/
-// Not doing this in this release:
-//xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context,
listener) {
-//	/*QueryRecord*/
-//	var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
-//	this._postponedQueries.addElement(queryRecord);
-//};
+xap.data.datasource.AbstractDataSource.prototype.addPostponedQuery = function (query, context,
listener) {
+	var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
+	this._postponedQueries.addElement(queryRecord);
+}
 /**
  * Executes all posponed queries in order they came in.
  * At the end of this method the postponed query vector is cleared 
@@ -619,23 +416,25 @@
  * @protected
  * @synchronized
  **/
-//xap.data.datasource.AbstractDataSource.prototype.executePostponedQueries = function ()
{
-//	try {
-//		for (var i = 0; i < this._postponedQueries.size(); i++) {
-//			/*QueryRecord*/
-//			var rec = this._postponedQueries.elementAt(i);
-//			try {
-//				this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
-//			}
-//			catch (e) { // DataAccessException,MalformedQueryException
-//				this.getLog().exception(e);
-//			}
-//		}
-//	}
-//	finally {
-//		this._postponedQueries.removeAllElements();
-//	}
-//};
+xap.data.datasource.AbstractDataSource.prototype.executePostponedQueries = function () {
+	try {
+		for (var i = 0; i < this._postponedQueries.size(); i++) {
+			/*QueryRecord*/
+			var rec = this._postponedQueries.elementAt(i);
+			try {
+				this.handleQuery(rec.getQuery(), rec.getContext(), rec.getListener());
+			}
+			catch (e) { 
+				
+				//TODO instead of logging just throw this?
+				this.getLog().exception(e);
+			}
+		}
+	}
+	finally {
+		this._postponedQueries.removeAllElements();
+	}
+}
 
 
 /**
@@ -644,67 +443,9 @@
  * @protected
  * @return {void}
  **/
-//xap.data.datasource.AbstractDataSource.prototype.clearPostponedQueries = function () {
-//	this._postponedQueries = new xap.util.Vector();
-//};
-
-
-///**
-// * @return vector of postponed queries whose execution has been postponed 
-// * for some reason (i.e. the source object was not available).
-// *
-// * @protected
-// * @return {Vector}
-// **/
-//xap.data.datasource.AbstractDataSource.prototype.getPostponedQueries = function () {
-//	return this._postponedQueries;
-//};
-/**
- * @return vector of all bound queries (bound type != ONE_TIME)
- *
- * @protected
- * @return {Vector}
- **/
-xap.data.datasource.AbstractDataSource.prototype.getBoundQueries = function () {
-	return this._boundQueries;
-};
-/**
- * Returns true if the url represents an absolute or relative HTTP URL
- * or classpath entry.
- * @param url
- * @return boolean
- * @protected
- * @param url{String}
- * @return {boolean}
- **/
-xap.data.datasource.AbstractDataSource.prototype.isHttpUrl = function (url) {
-	return url.indexOf("http://") == 0 || url.indexOf("https://") == 0 || url.indexOf("classpath://")
== 0 || url.indexOf("://") == -1;
-};
-/**
- * Extract the container name from the objectUrl.
- * 
- * @param sourceUrl
- * @return container name
- * @throws DataAccessException
- *
- * @protected
- * @sourceUrl{String}
- * @return {String}
- * @throws DataAccessException  
- **/
-xap.data.datasource.AbstractDataSource.prototype.getContainerName = function (sourceUrl)
{
-	/*int*/
-	var i = sourceUrl.indexOf("://");
-	if (i == -1) {
-// TODO: better exception?
-//	throw new DataAccessException( DataAccessException.INVALID_SOURCE_URL_MSGID,
-//									  sourceUrl );
-		throw new xap.util.Exception("Invalid source URL: " + sourceUrl);
-	}
-	/*String*/
-	var containerName = sourceUrl.substring(0, i);
-	return containerName;
-};
+xap.data.datasource.AbstractDataSource.prototype.clearPostponedQueries = function () {
+	this._postponedQueries = new xap.util.Vector();
+}
 
 /**
  * @return the static Log instance
@@ -741,14 +482,9 @@
  * @throws DataAccessException, MalformedQueryException,UnsupportedBindingTypeException
  **/
 xap.data.datasource.AbstractDataSource.prototype.handleGenericQuery = function (query, context,
listener) {
-	if (!this.isSupported(listener.getBindingType())) {
-		throw new UnsupportedBindingTypeException(listener.getBindingType(), this.getClass());
-	}
 	// take care of caching queries for later executions when the data
 	// changes
-	if (listener != null && listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME)
{
-		/*QueryRecord*/
-		
+	if (listener && listener.getBindingType() != xap.data.controller.BindingType.ONE_TIME)
{
 		var queryRecord = new xap.data.datasource.QueryRecord(query, context, listener);
 		this._boundQueries.addElement(queryRecord);
 	}
@@ -768,11 +504,9 @@
  * @param listener{RetrievalListener  }
  **/
 xap.data.datasource.AbstractDataSource.prototype.handleQuery = function (query, queryContext,
listener) {
-//	if (listener instanceof DataRetrievalListener) {
 	if (listener.isDataRetrievalListener()) {
 		this.handleDataQuery(query, queryContext, listener);
 	} else {
-//		if (listener instanceof DataSetRetrievalListener) {
 		if (listener.isDataSetRetrievalListener()) {	
 			this.handleDataSetQuery(query, queryContext, listener);
 		}

Modified: incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JavascriptDataSource.js Fri Dec  1 01:14:08
2006
@@ -16,7 +16,6 @@
 **/
 Xap.provide("xap.data.datasource.JavascriptDataSource");
 Xap.require("xap.util.Vector");
-Xap.require("xap.data.events.GenericPropertyChangeListener");
 Xap.require("xap.data.datasource.AbstractDataSet");
 xap.data.datasource.JavascriptDataSource = function (handler) {
 	//TODO: ? Most of what might be here seems to be in
@@ -37,7 +36,6 @@
 **/
 xap.data.datasource.JavascriptDataSource.prototype.initialize = function (id, session, dataSourceElement)
{
 	xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
-	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
 };
 /**
  * Get the object source from a specified location, make it a local

Modified: incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/JsonDataSource.js Fri Dec  1 01:14:08 2006
@@ -17,7 +17,6 @@
 **/
 Xap.provide("xap.data.datasource.JsonDataSource");
 Xap.require("xap.util.Vector");
-Xap.require("xap.data.events.GenericPropertyChangeListener");
 Xap.require("xap.data.datasource.AbstractDataSet");
 xap.data.datasource.JsonDataSource = function (handler) {
 	xap.data.datasource.JavascriptDataSource.call(this, handler);

Modified: incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/ObjectDataSource.js Fri Dec  1 01:14:08 2006
@@ -102,7 +102,6 @@
 // default no-args constructor
 };
 Xap.provide("xap.data.datasource.ObjectDataSource");
-Xap.require("xap.data.events.GenericPropertyChangeListener") ;
 
 
 
@@ -143,7 +142,6 @@
 **/
 xap.data.datasource.ObjectDataSource.prototype.initialize = function (id, session, dataSourceElement)
{
 	xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
-	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
 };
 /**
  * First attempts to remove the PropertyChangeListener from the old source 

Modified: incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js?view=diff&rev=481193&r1=481192&r2=481193
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js Fri Dec  1 01:14:08
2006
@@ -14,16 +14,18 @@
  *  limitations under the License.
  *
 **/
-Xap.provide("xap.data.datasource.SimpleDocumentDataSource");
+Xap.provide("xap.data.datasource.SimpleDocumentDataSource");
+
+Xap.require("xap.data.datasource.AbstractDataSource");
 Xap.require("xap.util.Vector");
-Xap.require("xap.data.events.GenericPropertyChangeListener") ;
 Xap.require("xap.data.datasource.AbstractDataSet") ;
 Xap.require("xap.xml.ParserFactory") ;
 Xap.require("xap.xml.dom.Document");
+Xap.require("google.xpath");
 
 
 
-xap.data.datasource.SimpleDocumentDataSource = function(handler,uri) {
+xap.data.datasource.SimpleDocumentDataSource = function() {
 	xap.data.datasource.AbstractDataSource.call(this) ;
 };
 
@@ -57,26 +59,6 @@
 	return doc;
 }
 
-
-
-/**
- * @see DataSource#initialize(String, ClientSession, Element)
- *
- * @param id{String}
- * @param session{ClientSession} 
- * @param element{XapElement}
- * @throws InitializationException  
- * @public
- * @return {void}
-**/
-xap.data.datasource.SimpleDocumentDataSource.prototype.initialize = function(id, session,
dataSourceElement) {
-	xap.data.datasource.AbstractDataSource.prototype.initialize.call(this, id, session, dataSourceElement);
-	
-	//TODO does this do anything??
-	this._propertyChangeListener = new xap.data.events.GenericPropertyChangeListener(this);
-};
-
-
 /**
  * @see AbstractDataSource#handleDataQuery( String, Context, 
  *										  DataRetrievalListener )
@@ -89,63 +71,16 @@
  * @return {void}
 **/
 xap.data.datasource.SimpleDocumentDataSource.prototype.handleDataQuery = function(query,
context, listener) {
-	// The document:
-	var contextObject = null ;
-	if (context != null) {
-		contextObject = context.getData();
-	} else {
-		contextObject =	this.getSource() ;
-	}
-
-// Objects we can use when evalling the iterator?:
-	var currentIndex = null ;
-	var currentCount = null ;
-	var totalCount = null ;	
-
-	/*Object*/
-	var theData = null ;
 	
-	var rawData =  xap.data.datasource.SimpleDocumentDataSource.executeQuery(contextObject,
query) ;
-	
-	theData = rawData;
-	
-	//IMPORTANT this is the wrong place to do type conversion!!
-//	if (context == null) {
-//		theData = rawData ;
-//	} else {
-//		contextObject = context.getData();		
-//		currentIndex = context.getIndex() ;
-//		currentCount = currentIndex + 1;
-//		totalCount = context.getDataSet().size() ;
-//		// We got back an array of result nodes; get
-//		// their values: or,
-//		// we got back a number or a string---use it:
-//		if( typeof rawData == "string" || typeof rawData=="number"){
-//			theData =  rawData ;
-//		} else {
-//			theData = new Array(rawData.length) ;
-//			for(var jj=0; jj <rawData.length; ++jj){
-//				var firstTextNode 
-//					= xap.xml.dom.XapElement.getFirstTextChild(rawData[jj]) ;
-//				// If a text node, use its text value:
-//				if (firstTextNode != null ){
-//					theData[jj] = firstTextNode.nodeValue ;
-//				} else {	
-//				theData[jj] = rawData[jj].nodeValue ;
-//				}
-//			}
-//			// Special, common, case---why do
-//			// I suddenly wish this were C?
-//			if( theData.length == 1 ){
-//				theData = theData[0] ;
-//			}			
-//		}
-//
-//
-//	}
-//	
-		
-	listener.dataRetrieved(query, theData, context);
+	if (!this.getSource()){
+		if (listener.getBindingType() == xap.data.controller.BindingType.ONE_TIME){
+			this.addPostponedQuery( query, context, listener );
+		}
+	}
+	else{
+		var rawData =  this.executeQuery(context, query) ;
+		listener.dataRetrieved(query, rawData, context);
+	}
 };
 
 /**
@@ -160,36 +95,18 @@
  * @throws DataAccessException, MalformedQueryException  
 **/
 xap.data.datasource.SimpleDocumentDataSource.prototype.handleDataSetQuery = function(query,
context, listener) {
-	/*Object*/
-	var theData = null ;
-	var contextObject = null ;
-	if (context == null ){
-		/*Object*/
-		contextObject = this.getSource();
-	} else {
-		// We had a context selecting down from the original data source
-		// ---this is an inner nested iterator:
-		contextObject = context.getData();
-	}
 	
-	if (contextObject==null){
-		return;//IMPORTANT this is a temp hack only
+	if (!this.getSource()){		
+		if (listener.getBindingType() == xap.data.controller.BindingType.ONE_TIME){
+			this.addPostponedQuery( query, context, listener );
+		}
+		
+	}
+	else{
+		theData = this.executeQuery(context, query) ;
+		var dataset = xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);		
+		listener.dataSetRetrieved(query, dataset, context);
 	}
-
-	try {			
-		theData = xap.data.datasource.SimpleDocumentDataSource.executeQuery(contextObject, query)
;
-	} catch (anException){
-		throw new xap.util.Exception(
-		"SimpleDocumentDataSource.handleDataSetQuery:Could not evaluate: '"
-										+ query
-										+"' against the document."
-										) ;
-	}
-	/*DataSet*/
-	var dataset 
-		= xap.data.datasource.AbstractDataSet.getDataSet(query, this, theData);		
-	listener.dataSetRetrieved(query, dataset, context);
-
 };
 
 
@@ -199,7 +116,13 @@
  * @see  handleDataQuery
  * @see  handleDataSetQuery
 **/ 
-xap.data.datasource.SimpleDocumentDataSource.executeQuery =function(documentObject,queryString){
+xap.data.datasource.SimpleDocumentDataSource.prototype.executeQuery =function(context ,queryString){
+	
+	var contextObject = this.getSource();
+	if (context){
+		contextObject = context.getData();
+	}
+
 	// TODO:
 	// Google requires lower-case attribute names...how to ensure
 	// that here?  Can't for now, but later we'll get theQuery = f( query )
@@ -207,24 +130,18 @@
 	var theQuery = queryString ;
 	var theData = null ;
 	try {
-		Xap.require("google.xpath");
-		var exprContext =   new google.ExprContext(documentObject) ;
+		var exprContext =   new google.ExprContext(contextObject) ;
 		var parsedXPathExpr = google.xpathParse(theQuery) ;
 		var targetNodes = parsedXPathExpr.evaluate( exprContext );
 		theData = targetNodes.nodeSetValue() ; // //array of dom nodes
 	} catch(ex){
 		throw new xap.util.Exception(
 				"SimpleDocumentDataSource.executeQuery::source: '"
-										+ documentObject
+										+ contextObject
 										+ theQuery
 										+"'\n"
 										+ex
 										) ;					
 	}
-	
 	return theData ;
-}
-
-
-
-
+}
\ No newline at end of file



Mime
View raw message