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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
<?php
/**
* class.memcached.php
* @package workflow.engine.ProcessMaker
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
class FileCache {
function __construct($dir) {
$this->dir = $dir;
}
private function _name($key) {
return sprintf ( "%s/%s", $this->dir, sha1 ( $key ) );
}
public function get($key, $expiration = 3600) {
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
return FALSE;
}
$cache_path = $this->_name ( $key );
if (! @file_exists ( $cache_path )) {
return FALSE;
}
if (filemtime ( $cache_path ) < (time () - $expiration)) {
// $this->clear($key);
// different users can have different timeout requests
return FALSE;
}
if (! $fp = @fopen ( $cache_path, 'rb' )) {
return FALSE;
}
flock ( $fp, LOCK_SH );
$cache = '';
if (filesize ( $cache_path ) > 0) {
$cache = unserialize ( fread ( $fp, filesize ( $cache_path ) ) );
}
else {
$cache = NULL;
}
flock ( $fp, LOCK_UN );
fclose ( $fp );
return $cache;
}
public function set($key, $data) {
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
return FALSE;
}
$cache_path = $this->_name ( $key );
if (! $fp = fopen ( $cache_path, 'wb' )) {
return FALSE;
}
if (flock ( $fp, LOCK_EX )) {
fwrite ( $fp, serialize ( $data ) );
flock ( $fp, LOCK_UN );
}
else {
return FALSE;
}
fclose ( $fp );
@chmod ( $cache_path, 0777 );
return TRUE;
}
public function clear($key) {
$cache_path = $this->_name ( $key );
if (file_exists ( $cache_path )) {
unlink ( $cache_path );
return TRUE;
}
return FALSE;
}
}

View File

@@ -24,131 +24,164 @@
*
*/
/**
* The ProcessMaker memcached class
*
* @package workflow.engine.ProcessMaker
*/
class PMmemcached {
const ONE_MINUTE = 60;
const ONE_HOUR = 3600;
const TWO_HOURS = 7200;
const EIGHT_HOURS = 28800;
var $version;
var $mem;
var $connected = false;
var $enabled = false;
var $supported = false;
static private $instance = NULL;
private function __construct( $workspace ) {
$this->enabled = MEMCACHED_ENABLED;
$this->connected = false;
$this->workspace = $workspace;
if (class_exists('Memcached')) {
$this->mem = new Memcached();
$this->class = 'Memcached';
}
else {
if (class_exists('Memcache')) {
$this->mem = new Memcache();
$this->class = 'Memcache';
$this->supported = true;
$this->connected = @$this->mem->connect( MEMCACHED_SERVER , 11211);
if ( $this->connected ) {
$this->version = $this->mem->getVersion();
}
class PMmemcached {
const ONE_MINUTE = 60;
const ONE_HOUR = 3600;
const TWO_HOURS = 7200;
const EIGHT_HOURS = 28800;
var $version;
var $mem;
var $connected = false;
var $enabled = false;
var $supported = false;
private static $instance = NULL;
private function __construct($workspace) {
$this->enabled = MEMCACHED_ENABLED;
$this->connected = false;
$this->workspace = $workspace;
if (class_exists ( 'Memcached' )) {
$this->mem = new Memcached ();
$this->class = 'Memcached';
$this->connected = true;
}
else {
if (class_exists ( 'Memcache' )) {
$this->mem = new Memcache ();
$this->class = 'Memcache';
$this->supported = true;
$this->connected = @$this->mem->connect ( MEMCACHED_SERVER, 11211 );
if ($this->connected) {
$this->version = $this->mem->getVersion ();
}
}
if ( ! MEMCACHED_ENABLED ) {
$this->connected = false;
return false;
}
}
/**
* to get singleton instance
*
* @access public
* @return object
*/
function &getSingleton( $workspace ) {
if (self::$instance == NULL) {
self::$instance = new PMmemcached( $workspace );
else {
G::Loadclass ( 'fileCache' );
// create cache folder
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
if (! file_exists ( $cacheFolder )) {
if (! mkdir ( $cacheFolder )) {
return false;
}
}
$this->class = 'fileCache';
$this->connected = true;
$this->mem = new FileCache ( $cacheFolder );
}
return self::$instance;
}
function set($key, $object, $timeout=0) {
if (! $this->connected ) return false;
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout) ;
}
function get($key) {
if (! $this->connected ) return false;
return $this->mem->get( $this->workspace . '_' . $key) ;
}
function add($key, $value ) {
if (! $this->connected ) return false;
return $this->mem->add( $this->workspace . '_' . $key, $value ) ;
}
function increment($key, $value ) {
if (! $this->connected ) return false;
return $this->mem->increment( $this->workspace . '_' . $key, $value ) ;
}
function delete($key) {
if (! $this->connected ) return false;
return $this->mem->delete( $this->workspace . '_' . $key) ;
}
function flush() {
if (! $this->connected ) return false;
return $this->mem->flush();
}
function getStats() {
if (! $this->connected ) return false;
return $status = $this->mem->getStats();
if (! MEMCACHED_ENABLED) {
$this->connected = false;
return false;
}
function printDetails() {
if (! $this->connected ) return false;
$status = $this->mem->getStats();
echo "<table border='1'>";
echo "<tr><td>Memcache Server version:</td><td> ".$status ["version"]."</td></tr>";
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status ["uptime"] /3660) ."</td></tr>";
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>".$status ["total_items"]."</td></tr>";
echo "<tr><td>Number of open connections </td><td>".$status ["curr_connections"]."</td></tr>";
echo "<tr><td>Total number of connections opened since the server started running </td><td>".$status ["total_connections"]."</td></tr>";
echo "<tr><td>Number of connection structures allocated by the server </td><td>".$status ["connection_structures"]."</td></tr>";
echo "<tr><td>Cumulative number of retrieval requests </td><td>".$status ["cmd_get"]."</td></tr>";
echo "<tr><td> Cumulative number of storage requests </td><td>".$status ["cmd_set"]."</td></tr>";
$percCacheHit=((real)$status ["get_hits"]/ (real)$status ["cmd_get"] *100);
$percCacheHit=round($percCacheHit,3);
$percCacheMiss=100-$percCacheHit;
echo "<tr><td>Number of keys that have been requested and found present </td><td>".$status ["get_hits"]." ($percCacheHit%)</td></tr>";
echo "<tr><td>Number of items that have been requested and not found </td><td>".$status ["get_misses"]."($percCacheMiss%)</td></tr>";
$MBRead= (real)$status["bytes_read"]/(1024*1024);
echo "<tr><td>Total number of bytes read by this server from network </td><td>".$MBRead." Mega Bytes</td></tr>";
$MBWrite=(real) $status["bytes_written"]/(1024*1024) ;
echo "<tr><td>Total number of bytes sent by this server to network </td><td>".$MBWrite." Mega Bytes</td></tr>";
$MBSize=(real) $status["limit_maxbytes"]/(1024*1024) ;
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>".$MBSize." Mega Bytes</td></tr>";
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>".$status ["evictions"]."</td></tr>";
echo "</table>";
}
/**
* to get singleton instance
*
* @access public
* @return object
*/
public static function getSingleton($workspace) {
if (! self::$instance instanceof self) {
self::$instance = new PMmemcached ( $workspace );
}
return self::$instance;
}
public function __clone() {
throw new Exception ( "Clone is not allowed." );
}
public function __wakeup() {
throw new Exception ( "Deserializing is not allowed." );
}
function set($key, $object, $timeout = 0) {
if (! $this->connected)
return false;
if ($this->class != 'filecache')
$this->mem->set ( $this->workspace . '_' . $key, $object, false, $timeout );
else
$this->mem->set ( $this->workspace . '_' . $key, $object );
}
function get($key) {
if (! $this->connected)
return false;
return $this->mem->get ( $this->workspace . '_' . $key );
}
function add($key, $value) {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
return $this->mem->add ( $this->workspace . '_' . $key, $value );
}
function increment($key, $value) {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
return $this->mem->increment ( $this->workspace . '_' . $key, $value );
}
function delete($key) {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
return $this->mem->delete ( $this->workspace . '_' . $key );
}
function flush() {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
return $this->mem->flush ();
}
function getStats() {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
return $status = $this->mem->getStats ();
}
function printDetails() {
if ((! $this->connected) || ($this->class == 'filecache'))
return false;
$status = $this->mem->getStats ();
echo "<table border='1'>";
echo "<tr><td>Memcache Server version:</td><td> " . $status ["version"] . "</td></tr>";
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status ["uptime"] / 3660) . "</td></tr>";
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>" . $status ["total_items"] . "</td></tr>";
echo "<tr><td>Number of open connections </td><td>" . $status ["curr_connections"] . "</td></tr>";
echo "<tr><td>Total number of connections opened since the server started running </td><td>" . $status ["total_connections"] . "</td></tr>";
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status ["connection_structures"] . "</td></tr>";
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status ["cmd_get"] . "</td></tr>";
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status ["cmd_set"] . "</td></tr>";
$percCacheHit = (( real ) $status ["get_hits"] / ( real ) $status ["cmd_get"] * 100);
$percCacheHit = round ( $percCacheHit, 3 );
$percCacheMiss = 100 - $percCacheHit;
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status ["get_hits"] . " ($percCacheHit%)</td></tr>";
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status ["get_misses"] . "($percCacheMiss%)</td></tr>";
$MBRead = ( real ) $status ["bytes_read"] / (1024 * 1024);
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
$MBWrite = ( real ) $status ["bytes_written"] / (1024 * 1024);
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";
$MBSize = ( real ) $status ["limit_maxbytes"] / (1024 * 1024);
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>" . $MBSize . " Mega Bytes</td></tr>";
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status ["evictions"] . "</td></tr>";
echo "</table>";
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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;
}
}

View File

@@ -0,0 +1,126 @@
<?php
require_once 'classes/model/om/BaseAppSolrQueue.php';
require_once 'classes/entities/AppSolrQueue.php';
/**
* Skeleton subclass for representing a row from the 'APP_SOLR_QUEUE' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class AppSolrQueue extends BaseAppSolrQueue {
public function exists($sAppUid)
{
try {
$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
if (!is_null($oRow))
{
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
return false;
}
}
public function createUpdate($sAppUid, $iUpdated)
{
$con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
try
{
if($this->exists($sAppUid)){
$con->begin();
//update record
//$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
//$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
//$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
//set field
$this->setAppUid($sAppUid);
$this->setAppUpdated($iUpdated);
if($this->validate())
{
$result=$this->save();
}
else
{
$con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
}
$con->commit();
return $result;
}else{
//create record
//set values
$this->setAppUid($sAppUid);
$this->setAppUpdated($iUpdated);
if($this->validate())
{
$result=$this->save();
}
else
{
$e=new Exception("Failed Validation in class ".get_class($this).".");
//$e->aValidationFailures=$this->getValidationFailures();
throw($e);
}
$con->commit();
return $result;
}
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
/**
* Returns the list of updated applications
* array of Entity_AppSolrQueue
*/
public function getListUpdatedApplications(){
$updatedApplications = array();
try
{
$c = new Criteria();
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
//"WHERE
$c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);
$rs = AppSolrQueuePeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
//echo $c->toString();
$rs->next();
$row = $rs->getRow();
while (is_array($row)) {
$appSolrQueue = Entity_AppSolrQueue::CreateEmpty();
$appSolrQueue->appUid = $row['APP_UID'];
$appSolrQueue->appUpdated = $row['APP_UPDATED'];
$updatedApplications[] = $appSolrQueue;
$rs->next();
$row = $rs->getRow();
}
return $updatedApplications;
}catch(Exception $e){
$con->rollback();
throw($e);
}
}
} // AppSolrQueue

View File

@@ -0,0 +1,23 @@
<?php
// include base peer class
require_once 'classes/model/om/BaseAppSolrQueuePeer.php';
// include object class
include_once 'classes/model/AppSolrQueue.php';
/**
* Skeleton subclass for performing query and update operations on the 'APP_SOLR_QUEUE' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class AppSolrQueuePeer extends BaseAppSolrQueuePeer {
} // AppSolrQueuePeer

View File

@@ -0,0 +1,73 @@
<?php
require_once 'propel/map/MapBuilder.php';
include_once 'creole/CreoleTypes.php';
/**
* This class adds structure of 'APP_SOLR_QUEUE' table to 'workflow' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package workflow.classes.model.map
*/
class AppSolrQueueMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'classes.model.map.AppSolrQueueMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('workflow');
$tMap = $this->dbMap->addTable('APP_SOLR_QUEUE');
$tMap->setPhpName('AppSolrQueue');
$tMap->setUseIdGenerator(false);
$tMap->addPrimaryKey('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('APP_UPDATED', 'AppUpdated', 'int', CreoleTypes::TINYINT, true, null);
} // doBuild()
} // AppSolrQueueMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff