BUG 0000 herbert> SOLR implementation in PMOS2

Solr support in PMOS2 includes:
Functionality:
- Implementation of Home views (Inbox, Draft, Participated, Unassigned). The views return fast results.
- Include read, unread, all,  and process filter in inbox View.
- Include process filter in draft view.
- Include started by me, completed by me, all, process, and status filter in participated view.
- Include process filter in unassigned view.
- Improved search functionality (search in user defined variables): Use the following syntax to search in process (user defined) variables. {variable_name}:{search_word} ex1:"causal:20*" where causal is the variable defined by the user.
  + Use of wildcards in search: Use * as wildcard at the begin or end of word
  + Multiple conditions in search: Separate multiple conditions by space ex2:"Materiales causal:20*" means that we are searching for the word Materiales and the causal that begin with 20.
  + Search in dates (interval ): Format=> {variable_date}:[yyyy-mm-dd TO yyyy-mm-dd]
    Local date not UTC date required
    ex: FechaRegistro:[2011-04-15 TO 2011-04-30] //registros con fecha entre el 2011-04-15 y el 2011-04-30.
  + we can use the wildcard *:
    ex: FechaRegistro:[* TO 2011-04-30] //registros con fecha menor o igual a 2011-04-30.
    FechaRegistro:[2011-04-15 TO *] //registros con fecha mayor o igual a 2011-04-15.
  + Search of exact phrases. format: {variable}:"frase a buscar"
    ex: Cliente:"Jesus Marin"

- Application update function.
	+ The function is called every time a change is detected in the application's data including the related delegations.
- Use of cache to improve performance

Not included:
- Order of task, sent by, and due date columns.

Pending:
- Advanced search view using faceted lists.
This commit is contained in:
Erik Amaru Ortiz
2012-05-15 10:56:48 -04:00
parent 444b745536
commit 1a8545df8a
29 changed files with 5198 additions and 126 deletions

View File

@@ -0,0 +1,35 @@
<?php
require_once ('Base.php');
/**
* Application Solr Queue
*/
class Entity_AppSolrQueue extends Entity_Base {
public $appUid = '';
public $appUpdated = 0;
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_AppSolrQueue ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_AppSolrQueue ();
$obj->initializeObject ( $data );
$requiredFields = array (
"appUid",
"appUpdated"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,135 @@
<?php
class Entity_Base {
/**
* this function check if a field is in the data sent in the constructor
* you can specify an array, and this function will use like alias
*/
protected function validateField($field, $default = false) {
$fieldIsEmpty = true;
// this is a trick, if $fields is a string, $fields will be an array with
// one element
if (is_array ( $field )) {
$fields = $field;
}
else {
$fields = array ();
$fields [] = $field;
}
// if there are aliases for this field, evaluate all aliases and take the
// first occurence
foreach ( $fields as $k => $f ) {
if (isset ( $this->temp [$f] )) {
$fieldIsEmpty = false;
return $this->temp [$f];
}
}
// field empty means the user has not sent a value for this Field, so we are
// using the default value
if ($fieldIsEmpty) {
if ($default !== false) {
return $default;
}
}
}
protected function validateRequiredFields($requiredFields = array()) {
foreach ( $requiredFields as $k => $field ) {
if ($this->{$field} === NULL) {
throw (new Zend_Exception ( "Field $field is required in " . get_class ( $this ) ));
die ();
}
}
}
/**
*
*
* Copy the values of the Entity to the array of aliases
* The array of aliases must be defined.
*
* @return Array of alias with the Entity values
*/
public function getAliasDataArray() {
$aAlias = array ();
// get aliases from class
$className = get_class ( $this );
if (method_exists ( $className, 'GetAliases' )) {
$aliases = $className::GetAliases ();
foreach ( $this as $field => $value )
if (isset ( $aliases [$field] )) {
// echo "Field exists in Aliases: " . $field . "\n";
// echo "Alias Name:" . $aliases[$field] . "\n";
// echo "Alias value:" . $value . "\n";
$aAlias [$aliases [$field]] = $value;
}
}
return $aAlias;
}
/**
*
*
* Set the data from array of alias to Entity
*
* @param $aAliasData array
* of data of aliases
*/
public function setAliasDataArray($aAliasData) {
// get aliases from class
$className = get_class ( $this );
if (method_exists ( $className, 'GetAliases' )) {
$aliases = $className::GetAliases ();
foreach ( $this as $field => $value )
if (isset ( $aliases [$field] ))
$this->{$field} = $aAliasData [$aliases [$field]];
}
}
/**
*
*
* Initialize object with values from $data.
* The values from data use properties or alias array.
*
* @param
* $data
*/
protected function initializeObject($data) {
// get aliases from class
$className = get_class ( $this );
$aliases = array ();
$swAliases = false;
if (method_exists ( $className, 'GetAliases' )) {
$aliases = $className::GetAliases ();
$swAliases = true;
}
// use object properties or aliases to initialize
foreach ( $this as $field => $value )
if (isset ( $data [$field] )) {
$this->$field = $data [$field];
}
elseif ($swAliases && isset ( $aliases [$field] ) && isset ( $data [$aliases [$field]] )) {
$this->$field = $data [$aliases [$field]];
}
}
public function serialize() {
if (isset ( $this->temp ))
unset ( $this->temp );
return serialize ( $this );
}
public function unserialize($str) {
$className = get_class ( $this );
$data = unserialize ( $str );
return new $className ( $data );
}
}

View File

@@ -0,0 +1,49 @@
<?php
require_once ('Base.php');
/**
*
*
* Facet group entity that represent a facet group
*
* @property $facetGroupName: The name of the facet (field name in solr index)
* @property $facetGroupPrintName: The print name of the facet (Human readable
* description)
* @property $facetGroupType: The type of facet group, field, daterange, filter,
* range
* @property $facetGroupId: An identifier to find group information
* @property $facetItems: array of facet items
* @author dev-HebertSaak
*
*/
class Entity_FacetGroup extends Entity_Base {
public $facetGroupName = '';
public $facetGroupPrintName = '';
public $facetGroupType = ''; // field, daterange, query
public $facetGroupId = '';
public $facetItems = array ();
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetGroup ();
return $obj;
}
static function CreateForInsert($data) {
$obj = new Entity_FacetGroup ();
$obj->initializeObject ( $data );
$requiredFields = array (
"facetGroupName",
"facetItems"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,36 @@
<?php
require_once ('Base.php');
class Entity_FacetInterfaceRequest extends Entity_Base {
public $searchText = '';
public $selectedFacetsString = ''; // string of selected facet groups and
// items in format:
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
// groupkey3::groupdesc3:::itemkey3::itemdesc3
// var $selectedFacetFields = array();
// var $selectedFacetTypes = array();
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetInterfaceRequest ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_FacetInterfaceRequest ();
$obj->initializeObject ( $data );
$requiredFields = array (
"searchText",
"selectedFacetsString"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,35 @@
<?php
require_once ('Base.php');
class Entity_FacetInterfaceResult extends Entity_Base {
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
public $aFacetGroup = array ();
public $aSelectedFacetGroupItem = array ();
public $sFilterText = '';
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetInterfaceResult ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_FacetInterfaceResult ();
$obj->initializeObject ( $data );
$requiredFields = array (
"aFacetGroup",
"aSelectedFacetGroupItem",
"sFilterText"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,42 @@
<?php
require_once ('Base.php');
/**
*
*
* Entity Face item, represent an option in a facet group
*
* @author dev-HebertSaak
*
*/
class Entity_FacetItem extends Entity_Base {
public $facetName = '';
public $facetPrintName = '';
public $facetCount = '';
public $facetSelectCondition = ''; // selected condition used to select
// this facet
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetItem ();
return $obj;
}
static function CreateForInsert($data) {
$obj = new Entity_FacetItem ();
$obj->initializeObject ( $data );
$requiredFields = array (
"facetName",
"facetCount"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,39 @@
<?php
require_once ('Base.php');
class Entity_FacetRequest extends Entity_Base {
public $workspace = '';
public $searchText = '';
public $facetFields = array ();
public $facetQueries = array ();
public $facetDates = array ();
public $facetDatesStart = '';
public $facetDatesEnd = '';
public $facetDateGap = '';
public $facetRanges = array ();
public $filters = array ();
public $selectedFacetsString = '';
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetRequest ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_FacetRequest ();
$obj->initializeObject ( $data );
$requiredFields = array (
"workspace"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,33 @@
<?php
require_once ('Base.php');
class Entity_FacetResult extends Entity_Base {
public $aFacetGroups = array ();
public $aSelectedFacetGroups = array ();
public $sFilterText = '';
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_FacetResult ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_FacetResult ();
$obj->initializeObject ( $data );
$requiredFields = array (
"aFacetGroups",
"aSelectedFacetGroups",
"sFilterText"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,36 @@
<?php
require_once ('Base.php');
class Entity_SelectedFacetGroupItem extends Entity_Base {
public $selectedFacetGroupName = '';
public $selectedFacetGroupPrintName = '';
public $selectedFacetItemName = '';
public $selectedFacetItemPrintName = '';
public $selectedFacetRemoveCondition = ''; // remove condition, string of
// selected facets without this
// facet
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_SelectedFacetGroupItem ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_SelectedFacetGroupItem ();
$obj->initializeObject ( $data );
$requiredFields = array (
"selectedFacetGroupName",
"selectedFacetItemName"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,36 @@
<?php
require_once ('Base.php');
class Entity_SolrQueryResult extends Entity_Base {
public $sEcho = '';
public $iTotalRecords = 0;
public $iTotalDisplayRecords = 10;
public $aaData = array (); // array of arrays of records to
// display
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_SolrQueryResult ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_SolrQueryResult ();
$obj->initializeObject ( $data );
$requiredFields = array (
'sEcho',
'iTotalRecords',
'iTotalDisplayRecords',
'aaData'
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,42 @@
<?php
require_once ('Base.php');
class Entity_SolrRequestData extends Entity_Base {
public $workspace = '';
public $startAfter = 0;
public $pageSize = 10;
public $searchText = '*:*';
public $filterText = ''; // comma separated list of filters field:value
public $numSortingCols = 0; // number of columns that are sorted
public $sortableCols = array (); // array of booleans indicating if column is
// sortable (true, false)
public $sortCols = array (); // array of indices of sorted columns index
// based in the total number of sorting cols
public $sortDir = array (); // array of direction of sorting for each
// column (desc, asc)
public $includeCols = array ();
public $resultFormat = 'xml'; // json, xml, php
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_SolrRequestData ();
return $obj;
}
static function CreateForRequestPagination($data) {
$obj = new Entity_SolrRequestData ();
$obj->initializeObject ( $data );
$requiredFields = array (
'workspace'
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}

View File

@@ -0,0 +1,31 @@
<?php
require_once ('Base.php');
class Entity_SolrUpdateDocument extends Entity_Base {
var $workspace = '';
var $document = '';
private function __construct() {
}
static function CreateEmpty() {
$obj = new Entity_SolrUpdateDocument ();
return $obj;
}
static function CreateForRequest($data) {
$obj = new Entity_SolrUpdateDocument ();
$obj->initializeObject ( $data );
$requiredFields = array (
"workspace",
"document"
);
$obj->validateRequiredFields ( $requiredFields );
return $obj;
}
}