From 33b2284955a8f0015922d4c69c5082141b584f27 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Tue, 5 Dec 2006 23:37:07 +0000
Subject: load the inlineeditor textbox in client side onload.
---
.../Data/SqlMap/Configuration/TParameterMap.php | 4 +-
framework/Data/SqlMap/Configuration/TResultMap.php | 4 +-
.../Data/SqlMap/Configuration/TResultProperty.php | 4 +-
.../Data/SqlMap/DataMapper/TPropertyAccess.php | 92 ++++++++------
framework/Data/SqlMap/DataMapper/TSqlMapCache.php | 136 ++++++++++-----------
.../Data/SqlMap/DataMapper/TSqlMapException.php | 30 +----
6 files changed, 133 insertions(+), 137 deletions(-)
(limited to 'framework/Data/SqlMap')
diff --git a/framework/Data/SqlMap/Configuration/TParameterMap.php b/framework/Data/SqlMap/Configuration/TParameterMap.php
index 8d09d9a9..e4d77a91 100644
--- a/framework/Data/SqlMap/Configuration/TParameterMap.php
+++ b/framework/Data/SqlMap/Configuration/TParameterMap.php
@@ -155,7 +155,7 @@ class TParameterMap extends TComponent
* @param mixed object to obtain the property from.
* @param TParameterProperty parameter property.
* @return mixed property value.
- * @throws TSqlMapExecutionException if property access is invalid.
+ * @throws TSqlMapException if property access is invalid.
*/
protected function getObjectValue($object,$property)
{
@@ -165,7 +165,7 @@ class TParameterMap extends TComponent
}
catch (TInvalidPropertyException $e)
{
- throw new TSqlMapExecutionException(
+ throw new TSqlMapException(
'sqlmap_unable_to_get_property_for_parameter',
$this->getID(), $property->getProperty(), get_class($object));
}
diff --git a/framework/Data/SqlMap/Configuration/TResultMap.php b/framework/Data/SqlMap/Configuration/TResultMap.php
index fa798dc2..5c608e77 100644
--- a/framework/Data/SqlMap/Configuration/TResultMap.php
+++ b/framework/Data/SqlMap/Configuration/TResultMap.php
@@ -155,7 +155,7 @@ class TResultMap extends TComponent
* Create a new instance of the class of this result map.
* @param TSqlMapTypeHandlerRegistry type handler registry.
* @return mixed new result object.
- * @throws TSqlMapExecutionException
+ * @throws TSqlMapException
*/
public function createInstanceOfResult($registry)
{
@@ -169,7 +169,7 @@ class TResultMap extends TComponent
}
catch (TSqlMapException $e)
{
- throw new TSqlMapExecutionException(
+ throw new TSqlMapException(
'sqlmap_unable_to_create_new_instance',
$this->getClass(), get_class($handler), $this->getID());
}
diff --git a/framework/Data/SqlMap/Configuration/TResultProperty.php b/framework/Data/SqlMap/Configuration/TResultProperty.php
index e8fc5c38..884f1a78 100644
--- a/framework/Data/SqlMap/Configuration/TResultProperty.php
+++ b/framework/Data/SqlMap/Configuration/TResultProperty.php
@@ -282,10 +282,12 @@ class TResultProperty extends TComponent
{
if(class_exists($type = $this->getType(), false)) //NO force autoloading
{
+ if($type==='TList')
+ return self::LIST_TYPE;
$class = new ReflectionClass($type);
if($class->isSubclassOf('TList'))
return self::LIST_TYPE;
- if($class->inmplementsInterface('ArrayAccess'))
+ if($class->implementsInterface('ArrayAccess'))
return self::ARRAY_TYPE;
}
if(strtolower($type) == 'array')
diff --git a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
index fea94fa4..901072ea 100644
--- a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
+++ b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
@@ -1,41 +1,54 @@
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2005-2007 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Data.SqlMap.DataMapper
+ */
+/**
+ * TPropertyAccess class provides dot notation stype property access and setting.
+ *
+ * Access object's properties (and subproperties) using dot path notation.
+ * The following are equivalent.
+ *
+ * echo $obj->property1;
+ * echo $obj->getProperty1();
+ * echo $obj['property1']; //$obj may be an array or object
+ * echo TPropertyAccess($obj, 'property1');
+ *
+ *
+ * Setting a property value.
+ *
+ * $obj1->propert1 = 'hello';
+ * $obj->setProperty('hello');
+ * $obj['property1'] = 'hello'; //$obj may be an array or object
+ * TPropertyAccess($obj, 'property1', 'hello');
+ *
+ *
+ * Subproperties are supported using the dot notation. E.g.
+ *
+ * echo $obj->property1->property2->property3
+ * echo TPropertyAccess::get($obj, 'property1.property2.property3');
+ *
+ *
+ * @author Wei Zhuo
+ * @version $Id$
+ * @package System.Data.SqlMap.DataMapper
+ * @since 3.1
+ */
class TPropertyAccess
{
- private $_obj;
- private $_performance=false;
-
- public function __construct($obj,$performance=false)
- {
- $this->_obj = $obj;
- $this->_performance=$performance;
- }
-
- public function __get($name)
- {
- return self::get($this->_obj,$name,$this->_performance);
- }
-
- public function __set($name,$value)
- {
- self::set($this->_obj,$name,$value,$this->_performance);
- }
-
/**
- * Evaluates the data value at the specified field.
- * - If the data is an array, then the field is treated as an array index
- * and the corresponding element value is returned;
- * - If the data is a TMap or TList object, then the field is treated as a key
- * into the map or list, and the corresponding value is returned.
- * - If the data is an object, the field is treated as a property or subproperty
- * defined with getter methods. For example, if the object has a method called
- * getMyValue(), then field 'MyValue' will retrive the result of this method call.
- * If getMyValue() returns an object which contains a method getMySubValue(),
- * then field 'MyValue.MySubValue' will return that method call result.
- * @param mixed data containing the field value, can be an array, TMap, TList or object.
- * @param mixed field value
- * @return mixed value at the specified field
- * @throw TInvalidDataValueException if field or data is invalid
+ * Gets the property value.
+ * @param mixed object or path.
+ * @param string property path.
+ * @return mixed property value.
+ * @throws TInvalidDataValueException if property path is invalid.
*/
public static function get($object,$path)
{
@@ -67,6 +80,11 @@ class TPropertyAccess
return $object;
}
+ /**
+ * @param mixed object or array
+ * @param string property path.
+ * @return boolean true if property path is valid
+ */
public static function has($object, $path)
{
if(!is_array($object) && !is_object($object))
@@ -96,6 +114,13 @@ class TPropertyAccess
return true;
}
+ /**
+ * Sets the property value.
+ * @param mixed object or array
+ * @param string property path.
+ * @param mixed new property value.
+ * @throws TInvalidDataValueException if property path is invalid.
+ */
public static function set(&$originalObject, $path, $value)
{
$properties = explode('.', $path);
@@ -105,7 +130,6 @@ class TPropertyAccess
else
$object = &$originalObject;
- //var_dump($object);
if(is_array($object) || $object instanceof ArrayAccess)
{
$object[$prop] = $value;
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
index 5cb9cbcb..a47ed52a 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
@@ -7,20 +7,9 @@
* @copyright Copyright © 2005-2007 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
- * @package System.DataAccess.SQLMap
+ * @package System.Data.SqlMap.DataMapper
*/
-interface ISqLMapCache
-{
- public function remove($key);
-
- public function flush();
-
- public function get($key);
-
- public function set($key, $value);
-}
-
/**
* Allow different implementation of caching strategy. See TSqlMapFifoCache
* for a first-in-first-out implementation. See TSqlMapLruCache for
@@ -28,10 +17,10 @@ interface ISqLMapCache
*
* @author Wei Zhuo
* @version $Id$
- * @package System.DataAccess.SQLMap
- * @since 3.0
+ * @package System.Data.SqlMap.DataMapper
+ * @since 3.1
*/
-abstract class TSqlMapCache implements ISqlMapCache
+abstract class TSqlMapCache implements ICache
{
protected $_keyList;
protected $_cache;
@@ -48,11 +37,18 @@ abstract class TSqlMapCache implements ISqlMapCache
$this->_keyList = new TList;
}
+ /**
+ * Maximum number of items to cache. Default size is 100.
+ * @param int cache size.
+ */
public function setCacheSize($value)
{
$this->_cacheSize=TPropertyValue::ensureInteger($value,100);
}
+ /**
+ * @return int cache size.
+ */
public function getCacheSize()
{
return $this->_cacheSize;
@@ -61,7 +57,7 @@ abstract class TSqlMapCache implements ISqlMapCache
/**
* @return object the object removed if exists, null otherwise.
*/
- public function remove($key)
+ public function delete($key)
{
$object = $this->get($key);
$this->_cache->remove($key);
@@ -78,6 +74,13 @@ abstract class TSqlMapCache implements ISqlMapCache
$this->_cache->clear();
}
+ /**
+ * @throws TSqlMapException not implemented.
+ */
+ public function add($id,$value,$expire=0,$dependency=null)
+ {
+ throw new TSqlMapException('sqlmap_use_set_to_store_cache');
+ }
}
/**
@@ -86,8 +89,8 @@ abstract class TSqlMapCache implements ISqlMapCache
*
* @author Wei Zhuo
* @version $Id$
- * @package System.DataAccess.SQLMap
- * @since 3.0
+ * @package System.Data.SqlMap.DataMapper
+ * @since 3.1
*/
class TSqlMapFifoCache extends TSqlMapCache
{
@@ -100,11 +103,12 @@ class TSqlMapFifoCache extends TSqlMapCache
}
/**
- * Adds an item with the specified key and value into cached data.
+ * Stores a value identified by a key into cache.
+ * The expire and dependency parameters are ignored.
* @param string cache key
* @param mixed value to cache.
*/
- public function set($key, $value)
+ public function set($key, $value,$expire=0,$dependency=null)
{
$this->_cache->add($key, $value);
$this->_keyList->add($key);
@@ -122,8 +126,8 @@ class TSqlMapFifoCache extends TSqlMapCache
*
* @author Wei Zhuo
* @version $Id$
- * @package System.DataAccess.SQLMap
- * @since 3.0
+ * @package System.Data.SqlMap.DataMapper
+ * @since 3.1
*/
class TSqlMapLruCache extends TSqlMapCache
{
@@ -138,16 +142,15 @@ class TSqlMapLruCache extends TSqlMapCache
$this->_keyList->add($key);
return $this->_cache->itemAt($key);
}
- else
- return null;
}
/**
- * Adds an item with the specified key and value into cached data.
- * @param string cache key
- * @param mixed value to cache.
+ * Stores a value identified by a key into cache.
+ * The expire and dependency parameters are ignored.
+ * @param string the key identifying the value to be cached
+ * @param mixed the value to be cached
*/
- public function set($key, $value)
+ public function set($key, $value,$expire=0,$dependency=null)
{
$this->_cache->add($key, $value);
$this->_keyList->add($key);
@@ -159,71 +162,66 @@ class TSqlMapLruCache extends TSqlMapCache
}
}
-class TSqlMapApplicationCache implements ISqlMapCache
+/**
+ * TSqlMapApplicationCache uses the default Prado application cache for
+ * caching SqlMap results.
+ *
+ * @author Wei Zhuo
+ * @version $Id$
+ * @package System.Data.SqlMap.DataMapper
+ * @since 3.1
+ */
+class TSqlMapApplicationCache implements ICache
{
- private $_cache;
- private $_expiry=0;
- private $_property=array();
- private $_cacheModelID;
-
- public function __sleep()
- {
- $this->_cache = null;
- return array_keys(get_object_vars($this));
- }
-
- public function remove($key)
+ /**
+ * @param string item to be deleted.
+ */
+ public function delete($key)
{
$this->getCache()->delete($key);
}
+ /**
+ * Deletes all items in the cache.
+ */
public function flush()
{
$this->getCache()->flush();
}
+ /**
+ * @return mixed Gets a cached object with the specified key.
+ */
public function get($key)
{
$result = $this->getCache()->get($key);
return $result === false ? null : $result;
}
- public function set($key, $value)
- {
- $this->getCache()->set($key, $value, $this->_expiry);
- }
-
- public function configure($model, $properties)
+ /**
+ * Stores a value identified by a key into cache.
+ * @param string the key identifying the value to be cached
+ * @param mixed the value to be cached
+ */
+ public function set($key, $value,$expire=0,$dependency=null)
{
- $this->_property = $properties;
- $this->_cacheModelID = $model->getID();
+ $this->getCache()->set($key, $value, $expire,$dependency);
}
+ /**
+ * @return ICache Application cache instance.
+ */
protected function getCache()
{
- if(is_null($this->_cache))
- $this->initialize();
- return $this->_cache;
+ return Prado::getApplication()->getCache();
}
- protected function initialize()
+ /**
+ * @throws TSqlMapException not implemented.
+ */
+ public function add($id,$value,$expire=0,$dependency=null)
{
- if(isset($this->_property['expiry']))
- $this->_expiry = intval($this->_property['expiry']);
-
- if(isset($this->_property['cacheModule']))
- {
- $id = $this->_property['cacheModule'];
- $this->_cache = Prado::getApplication()->getModule($id);
- }
- else
- {
- $this->_cache = Prado::getApplication()->getCache();
- }
-
- if(!($this->_cache instanceof ICache))
- throw new TSqlMapConfigurationException(
- 'sqlmap_invalid_prado_cache', $this->_cacheModelID);
+ throw new TSqlMapException('sqlmap_use_set_to_store_cache');
}
}
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapException.php b/framework/Data/SqlMap/DataMapper/TSqlMapException.php
index 9a2db478..52fedb13 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapException.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapException.php
@@ -54,31 +54,6 @@ class TSqlMapConfigurationException extends TSqlMapException
}
-class TUndefinedAttributeException extends TSqlMapConfigurationException
-{
- public function __construct($attr, $node, $object, $file)
- {
- parent::__construct(
- 'sqlmap_undefined_attribute', get_class($object), $attr,
- htmlentities($node->asXml()),$file);
- }
-}
-
-class TSqlMapExecutionException extends TSqlMapException
-{
-}
-
-class TSqlMapQueryExecutionException extends TSqlMapExecutionException
-{
- protected $parent;
- public function __construct($statement, $exception)
- {
- $this->parent = $exception;
- parent::__construct('sqlmap_query_execution_error',
- $statement->getID(), $exception->getMessage());
- }
-}
-
class TSqlMapUndefinedException extends TSqlMapException
{
@@ -88,12 +63,9 @@ class TSqlMapDuplicateException extends TSqlMapException
{
}
-class TSqlMapConnectionException extends TSqlMapException
-{
-}
class TInvalidPropertyException extends TSqlMapException
{
-
}
+
?>
\ No newline at end of file
--
cgit v1.2.3