CODE STYLE class.searchIndex.php
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
@@ -19,10 +19,8 @@
|
||||
*
|
||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class used as interface to have access to the search index services
|
||||
*
|
||||
@@ -34,7 +32,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
function __construct($solrIsEnabled = false, $solrHost = "")
|
||||
public function __construct ($solrIsEnabled = false, $solrHost = "")
|
||||
{
|
||||
// check if Zend Library is available
|
||||
// if(class_exists("Zend_Registry")){
|
||||
@@ -51,6 +49,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
$this->_solrHost = $solrHost;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
@@ -59,8 +58,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
*
|
||||
* no input parameters @param[in]
|
||||
*
|
||||
* @param
|
||||
* [out] bool true if index service is enabled false in other case
|
||||
* @param [out] bool true if index service is enabled false in other case
|
||||
*/
|
||||
public function isEnabled ()
|
||||
{
|
||||
@@ -77,10 +75,8 @@ class BpmnEngine_Services_SearchIndex
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param
|
||||
* [out] array FacetGroup
|
||||
* @param [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param [out] array FacetGroup
|
||||
*/
|
||||
public function getFacetsList ($facetRequestEntity)
|
||||
{
|
||||
@@ -99,10 +95,12 @@ class BpmnEngine_Services_SearchIndex
|
||||
$facetRequestEntity->selectedFacetsString = str_replace( ',,', ',', $facetRequestEntity->selectedFacetsString );
|
||||
// remove descriptions of selected facet groups
|
||||
|
||||
|
||||
$aGroups = explode( ',', $facetRequestEntity->selectedFacetsString );
|
||||
|
||||
$aGroups = array_filter( $aGroups ); // remove empty items
|
||||
|
||||
|
||||
$aSelectedFacetGroups = array ();
|
||||
foreach ($aGroups as $i => $value) {
|
||||
$gi = explode( ':::', $value );
|
||||
@@ -115,12 +113,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
if ($count == 0) {
|
||||
$removeCondition = str_replace( $value, '', $facetRequestEntity->selectedFacetsString, $count );
|
||||
}
|
||||
$selectedFacetGroupData = array (
|
||||
'selectedFacetGroupName' => $gr [0],
|
||||
'selectedFacetGroupPrintName' => $gr [1],
|
||||
'selectedFacetItemName' => $it [0],
|
||||
'selectedFacetItemPrintName' => $it [1],
|
||||
'selectedFacetRemoveCondition' => $removeCondition
|
||||
$selectedFacetGroupData = array ('selectedFacetGroupName' => $gr[0],'selectedFacetGroupPrintName' => $gr[1],'selectedFacetItemName' => $it[0],'selectedFacetItemPrintName' => $it[1],'selectedFacetRemoveCondition' => $removeCondition
|
||||
);
|
||||
|
||||
$aSelectedFacetGroups[] = Entity_SelectedFacetGroupItem::createForRequest( $selectedFacetGroupData );
|
||||
@@ -136,11 +129,9 @@ class BpmnEngine_Services_SearchIndex
|
||||
// exclude facetFields and facetDates included in filter from the next
|
||||
// list of facets
|
||||
foreach ($aSelectedFacetGroups as $value) {
|
||||
$facetRequestEntity->facetFields = array_diff ($facetRequestEntity->facetFields, array (
|
||||
$value->selectedFacetGroupName
|
||||
$facetRequestEntity->facetFields = array_diff( $facetRequestEntity->facetFields, array ($value->selectedFacetGroupName
|
||||
) );
|
||||
$facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
|
||||
$value->selectedFacetGroupName
|
||||
$facetRequestEntity->facetDates = array_diff( $facetRequestEntity->facetDates, array ($value->selectedFacetGroupName
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -174,8 +165,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||
if (count( $facetvalues ) > 0) // if the group have facets included
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
$data = array ('facetGroupName' => $facetGroup
|
||||
);
|
||||
$data['facetGroupPrintName'] = $facetGroup;
|
||||
$data['facetGroupType'] = 'field';
|
||||
@@ -206,8 +196,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
if (count( (array) $facetvalues ) > 3) // if the group have any facets included
|
||||
// besides start, end and gap
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
$data = array ('facetGroupName' => $facetGroup
|
||||
);
|
||||
$data['facetGroupPrintName'] = $facetGroup;
|
||||
$data['facetGroupType'] = 'daterange';
|
||||
@@ -220,8 +209,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// the last group
|
||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
@@ -255,14 +243,12 @@ class BpmnEngine_Services_SearchIndex
|
||||
$filterText = substr_replace( $filterText, '', - 1 );
|
||||
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create result
|
||||
$dataFacetResult = array (
|
||||
'aFacetGroups' => $facetGroups,
|
||||
'aSelectedFacetGroups' => $aSelectedFacetGroups,
|
||||
'sFilterText' => $filterText
|
||||
$dataFacetResult = array ('aFacetGroups' => $facetGroups,'aSelectedFacetGroups' => $aSelectedFacetGroups,'sFilterText' => $filterText
|
||||
);
|
||||
$facetResult = Entity_FacetResult::createForRequest( $dataFacetResult );
|
||||
|
||||
@@ -271,6 +257,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Get the total number of documents in search server
|
||||
*
|
||||
* @param string $workspace
|
||||
* @return integer number of documents
|
||||
*
|
||||
@@ -290,6 +277,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Update document Index
|
||||
*
|
||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||
*/
|
||||
public function updateIndexDocument ($solrUpdateDocumentEntity)
|
||||
@@ -304,6 +292,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Delete document from index
|
||||
*
|
||||
* @param string $workspace
|
||||
* @param string $idQuery
|
||||
*/
|
||||
@@ -319,6 +308,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Commit index changes
|
||||
*
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function commitIndexChanges ($workspace)
|
||||
@@ -333,6 +323,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Optimize index changes
|
||||
*
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function optimizeIndexChanges ($workspace)
|
||||
@@ -347,6 +338,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
|
||||
/**
|
||||
* Call Solr server to return the list of paginated pages.
|
||||
*
|
||||
* @param FacetRequest $solrRequestData
|
||||
* @return Entity_SolrQueryResult
|
||||
*/
|
||||
@@ -374,6 +366,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
|
||||
// array(''));
|
||||
|
||||
|
||||
// execute query
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
||||
$solrPaginatedResult = $solr->executeQuery( $solrRequestData );
|
||||
@@ -387,13 +380,11 @@ class BpmnEngine_Services_SearchIndex
|
||||
$docs = $solrPaginatedResult->response->docs;
|
||||
// print_r($docs);
|
||||
// insert list of names in docs result
|
||||
$data = array (
|
||||
"sEcho" => '', // must be completed in response
|
||||
$data = array ("sEcho" => '', // must be completed in response
|
||||
"iTotalRecords" => intval( $numTotalDocs ), // we must get the
|
||||
// total number of
|
||||
// documents
|
||||
"iTotalDisplayRecords" => $numFound,
|
||||
"aaData" => array ()
|
||||
"iTotalDisplayRecords" => $numFound,"aaData" => array ()
|
||||
);
|
||||
// copy result document or add placeholders to result
|
||||
foreach ($docs as $i => $doc) {
|
||||
@@ -401,12 +392,10 @@ class BpmnEngine_Services_SearchIndex
|
||||
foreach ($solrRequestData->includeCols as $columnName) {
|
||||
if ($columnName == '') {
|
||||
$data['aaData'][$i][] = ''; // placeholder
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (isset( $doc->$columnName )) {
|
||||
$data['aaData'][$i][] = $doc->$columnName;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$data['aaData'][$i][] = '';
|
||||
}
|
||||
}
|
||||
@@ -416,11 +405,13 @@ class BpmnEngine_Services_SearchIndex
|
||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest( $data );
|
||||
//
|
||||
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of stored fields in the index.
|
||||
*
|
||||
* @param string $workspace
|
||||
* @return array of index fields
|
||||
*/
|
||||
@@ -441,8 +432,7 @@ class BpmnEngine_Services_SearchIndex
|
||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||
// Maintain case sensitive variable names
|
||||
$listFields[$originalFieldName] = $key;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// $listFields[strtolower($key)] = $key;
|
||||
// Maintain case sensitive variable names
|
||||
$listFields[$key] = $key;
|
||||
|
||||
Reference in New Issue
Block a user