summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap/Configuration
diff options
context:
space:
mode:
authorwei <>2006-12-16 03:56:03 +0000
committerwei <>2006-12-16 03:56:03 +0000
commitddc0de38f64e5834ce04f0407a8416172b596655 (patch)
treea94c75b6e7a4f443f748124b84e30d02826bb23a /framework/DataAccess/SQLMap/Configuration
parentc8689010d28a0fe2a734131a2964d7df394cdf6c (diff)
removed adodb and framework/DataAccess
Diffstat (limited to 'framework/DataAccess/SQLMap/Configuration')
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php179
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TDiscriminator.php86
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TDomSqlMapBuilder.php521
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TInlineParameterMapParser.php50
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TParameterMap.php95
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TParameterProperty.php72
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TResultMap.php83
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TResultProperty.php166
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php23
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapCacheModel.php131
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapConditionalTag.php176
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapDelete.php7
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapInsert.php15
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapSelect.php11
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapSelectKey.php26
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapStatement.php109
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSqlMapUpdate.php11
17 files changed, 0 insertions, 1761 deletions
diff --git a/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php b/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php
deleted file mode 100644
index 2441dedf..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TConfigDeserialize.php
+++ /dev/null
@@ -1,179 +0,0 @@
-<?php
-
-class TConfigDeserialize
-{
- private $_properties;
-
- public function __construct($properties)
- {
- $this->_properties = $properties;
- }
-
- public function loadConfiguration($object, $node, $file)
- {
- foreach($node->attributes() as $k=>$v)
- {
- if($object->canSetProperty($k))
- $object->{'set'.$k}($this->replaceProperties((string)($v)));
- else
- throw new TUndefinedAttributeException($k,$node,$object,$file);
- }
- }
-
- public function replaceProperties($string)
- {
- foreach($this->_properties as $find => $replace)
- $string = str_replace('${'.$find.'}', $replace, $string);
- return $string;
- }
-
- public function parameterMap($node, $sqlMap, $file)
- {
- $parameterMap = new TParameterMap;
- $this->loadConfiguration($parameterMap, $node, $file);
- foreach($node->parameter as $parameter)
- {
- $property = $this->parameterProperty($parameter, $sqlMap, $file);
- $property->initialize($sqlMap);
- $parameterMap->addParameterProperty($property);
- }
- return $parameterMap;
- }
-
- public function parameterProperty($node, $sqlMap, $file)
- {
- $property = new TParameterProperty;
- $this->loadConfiguration($property, $node, $file);
- return $property;
- }
-
- public function select($node, $sqlMap, $file)
- {
- $select = new TSqlMapSelect;
- $this->loadConfiguration($select, $node, $file);
- $select->initialize($sqlMap);
- return $select;
- }
-
- public function update($node, $sqlMap, $file)
- {
- $update = new TSqlMapUpdate;
- $this->loadConfiguration($update, $node, $file);
- $update->initialize($sqlMap);
- return $update;
- }
-
- public function delete($node, $sqlMap, $file)
- {
- $delete = new TSqlMapDelete;
- $this->loadConfiguration($delete, $node, $file);
- $delete->initialize($sqlMap);
- return $delete;
- }
-
-
- public function insert($node, $sqlMap, $file)
- {
- $insert = new TSqlMapInsert;
- $this->loadConfiguration($insert, $node, $file);
- if(isset($node->selectKey))
- {
- $selectKey = new TSqlMapSelectKey;
- $this->loadConfiguration($selectKey, $node->selectKey, $file);
- $type = $selectKey->getType();
- $selectKey->setType(strtolower($type) == 'post' ? 'post' : 'pre');
- $insert->setSelectKey($selectKey);
- }
- if(isset($node->generate))
- {
- var_dump("add generate");
- }
-
- $insert->initialize($sqlMap);
- return $insert;
- }
-
- public function statement($node, $sqlMap, $file)
- {
- $statement = new TSqlMapStatement;
- $this->loadConfiguration($statement, $node, $file);
- $statement->initialize($sqlMap);
- return $statement;
- }
-
- public function resultMap($node, $sqlMap, $file)
- {
- $resultMap = new TResultMap;
- $resultMap->initialize($sqlMap);
- $this->loadConfiguration($resultMap, $node, $file);
- foreach($node->result as $result)
- {
- $property = $this->resultProperty($result, $sqlMap, $file);
- $property->initialize($sqlMap, $resultMap);
- $resultMap->addResultProperty($property);
- }
-
- $discriminator = null;
- if(isset($node->discriminator))
- {
- $discriminator = new TDiscriminator;
- $this->loadConfiguration($discriminator, $node->discriminator, $file);
- $discriminator->initMapping($sqlMap, $resultMap);
- }
-
-
-
- foreach($node->subMap as $subMapNode)
- {
- if(isset($subMapNode['value']))
- {
- if(is_null($discriminator))
- throw new TSqlMapConfigurationException(
- 'sqlmap_undefined_discriminator', $resultMap->getID(), $file);
-
- $subMap = new TSubMap;
- $this->loadConfiguration($subMap, $subMapNode, $file);
- $discriminator->add($subMap);
- }
- }
- if(!is_null($discriminator))
- $resultMap->setDiscriminator($discriminator);
- return $resultMap;
- }
-
- public function resultProperty($node, $sqlMap, $file)
- {
- $resultProperty = new TResultProperty;
- $this->loadConfiguration($resultProperty, $node, $file);
- return $resultProperty;
- }
-
- public function cacheModel($node, $sqlMap, $file)
- {
- $cacheModel = new TSqlMapCacheModel;
- $this->loadConfiguration($cacheModel, $node, $file);
-/* if(isset($node->flushInterval))
- {
- $interval = $node->flushInterval;
- $span = 0; //span in seconds
- if(isset($interval['hours']))
- $span += intval($interval['hours'])*60*60;
- if(isset($interval['minutes']))
- $span += intval($interval['minutes'])*60;
- if(isset($interval['seconds']))
- $span += intval($interval['seconds']);
- if($span > 0)
- $cacheModel->setFlushInterval($span);
- }*/
- if(isset($node->property))
- {
- foreach($node->property as $property)
- $cacheModel->addProperty((string)$property['name'],
- (string)$property['value']);
- }
- return $cacheModel;
- }
-}
-
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TDiscriminator.php b/framework/DataAccess/SQLMap/Configuration/TDiscriminator.php
deleted file mode 100644
index 0ee34e3e..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TDiscriminator.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-class TDiscriminator extends TComponent
-{
- private $_column='';
- private $_type='';
- private $_typeHandler=null;
- private $_dbType='';
- private $_columnIndex='';
- private $_nullValue='';
- private $_mapping='';
- private $_resultMaps=array();
- private $_subMaps=array();
-
- public function getColumn(){ return $this->_column; }
- public function setColumn($value){ $this->_column = $value; }
-
- public function getType(){ return $this->_type; }
- public function setType($value){ $this->_type = $value; }
-
- public function getTypeHandler(){ return $this->_typeHandler; }
- public function setTypeHandler($value){ $this->_typeHandler = $value; }
-
- public function getDbType(){ return $this->_dbType; }
- public function setDbType($value){ $this->_dbType = $value; }
-
- public function getColumnIndex(){ return $this->_columnIndex; }
- public function setColumnIndex($value){ $this->_columnIndex = $value; }
-
- public function getNullValue(){ return $this->_nullValue; }
- public function setNullValue($value){ $this->_nullValue = $value; }
-
- public function getMapping(){ return $this->_mapping; }
-
- public function getResultMaps(){ return $this->_resultMaps; }
- public function setResultMaps($value){ $this->_resultMaps = $value; }
-
- public function add($subMap)
- {
- $this->_subMaps[] = $subMap;
- }
-
- public function getSubMap($value)
- {
- if(isset($this->_resultMaps[$value]))
- return $this->_resultMaps[$value];
- else
- return null;
- }
-
- public function initMapping($sqlMap, $resultMap)
- {
- $this->_mapping = new TResultProperty;
- $this->_mapping->setColumn($this->getColumn());
- $this->_mapping->setColumnIndex($this->getColumnIndex());
- $this->_mapping->setType($this->getType());
- $this->_mapping->setTypeHandler($this->getTypeHandler());
- $this->_mapping->setDbType($this->getDbType());
- $this->_mapping->setNullValue($this->getNullValue());
- $this->_mapping->initialize($sqlMap, $resultMap);
- }
-
- public function initialize($sqlMap)
- {
- foreach($this->_subMaps as $subMap)
- {
- $this->_resultMaps[$subMap->getValue()] =
- $sqlMap->getResultMap($subMap->getResultMapping());
- }
- }
-}
-
-
-class TSubMap extends TComponent
-{
- private $_value='';
- private $_resultMapping='';
-
- public function getValue(){ return $this->_value; }
- public function setValue($value){ $this->_value = $value; }
-
- public function getResultMapping(){ return $this->_resultMapping; }
- public function setResultMapping($value){ $this->_resultMapping = $value; }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TDomSqlMapBuilder.php b/framework/DataAccess/SQLMap/Configuration/TDomSqlMapBuilder.php
deleted file mode 100644
index e43e362d..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TDomSqlMapBuilder.php
+++ /dev/null
@@ -1,521 +0,0 @@
-<?php
-
-class TDomSqlMapBuilder
-{
- const DEFAULT_CONFIG_FILE = 'sqlmap.xml';
-
- private $_document;
-
- private $_sqlMapper;
-
- private $_configFile;
-
- private $_properties;
-
- private $_deserialize;
-
- private $_useNamespaces = false;
-
- private $_FlushOnExecuteStatements=array();
-
- public function __construct($cachedir='./cache')
- {
- $this->_properties = new TMap;
- $this->_deserialize = new TConfigDeserialize($this->_properties);
- }
-
- public function configure($resource=null)
- {
- if($resource instanceof SimpleXMLElement)
- return $this->build($resource);
-
- if(!is_string($resource))
- $resource = self::DEFAULT_CONFIG_FILE;
-
- $this->_configFile = $resource;
- if(!is_file($resource))
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_config', $resource);
-
- return $this->build($this->getConfigAsXmlDocument($resource));
- }
-
- protected function getConfigAsXmlDocument($file)
- {
- return simplexml_load_file($file);
- }
-
- public function build(SimpleXMLElement $document)
- {
- $this->_document = $document;
- $this->initializeSQLMap($document);
- return $this->_sqlMapper;
- }
-
- protected function initializeSQLMap($document)
- {
- $this->_sqlMapper = new TSqlMapper(new TTypeHandlerFactory);
-
- if(isset($document->properties))
- {
- $this->loadGlobalProperties($document->properties);
- }
-
- if(isset($document->settings) && isset($document->settings->setting))
- $this->configureSettings($document->settings);
-
- foreach($document->xpath('//typeHandler') as $handler)
- $this->loadTypeHandler($handler, $this->_configFile);
-
- //load database provider
- if(isset($document->provider) && isset($document->provider->datasource))
- {
- $this->loadProvider($document->provider,
- $document->provider->datasource, $document, $this->_configFile);
- }
- else
- {
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_db_config', $this->_configFile);
- }
-
- foreach($document->xpath('//sqlMap') as $sqlmap)
- $this->loadSqlMappingFiles($sqlmap);
- $this->resolveResultMapping();
-
- if($this->_sqlMapper->getIsCacheModelsEnabled())
- $this->attachCacheModel();
- }
-
- protected function configureSettings($node)
- {
- foreach($node->setting as $setting)
- {
- if(isset($setting['useStatementNamespaces']))
- {
- $this->_useNamespaces =
- TPropertyValue::ensureBoolean(
- (string)$setting['useStatementNamespaces']);
- }
-
- if(isset($setting['cacheModelsEnabled']))
- {
- $this->_sqlMapper->setCacheModelsEnabled(
- TPropertyValue::ensureBoolean(
- (string)$setting['cacheModelsEnabled']));
- }
- }
- }
-
- /**
- * Attach CacheModel to statement and register trigger statements for
- * cache models
- */
- protected function attachCacheModel()
- {
- foreach($this->_sqlMapper->getStatements() as $mappedStatement)
- {
- if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0)
- {
- $cache = $this->_sqlMapper->getCache($model);
- //var_dump($model);
- $mappedStatement->getStatement()->setCache($cache);
- }
- }
-
- foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs)
- {
- if(count($statementIDs) > 0)
- {
- foreach($statementIDs as $statementID)
- {
- $cacheModel = $this->_sqlMapper->getCache($cacheID);
- $statement = $this->_sqlMapper->getMappedStatement($statementID);
- $cacheModel->registerTriggerStatement($statement);
- }
- }
- }
- }
-
- protected function loadGlobalProperties($node)
- {
- if(isset($node['resource']))
- $this->loadPropertyResource($node);
-
- foreach($node->children() as $child)
- {
- if(isset($child['resource']))
- $this->loadPropertyResource($child);
- $this->_properties[(string)$child['key']] = (string)$child['value'];
- }
- }
-
- protected function loadPropertyResource($node)
- {
- $resource = $this->getResourceFromPath((string)$node['resource']);
- $properties = $this->getConfigAsXmlDocument($resource);
- $this->loadGlobalProperties($properties);
- }
-
- protected function loadProvider($providerNode, $node, $document, $file)
- {
- //$id = (string)$node['id'];
- $class = (string)$providerNode['class'];
- if(strlen($class) > 0)
- {
- if(class_exists($class,false))
- {
- $provider = new $class;
- $this->_deserialize->loadConfiguration($provider, $node,$file);
- $this->_sqlMapper->setDataProvider($provider);
- }
- else
- {
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_find_provider_class_def', $file, $class);
- }
- }
- else
- {
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_find_provider_class', $file);
- }
- //var_dump($node);
- }
-
- protected function loadTypeHandler($node, $file)
- {
- if(!is_null($node['type']) && !is_null($node['callback']))
- {
- $type = (string)$node['type'];
- $dbType = (string)$node['dbType'];
- $class = (string)$node['callback'];
- if(class_exists('Prado', false))
- {
- $handler = Prado::createComponent($class);
- }
- else
- {
- if(class_exists($class,false))
- $handler = new $class;
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_type_handler_class_undef', $file, $class);
- }
- $factory = $this->_sqlMapper->getTypeHandlerFactory();
- $factory->register($type, $handler, $dbType);
- }
- else
- {
- throw new TSqlMapConfigurationException(
- 'sqlmap_type_handler_callback_undef', $file);
- }
- }
-
- protected function loadSqlMappingFiles($node)
- {
- $resource = $this->getResourceFromPath((string)$node['resource']);
- $sqlmap = $this->getConfigAsXmlDocument($resource);
- $this->configureSqlMap($sqlmap,$resource);
- }
-
- protected function getResourceFromPath($resource)
- {
- $basedir = dirname($this->_configFile);
- $file = realpath($basedir.'/'.$resource);
- if(!is_string($file) || !is_file($file))
- $file = realpath($resource);
- if(is_string($file) && is_file($file))
- return $file;
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_resource', $resource);
- }
-
- protected function configureSqlMap($document,$file)
- {
- // if(isset($document->typeAlias))
- // foreach($document->typeAlias as $node)
- // TTypeAliasDeSerializer::Deserialize($node, $this->_sqlMapper);
- foreach($document->xpath('//resultMap') as $node)
- $this->loadResultMap($node,$document,$file);
-
- foreach($document->xpath('//parameterMap') as $node)
- $this->loadParameterMap($node, $document, $file);
-
- foreach($document->xpath('//statement') as $node)
- $this->loadStatementTag($node, $document,$file);
-
- foreach($document->xpath('//select') as $node)
- $this->loadSelectTag($node, $document, $file);
-
- foreach($document->xpath('//insert') as $node)
- $this->loadInsertTag($node, $document, $file);
-
- foreach($document->xpath('//update') as $node)
- $this->loadUpdateTag($node, $document, $file);
-
- foreach($document->xpath('//delete') as $node)
- $this->loadDeleteTag($node, $document, $file);
-/* if(isset($document->procedure))
- foreach($document->procedure as $node)
- $this->loadProcedureTag($node);
-*/
- if($this->_sqlMapper->getIsCacheModelsEnabled())
- {
- if(isset($document->cacheModel))
- foreach($document->cacheModel as $node)
- $this->loadCacheModel($node, $document, $file);
- }
- }
-
- protected function loadCacheModel($node, $document, $file)
- {
- $cacheModel = $this->_deserialize->cacheModel($node, $this->_sqlMapper, $file);
- if(isset($node->flushOnExecute))
- {
- foreach($node->flushOnExecute as $flush)
- {
- $id = $cacheModel->getID();
- if(!isset($this->_FlushOnExecuteStatements[$id]))
- $this->_FlushOnExecuteStatements[$id] = array();
-
- $this->_FlushOnExecuteStatements[$id][] = (string)$flush['statement'];
- }
- }
- //var_dump($cacheModel);
- $cacheModel->initialize($this->_sqlMapper);
- $this->_sqlMapper->addCache($cacheModel);
- }
-
- protected function loadUpdateTag($node, $document, $file)
- {
- $update = $this->_deserialize->insert($node, $this->_sqlMapper, $file);
- if(!is_null($update->getGenerate()))
- {
- var_dump('generate update');
- }
- else
- {
- $this->processSqlStatement($update, $document, $node, $file);
- }
- $mappedStatement = new TUpdateMappedStatement($this->_sqlMapper, $update);
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- }
-
- protected function loadDeleteTag($node, $document, $file)
- {
- $delete = $this->_deserialize->delete($node, $this->_sqlMapper, $file);
- if(!is_null($delete->getGenerate()))
- {
- var_dump('generate delete');
- }
- else
- {
- $this->processSqlStatement($delete, $document, $node, $file);
- }
- $mappedStatement = new TDeleteMappedStatement($this->_sqlMapper, $delete);
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- }
-
-
- protected function loadParameterMap($node, $document, $file)
- {
- $id = (string)$node['id'];
- if($this->_sqlMapper->getParameterMaps()->contains($id))
- return;
- $parameterMap = $this->_deserialize->parameterMap($node, $this->_sqlMapper, $file);
- $extendMap = $parameterMap->getExtends();
- if(strlen($extendMap) > 0)
- {
- if($this->_sqlMapper->getParameterMaps()->contains($extendMap) == false)
- {
- $nodes = $document->xpath("//parameterMap[@id='{$extendMap}']");
- if(isset($nodes[0]))
- $this->loadParameterMap($nodes[0],$document,$file);
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_parent_parameter_map', $extendMap, $file);
- }
- $superMap = $this->_sqlMapper->getParameterMap($extendMap);
- $index = 0;
- foreach($superMap->getPropertyNames() as $propertyName)
- {
- $parameterMap->insertParameterProperty($index++,
- $superMap->getProperty($propertyName));
- }
- }
- $this->_sqlMapper->addParameterMap($parameterMap);
- }
-
- protected function loadInsertTag($node, $document, $file)
- {
- $insert = $this->_deserialize->insert($node, $this->_sqlMapper, $file);
- if(!is_null($insert->getGenerate()))
- {
- var_dump("generate insert");
- }
- else
- {
- $this->processSqlStatement($insert, $document, $node, $file);
- }
-
- $mappedStatement = new TInsertMappedStatement($this->_sqlMapper, $insert);
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- if(!is_null($insert->getSelectKey()))
- {
- $selectKey = $insert->getSelectKey();
- $selectKey->setID($insert->getID());
- $selectKey->initialize($this->_sqlMapper);
- $selectKey->setID($insert->getID().'.SelectKey');
- $this->processSqlStatement($selectKey,
- $document, $node->selectKey, $file);
- $mappedStatement = new TMappedStatement($this->_sqlMapper, $selectKey);
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- }
- }
-
- protected function processSqlStatement($statement, $document, $node, $file)
- {
- $commandText = (string)$node;
- if(strlen($extend = $statement->getExtends()) > 0)
- {
- $superNodes = $document->xpath("//*[@id='{$extend}']");
- if(isset($superNodes[0]))
- $commandText = (string)$superNodes[0] . $commandText;
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_parent_sql', $extend, $file);
- }
-
- //$sql = new TStaticSql();
- //$sql->buildPreparedStatement($statement, (string)$node);
- $commandText = $this->_deserialize->replaceProperties($commandText);
- $this->applyInlineParameterMap($statement, $commandText, $node, $file);
- //$statement->setSql($sql);
- }
-
- protected function applyInlineParameterMap($statement, $sqlStatement, $node, $file)
- {
- $scope['statement'] = $statement->getID();
- $scope['file'] = $file;
-
- if($statement->parameterMap() == null)
- {
- // Build a Parametermap with the inline parameters.
- // if they exist. Then delete inline infos from sqltext.
- $parameterParser = new TInlineParameterMapParser;
- $sqlText = $parameterParser->parse(
- $this->_sqlMapper, $statement, $sqlStatement, $scope);
- if(count($sqlText['parameters']) > 0)
- {
- $map = new TParameterMap();
- $map->setID($statement->getID().'-InLineParameterMap');
- $statement->setInlineParameterMap($map);
- foreach($sqlText['parameters'] as $property)
- $map->addParameterProperty($property);
- }
- $sqlStatement = $sqlText['sql'];
- }
-
- $simpleDynamic = new TSimpleDynamicParser;
- $dynamics = $simpleDynamic->parse($this->_sqlMapper, $statement, $sqlStatement, $scope);
- if(count($dynamics['parameters']) > 0)
- {
- $sql = new TSimpleDynamicSql($dynamics['parameters']);
- $sqlStatement = $dynamics['sql'];
- }
- else
- $sql = new TStaticSql();
- $sql->buildPreparedStatement($statement, $sqlStatement);
- $statement->setSql($sql);
- }
-
- protected function resolveResultMapping()
- {
- $maps = $this->_sqlMapper->getResultMaps();
- foreach($maps as $entry)
- {
- foreach($entry->getColumns() as $item)
- {
- $resultMap = $item->getResultMapping();
- if(strlen($resultMap) > 0)
- {
- if($maps->contains($resultMap))
- $item->setNestedResultMap($maps[$resultMap]);
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_result_mapping',
- $resultMap, $this->_configFile, $entry->getID());
- }
- }
- if(!is_null($entry->getDiscriminator()))
- {
- $entry->getDiscriminator()->initialize($this->_sqlMapper);
- }
- }
- }
-
- protected function loadSelectTag($node, $document, $file)
- {
- $select = $this->_deserialize->select($node, $this->_sqlMapper, $file);
- if(!is_null($select->getGenerate()))
- {
- var_dump("generate select");
- }
- else
- {
- $this->processSqlStatement($select, $document, $node, $file);
- /*$sql = new TStaticSql();
- $sql->buildPreparedStatement($select, (string)$node);
- $select->setSql($sql);*/
- }
-
- $mappedStatement = new TMappedStatement($this->_sqlMapper, $select);
- if($this->_sqlMapper->getIsCacheModelsEnabled() &&
- strlen($select->getCacheModel()) > 0)
- {
- $mappedStatement = new TCachingStatement($mappedStatement);
- }
-
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- }
-
- protected function loadResultMap($node,$document,$file)
- {
- $resultMap = $this->_deserialize->resultMap($node, $this->_sqlMapper,$file);
- $extendMap = $resultMap->getExtends();
- if(strlen($extendMap) > 0)
- {
- if(!$this->_sqlMapper->getResultMaps()->contains($extendMap))
- {
- $nodes = $document->xpath("//resultMap[@id='{$extendMap}']");
- if(isset($nodes[0]))
- $this->loadResultMap($nodes[0],$document,$file);
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_parent_result_map', $extendMap, $file);
- }
- $superMap = $this->_sqlMapper->getResultMap($extendMap);
- $resultMap->getColumns()->mergeWith($superMap->getColumns());
- }
- if(!$this->_sqlMapper->getResultMaps()->contains($resultMap->getID()))
- $this->_sqlMapper->addResultMap($resultMap);
- }
-
-
- protected function loadStatementTag($node, $document, $file)
- {
- $statement = $this->_deserialize->statement($node, $this->_sqlMapper, $file);
-
- /*$sql = new TStaticSql();
- $sql->buildPreparedStatement($statement, (string)$node);
- $statement->setSql($sql);*/
- $this->processSqlStatement($statement, $document, $node, $file);
-
- $mappedStatement = new TMappedStatement($this->_sqlMapper, $statement);
- $this->_sqlMapper->addMappedStatement($mappedStatement);
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TInlineParameterMapParser.php b/framework/DataAccess/SQLMap/Configuration/TInlineParameterMapParser.php
deleted file mode 100644
index bc633b2c..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TInlineParameterMapParser.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-class TInlineParameterMapParser
-{
- private $PARAMETER_TOKEN_REGEXP = '/#(#?[^#]+#?)#/';
-
- public function parse($sqlMap, $statement, $sqlText, $scope)
- {
- $parameterClass = !is_null($statement)
- ? $statement->getParameterClass() : null;
- $matches = array();
- $mappings = array();
- preg_match_all($this->PARAMETER_TOKEN_REGEXP, $sqlText, $matches);
-
- for($i = 0, $k=count($matches[1]); $i<$k; $i++)
- {
- $mappings[] = $this->parseMapping($matches[1][$i],
- $parameterClass, $sqlMap, $scope);
- $sqlText = str_replace($matches[0][$i], '?', $sqlText);
- }
- return array('sql'=>$sqlText, 'parameters'=>$mappings);
- }
-
- /**
- * Parse inline parameter with syntax as
- * #propertyName,type=string,dbype=Varchar,nullValue=N/A,handler=string#
- */
- protected function parseMapping($token, $parameterClass, $sqlMap, $scope)
- {
- $mapping = new TParameterProperty;
- $properties = explode(',', $token);
- $mapping->setProperty(trim(array_shift($properties)));
- //var_dump($properties);
- foreach($properties as $property)
- {
- $prop = explode('=',$property);
- $name = trim($prop[0]); $value=trim($prop[1]);
- if($mapping->canSetProperty($name))
- $mapping->{'set'.$name}($value);
- else
- throw new TSqlMapUndefinedException(
- 'sqlmap_undefined_property_inline_map',
- $name, $scope['statement'], $scope['file']);
- }
- $mapping->initialize($sqlMap);
- return $mapping;
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TParameterMap.php b/framework/DataAccess/SQLMap/Configuration/TParameterMap.php
deleted file mode 100644
index b3c6ed6e..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TParameterMap.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-class TParameterMap extends TComponent
-{
- private $_ID='';
- private $_extend='';
- private $_properties;
- private $_propertyMap;
- private $_extendMap;
-
- public function __construct()
- {
- $this->_properties = new TList;
- $this->_propertyMap = new TMap;
- }
-
- public function getProperties(){ return $this->_properties; }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getExtends(){ return $this->_extend; }
- public function setExtends($value){ $this->_extend = $value; }
-
- public function getProperty($index)
- {
- if(is_string($index))
- return $this->_propertyMap->itemAt($index);
- else if(is_int($index))
- return $this->_properties->itemAt($index);
- else
- throw new TDataMapperException(
- 'sqlmap_index_must_be_string_or_int', $index);
- }
-
- public function addParameterProperty(TParameterProperty $property)
- {
- $this->_propertyMap->add($property->getProperty(), $property);
- $this->_properties->add($property);
- }
-
- public function insertParameterProperty($index, TParameterProperty $property)
- {
- $this->_propertyMap->add($property->getProperty(), $property);
- $this->_properties->insertAt($index, $property);
- }
-
- public function getPropertyNames()
- {
- return $this->_propertyMap->getKeys();
- }
-
- public function getParameter($mapping, $parameterValue, $statement)
- {
- $value = $parameterValue;
- $typeHandler = $mapping->getTypeHandler();
- try
- {
- $value = TPropertyAccess::get($parameterValue, $mapping->getProperty());
- }
- catch (TInvalidPropertyException $e)
- {
- throw new TSqlMapExecutionException(
- 'sqlmap_unable_to_get_property_for_parameter',$this->getID(),
- $mapping->getProperty(), get_class($parameterValue),
- $e->getMessage(), $statement->getID());
- }
-
- if(!is_null($typeHandler))
- {
- try
- {
- $value = $typeHandler->getParameter($value);
- }
- catch (Exception $e)
- {
- throw new TSqlMapExecutionException(
- 'sqlmap_error_in_parameter_from_handler',$this->getID(),
- $value, get_class($typeHandler), $e->getMessage());
- }
- }
-
- if(!is_null($nullValue = $mapping->getNullValue()))
- {
- if($nullValue === $value)
- $value = null;
- }
-
- if(!is_null($type = $mapping->getType()))
- $value = TTypeHandlerFactory::convertToType($type, $value);
-
- return $value;
- }
-}
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TParameterProperty.php b/framework/DataAccess/SQLMap/Configuration/TParameterProperty.php
deleted file mode 100644
index 196f27f5..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TParameterProperty.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-class TParameterProperty extends TComponent
-{
- private $_typeHandler=null;
- private $_type=null;
- private $_column='';
- private $_dbType='';
- private $_property='';
- private $_nullValue=null;
- private $_typeHandlerFactory;
-
- private $_size;
- private $_precision;
- private $_scale;
- private $_direction;
-
- public function getTypeHandler()
- {
- if(is_null($this->_typeHandlerFactory)) return null;
- if(!is_null($this->_typeHandler))
- {
- return $this->_typeHandlerFactory->getTypeHandler(
- $this->_typeHandler, $this->_dbType);
- }
- else if(!is_null($this->getType()))
- return $this->_typeHandlerFactory->getTypeHandler(
- $this->getType(), $this->_dbType);
- else
- return null;
- }
- public function setTypeHandler($value){ $this->_typeHandler = $value; }
-
- public function getType(){ return $this->_type; }
- public function setType($value){ $this->_type = $value; }
-
- public function getColumn(){ return $this->_column; }
- public function setColumn($value){ $this->_column = $value; }
-
- public function getDbType(){ return $this->_dbType; }
- public function setDbType($value){ $this->_dbType = $value; }
-
- public function getProperty(){ return $this->_property; }
- public function setProperty($value){ $this->_property = $value; }
-
- public function getNullValue(){ return $this->_nullValue; }
- public function setNullValue($value){ $this->_nullValue = $value; }
-
- public function getSize(){ return $this->_size; }
- public function setSize($value){ $this->_size = $value; }
-
- public function getPrecision(){ return $this->_precision; }
- public function setPrecision($value){ $this->_precision = $value; }
-
- public function getScale(){ return $this->_scale; }
- public function setScale($value){ $this->_scale = $value; }
-
-
- public function getDirection(){ return $this->_direction; }
- public function setDirection($value){ $this->_direction = $value; }
-
- public function initialize($sqlMap)
- {
- $this->_typeHandlerFactory = $sqlMap->getTypeHandlerFactory();
- // $type = !is_null($this->_typeHandler) ? $this->_typeHandler: $this->_type;
- // $this->setTypeHandler($sqlMap->getTypeHandlerFactory()->getTypeHandler($type));
- // if(!is_null($type))
- // var_dump($sqlMap->getTypeHandlerFactory());
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TResultMap.php b/framework/DataAccess/SQLMap/Configuration/TResultMap.php
deleted file mode 100644
index b8032c81..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TResultMap.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-class TResultMap extends TComponent
-{
- private $_ID='';
- private $_className='';
- private $_columns='';
- private $_extendMap='';
- private $_groupBy='';
- private $_discriminator=null;
- private $_typeHandlerFactory=null;
-
- public function __construct()
- {
- $this->_columns = new TMap;
- }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getClass(){ return $this->_className; }
- public function setClass($value){ $this->_className = $value; }
-
- public function getColumns(){ return $this->_columns; }
- public function setColumns($value){ $this->_columns = $value; }
-
- public function getExtends(){ return $this->_extendMap; }
- public function setExtends($value){ $this->_extendMap = $value; }
-
- public function getGroupBy(){ return $this->_groupBy; }
- public function setGroupBy($value){ $this->_groupBy = $value; }
-
- public function getDiscriminator(){ return $this->_discriminator; }
- public function setDiscriminator($value){ $this->_discriminator = $value; }
-
- public function initialize($sqlMap, $resultMap=null)
- {
- $this->_typeHandlerFactory = $sqlMap->getTypeHandlerFactory();
- }
-
- public function addResultProperty(TResultProperty $property)
- {
- $this->_columns->add($property->getProperty(), $property);
- }
-
- public function createInstanceOfResult()
- {
- $handler = $this->_typeHandlerFactory->getTypeHandler($this->getClass());
-
- try
- {
- if(!is_null($handler))
- return $handler->createNewInstance();
- else
- return TTypeHandlerFactory::createInstanceOf($this->getClass());
- }
- catch (TDataMapperException $e)
- {
- throw new TSqlMapExecutionException(
- 'sqlmap_unable_to_create_new_instance',
- $this->getClass(), get_class($handler), $this->getID());
- }
- }
-
- public function resolveSubMap($row)
- {
- $subMap = $this;
- if(!is_null($disc = $this->getDiscriminator()))
- {
- $mapping = $disc->getMapping();
- $dataValue = $mapping->getDatabaseValue($row);
- $subMap = $disc->getSubMap((string)$dataValue);
-
- if(is_null($subMap))
- $subMap = $this;
- else if($subMap !== $this)
- $subMap = $subMap->resolveSubMap($row);
- }
- return $subMap;
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TResultProperty.php b/framework/DataAccess/SQLMap/Configuration/TResultProperty.php
deleted file mode 100644
index 29ee366e..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TResultProperty.php
+++ /dev/null
@@ -1,166 +0,0 @@
-<?php
-
-class TResultProperty extends TComponent
-{
- private $_nullValue=null;
- private $_propertyName='';
- private $_columnName='';
- private $_columnIndex=-1;
- private $_nestedResultMapName='';
- private $_nestedResultMap=null;
- private $_valueType=null;
- private $_typeHandler=null;
- private $_isLazyLoad=false;
- private $_select='';
- private $_dbType='';
- private $_typeHandlerFactory;
- private $_hostResultMapID='inplicit internal mapping';
-
- const LIST_TYPE = 0;
- const ARRAY_TYPE = 1;
- const OBJECT_TYPE = 2;
-
- public function getNullValue(){ return $this->_nullValue; }
- public function setNullValue($value){ $this->_nullValue = $value; }
-
- public function getProperty(){ return $this->_propertyName; }
- public function setProperty($value){ $this->_propertyName = $value; }
-
- public function getColumn(){ return $this->_columnName; }
- public function setColumn($value){ $this->_columnName = $value; }
-
- public function getColumnIndex(){ return $this->_columnIndex; }
- public function setColumnIndex($value){ $this->_columnIndex = TPropertyValue::ensureInteger($value,-1); }
-
- public function getResultMapping(){ return $this->_nestedResultMapName; }
- public function setResultMapping($value){ $this->_nestedResultMapName = $value; }
-
- public function getNestedResultMap(){ return $this->_nestedResultMap; }
- public function setNestedResultMap($value){ $this->_nestedResultMap = $value; }
-
- public function getType(){ return $this->_valueType; }
- public function setType($value) { $this->_valueType = $value; }
-
- public function getTypeHandler()
- {
- if(is_null($this->_typeHandlerFactory)) return null;
- if(!is_null($this->_typeHandler))
- return $this->_typeHandlerFactory->getTypeHandler(
- $this->_typeHandler, $this->_dbType);
- else if(!is_null($this->getType()))
- return $this->_typeHandlerFactory->getTypeHandler(
- $this->getType(), $this->_dbType);
- else
- return null;
- }
- public function setTypeHandler($value) { $this->_typeHandler = $value; }
-
- public function getSelect(){ return $this->_select; }
- public function setSelect($value){ $this->_select = $value; }
-
- public function getLazyLoad(){ return $this->_isLazyLoad; }
- public function setLazyLoad($value){ $this->_isLazyLoad = TPropertyValue::ensureBoolean($value,false); }
-
- public function getDbType(){ return $this->_dbType; }
- public function setDbType($value){ $this->_dbType = $value; }
-
- public function initialize($sqlMap, $resultMap=null)
- {
- $this->_typeHandlerFactory = $sqlMap->getTypeHandlerFactory();
- if(!is_null($resultMap))
- $this->_hostResultMapID = $resultMap->getID();
-// $type = !is_null($this->_typeHandler) ? $this->_typeHandler: $this->_valueType;
-// $this->setTypeHandler($sqlMap->getTypeHandlerFactory()->getTypeHandler($type));
- }
-
- public function getDatabaseValue($row,$forceType=true)
- {
- $value = null;
- if($this->_columnIndex > 0 && isset($row[$this->_columnIndex]))
- $value = $this->getTypedValue($row[$this->_columnIndex], $forceType);
- else if(isset($row[$this->_columnName]))
- $value = $this->getTypedValue($row[$this->_columnName],$forceType);
- if(is_null($value) && !is_null($this->_nullValue))
- $value = $this->getTypedValue($this->_nullValue,$forceType);
- return $value;
- }
-
- public function getOrdinalValue($row)
- {
- return $this->getDatabaseValue($row,false);
- }
-
- private function getTypedValue($value, $forceType=true)
- {
- if(!$forceType) return $value;
- if(is_null($this->getTypeHandler()))
- {
- return TTypeHandlerFactory::convertToType($this->_valueType, $value);
- }
- else
- {
- try
- {
- return $this->getTypeHandler()->getResult($value);
- }
- catch (Exception $e)
- {
- throw new TSqlMapExecutionException(
- 'sqlmap_error_in_result_property_from_handler',$this->_hostResultMapID,
- $value, get_class($this->getTypeHandler()), $e->getMessage());
- }
- }
- }
-
-
- public function getPropertyType($type=null)
- {
- if(is_null($type))
- $type = $this->getType();
- if(class_exists($type, false)) //NO force autoloading
- {
- $class = new ReflectionClass($type);
- if($class->isSubclassOf('TList'))
- return self::LIST_TYPE;
- if($class->inmplementsInterface('ArrayAccess'))
- return self::ARRAY_TYPE;
- }
- if(strtolower($type) == 'array')
- return self::ARRAY_TYPE;
- return self::OBJECT_TYPE;
- }
-
- public function isListType($target)
- {
- if(is_null($this->getType()))
- {
- $prop = TPropertyAccess::get($target,$this->getProperty());
- return $prop instanceof TList;
- }
- return $this->getPropertyType() == self::LIST_TYPE;
- }
-
- public function isArrayType($target)
- {
- if(is_null($this->getType()))
- {
- $prop = TPropertyAccess::get($target,$this->getProperty());
- if(is_object($prop))
- return $prop instanceof ArrayAccess;
- return is_array($prop);
- }
- return $this->getPropertyType() == self::ARRAY_TYPE;
- }
-
- public function isObjectType($target)
- {
- if(is_null($this->getType()))
- {
- $prop = TPropertyAccess::get($target,$this->getProperty());
- return is_object($prop);
- }
- return $this->getPropertyType() == self::OBJECT_TYPE;
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php b/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
deleted file mode 100644
index e58d8af8..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-class TSimpleDynamicParser
-{
- private $PARAMETER_TOKEN_REGEXP = '/\$([^\$]+)\$/';
-
- const DYNAMIC_TOKEN = '`!`';
-
- public function parse($sqlMap, $statement, $sqlText, $scope)
- {
- $matches = array();
- $mappings = array();
- preg_match_all($this->PARAMETER_TOKEN_REGEXP, $sqlText, $matches);
- for($i = 0, $k=count($matches[1]); $i<$k; $i++)
- {
- $mappings[] = $matches[1][$i];
- $sqlText = str_replace($matches[0][$i], self::DYNAMIC_TOKEN, $sqlText);
- }
- return array('sql'=>$sqlText, 'parameters'=>$mappings);
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapCacheModel.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapCacheModel.php
deleted file mode 100644
index 3bd20933..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapCacheModel.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-
-class TSqlMapCacheModel extends TComponent
-{
- private $_cache;
-// private $_flushInterval = -1;
- private $_hits = 0;
- private $_requests = 0;
- private $_id;
-// private $_lastFlush;
- private $_implementation;
- private $_properties = array();
-
-
- public function getID(){ return $this->_id; }
- public function setID($value){ $this->_id = $value; }
-
- public function getImplementation(){ return $this->_implementation; }
- public function setImplementation($value){ $this->_implementation = $value; }
-
-// public function getFlushInterval(){ return $this->_flushInterval; }
-// public function setFlushInterval($value){ $this->_flushInterval = $value; }
-
- public function initialize($sqlMap)
- {
- $implementation = $this->getImplementationClass(
- $sqlMap->getTypeHandlerFactory());
- $this->_cache = new $implementation;
- $this->_cache->configure($this, $this->_properties);
- }
-
- protected function getImplementationClass($typeFactory)
- {
- switch(strtolower($this->_implementation))
- {
- case 'fifo': return 'TSqlMapFifoCache';
- case 'lru' : return 'TSqlMapLruCache';
- case 'basic' : return 'TSqlMapApplicationCache';
- }
-
- if(class_exists($this->_implementation, false))
- $class = $this->_implementation;
- else
- $class = $typeFactory->getTypeHandler($this->_implementation);
- if(!is_null($class))
- return $class;
- else
- throw new TSqlMapConfigurationException(
- 'sqlmap_unable_to_find_implemenation', $this->_implementation);
- }
-
- public function addProperty($name, $value)
- {
- $this->_properties[strtolower($name)] = $value;
- }
-
- public function registerTriggerStatement($mappedStatement)
- {
- $mappedStatement->attachEventHandler('OnExecuteQuery',
- array($this, 'flushHandler'));
- }
-
- protected function flushHandler($sender, $param)
- {
- $this->flush();
- }
-
- public function flush()
- {
- $this->_cache->flush();
- }
-
- public function get($key)
- {
- if($key instanceof TSqlMapCacheKey)
- $key = $key->getHash();
-
- //if flush ?
- $value = $this->_cache->get($key);
- $this->_requests++;
- if(!is_null($value))
- $this->_hits++;
- return $value;
- }
-
- public function set($key, $value)
- {
- if($key instanceof TSqlMapCacheKey)
- $key = $key->getHash();
-
- if(!is_null($value))
- $this->_cache->set($key, $value);
- }
-
- public function getHitRatio()
- {
- if($this->_requests != 0)
- return $this->_hits / $this->_requests;
- else
- return 0;
- }
-}
-
-
-class TSqlMapCacheKey
-{
- private $_key;
-
- public function __construct($object)
- {
- $this->_key = $this->generateKey(serialize($object));
- }
-
- protected function generateKey($string)
- {
- return sprintf('%x',crc32($string));
- }
-
- public function getHash()
- {
- return $this->_key;
- }
-
- public function __toString()
- {
- return $this->getHash();
- }
-}
-
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapConditionalTag.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapConditionalTag.php
deleted file mode 100644
index dfb98223..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapConditionalTag.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-
-/**
- * TSqlMapConditionalTag class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package System.DataAccess.SQLMap.Configuration
- * @since 3.0
- */
-class TSqlMapConditionalTag extends TComponent
-{
- public static $ConditionalChecks = array
- (
- 'isEqual', 'isNotEqual',
- 'isGreaterThan', 'isGreaterEqual',
- 'isLessThan', 'isLessEqual'
- );
-
- public static $UnaryChecks = array
- (
- 'isNull', 'isNotNull',
- 'isEmpty', 'isNotEmpty'
- );
-
- public static $ParameterChecks = array
- (
- 'isPropertyAvailable', 'isPropertyNotAvailable',
- 'isParameterPresent', 'isParameterNotPresent'
- );
-
- private $_tagName;
- private $_prepend='';
- private $_property;
- private $_propertyType = 'string';
- private $_compareProperty;
- private $_compareValue;
-
- public function getTagName(){ return $this->_tagName; }
- public function setTagName($value){ $this->_tagName = $value; }
-
- public function getPrepend(){ return $this->_prepend; }
- public function setPrepend($value){ $this->_prepend = $value; }
-
- public function getProperty(){ return $this->_property; }
- public function setProperty($value){ $this->_property = $value; }
-
- public function getCompareProperty(){ return $this->_compareProperty; }
- public function setCompareProperty($value){ $this->_compareProperty = $value; }
-
- public function getCompareValue(){ return $this->_compareValue; }
- public function setCompareValue($value){ $this->_compareValue = $value; }
-
- public function getPropertyType(){ return $this->_propertyType; }
- public function setPropertyType($value){ $this->_propertyType = $value; }
-
- /**
- * Evaluates the conditional tag, return true if satisfied, false otherwise.
- * @param object current conditional tag context.
- * @param object query parameter object.
- * @return boolean true if conditions are met, false otherwise.
- */
- public function evaluate($context, $parameter)
- {
- $value = $this->getPropertyValue($parameter, $this->getProperty());
- if(in_array($this->getTagName(), self::$UnaryChecks))
- return $this->evaluateUnary($context, $value);
- else if(in_array($this->getTagName(), self::$ConditionalChecks))
- {
- $comparee = $this->getComparisonValue($parameter);
- return $this->evaluateConditional($context, $value, $comparee);
- }
- else
- return $this->evaluateParameterCheck($context, $parameter);
- }
-
- protected function evaluateUnary($context, $value)
- {
- switch($this->getTagName())
- {
- case 'isNull':
- return is_null($value);
- case 'isNotNull':
- return !is_null($value);
- case 'isEmpty':
- return empty($value);
- case 'isNotEmpty':
- return !empty($value);
- }
- }
-
- protected function evaluateConditional($context, $valueA, $valueB)
- {
- switch($this->getTagName())
- {
- case 'isEqual': return $valueA == $valueB;
- case 'isNotEqual': return $valueA != $valueB;
- case 'isGreaterThan': return $valueA > $valueB;
- case 'isGreaterEqual': return $valueA >= $valueB;
- case 'isLessThan': return $valueA < $valueB;
- case 'isLessEqual': return $valueA <= $valueB;
- }
- }
-
- protected function evaluateParameterCheck($context, $parameter)
- {
- switch($this->getTagName())
- {
- case 'isPropertyAvailable': return TPropertyAccess::has(
- $parameter, $this->getProperty());
- case 'isPropertyAvailable': return TPropertyAccess::has(
- $parameter, $this->getProperty()) == false;
- case 'isParameterPresent': return !is_null($parameter);
- case 'isParameterNotPresent': return is_null($parameter);
- }
- }
-
- /**
- * @param object query parameter object.
- * @return mixed value for comparison.
- */
- protected function getComparisonValue($parameter)
- {
- if(strlen($property = $this->getCompareProperty()) > 0
- && (is_array($parameter) || is_object($parameter)))
- {
- $value = TPropertyAccess::get($parameter, $property);
- }
- else
- $value = $this->getCompareValue();
- return $this->ensureType($value);
- }
-
- /**
- * @param object query parameter object
- * @param string name of the property in the parameter object used for comparison.
- * @return mixed value for comparison.
- */
- protected function getPropertyValue($parameter, $property)
- {
- if(!is_null($property) && !is_null($parameter))
- {
- if(is_array($parameter) || is_object($parameter))
- return $this->ensureType(TPropertyAccess::get($parameter, $property));
- else
- return $this->ensureType($parameter);
- }
- else
- return null;
- }
-
- /**
- * @param string property value
- * @return mixed enforces property value to type given by {@link getPropertyType PropertyType}.
- */
- protected function ensureType($value)
- {
- switch(strtolower($this->getPropertyType()))
- {
- case 'boolean':
- return TPropertyValue::ensureBoolean($value);
- case 'integer': case 'int':
- return TPropertyValue::ensureInteger($value);
- case 'float': case 'double':
- return TPropertyValue::ensureFloat($value);
- case 'array':
- return TPropertyValue::ensureArray($value);
- case 'object':
- return TPropertyValue::ensureObject($value);
- default:
- return TPropertyValue::ensureString($value);
- }
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapDelete.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapDelete.php
deleted file mode 100644
index 9ca3843a..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapDelete.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-class TSqlMapDelete extends TSqlMapUpdate
-{
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapInsert.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapInsert.php
deleted file mode 100644
index c8d798c5..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapInsert.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-class TSqlMapInsert extends TSqlMapStatement
-{
- private $_selectKey=null;
- private $_generate=null;
-
- public function getSelectKey(){ return $this->_selectKey; }
- public function setSelectKey($value){ $this->_selectKey = $value; }
-
- public function getGenerate(){ return $this->_generate; }
- public function setGenerate($value){ $this->_generate = $value; }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapSelect.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapSelect.php
deleted file mode 100644
index b33bc27e..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapSelect.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-class TSqlMapSelect extends TSqlMapStatement
-{
- private $_generate;
-
- public function getGenerate(){ return $this->_generate; }
- public function setGenerate($value){ $this->_generate = $value; }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapSelectKey.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapSelectKey.php
deleted file mode 100644
index b73d4ef0..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapSelectKey.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-class TSqlMapSelectKey extends TSqlMapStatement
-{
- private $_type = 'post';
- private $_property = '';
-
- public function getType(){ return $this->_type; }
- public function setType($value){ $this->_type = $value; }
-
- public function getProperty(){ return $this->_property; }
- public function setProperty($value){ $this->_property = $value; }
-
- public function setExtends($value)
- {
- throw new TSqlMapConfigurationException(
- 'sqlmap_can_not_extend_select_key');
- }
-
- public function getIsAfter()
- {
- return $this->_type == 'post';
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapStatement.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapStatement.php
deleted file mode 100644
index 414ad2f1..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapStatement.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-class TSqlMapStatement extends TComponent
-{
- private $_ID='';
- private $_parameterMapName='';
- private $_parameterMap;
- private $_parameterClassName='';
-// private $_parameterClass;
- private $_resultMapName='';
- private $_resultMap;
- private $_resultClassName='';
-// private $_resultClass;
- private $_cacheModelName='';
- private $_remapResults=false;
- private $_SQL='';
- private $_listClass='';
- private $_typeHandler;
- private $_extendStatement='';
- private $_cache;
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getParameterMap(){ return $this->_parameterMapName; }
- public function setParameterMap($value){ $this->_parameterMapName = $value; }
-
- public function getParameterClass(){ return $this->_parameterClassName; }
- public function setParameterClass($value){ $this->_parameterClassName = $value; }
-
- public function getResultMap(){ return $this->_resultMapName; }
- public function setResultMap($value){ $this->_resultMapName = $value; }
-
- public function getResultClass(){ return $this->_resultClassName; }
- public function setResultClass($value){ $this->_resultClassName = $value; }
-
- public function getCacheModel(){ return $this->_cacheModelName; }
- public function setCacheModel($value){ $this->_cacheModelName = $value; }
-
- public function getCache(){ return $this->_cache; }
- public function setCache($value){ $this->_cache = $value; }
-
- public function getRemapResults(){ return $this->_remapResults; }
- public function setRemapResults($value){ $this->_remapResults = TPropertyValue::ensureBoolean($value,false); }
-
- public function getSQL(){ return $this->_SQL; }
- public function setSQL($value){ $this->_SQL = $value; }
-
- public function getListClass(){ return $this->_listClass; }
- public function setListClass($value){ $this->_listClass = $value; }
-
- public function getExtends(){ return $this->_extendStatement; }
- public function setExtends($value){ $this->_extendStatement = $value; }
-
- public function resultMap(){ return $this->_resultMap; }
- public function parameterMap(){ return $this->_parameterMap; }
-
- public function setInlineParameterMap($map)
- {
- $this->_parameterMap = $map;
- }
-// public function parameterClass(){ return $this->_parameterClass; }
-// public function resultClass(){ return $this->_resultClass; }
-
- public function initialize($sqlMap)
- {
- $this->_typeHandler = $sqlMap->getTypeHandlerFactory();
- if(strlen($this->_resultMapName) > 0)
- $this->_resultMap = $sqlMap->getResultMap($this->_resultMapName);
- if(strlen($this->_parameterMapName) > 0)
- $this->_parameterMap = $sqlMap->getParameterMap($this->_parameterMapName);
- }
-
-
- public function createInstanceOfListClass()
- {
- if(strlen($type = $this->getListClass()) > 0)
- return $this->createInstanceOf($type);
- return array(); //new TList;
- }
-
- protected function createInstanceOf($type,$row=null)
- {
- $handler = $this->_typeHandler->getTypeHandler($type);
-
- try
- {
- if(!is_null($handler))
- return $handler->createNewInstance($row);
- else
- return TTypeHandlerFactory::createInstanceOf($type);
- }
- catch (TDataMapperException $e)
- {
- throw new TSqlMapExecutionException(
- 'sqlmap_unable_to_create_new_instance',
- $type, get_class($handler), $this->getID());
- }
-
- }
-
- public function createInstanceOfResultClass($row)
- {
- if(strlen($type= $this->getResultClass()) > 0)
- return $this->createInstanceOf($type,$row);
- }
-}
-
-?> \ No newline at end of file
diff --git a/framework/DataAccess/SQLMap/Configuration/TSqlMapUpdate.php b/framework/DataAccess/SQLMap/Configuration/TSqlMapUpdate.php
deleted file mode 100644
index 26d00e39..00000000
--- a/framework/DataAccess/SQLMap/Configuration/TSqlMapUpdate.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-class TSqlMapUpdate extends TSqlMapStatement
-{
- private $_generate;
-
- public function getGenerate(){ return $this->_generate; }
- public function setGenerate($value){ $this->_generate = $value; }
-}
-
-?> \ No newline at end of file