HOR-3670-RG Files review:
workflow/engine/classes/BpmnEngine_Services_SearchIndex.php workflow/engine/classes/Bzip_File.php workflow/engine/classes/CLI.php workflow/engine/classes/Cases.php workflow/engine/classes/Configurations.php
This commit is contained in:
@@ -77,7 +77,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
*/
|
||||
public function isSolrEnabled()
|
||||
{
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$solrStatusResult = $searchIndex->isEnabled ($this->_solrInstance);
|
||||
return $solrStatusResult;
|
||||
@@ -409,7 +409,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
);
|
||||
$solrRequestData = Entity_SolrRequestData::createForRequestPagination ($data);
|
||||
// use search index to return list of cases
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$solrQueryResult = $searchIndex->getDataTablePaginatedList ($solrRequestData);
|
||||
if($this->debug)
|
||||
@@ -946,7 +946,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
|
||||
// search the first
|
||||
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$ListFieldsInfo = $searchIndex->getIndexFields ($this->_solrInstance);
|
||||
|
||||
@@ -1240,7 +1240,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
);
|
||||
$oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest ($data);
|
||||
|
||||
$oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$oSearchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
$oSearchIndex->updateIndexDocument ($oSolrUpdateDocument);
|
||||
|
||||
@@ -1350,7 +1350,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
|
||||
try{
|
||||
|
||||
$oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$oSearchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
foreach ($aaAPPUIDs as $aAPPUID) {
|
||||
$idQuery = "APP_UID:" . $aAPPUID ['APP_UID'];
|
||||
@@ -2889,7 +2889,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
*/
|
||||
public function getCountApplicationsSearchIndex()
|
||||
{
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$count = $searchIndex->getNumberDocuments ($this->_solrInstance);
|
||||
|
||||
@@ -2903,7 +2903,7 @@ require_once "classes/model/AppSolrQueue.php";
|
||||
*/
|
||||
public function optimizeSearchIndex()
|
||||
{
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex ($this->_solrIsEnabled, $this->_solrHost);
|
||||
// execute query
|
||||
$searchIndex->optimizeIndexChanges ($this->_solrInstance);
|
||||
}
|
||||
|
||||
418
workflow/engine/classes/BpmnEngineServicesSearchIndex.php
Normal file
418
workflow/engine/classes/BpmnEngineServicesSearchIndex.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class used as interface to have access to the search index services
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/
|
||||
class BpmnEngineServicesSearchIndex
|
||||
{
|
||||
|
||||
private $_solrIsEnabled = false;
|
||||
private $_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->_solrHost = $solrHost;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* no input parameters @param[in]
|
||||
*
|
||||
* @param
|
||||
* [out] bool true if index service is enabled false in other case
|
||||
*/
|
||||
public function isEnabled($workspace)
|
||||
{
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once('class.solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
return $solr->isEnabled($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of facets in base to the specified query and filter
|
||||
* @gearman = true
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param
|
||||
* [out] array FacetGroup
|
||||
*/
|
||||
public function getFacetsList($facetRequestEntity)
|
||||
{
|
||||
require_once('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once('entities/FacetGroup.php');
|
||||
require_once('entities/FacetItem.php');
|
||||
require_once('entities/SelectedFacetGroupItem.php');
|
||||
require_once('entities/FacetResult.php');
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// get array of selected facet groups
|
||||
$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);
|
||||
$gr = explode('::', $gi [0]);
|
||||
$it = explode('::', $gi [1]);
|
||||
|
||||
// create string for remove condition
|
||||
$count = 0;
|
||||
$removeCondition = str_replace($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
|
||||
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
|
||||
);
|
||||
|
||||
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest($selectedFacetGroupData);
|
||||
}
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// convert request to index request
|
||||
// create filters
|
||||
$filters = array();
|
||||
if (!empty($aSelectedFacetGroups)) {
|
||||
// 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->facetDates = array_diff($facetRequestEntity->facetDates, array(
|
||||
$value->selectedFacetGroupName
|
||||
));
|
||||
}
|
||||
|
||||
// $facetFields = array_diff($facetFields,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
// $facetDates = array_diff($facetDates,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
foreach ($aSelectedFacetGroups as $group) {
|
||||
$filters [] = $group->selectedFacetGroupName . ':' . urlencode($group->selectedFacetItemName);
|
||||
}
|
||||
}
|
||||
$facetRequestEntity->filters = $filters;
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$facetsList = $solr->getFacetsList($facetRequestEntity);
|
||||
|
||||
$numFound = $facetsList->response->numFound;
|
||||
|
||||
$facetCounts = $facetsList->facet_counts;
|
||||
|
||||
$facetGroups = array();
|
||||
// convert facet fields result to objects
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet field results
|
||||
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||
if (!empty($facetFieldsResult)) {
|
||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||
if (count($facetvalues) > 0) { // if the group have facets included
|
||||
$data = array(
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'field';
|
||||
$facetItems = array();
|
||||
for ($i = 0; $i < count($facetvalues); $i += 2) {
|
||||
$dataItem = array();
|
||||
$dataItem ['facetName'] = $facetvalues [$i];
|
||||
$dataItem ['facetPrintName'] = $facetvalues [$i];
|
||||
$dataItem ['facetCount'] = $facetvalues [$i + 1];
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet date ranges results
|
||||
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||
if (!empty($facetDatesResult)) {
|
||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||
if (count((array) $facetvalues) > 3) { // if the group have any facets included
|
||||
// besides start, end and gap
|
||||
$data = array(
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'daterange';
|
||||
$facetItems = array();
|
||||
$facetvalueskeys = array_keys((array) $facetvalues);
|
||||
foreach ($facetvalueskeys as $i => $k) {
|
||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||
$dataItem = array();
|
||||
if ($i < count($facetvalueskeys) - 4) {
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
} else {
|
||||
// the last group
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
}
|
||||
|
||||
$dataItem ['facetCount'] = $facetvalues->$k;
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
}
|
||||
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:convert facet queries
|
||||
// -----
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create a filter string used in the filter of results of a datatable
|
||||
$filterText = ''; // the list of selected filters used for filtering result,
|
||||
// send in ajax
|
||||
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
|
||||
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode($selectedFacetGroup->selectedFacetItemName) . ',';
|
||||
}
|
||||
$filterText = substr_replace($filterText, '', - 1);
|
||||
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create result
|
||||
$dataFacetResult = array(
|
||||
'aFacetGroups' => $facetGroups,
|
||||
'aSelectedFacetGroups' => $aSelectedFacetGroups,
|
||||
'sFilterText' => $filterText
|
||||
);
|
||||
$facetResult = Entity_FacetResult::createForRequest($dataFacetResult);
|
||||
|
||||
return $facetResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of documents in search server
|
||||
* @param string $workspace
|
||||
* @return integer number of documents
|
||||
*
|
||||
*/
|
||||
public function getNumberDocuments($workspace)
|
||||
{
|
||||
require_once('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$numberDocuments = $solr->getNumberDocuments($workspace);
|
||||
|
||||
return $numberDocuments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update document Index
|
||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||
*/
|
||||
public function updateIndexDocument($solrUpdateDocumentEntity)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->updateDocument($solrUpdateDocumentEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete document from index
|
||||
* @param string $workspace
|
||||
* @param string $idQuery
|
||||
*/
|
||||
public function deleteDocumentFromIndex($workspace, $idQuery)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->deleteDocument($workspace, $idQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function commitIndexChanges($workspace)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->commitChanges($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function optimizeIndexChanges($workspace)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->optimizeChanges($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call Solr server to return the list of paginated pages.
|
||||
* @param FacetRequest $solrRequestData
|
||||
* @return Entity_SolrQueryResult
|
||||
*/
|
||||
public function getDataTablePaginatedList($solrRequestData)
|
||||
{
|
||||
require_once('class.solr.php');
|
||||
require_once('entities/SolrRequestData.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
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
$solrPaginatedResult = $solr->executeQuery($solrRequestData);
|
||||
|
||||
// get total number of documents in index
|
||||
$numTotalDocs = $solr->getNumberDocuments($solrRequestData->workspace);
|
||||
|
||||
// create the Datatable response of the query
|
||||
$numFound = $solrPaginatedResult->response->numFound;
|
||||
|
||||
$docs = $solrPaginatedResult->response->docs;
|
||||
// print_r($docs);
|
||||
// insert list of names in docs result
|
||||
$data = array(
|
||||
"sEcho" => '', // must be completed in response
|
||||
"iTotalRecords" => intval($numTotalDocs), // we must get the
|
||||
// total number of
|
||||
// documents
|
||||
"iTotalDisplayRecords" => $numFound,
|
||||
"aaData" => array()
|
||||
);
|
||||
// copy result document or add placeholders to result
|
||||
foreach ($docs as $i => $doc) {
|
||||
$data ['aaData'] [$i] = array();
|
||||
foreach ($solrRequestData->includeCols as $columnName) {
|
||||
if ($columnName == '') {
|
||||
$data ['aaData'] [$i] [] = ''; // placeholder
|
||||
} else {
|
||||
if (isset($doc->$columnName)) {
|
||||
$data ['aaData'] [$i] [$columnName] = $doc->$columnName;
|
||||
} else {
|
||||
$data ['aaData'] [$i] [$columnName] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest($data);
|
||||
//
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of stored fields in the index.
|
||||
* @param string $workspace
|
||||
* @return array of index fields
|
||||
*/
|
||||
public function getIndexFields($workspace)
|
||||
{
|
||||
require_once('class.solr.php');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// print "SearchIndex!!!!";
|
||||
// create list of facets
|
||||
$solrFieldsData = $solr->getListIndexedStoredFields($workspace);
|
||||
// copy list of arrays
|
||||
$listFields = array();
|
||||
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||
if (array_key_exists('dynamicBase', $fieldData)) {
|
||||
$originalFieldName = substr($key, 0, - strlen($fieldData->dynamicBase) + 1);
|
||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$originalFieldName] = $key;
|
||||
} else {
|
||||
// $listFields[strtolower($key)] = $key;
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$key] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $listFields;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,453 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
* 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, 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
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class used as interface to have access to the search index services
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/class BpmnEngine_Services_SearchIndex
|
||||
{
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
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->_solrHost = $solrHost;
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* no input parameters @param[in]
|
||||
*
|
||||
* @param
|
||||
* [out] bool true if index service is enabled false in other case
|
||||
*/
|
||||
public function isEnabled($workspace)
|
||||
{
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('class.solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
return $solr->isEnabled ($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of facets in base to the specified query and filter
|
||||
* @gearman = true
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
|
||||
* @param
|
||||
* [out] array FacetGroup
|
||||
*/
|
||||
public function getFacetsList($facetRequestEntity)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('entities/FacetGroup.php');
|
||||
require_once ('entities/FacetItem.php');
|
||||
require_once ('entities/SelectedFacetGroupItem.php');
|
||||
require_once ('entities/FacetResult.php');
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// get array of selected facet groups
|
||||
$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);
|
||||
$gr = explode ('::', $gi [0]);
|
||||
$it = explode ('::', $gi [1]);
|
||||
|
||||
// create string for remove condition
|
||||
$count = 0;
|
||||
$removeCondition = str_replace ($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
|
||||
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
|
||||
);
|
||||
|
||||
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
|
||||
}
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// convert request to index request
|
||||
// create filters
|
||||
$filters = array ();
|
||||
if (! empty ($aSelectedFacetGroups)) {
|
||||
// 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->facetDates = array_diff ($facetRequestEntity->facetDates, array (
|
||||
$value->selectedFacetGroupName
|
||||
));
|
||||
}
|
||||
|
||||
// $facetFields = array_diff($facetFields,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
// $facetDates = array_diff($facetDates,
|
||||
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||
foreach ($aSelectedFacetGroups as $group) {
|
||||
$filters [] = $group->selectedFacetGroupName . ':' . urlencode ($group->selectedFacetItemName);
|
||||
}
|
||||
}
|
||||
$facetRequestEntity->filters = $filters;
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$facetsList = $solr->getFacetsList ($facetRequestEntity);
|
||||
|
||||
$numFound = $facetsList->response->numFound;
|
||||
|
||||
$facetCounts = $facetsList->facet_counts;
|
||||
|
||||
$facetGroups = array ();
|
||||
// convert facet fields result to objects
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet field results
|
||||
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||
if (! empty ($facetFieldsResult)) {
|
||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||
if (count ($facetvalues) > 0) // if the group have facets included
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'field';
|
||||
$facetItems = array ();
|
||||
for ($i = 0; $i < count ($facetvalues); $i += 2) {
|
||||
$dataItem = array ();
|
||||
$dataItem ['facetName'] = $facetvalues [$i];
|
||||
$dataItem ['facetPrintName'] = $facetvalues [$i];
|
||||
$dataItem ['facetCount'] = $facetvalues [$i + 1];
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* *********************************************************************
|
||||
*/
|
||||
// include facet date ranges results
|
||||
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||
if (! empty ($facetDatesResult)) {
|
||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||
if (count ((array)$facetvalues) > 3) // if the group have any facets included
|
||||
// besides start, end and gap
|
||||
{
|
||||
$data = array (
|
||||
'facetGroupName' => $facetGroup
|
||||
);
|
||||
$data ['facetGroupPrintName'] = $facetGroup;
|
||||
$data ['facetGroupType'] = 'daterange';
|
||||
$facetItems = array ();
|
||||
$facetvalueskeys = array_keys ((array)$facetvalues);
|
||||
foreach ($facetvalueskeys as $i => $k) {
|
||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||
$dataItem = array ();
|
||||
if ($i < count ($facetvalueskeys) - 4) {
|
||||
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||
}
|
||||
else {
|
||||
// the last group
|
||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||
}
|
||||
|
||||
$dataItem ['facetCount'] = $facetvalues->$k;
|
||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||
$facetItems [] = $newFacetItem;
|
||||
}
|
||||
}
|
||||
|
||||
$data ['facetItems'] = $facetItems;
|
||||
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||
|
||||
$facetGroups [] = $newFacetGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:convert facet queries
|
||||
// -----
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create a filter string used in the filter of results of a datatable
|
||||
$filterText = ''; // the list of selected filters used for filtering result,
|
||||
// send in ajax
|
||||
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
|
||||
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode ($selectedFacetGroup->selectedFacetItemName) . ',';
|
||||
}
|
||||
$filterText = substr_replace ($filterText, '', - 1);
|
||||
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
*/
|
||||
// Create result
|
||||
$dataFacetResult = array (
|
||||
'aFacetGroups' => $facetGroups,
|
||||
'aSelectedFacetGroups' => $aSelectedFacetGroups,
|
||||
'sFilterText' => $filterText
|
||||
);
|
||||
$facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
|
||||
|
||||
return $facetResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of documents in search server
|
||||
* @param string $workspace
|
||||
* @return integer number of documents
|
||||
*
|
||||
*/
|
||||
public function getNumberDocuments($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
// require_once (ROOT_PATH .
|
||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$numberDocuments = $solr->getNumberDocuments ($workspace);
|
||||
|
||||
return $numberDocuments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update document Index
|
||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||
*/
|
||||
public function updateIndexDocument($solrUpdateDocumentEntity)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->updateDocument ($solrUpdateDocumentEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete document from index
|
||||
* @param string $workspace
|
||||
* @param string $idQuery
|
||||
*/
|
||||
public function deleteDocumentFromIndex($workspace, $idQuery)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// create list of facets
|
||||
$solr->deleteDocument ($workspace, $idQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function commitIndexChanges($workspace)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->commitChanges ($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize index changes
|
||||
* @param string $workspace
|
||||
*/
|
||||
public function optimizeIndexChanges($workspace)
|
||||
{
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// commit
|
||||
$solr->optimizeChanges ($workspace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call Solr server to return the list of paginated pages.
|
||||
* @param FacetRequest $solrRequestData
|
||||
* @return Entity_SolrQueryResult
|
||||
*/
|
||||
public function getDataTablePaginatedList($solrRequestData)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
require_once ('entities/SolrRequestData.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
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
|
||||
|
||||
// get total number of documents in index
|
||||
$numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
|
||||
|
||||
// create the Datatable response of the query
|
||||
$numFound = $solrPaginatedResult->response->numFound;
|
||||
|
||||
$docs = $solrPaginatedResult->response->docs;
|
||||
// print_r($docs);
|
||||
// insert list of names in docs result
|
||||
$data = array (
|
||||
"sEcho" => '', // must be completed in response
|
||||
"iTotalRecords" => intval ($numTotalDocs), // we must get the
|
||||
// total number of
|
||||
// documents
|
||||
"iTotalDisplayRecords" => $numFound,
|
||||
"aaData" => array ()
|
||||
);
|
||||
// copy result document or add placeholders to result
|
||||
foreach ($docs as $i => $doc) {
|
||||
$data ['aaData'] [$i] = array ();
|
||||
foreach ($solrRequestData->includeCols as $columnName) {
|
||||
if ($columnName == '') {
|
||||
$data ['aaData'] [$i] [] = ''; // placeholder
|
||||
}
|
||||
else {
|
||||
if (isset ($doc->$columnName)) {
|
||||
$data ['aaData'] [$i] [$columnName] = $doc->$columnName;
|
||||
}
|
||||
else {
|
||||
$data ['aaData'] [$i] [$columnName] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
|
||||
//
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of stored fields in the index.
|
||||
* @param string $workspace
|
||||
* @return array of index fields
|
||||
*/
|
||||
public function getIndexFields($workspace)
|
||||
{
|
||||
require_once ('class.solr.php');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||
|
||||
// print "SearchIndex!!!!";
|
||||
// create list of facets
|
||||
$solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
|
||||
// copy list of arrays
|
||||
$listFields = array ();
|
||||
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||
if (array_key_exists ('dynamicBase', $fieldData)) {
|
||||
$originalFieldName = substr ($key, 0, - strlen ($fieldData->dynamicBase) + 1);
|
||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$originalFieldName] = $key;
|
||||
}
|
||||
else {
|
||||
// $listFields[strtolower($key)] = $key;
|
||||
// Maintain case sensitive variable names
|
||||
$listFields [$key] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $listFields;
|
||||
}
|
||||
|
||||
}
|
||||
63
workflow/engine/classes/BzipFile.php
Normal file
63
workflow/engine/classes/BzipFile.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is derived from the class archive, is employed to use files .bzip
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
*/class BzipFile extends tar_file
|
||||
{
|
||||
|
||||
/**
|
||||
* This function is the constructor of the class bzip_file
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function BzipFile($name)
|
||||
{
|
||||
$this->tar_file($name);
|
||||
$this->options['type'] = "bzip";
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is employed to create files .
|
||||
* bzip
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function create_bzip()
|
||||
{
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
$pwd = getcwd();
|
||||
chdir($this->options['basedir']);
|
||||
if ($fp = bzopen($this->options['name'], "wb")) {
|
||||
fseek($this->archive, 0);
|
||||
while ($temp = fread($this->archive, 1048576)) {
|
||||
bzwrite($fp, $temp);
|
||||
}
|
||||
bzclose($fp);
|
||||
chdir($pwd);
|
||||
} else {
|
||||
$this->error[] = "Could not open {$this->options['name']} for writing.";
|
||||
chdir($pwd);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->archive = bzcompress($this->archive, $this->options['level']);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function open a archive of the class bzip_file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function open_archive()
|
||||
{
|
||||
return @bzopen($this->options['name'], "rb");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
/*--------------------------------------------------
|
||||
* TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.1
|
||||
* By Devin Doucette
|
||||
* Copyright (c) 2005 Devin Doucette
|
||||
* Email: darksnoopy@shaw.ca
|
||||
*--------------------------------------------------
|
||||
* Email bugs/suggestions to darksnoopy@shaw.ca
|
||||
*--------------------------------------------------
|
||||
* This script has been created and released under
|
||||
* the GNU GPL and is free to use and redistribute
|
||||
* only if this copyright statement is not removed
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* This class is derived from the class archive, is employed to use files .bzip
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
*/class bzip_file extends tar_file
|
||||
{
|
||||
|
||||
/**
|
||||
* This function is the constructor of the class bzip_file
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function bzip_file ($name)
|
||||
{
|
||||
$this->tar_file( $name );
|
||||
$this->options['type'] = "bzip";
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is employed to create files .
|
||||
* bzip
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function create_bzip ()
|
||||
{
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
if ($fp = bzopen( $this->options['name'], "wb" )) {
|
||||
fseek( $this->archive, 0 );
|
||||
while ($temp = fread( $this->archive, 1048576 )) {
|
||||
bzwrite( $fp, $temp );
|
||||
}
|
||||
bzclose( $fp );
|
||||
chdir( $pwd );
|
||||
} else {
|
||||
$this->error[] = "Could not open {$this->options['name']} for writing.";
|
||||
chdir( $pwd );
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->archive = bzcompress( $this->archive, $this->options['level'] );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function open a archive of the class bzip_file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function open_archive ()
|
||||
{
|
||||
return @bzopen( $this->options['name'], "rb" );
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,6 @@
|
||||
<?php
|
||||
|
||||
use \ProcessMaker\BusinessModel\WebEntryEvent;
|
||||
|
||||
/**
|
||||
* class.case.php
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
/**
|
||||
@@ -34,14 +8,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
* This object is applied to Task
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Cases object where you can do start, load, update, refresh about cases
|
||||
* This object is applied to Task
|
||||
* @package workflow.engine.classes
|
||||
*/class Cases
|
||||
class Cases
|
||||
{
|
||||
|
||||
private $appSolr = null;
|
||||
public $dir = 'ASC';
|
||||
public $sort = 'APP_MSG_DATE';
|
||||
@@ -550,7 +518,6 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
$oCurUser->load($aAppDel['USR_UID']);
|
||||
$aFields['CURRENT_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
|
||||
}
|
||||
|
||||
} catch (Exception $oError) {
|
||||
$aFields['CURRENT_USER'] = '';
|
||||
}
|
||||
@@ -848,7 +815,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
return $aReturn;
|
||||
}
|
||||
|
||||
public function array_key_intersect(&$a, &$b) {
|
||||
public function array_key_intersect(&$a, &$b)
|
||||
{
|
||||
$array = array();
|
||||
while (list($key, $value) = each($a)) {
|
||||
if (isset($b[$key])) {
|
||||
@@ -1276,7 +1244,6 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
} else {
|
||||
$result = true;
|
||||
}
|
||||
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
} finally {
|
||||
@@ -1439,7 +1406,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
* @param array $previousTasks
|
||||
* @return array $taskReviewed
|
||||
*/
|
||||
public function getReviewedTasksRecursive($taskUid, $appUid, $previousTasks) {
|
||||
public function getReviewedTasksRecursive($taskUid, $appUid, $previousTasks)
|
||||
{
|
||||
$taskReviewed = array();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(RoutePeer::ROU_NEXT_TASK, $taskUid);
|
||||
@@ -2348,7 +2316,6 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
$iPosition += 1;
|
||||
$aNextStep = null;
|
||||
if ($iPosition <= $iLastStep) {
|
||||
|
||||
while ($iPosition <= $iLastStep) {
|
||||
$bAccessStep = false;
|
||||
//step
|
||||
@@ -2626,7 +2593,6 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
||||
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||
if (G::LoadSystemExist($sDataBase)) {
|
||||
|
||||
$oDataBase = new database();
|
||||
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
|
||||
$c->addAsColumn(
|
||||
@@ -4016,7 +3982,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
* @param string $iDelegation
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isUnassignedPauseCase($sAppUid, $iDelegation){
|
||||
public static function isUnassignedPauseCase($sAppUid, $iDelegation)
|
||||
{
|
||||
$oAppDelegation = new AppDelegation();
|
||||
$aFieldsDel = $oAppDelegation->Load($sAppUid, $iDelegation);
|
||||
$usrUid = $aFieldsDel['USR_UID'];
|
||||
@@ -5767,9 +5734,9 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
*/
|
||||
public function getAllObjects($PRO_UID, $APP_UID, $TAS_UID = '', $USR_UID = '', $delIndex = 0)
|
||||
{
|
||||
$ACTIONS = Array('VIEW', 'BLOCK', 'DELETE'); //TO COMPLETE
|
||||
$MAIN_OBJECTS = Array();
|
||||
$RESULT_OBJECTS = Array();
|
||||
$ACTIONS = array('VIEW', 'BLOCK', 'DELETE'); //TO COMPLETE
|
||||
$MAIN_OBJECTS = array();
|
||||
$RESULT_OBJECTS = array();
|
||||
|
||||
foreach ($ACTIONS as $action) {
|
||||
$MAIN_OBJECTS[$action] = $this->getAllObjectsFrom($PRO_UID, $APP_UID, $TAS_UID, $USR_UID, $action, $delIndex);
|
||||
@@ -6460,7 +6427,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
public function getAllObjectsFromProcess($PRO_UID, $OBJ_TYPE = '%')
|
||||
{
|
||||
$RESULT = Array();
|
||||
$RESULT = array();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
||||
$oCriteria->addSelectColumn(AppDocumentPeer::APP_UID);
|
||||
@@ -6758,7 +6725,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if (isset($sumary) && $sumary === true) {
|
||||
$sumary = Array();
|
||||
$sumary = array();
|
||||
while ($rs->next()) {
|
||||
$nCount++;
|
||||
$row = $rs->getRow();
|
||||
@@ -6769,7 +6736,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
$sumary[$row['PRO_UID']]['name'] = $row['APP_PRO_TITLE'];
|
||||
}
|
||||
}
|
||||
return Array('count' => $nCount, 'sumary' => $sumary);
|
||||
return array('count' => $nCount, 'sumary' => $sumary);
|
||||
} else {
|
||||
while ($rs->next()) {
|
||||
$nCount++;
|
||||
@@ -6788,7 +6755,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
*/
|
||||
public function getAllConditionCasesCount($types, $sumary = null)
|
||||
{
|
||||
$aResult = Array();
|
||||
$aResult = array();
|
||||
foreach ($types as $type) {
|
||||
$aResult[$type] = $this->getConditionCasesCount($type, $sumary);
|
||||
}
|
||||
@@ -6974,7 +6941,7 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
$rs = UsersPeer::doSelectRs($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rows = Array();
|
||||
$rows = array();
|
||||
while ($rs->next()) {
|
||||
$rows[] = $rs->getRow();
|
||||
}
|
||||
@@ -7212,7 +7179,6 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
eval("\$criteria3->add(" . $pmTableName . "Peer::APP_UID, \$applicationUid);");
|
||||
eval($pmTableName . "Peer::doDelete(\$criteria3);");
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -7243,7 +7209,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
public function unserializeData($data) {
|
||||
public function unserializeData($data)
|
||||
{
|
||||
$unserializedData = @unserialize($data);
|
||||
|
||||
// BUG 8134, FIX!// for single/double quote troubles // Unserialize with utf8 content get trouble
|
||||
@@ -7315,7 +7282,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
private function orderStartCasesByCategoryAndName ($rows) {
|
||||
private function orderStartCasesByCategoryAndName($rows)
|
||||
{
|
||||
//now we order in category, proces_name order:
|
||||
$comparatorSequence = array(
|
||||
function ($a, $b) {
|
||||
|
||||
@@ -1,50 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* class.configuration.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.
|
||||
*
|
||||
*/
|
||||
//
|
||||
// It works with the table CONFIGURATION in a WF dataBase
|
||||
// Copyright (C) 2007 COLOSA
|
||||
// License: LGPL, see LICENSE
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* ProcessConfiguration - ProcessConfiguration
|
||||
/**
|
||||
* Extends Configuration
|
||||
*
|
||||
*
|
||||
* @copyright 2007 COLOSA
|
||||
* @version Release: @package_version@
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/class Configurations // extends Configuration
|
||||
*/
|
||||
class Configurations // extends Configuration
|
||||
{
|
||||
|
||||
public $aConfig = array();
|
||||
private $Configuration = null;
|
||||
private $UserConfig = null;
|
||||
@@ -162,7 +126,6 @@
|
||||
try {
|
||||
$this->Fields = $this->Configuration->load($cfg, $obj, $pro, $usr, $app);
|
||||
} catch (Exception $e) {
|
||||
|
||||
} // the configuration does not exist
|
||||
|
||||
|
||||
@@ -171,7 +134,7 @@
|
||||
}
|
||||
|
||||
if (!is_array($this->aConfig)) {
|
||||
$this->aConfig = Array();
|
||||
$this->aConfig = array();
|
||||
}
|
||||
|
||||
return $this->aConfig;
|
||||
@@ -530,15 +493,15 @@
|
||||
|
||||
public function getUserNameFormats()
|
||||
{
|
||||
$formats[] = Array('id' => '@firstName @lastName', //the id , don't translate
|
||||
$formats[] = array('id' => '@firstName @lastName', //the id , don't translate
|
||||
'name' => G::loadTranslation('ID_USERNAME_FORMAT_1') //label displayed, can be translated
|
||||
);
|
||||
$formats[] = Array('id' => '@firstName @lastName (@userName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_2'));
|
||||
$formats[] = Array('id' => '@userName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_3'));
|
||||
$formats[] = Array('id' => '@userName (@firstName @lastName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_4'));
|
||||
$formats[] = Array('id' => '@lastName @firstName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_5'));
|
||||
$formats[] = Array('id' => '@lastName, @firstName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_6'));
|
||||
$formats[] = Array('id' => '@lastName, @firstName (@userName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_7'));
|
||||
$formats[] = array('id' => '@firstName @lastName (@userName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_2'));
|
||||
$formats[] = array('id' => '@userName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_3'));
|
||||
$formats[] = array('id' => '@userName (@firstName @lastName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_4'));
|
||||
$formats[] = array('id' => '@lastName @firstName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_5'));
|
||||
$formats[] = array('id' => '@lastName, @firstName', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_6'));
|
||||
$formats[] = array('id' => '@lastName, @firstName (@userName)', 'name' => G::loadTranslation('ID_USERNAME_FORMAT_7'));
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@
|
||||
);
|
||||
|
||||
//Use search index to return list of cases
|
||||
$searchIndex = new BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
||||
$searchIndex = new BpmnEngineServicesSearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
||||
|
||||
//Execute query
|
||||
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
|
||||
|
||||
@@ -419,7 +419,7 @@ class Cases
|
||||
)
|
||||
);
|
||||
//Use search index to return list of cases
|
||||
$searchIndex = new \BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
||||
$searchIndex = new \BpmnEngineServicesSearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
||||
//Execute query
|
||||
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
|
||||
//Get the missing data from database
|
||||
|
||||
Reference in New Issue
Block a user