Author: dr
Date: Mon Mar  3 15:47:53 2008
New Revision: 7499

Log:
- Added missing files.
#- Some of those might not be needed actually, will remove them later.

Added:
    trunk/Search/src/abstraction/implementations/find_solr.php   (with props)
    trunk/Search/src/abstraction/query.php   (with props)
    trunk/Search/src/abstraction/query_tools.php   (with props)
    trunk/Search/src/exceptions/transaction.php   (with props)
    trunk/Search/src/handlers/delete_handler.php   (with props)
    trunk/Search/src/handlers/find_handler.php   (with props)

Added: trunk/Search/src/abstraction/implementations/find_solr.php
==============================================================================
--- trunk/Search/src/abstraction/implementations/find_solr.php (added)
+++ trunk/Search/src/abstraction/implementations/find_solr.php [iso-8859-1] Mon 
Mar  3 15:47:53 2008
@@ -1,0 +1,155 @@
+<?php
+class ezcSearchFindQuerySolr implements ezcSearchFindQuery
+{
+    /**
+     * Holds the expression object
+     *
+     * @var ezcSearchExpression
+     */
+    public $expr;
+
+    /**
+     * Holds the columns to return in the search result
+     *
+     * @var array
+     */
+    public $resultFields;
+
+    public $whereClauses;
+
+    public $handler;
+    public $definition;
+
+    /**
+     * Constructs a new ezcSearchFindQuerySolr object
+     */
+    public function __construct( $handler, $definition = null )
+    {
+        $this->handler = $handler;
+        $this->definition = $definition;
+        $this->resultFields = array();
+    }
+
+    public function reset()
+    {
+        $this->resultFields = array();
+    }
+
+    public function select()
+    {
+        $args = func_get_args();
+        $cols = ezcSearchQueryTools::arrayFlatten( $args );
+        $this->resultFields = array_merge( $this->resultFields, $cols );
+        return $this;
+    }
+
+    public function where( $clause )
+    {
+        $this->whereClauses[] = $clause;
+        return $this;
+    }
+
+    public function limit( $limit, $offset = '' )
+    {
+    }
+
+    public function orderBy( $column, $type = ezcSearchQueryTools::ASC )
+    {
+    }
+
+    public function getQuery()
+    {
+    }
+
+    /**
+     * Returns a string containing a field/value specifier
+     *
+     * @param string $field
+     * @param mixed $value
+     *
+     * @return string
+     */
+    public function eq( $field, $value )
+    {
+        $field = trim( $field );
+
+        $value = $this->handler->mapFieldValue( $value );
+
+        if ( $this->definition && isset( $this->definition->fields[$field] ) )
+        {
+            $field = $this->handler->mapFieldType( $field, 
$this->definition->fields[$field]->type );
+        }
+
+        $ret = "$field:$value";
+
+        if ( $this->definition && isset( $this->definition->fields[$field] ) 
&& $this->definition->fields[$field]->boost != 1 )
+        {
+            $ret .= "^{$this->definition->fields[$field]->boost}";
+        }
+        return $ret;
+    }
+
+    /**
+     * Returns a string containing a field/value specifier
+     *
+     * @param string $field
+     * @param mixed $value
+     *
+     * @return string
+     */
+    public function between( $field, $value1, $value2 )
+    {
+        $field = trim( $field );
+
+        $value1 = $this->handler->mapFieldValue( $value1 );
+        $value2 = $this->handler->mapFieldValue( $value2 );
+
+        if ( $this->definition && isset( $this->definition->fields[$field] ) )
+        {
+            $field = $this->handler->mapFieldType( $field, 
$this->definition->fields[$field]->type );
+        }
+
+        $ret = "$field:[$value1 TO $value2]";
+
+        if ( $this->definition && isset( $this->definition->fields[$field] ) 
&& $this->definition->fields[$field]->boost != 1 )
+        {
+            $ret .= "^{$this->definition->fields[$field]->boost}";
+        }
+        return $ret;
+    }
+
+    public function lOr( $clause1, $clause2 )
+    {
+        return "($clause1 OR $clause2)";
+    }
+
+    public function lAnd( $clause1, $clause2 )
+    {
+        return "($clause1 AND $clause2)";
+    }
+
+    public function not( $clause )
+    {
+        return "!$clause";
+    }
+
+    public function important( $clause )
+    {
+        return "+$clause";
+    }
+
+    public function boost( $clause, $boostFactor )
+    {
+        return "$clause^$boostFactor";
+    }
+
+    public function fuzz( $clause, $fuzzFactor = false )
+    {
+        if ( $fuzzFactor )
+        {
+            return "$clause~$fuzzFactor";
+        }
+        return "$clause~";
+    }
+}
+?>

Propchange: trunk/Search/src/abstraction/implementations/find_solr.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Search/src/abstraction/query.php
==============================================================================
--- trunk/Search/src/abstraction/query.php (added)
+++ trunk/Search/src/abstraction/query.php [iso-8859-1] Mon Mar  3 15:47:53 2008
@@ -1,0 +1,106 @@
+<?php
+/**
+ * File containing the ezcSearchFindQuery class.
+ *
+ * @package Search
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Class to create select search backend indepentent search queries.
+ *
+ * @package Search
+ * @version //autogentag//
+ * @mainclass
+ */
+interface ezcSearchQuery
+{
+    public function __construct( $handler, $definition = null );
+
+    /**
+     * Resets the query object for reuse.
+     *
+     * @return void
+     */
+    public function reset();
+
+    /**
+     * Adds a where clause with logical expressions to the query.
+     *
+     * where() accepts an arbitrary number of parameters. Each parameter
+     * must contain a logical expression or an array with logical expressions.
+     * If you specify multiple logical expression they are connected using
+     * a logical and.
+     *
+     * Multiple calls to where() will join the expressions using a logical and.
+     *
+     * Example:
+     * <code>
+     * $q->select( '*' )->from( 'table' )->where( $q->expr->eq( 'id', 1 ) );
+     * </code>
+     *
+     * @throws ezcQueryVariableParameterException if called with no parameters.
+     * @param string|array(string) $... Either a string with a logical 
expression name
+     * or an array with logical expressions.
+     * @return ezcQuerySelect
+     */
+    public function where( $clause );
+
+    /**
+     * Returns SQL that limits the result set.
+     *
+     * $limit controls the maximum number of rows that will be returned.
+     * $offset controls which row that will be the first in the result
+     * set from the total amount of matching rows.
+     *
+     * Example:
+     * <code>
+     * $q->select( '*' )->from( 'table' )
+     *                  ->limit( 10, 0 );
+     * </code>
+     *
+     * LIMIT is not part of SQL92. It is implemented here anyway since all
+     * databases support it one way or the other and because it is
+     * essential.
+     *
+     * @param string $limit integer expression
+     * @param string $offset integer expression
+     * @return ezcQuerySelect
+     */
+    public function limit( $limit, $offset = '' );
+
+    /**
+     * Returns SQL that orders the result set by a given column.
+     *
+     * You can call orderBy multiple times. Each call will add a
+     * column to order by.
+     *
+     * Example:
+     * <code>
+     * $q->select( '*' )->from( 'table' )
+     *                  ->orderBy( 'id' );
+     * </code>
+     *
+     * @param string $column a column name in the result set
+     * @param string $type if the column should be sorted ascending or 
descending.
+     *        you can specify this using ezcQuerySelect::ASC or 
ezcQuerySelect::DESC
+     * @return ezcQuery a pointer to $this
+     */
+    public function orderBy( $column, $type = self::ASC );
+
+    /**
+     * Returns the complete select query string.
+     *
+     * This method uses the build methods to build the
+     * various parts of the select query.
+     *
+     * @todo add newlines? easier for debugging
+     * @throws ezcQueryInvalidException if it was not possible to build a 
valid query.
+     * @return string
+     */
+    public function getQuery();
+}
+
+?>

Propchange: trunk/Search/src/abstraction/query.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Search/src/abstraction/query_tools.php
==============================================================================
--- trunk/Search/src/abstraction/query_tools.php (added)
+++ trunk/Search/src/abstraction/query_tools.php [iso-8859-1] Mon Mar  3 
15:47:53 2008
@@ -1,0 +1,51 @@
+<?php
+/**
+ * File containing the ezcSearchQuery class.
+ *
+ * @package Search
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * The ezcSearchQuery class provides the common API for all Query objects.
+ *
+ * Subclasses should provide functionality to build an actual query.
+ *
+ * @package Search
+ * @version //autogentag//
+ * @private
+ */
+class ezcSearchQueryTools
+{
+    const ASC = 1;
+    const DESC = 2;
+
+    /**
+     * Returns all the elements in $array as one large single dimensional 
array.
+     *
+     * @todo public? Currently this is needed for QueryExpression.
+     * @param array $array
+     * @return array
+     */
+    static public function arrayFlatten( array $array )
+    {
+        $flat = array();
+        foreach ( $array as $arg )
+        {
+            switch ( gettype( $arg ) )
+            {
+                case 'array':
+                    $flat = array_merge( $flat, $arg );
+                    break;
+
+                default:
+                    $flat[] = $arg;
+                    break;
+            }
+        }
+        return $flat;
+    }
+}
+?>

Propchange: trunk/Search/src/abstraction/query_tools.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Search/src/exceptions/transaction.php
==============================================================================
--- trunk/Search/src/exceptions/transaction.php (added)
+++ trunk/Search/src/exceptions/transaction.php [iso-8859-1] Mon Mar  3 
15:47:53 2008
@@ -1,0 +1,27 @@
+<?php
+/**
+ * File containing the ezcSearchTransactionException class.
+ *
+ * @package Search
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * This exception is thrown in case something with a transaction goes wrong.
+ *
+ * @package Search
+ * @version //autogentag//
+ */
+class ezcSearchTransactionException extends ezcSearchException
+{
+    /**
+     * Constructs an ezcSearchTransactionException
+     */
+    public function __construct( $message )
+    {
+        parent::__construct( $message );
+    }
+}
+?>

Propchange: trunk/Search/src/exceptions/transaction.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Search/src/handlers/delete_handler.php
==============================================================================
--- trunk/Search/src/handlers/delete_handler.php (added)
+++ trunk/Search/src/handlers/delete_handler.php [iso-8859-1] Mon Mar  3 
15:47:53 2008
@@ -1,0 +1,25 @@
+<?php
+/**
+ * File containing the ezcSearchDeleteHandler class.
+ *
+ * @package Search
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Helper class for ezcSearchSession to handle document indexing.
+ *
+ * An instance of this class is used internally in [EMAIL PROTECTED] 
ezcSearchSession}
+ * and takes care for indexing documents.
+ * 
+ * @package Search
+ * @version //autogen//
+ * @access private
+ */
+class ezcSearchDeleteHandler
+{
+}
+
+?>

Propchange: trunk/Search/src/handlers/delete_handler.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/Search/src/handlers/find_handler.php
==============================================================================
--- trunk/Search/src/handlers/find_handler.php (added)
+++ trunk/Search/src/handlers/find_handler.php [iso-8859-1] Mon Mar  3 15:47:53 
2008
@@ -1,0 +1,25 @@
+<?php
+/**
+ * File containing the ezcSearchFindHandler class.
+ *
+ * @package Search
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Helper class for ezcSearchSession to handle document indexing.
+ *
+ * An instance of this class is used internally in [EMAIL PROTECTED] 
ezcSearchSession}
+ * and takes care for indexing documents.
+ * 
+ * @package Search
+ * @version //autogen//
+ * @access private
+ */
+class ezcSearchFindHandler
+{
+}
+
+?>

Propchange: trunk/Search/src/handlers/find_handler.php
------------------------------------------------------------------------------
    svn:eol-style = native


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to