HOR-3670-RG observations

This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-08-11 14:54:56 -04:00
parent 63716c1358
commit 7be91035cf
2 changed files with 14 additions and 90 deletions

View File

@@ -2,49 +2,28 @@
/** /**
* Class used as interface to have access to the search index services * Class used as interface to have access to the search index services
*
* @author Herbert Saal Gutierrez
*
*/ */
class BpmnEngineServicesSearchIndex class BpmnEngineServicesSearchIndex
{ {
private $_solrIsEnabled = false; private $_solrIsEnabled = false;
private $_solrHost = ""; private $_solrHost = "";
public function __construct($solrIsEnabled = false, $solrHost = "") public function __construct($solrIsEnabled = false, $solrHost = "")
{ {
// check if Zend Library is available
// if(class_exists("Zend_Registry")){
// $registry = Zend_Registry::getInstance();
// //check if configuration is enabled
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
// $registry->get('solrEnabled') == 1;
// $this->solrHost =
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
// }
// else{
// //use the parameters to initialize class
$this->_solrIsEnabled = $solrIsEnabled; $this->_solrIsEnabled = $solrIsEnabled;
$this->_solrHost = $solrHost; $this->_solrHost = $solrHost;
// }
} }
/** /**
* Verify if the Solr service is available * Verify if the Solr service is available
*
* @gearman = false * @gearman = false
* @rest = false * @rest = false
* @background = false * @background = false no input parameters @param[in]
* * @param [out] bool true if index service is enabled false in other case
* no input parameters @param[in]
*
* @param
* [out] bool true if index service is enabled false in other case
*/ */
public function isEnabled($workspace) public function isEnabled($workspace)
{ {
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once('class.solr.php'); require_once('class.solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost); $solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
return $solr->isEnabled($workspace); return $solr->isEnabled($workspace);
@@ -52,28 +31,21 @@ class BpmnEngineServicesSearchIndex
/** /**
* Get the list of facets in base to the specified query and filter * Get the list of facets in base to the specified query and filter
*
* @gearman = true * @gearman = true
* @rest = false * @rest = false
* @background = false * @background = false
* * @param [in] Entity_FacetRequest facetRequestEntity Facet request entity
* @param * @param [out] array FacetGroup
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
* @param
* [out] array FacetGroup
*/ */
public function getFacetsList($facetRequestEntity) public function getFacetsList($facetRequestEntity)
{ {
require_once('class.solr.php'); require_once('class.solr.php');
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once('entities/FacetGroup.php'); require_once('entities/FacetGroup.php');
require_once('entities/FacetItem.php'); require_once('entities/FacetItem.php');
require_once('entities/SelectedFacetGroupItem.php'); require_once('entities/SelectedFacetGroupItem.php');
require_once('entities/FacetResult.php'); require_once('entities/FacetResult.php');
/**
* ***************************************************************
*/
// get array of selected facet groups // get array of selected facet groups
$facetRequestEntity->selectedFacetsString = str_replace(',,', ',', $facetRequestEntity->selectedFacetsString); $facetRequestEntity->selectedFacetsString = str_replace(',,', ',', $facetRequestEntity->selectedFacetsString);
// remove descriptions of selected facet groups // remove descriptions of selected facet groups
@@ -105,9 +77,6 @@ class BpmnEngineServicesSearchIndex
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest($selectedFacetGroupData); $aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest($selectedFacetGroupData);
} }
/**
* ***************************************************************
*/
// convert request to index request // convert request to index request
// create filters // create filters
$filters = array(); $filters = array();
@@ -123,10 +92,6 @@ class BpmnEngineServicesSearchIndex
)); ));
} }
// $facetFields = array_diff($facetFields,
// $facetInterfaceRequestEntity->selectedFacetGroups);
// $facetDates = array_diff($facetDates,
// $facetInterfaceRequestEntity->selectedFacetGroups);
foreach ($aSelectedFacetGroups as $group) { foreach ($aSelectedFacetGroups as $group) {
$filters [] = $group->selectedFacetGroupName . ':' . urlencode($group->selectedFacetItemName); $filters [] = $group->selectedFacetGroupName . ':' . urlencode($group->selectedFacetItemName);
} }
@@ -143,10 +108,8 @@ class BpmnEngineServicesSearchIndex
$facetCounts = $facetsList->facet_counts; $facetCounts = $facetsList->facet_counts;
$facetGroups = array(); $facetGroups = array();
// convert facet fields result to objects // convert facet fields result to objects
/**
* *********************************************************************
*/
// include facet field results // include facet field results
$facetFieldsResult = $facetsList->facet_counts->facet_fields; $facetFieldsResult = $facetsList->facet_counts->facet_fields;
if (!empty($facetFieldsResult)) { if (!empty($facetFieldsResult)) {
@@ -174,9 +137,7 @@ class BpmnEngineServicesSearchIndex
} }
} }
} }
/**
* *********************************************************************
*/
// include facet date ranges results // include facet date ranges results
$facetDatesResult = $facetsList->facet_counts->facet_dates; $facetDatesResult = $facetsList->facet_counts->facet_dates;
if (!empty($facetDatesResult)) { if (!empty($facetDatesResult)) {
@@ -217,10 +178,6 @@ class BpmnEngineServicesSearchIndex
} }
} }
// TODO:convert facet queries // TODO:convert facet queries
// -----
/**
* ***************************************************************
*/
// Create a filter string used in the filter of results of a datatable // Create a filter string used in the filter of results of a datatable
$filterText = ''; // the list of selected filters used for filtering result, $filterText = ''; // the list of selected filters used for filtering result,
// send in ajax // send in ajax
@@ -228,11 +185,7 @@ class BpmnEngineServicesSearchIndex
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode($selectedFacetGroup->selectedFacetItemName) . ','; $filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode($selectedFacetGroup->selectedFacetItemName) . ',';
} }
$filterText = substr_replace($filterText, '', - 1); $filterText = substr_replace($filterText, '', - 1);
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
/**
* ***************************************************************
*/
// Create result // Create result
$dataFacetResult = array( $dataFacetResult = array(
'aFacetGroups' => $facetGroups, 'aFacetGroups' => $facetGroups,
@@ -253,8 +206,6 @@ class BpmnEngineServicesSearchIndex
public function getNumberDocuments($workspace) public function getNumberDocuments($workspace)
{ {
require_once('class.solr.php'); require_once('class.solr.php');
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost); $solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
// create list of facets // create list of facets
@@ -323,23 +274,6 @@ class BpmnEngineServicesSearchIndex
require_once('entities/SolrRequestData.php'); require_once('entities/SolrRequestData.php');
require_once('entities/SolrQueryResult.php'); require_once('entities/SolrQueryResult.php');
// prepare the list of sorted columns
// verify if the data of sorting is available
//if (isset ($solrRequestData->sortCols [0])) {
// for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
// verify if column is sortable
//if ($solrRequestData->includeCols [$solrRequestData->sortCols [$i]] != '' && $solrRequestData->sortableCols [$i] == "true") {
// change sorting column index to column names
//$solrRequestData->sortCols [$i] = $solrRequestData->includeCols [$solrRequestData->sortCols [$i]];
// define the direction of the sorting columns
//$solrRequestData->sortDir [$i] = $solrRequestData->sortDir [$i];
//}
// }
//}
// remove placeholder fields
// the placeholder doesn't affect the the solr's response
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
// array(''));
// execute query // execute query
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost); $solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
$solrPaginatedResult = $solr->executeQuery($solrRequestData); $solrPaginatedResult = $solr->executeQuery($solrRequestData);
@@ -351,13 +285,12 @@ class BpmnEngineServicesSearchIndex
$numFound = $solrPaginatedResult->response->numFound; $numFound = $solrPaginatedResult->response->numFound;
$docs = $solrPaginatedResult->response->docs; $docs = $solrPaginatedResult->response->docs;
// print_r($docs);
// insert list of names in docs result // insert list of names in docs result
$data = array( $data = array(
"sEcho" => '', // must be completed in response "sEcho" => '', // must be completed in response
"iTotalRecords" => intval($numTotalDocs), // we must get the "iTotalRecords" => intval($numTotalDocs), // we must get the
// total number of // total number of documents
// documents
"iTotalDisplayRecords" => $numFound, "iTotalDisplayRecords" => $numFound,
"aaData" => array() "aaData" => array()
); );
@@ -378,7 +311,6 @@ class BpmnEngineServicesSearchIndex
} }
$solrQueryResponse = Entity_SolrQueryResult::createForRequest($data); $solrQueryResponse = Entity_SolrQueryResult::createForRequest($data);
//
return $solrQueryResponse; return $solrQueryResponse;
} }
@@ -394,19 +326,16 @@ class BpmnEngineServicesSearchIndex
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost); $solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
// print "SearchIndex!!!!";
// create list of facets
$solrFieldsData = $solr->getListIndexedStoredFields($workspace); $solrFieldsData = $solr->getListIndexedStoredFields($workspace);
// copy list of arrays // copy list of arrays
$listFields = array(); $listFields = array();
foreach ($solrFieldsData->fields as $key => $fieldData) { foreach ($solrFieldsData->fields as $key => $fieldData) {
if (array_key_exists('dynamicBase', $fieldData)) { if (array_key_exists('dynamicBase', $fieldData)) {
$originalFieldName = substr($key, 0, - strlen($fieldData->dynamicBase) + 1); $originalFieldName = substr($key, 0, - strlen($fieldData->dynamicBase) + 1);
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
// Maintain case sensitive variable names // Maintain case sensitive variable names
$listFields [$originalFieldName] = $key; $listFields [$originalFieldName] = $key;
} else { } else {
// $listFields[strtolower($key)] = $key;
// Maintain case sensitive variable names // Maintain case sensitive variable names
$listFields [$key] = $key; $listFields [$key] = $key;
} }
@@ -414,5 +343,4 @@ class BpmnEngineServicesSearchIndex
return $listFields; return $listFields;
} }
} }

View File

@@ -1,12 +1,9 @@
<?php <?php
/** /**
*
* This class is derived from the class archive, is employed to use files .bzip * This class is derived from the class archive, is employed to use files .bzip
* */
* @package workflow.engine.classes class BzipFile extends tar_file
*
*/class BzipFile extends tar_file
{ {
/** /**
@@ -59,5 +56,4 @@
{ {
return @bzopen($this->options['name'], "rb"); return @bzopen($this->options['name'], "rb");
} }
} }