Index of the minimun value found
- */
- public function aaGetMinimun ($arr, $column, $columnType = 'STRING', $columnCondition = "", $condition = "")
- {
- // get first value
- $auxValue = $arr[0][$column];
- $index = null;
- foreach ($arr as $i => $row) {
- switch ($columnType) {
- case 'STRING':
- if ((strnatcmp( $row[$column], $auxValue ) <= 0) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
- $auxValue = $row[$column];
- $index = $i;
- }
- break;
- case 'NUMBER':
- if (($row[$column] <= $auxValue) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
- $auxValue = $row[$column];
- $index = $i;
- }
- break;
- case 'DATE':
- if ((strtotime( $row[$column] ) <= strtotime( $auxValue )) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
- $auxValue = $row[$column];
- $index = $i;
-
- }
- break;
- }
- }
- return $index;
- }
-
- /**
- * Search array of indexes that fullfill the conditions
- *
- * @param array of arrays $arr contains the arrays that are searched
- * @param array $andColumnsConditions contain the conditions that must fullfill 'Column'=>'Condition'
- * @return array of indexes with the found records
- */
- public function aaSearchRecords ($arr, $andColumnsConditions)
- {
- $indexes = array ();
+ return $index;
+ }
+
+ /**
+ * Search array of indexes that fullfill the conditions
+ *
+ * @param
+ * array of arrays $arr contains the arrays that are searched
+ * @param array $andColumnsConditions
+ * contain the conditions that must fullfill 'Column'=>'Condition'
+ * @return array of indexes with the found records
+ */
+ public function aaSearchRecords($arr, $andColumnsConditions)
+ {
+ $indexes = array ();
+ $isEqual = true;
+ foreach ($arr as $i => $row) {
+ $evaluateRow = false;
+ // evaluate each row
+ foreach ($andColumnsConditions as $column => $valueCondition) {
+ $condition = $valueCondition;
$isEqual = true;
- foreach ($arr as $i => $row) {
+ if ($valueCondition == 'NULL') {
+ $isEqual = true;
+ $condition = '';
+ }
+ if ($valueCondition == 'NOTNULL') {
+ $isEqual = false;
+ $condition = '';
+ }
+ if ($isEqual) {
+ if ($row [$column] == $condition) {
+ $evaluateRow = true;
+ }
+ else {
$evaluateRow = false;
- // evaluate each row
- foreach ($andColumnsConditions as $column => $valueCondition) {
- $condition = $valueCondition;
- $isEqual = true;
- if ($valueCondition == 'NULL') {
- $isEqual = true;
- $condition = '';
- }
- if ($valueCondition == 'NOTNULL') {
- $isEqual = false;
- $condition = '';
- }
- if ($isEqual) {
- if ($row[$column] == $condition) {
- $evaluateRow = true;
- } else {
- $evaluateRow = false;
- break;
- }
- } else {
- if ($row[$column] != $condition) {
- $evaluateRow = true;
- } else {
- $evaluateRow = false;
- break;
- }
- }
- }
- // add row to indexes
- if ($evaluateRow) {
- $indexes[] = $i;
- }
+ breaK;
+ }
}
- return $indexes;
- }
-
- /**
- * Get application and delegation data from database
- *
- * @param string $AppUID the application identifier
- * @return array of records from database
- */
- public function getApplicationDelegationData ($AppUID)
- {
-
- $allAppDbData = array ();
-
- $c = new Criteria();
-
- $c->addSelectColumn( ApplicationPeer::APP_UID );
- $c->addSelectColumn( ApplicationPeer::APP_NUMBER );
- $c->addSelectColumn( ApplicationPeer::APP_STATUS );
- $c->addSelectColumn( ApplicationPeer::PRO_UID );
- $c->addSelectColumn( ApplicationPeer::APP_CREATE_DATE );
- $c->addSelectColumn( ApplicationPeer::APP_FINISH_DATE );
- $c->addSelectColumn( ApplicationPeer::APP_UPDATE_DATE );
- $c->addSelectColumn( ApplicationPeer::APP_DATA );
-
- $c->addAsColumn( 'APP_TITLE', 'capp.CON_VALUE' );
- $c->addAsColumn( 'PRO_TITLE', 'cpro.CON_VALUE' );
-
- $c->addSelectColumn( 'ad.DEL_INDEX' );
- $c->addSelectColumn( 'ad.DEL_PREVIOUS' );
- $c->addSelectColumn( 'ad.TAS_UID' );
- $c->addSelectColumn( 'ad.USR_UID' );
- $c->addSelectColumn( 'ad.DEL_TYPE' );
- $c->addSelectColumn( 'ad.DEL_THREAD' );
- $c->addSelectColumn( 'ad.DEL_THREAD_STATUS' );
- $c->addSelectColumn( 'ad.DEL_PRIORITY' );
- $c->addSelectColumn( 'ad.DEL_DELEGATE_DATE' );
- $c->addSelectColumn( 'ad.DEL_INIT_DATE' );
- $c->addSelectColumn( 'ad.DEL_TASK_DUE_DATE' );
- $c->addSelectColumn( 'ad.DEL_FINISH_DATE' );
- $c->addSelectColumn( 'ad.DEL_DURATION' );
- $c->addSelectColumn( 'ad.DEL_QUEUE_DURATION' );
- $c->addSelectColumn( 'ad.DEL_DELAY_DURATION' );
- $c->addSelectColumn( 'ad.DEL_STARTED' );
- $c->addSelectColumn( 'ad.DEL_FINISHED' );
- $c->addSelectColumn( 'ad.DEL_DELAYED' );
- $c->addSelectColumn( 'ad.APP_OVERDUE_PERCENTAGE' );
-
- $c->addSelectColumn( 'at.APP_THREAD_INDEX' );
- $c->addSelectColumn( 'at.APP_THREAD_PARENT' );
- $c->addSelectColumn( 'at.APP_THREAD_STATUS' );
-
- $c->addAlias("capp", ContentPeer::TABLE_NAME);
- $c->addAlias("cpro", ContentPeer::TABLE_NAME);
- $c->addAlias("ad", AppDelegationPeer::TABLE_NAME);
- $c->addAlias("at", AppThreadPeer::TABLE_NAME);
-
- $aConditions = array ();
- $aConditions[] = array (ApplicationPeer::APP_UID,'capp.CON_ID'
- );
- $aConditions[] = array ('capp.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'APP_TITLE' . DBAdapter::getStringDelimiter()
- );
- $aConditions[] = array ('capp.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
- );
- $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
-
- $aConditions = array ();
- $aConditions[] = array (ApplicationPeer::PRO_UID,'cpro.CON_ID'
- );
- $aConditions[] = array ('cpro.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter()
- );
- $aConditions[] = array ('cpro.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
- );
- $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
-
- $c->addJoin( ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN );
-
- $aConditions = array ();
- $aConditions[] = array ('ad.APP_UID','at.APP_UID'
- );
- $aConditions[] = array ('ad.DEL_THREAD','at.APP_THREAD_INDEX'
- );
- $c->addJoinMC( $aConditions, Criteria::JOIN );
-
- $c->add( ApplicationPeer::APP_UID, $AppUID );
-
- $rs = ApplicationPeer::doSelectRS( $c );
- $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
-
- $rs->next();
- $row = $rs->getRow();
-
- while (is_array( $row )) {
- $allAppDbData[] = $row;
- $rs->next();
- $row = $rs->getRow();
+ else {
+ if ($row [$column] != $condition) {
+ $evaluateRow = true;
+ }
+ else {
+ $evaluateRow = false;
+ breaK;
+ }
}
- return $allAppDbData;
+ }
+ // add row to indexes
+ if ($evaluateRow) {
+ $indexes [] = $i;
+ }
+ }
+ return $indexes;
+ }
+
+ /**
+ * Get application and delegation data from database
+ *
+ * @param string $AppUID
+ * the application identifier
+ * @return array of records from database
+ */
+ public function getApplicationDelegationData($AppUID)
+ {
+
+ $allAppDbData = array ();
+
+ $c = new Criteria ();
+
+ $c->addSelectColumn (ApplicationPeer::APP_UID);
+ $c->addSelectColumn (ApplicationPeer::APP_NUMBER);
+ $c->addSelectColumn (ApplicationPeer::APP_STATUS);
+ $c->addSelectColumn (ApplicationPeer::PRO_UID);
+ $c->addSelectColumn (ApplicationPeer::APP_CREATE_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_FINISH_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_UPDATE_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_DATA);
+
+ $c->addAsColumn ('APP_TITLE', 'capp.CON_VALUE');
+ $c->addAsColumn ('PRO_TITLE', 'cpro.CON_VALUE');
+
+ $c->addSelectColumn ('ad.DEL_INDEX');
+ $c->addSelectColumn ('ad.DEL_PREVIOUS');
+ $c->addSelectColumn ('ad.TAS_UID');
+ $c->addSelectColumn ('ad.USR_UID');
+ $c->addSelectColumn ('ad.DEL_TYPE');
+ $c->addSelectColumn ('ad.DEL_THREAD');
+ $c->addSelectColumn ('ad.DEL_THREAD_STATUS');
+ $c->addSelectColumn ('ad.DEL_PRIORITY');
+ $c->addSelectColumn ('ad.DEL_DELEGATE_DATE');
+ $c->addSelectColumn ('ad.DEL_INIT_DATE');
+ $c->addSelectColumn ('ad.DEL_TASK_DUE_DATE');
+ $c->addSelectColumn ('ad.DEL_FINISH_DATE');
+ $c->addSelectColumn ('ad.DEL_DURATION');
+ $c->addSelectColumn ('ad.DEL_QUEUE_DURATION');
+ $c->addSelectColumn ('ad.DEL_DELAY_DURATION');
+ $c->addSelectColumn ('ad.DEL_STARTED');
+ $c->addSelectColumn ('ad.DEL_FINISHED');
+ $c->addSelectColumn ('ad.DEL_DELAYED');
+ $c->addSelectColumn ('ad.APP_OVERDUE_PERCENTAGE');
+
+ $c->addSelectColumn ('at.APP_THREAD_INDEX');
+ $c->addSelectColumn ('at.APP_THREAD_PARENT');
+ $c->addSelectColumn ('at.APP_THREAD_STATUS');
+
+ $c->addAlias ('capp', 'CONTENT');
+ $c->addAlias ('cpro', 'CONTENT');
+ $c->addAlias ('ad', 'APP_DELEGATION');
+ $c->addAlias ('at', 'APP_THREAD');
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ ApplicationPeer::APP_UID,
+ 'capp.CON_ID'
+ );
+ $aConditions [] = array (
+ 'capp.CON_CATEGORY',
+ DBAdapter::getStringDelimiter () . 'APP_TITLE' . DBAdapter::getStringDelimiter ()
+ );
+ $aConditions [] = array (
+ 'capp.CON_LANG',
+ DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
+ );
+ $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ ApplicationPeer::PRO_UID,
+ 'cpro.CON_ID'
+ );
+ $aConditions [] = array (
+ 'cpro.CON_CATEGORY',
+ DBAdapter::getStringDelimiter () . 'PRO_TITLE' . DBAdapter::getStringDelimiter ()
+ );
+ $aConditions [] = array (
+ 'cpro.CON_LANG',
+ DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
+ );
+ $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
+
+ $c->addJoin (ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ 'ad.APP_UID',
+ 'at.APP_UID'
+ );
+ $aConditions [] = array (
+ 'ad.DEL_THREAD',
+ 'at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC ($aConditions, Criteria::JOIN);
+
+ $c->add (ApplicationPeer::APP_UID, $AppUID);
+
+ $rs = ApplicationPeer::doSelectRS ($c);
+ $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
+
+ $rs->next ();
+ $row = $rs->getRow ();
+
+ while (is_array ($row)) {
+ $allAppDbData [] = $row;
+ $rs->next ();
+ $row = $rs->getRow ();
}
- /**
- * Get application and delegation data from database
- *
- * @param string $aAppUID array of application identifiers
- * @return array of array of records from database
- */
- public function getListApplicationUpdateDelegationData($aaAppUIDs)
- {
- $allAppDbData = array();
+ //Propel::close();
- $c = new Criteria();
+ return $allAppDbData;
+ }
+
+ /**
+ * Get application and delegation data from database
+ *
+ * @param string $aAppUID
+ * array of application identifiers
+ * @return array of array of records from database
+ */
+ public function getListApplicationUpdateDelegationData($aaAppUIDs)
+ {
+
+ $allAppDbData = array ();
+
+ $c = new Criteria ();
+
+ $c->addSelectColumn (ApplicationPeer::APP_UID);
+ $c->addSelectColumn (ApplicationPeer::APP_NUMBER);
+ $c->addSelectColumn (ApplicationPeer::APP_STATUS);
+ $c->addSelectColumn (ApplicationPeer::PRO_UID);
+ $c->addSelectColumn (ApplicationPeer::APP_CREATE_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_FINISH_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_UPDATE_DATE);
+ $c->addSelectColumn (ApplicationPeer::APP_DATA);
+
+ $c->addAsColumn ('APP_TITLE', 'capp.CON_VALUE');
+ $c->addAsColumn ('PRO_TITLE', 'cpro.CON_VALUE');
+
+ $c->addSelectColumn ('ad.DEL_INDEX');
+ $c->addSelectColumn ('ad.DEL_PREVIOUS');
+ $c->addSelectColumn ('ad.TAS_UID');
+ $c->addSelectColumn ('ad.USR_UID');
+ $c->addSelectColumn ('ad.DEL_TYPE');
+ $c->addSelectColumn ('ad.DEL_THREAD');
+ $c->addSelectColumn ('ad.DEL_THREAD_STATUS');
+ $c->addSelectColumn ('ad.DEL_PRIORITY');
+ $c->addSelectColumn ('ad.DEL_DELEGATE_DATE');
+ $c->addSelectColumn ('ad.DEL_INIT_DATE');
+ $c->addSelectColumn ('ad.DEL_TASK_DUE_DATE');
+ $c->addSelectColumn ('ad.DEL_FINISH_DATE');
+ $c->addSelectColumn ('ad.DEL_DURATION');
+ $c->addSelectColumn ('ad.DEL_QUEUE_DURATION');
+ $c->addSelectColumn ('ad.DEL_DELAY_DURATION');
+ $c->addSelectColumn ('ad.DEL_STARTED');
+ $c->addSelectColumn ('ad.DEL_FINISHED');
+ $c->addSelectColumn ('ad.DEL_DELAYED');
+ $c->addSelectColumn ('ad.APP_OVERDUE_PERCENTAGE');
+
+ $c->addSelectColumn ('at.APP_THREAD_INDEX');
+ $c->addSelectColumn ('at.APP_THREAD_PARENT');
+ $c->addSelectColumn ('at.APP_THREAD_STATUS');
- $c->addSelectColumn(ApplicationPeer::APP_UID);
- $c->addSelectColumn(ApplicationPeer::APP_NUMBER);
- $c->addSelectColumn(ApplicationPeer::APP_STATUS);
- $c->addSelectColumn(ApplicationPeer::PRO_UID);
- $c->addSelectColumn(ApplicationPeer::APP_CREATE_DATE);
- $c->addSelectColumn(ApplicationPeer::APP_FINISH_DATE);
- $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE);
- $c->addSelectColumn(ApplicationPeer::APP_DATA);
+ $c->addAsColumn("PRO_CATEGORY_UID", "pro.PRO_CATEGORY");
+
+ $c->addAlias ('capp', 'CONTENT');
+ $c->addAlias ('cpro', 'CONTENT');
+ $c->addAlias ('ad', 'APP_DELEGATION');
+ $c->addAlias ('at', 'APP_THREAD');
+ $c->addAlias ("pro", ProcessPeer::TABLE_NAME);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ ApplicationPeer::APP_UID,
+ 'capp.CON_ID'
+ );
+ $aConditions [] = array (
+ 'capp.CON_CATEGORY',
+ DBAdapter::getStringDelimiter () . 'APP_TITLE' . DBAdapter::getStringDelimiter ()
+ );
+ $aConditions [] = array (
+ 'capp.CON_LANG',
+ DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
+ );
+ $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ ApplicationPeer::PRO_UID,
+ 'cpro.CON_ID'
+ );
+ $aConditions [] = array (
+ 'cpro.CON_CATEGORY',
+ DBAdapter::getStringDelimiter () . 'PRO_TITLE' . DBAdapter::getStringDelimiter ()
+ );
+ $aConditions [] = array (
+ 'cpro.CON_LANG',
+ DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
+ );
+ $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
+
+ $c->addJoin (ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ 'ad.APP_UID',
+ 'at.APP_UID'
+ );
+ $aConditions [] = array (
+ 'ad.DEL_THREAD',
+ 'at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC ($aConditions, Criteria::JOIN);
- $c->addAsColumn("APP_TITLE", "capp.CON_VALUE");
- $c->addAsColumn("PRO_TITLE", "cpro.CON_VALUE");
-
- $c->addSelectColumn("ad.DEL_INDEX");
- $c->addSelectColumn("ad.DEL_PREVIOUS");
- $c->addSelectColumn("ad.TAS_UID");
- $c->addSelectColumn("ad.USR_UID");
- $c->addSelectColumn("ad.DEL_TYPE");
- $c->addSelectColumn("ad.DEL_THREAD");
- $c->addSelectColumn("ad.DEL_THREAD_STATUS");
- $c->addSelectColumn("ad.DEL_PRIORITY");
- $c->addSelectColumn("ad.DEL_DELEGATE_DATE");
- $c->addSelectColumn("ad.DEL_INIT_DATE");
- $c->addSelectColumn("ad.DEL_TASK_DUE_DATE");
- $c->addSelectColumn("ad.DEL_FINISH_DATE");
- $c->addSelectColumn("ad.DEL_DURATION");
- $c->addSelectColumn("ad.DEL_QUEUE_DURATION");
- $c->addSelectColumn("ad.DEL_DELAY_DURATION");
- $c->addSelectColumn("ad.DEL_STARTED");
- $c->addSelectColumn("ad.DEL_FINISHED");
- $c->addSelectColumn("ad.DEL_DELAYED");
- $c->addSelectColumn("ad.APP_OVERDUE_PERCENTAGE");
-
- $c->addSelectColumn("at.APP_THREAD_INDEX");
- $c->addSelectColumn("at.APP_THREAD_PARENT");
- $c->addSelectColumn("at.APP_THREAD_STATUS");
-
- $c->addAsColumn("APPDELY_APP_DELAY_UID", "appDely.APP_DELAY_UID");
- $c->addAsColumn("APPDELY_APP_TYPE", "appDely.APP_TYPE");
- $c->addAsColumn("APPDELY_APP_DISABLE_ACTION_USER", "appDely.APP_DISABLE_ACTION_USER");
-
- $c->addAsColumn("PRO_CATEGORY_UID", "pro.PRO_CATEGORY");
-
- $c->addAlias("capp", ContentPeer::TABLE_NAME);
- $c->addAlias("cpro", ContentPeer::TABLE_NAME);
- $c->addAlias("ad", AppDelegationPeer::TABLE_NAME);
- $c->addAlias("at", AppThreadPeer::TABLE_NAME);
- $c->addAlias("appDely", AppDelayPeer::TABLE_NAME);
- $c->addAlias("pro", ProcessPeer::TABLE_NAME);
-
- $arrayCondition = array();
- $arrayCondition[] = array(ApplicationPeer::APP_UID, "capp.CON_ID");
- $arrayCondition[] = array("capp.CON_CATEGORY", DBAdapter::getStringDelimiter() . "APP_TITLE" . DBAdapter::getStringDelimiter());
- $arrayCondition[] = array("capp.CON_LANG", DBAdapter::getStringDelimiter() . "en" . DBAdapter::getStringDelimiter());
- $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- $arrayCondition = array();
- $arrayCondition[] = array(ApplicationPeer::PRO_UID, "cpro.CON_ID");
- $arrayCondition[] = array("cpro.CON_CATEGORY", DBAdapter::getStringDelimiter() . "PRO_TITLE" . DBAdapter::getStringDelimiter());
- $arrayCondition[] = array("cpro.CON_LANG", DBAdapter::getStringDelimiter() . "en" . DBAdapter::getStringDelimiter());
- $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- $c->addJoin(ApplicationPeer::APP_UID, "ad.APP_UID", Criteria::JOIN);
-
- $arrayCondition = array();
- $arrayCondition[] = array("ad.APP_UID", "at.APP_UID");
- $arrayCondition[] = array("ad.DEL_THREAD", "at.APP_THREAD_INDEX");
- $c->addJoinMC($arrayCondition, Criteria::JOIN);
-
- $arrayCondition = array();
- $arrayCondition[] = array("ad.APP_UID", "appDely.APP_UID");
- $arrayCondition[] = array("ad.DEL_INDEX", "appDely.APP_DEL_INDEX");
- $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- $arrayCondition = array();
- $arrayCondition[] = array(ApplicationPeer::PRO_UID, "pro.PRO_UID");
- $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- $c->add(ApplicationPeer::APP_UID, $aaAppUIDs, Criteria::IN);
-
- $rs = ApplicationPeer::doSelectRS($c);
- $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- while ($rs->next()) {
- $row = $rs->getRow();
-
- $allAppDbData[] = $row;
- }
-
- return $allAppDbData;
+ $arrayCondition = array();
+ $arrayCondition[] = array(ApplicationPeer::PRO_UID, "pro.PRO_UID");
+ $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
+
+ $c->add (ApplicationPeer::APP_UID, $aaAppUIDs, Criteria::IN);
+
+ $rs = ApplicationPeer::doSelectRS ($c);
+ $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
+
+ $rs->next ();
+ $row = $rs->getRow ();
+
+ while (is_array ($row)) {
+ $allAppDbData [] = $row;
+ $rs->next ();
+ $row = $rs->getRow ();
}
- /**
- * Get the list of groups of unassigned users of the specified task from
- * database
- *
- * @param string $ProUID Process identifier
- * @param string $TaskUID task identifier
- * @return array of unassigned user groups
- */
- public function getTaskUnassignedUsersGroupsData ($ProUID, $TaskUID)
- {
- $unassignedUsersGroups = array ();
+ //Propel::close();
- $c = new Criteria();
+ return $allAppDbData;
+ }
+
+ /**
+ * Get the list of groups of unassigned users of the specified task from
+ * database
+ *
+ * @param string $ProUID
+ * Process identifier
+ * @param string $TaskUID
+ * task identifier
+ * @return array of unassigned user groups
+ */
+ public function getTaskUnassignedUsersGroupsData($ProUID, $TaskUID)
+ {
+ $unassignedUsersGroups = array ();
+
+ $c = new Criteria ();
+
+ $c->addSelectColumn (TaskUserPeer::USR_UID);
+ $c->addSelectColumn (TaskUserPeer::TU_RELATION);
+
+ $aConditions = array ();
+ $aConditions [] = array (
+ TaskPeer::TAS_UID,
+ TaskUserPeer::TAS_UID
+ );
+ $aConditions [] = array (
+ TaskPeer::TAS_ASSIGN_TYPE,
+ DBAdapter::getStringDelimiter () . 'SELF_SERVICE' . DBAdapter::getStringDelimiter ()
+ );
+ $c->addJoinMC ($aConditions, Criteria::JOIN);
+
+ $c->add (TaskPeer::PRO_UID, $ProUID);
+ $c->add (TaskPeer::TAS_UID, $TaskUID);
+
+ $rs = TaskPeer::doSelectRS ($c);
+ $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
+ // echo $c->toString();
+ $rs->next ();
+ $row = $rs->getRow ();
+
+ while (is_array ($row)) {
+ $unassignedUsersGroups [] = $row;
+ $rs->next ();
+ $row = $rs->getRow ();
+ }
+
+ //Propel::close();
- $c->addSelectColumn( TaskUserPeer::USR_UID );
- $c->addSelectColumn( TaskUserPeer::TU_RELATION );
+ return $unassignedUsersGroups;
+ }
+
+ /**
+ * Get the list of dynaform file names associated with the specified process
+ * from database
+ *
+ * @param string $ProUID
+ * process identifier
+ * @return array of dynaform file names
+ */
+ public function getProcessDynaformFileNames($ProUID)
+ {
+ $dynaformFileNames = array ();
+
+ $c = new Criteria ();
+
+ $c->addSelectColumn (DynaformPeer::DYN_FILENAME);
+
+ $c->add (DynaformPeer::PRO_UID, $ProUID);
+
+ $rs = DynaformPeer::doSelectRS ($c);
+ $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
+ $rs->next ();
+ $row = $rs->getRow ();
+
+ while (is_array ($row)) {
+ $dynaformFileNames [] = $row;
+ $rs->next ();
+ $row = $rs->getRow ();
+ }
+
+ //Propel::close();
- $aConditions = array ();
- $aConditions[] = array (TaskPeer::TAS_UID,TaskUserPeer::TAS_UID
- );
- $aConditions[] = array (TaskPeer::TAS_ASSIGN_TYPE,DBAdapter::getStringDelimiter() . 'SELF_SERVICE' . DBAdapter::getStringDelimiter()
- );
- $c->addJoinMC( $aConditions, Criteria::JOIN );
+ return $dynaformFileNames;
+ }
+
+ /**
+ * Store a flag indicating if the application was updated in database
+ * table APP_SOLR_QUEUE
+ *
+ * @param string $AppUid
+ * applicatiom identifier
+ * @param integer $updated
+ * 0:false, not updated, 1: updated, 2:deleted
+ */
+ public function applicationChangedUpdateSolrQueue($AppUid, $updated)
+ {
+ $traceData = $this->getCurrentTraceInfo();
+ //var_dump($traceData);
- $c->add( TaskPeer::PRO_UID, $ProUID );
- $c->add( TaskPeer::TAS_UID, $TaskUID );
+ $oAppSolrQueue = new AppSolrQueue ();
+
+ $oAppSolrQueue->createUpdate ($AppUid, $traceData, $updated);
+ }
- $rs = TaskPeer::doSelectRS( $c );
- $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
- // echo $c->toString();
- $rs->next();
- $row = $rs->getRow();
+ private function getCurrentTraceInfo()
+ {
+ $resultTraceString = "";
- while (is_array( $row )) {
- $unassignedUsersGroups[] = $row;
- $rs->next();
- $row = $rs->getRow();
- }
+ //
+ $traceData = debug_backtrace();
+ foreach ($traceData as $key => $value) {
+ if($value['function'] != 'getCurrentTraceInfo' && $value['function'] != 'require_once')
+ $resultTraceString .= $value['file'] . " (" . $value['line'] . ") " . $value['function'] . "\n";
+ }
+ return $resultTraceString;
+ }
+
+ /**
+ * Update application records in Solr that are stored in APP_SOLR_QUEUE table
+ */
+ public function synchronizePendingApplications()
+ {
+ if(!$this->isSolrEnabled())
+ throw new Exception(date('Y-m-d H:i:s:u') . " Error connecting to solr server.");
+
+ // check table of pending updates
+ $oAppSolrQueue = new AppSolrQueue ();
+
+ $aAppSolrQueue = $oAppSolrQueue->getListUpdatedApplications ();
- return $unassignedUsersGroups;
+ $trunkSize = 100;
+ //filter updated cases
+ $aUpdatedApplications = array();
+ $aDeletedApplications = array();
+ foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
+ // call the syncronization function
+ if($oAppSolrQueueEntity->appUpdated == 1){
+ $aUpdatedApplications[] = array ('APP_UID' => $oAppSolrQueueEntity->appUid );
+ }
+ if($oAppSolrQueueEntity->appUpdated == 2){
+ $aDeletedApplications[] = array ('APP_UID' => $oAppSolrQueueEntity->appUid );
+ }
}
- /**
- * Get the list of dynaform file names associated with the specified process
- * from database
- *
- * @param string $ProUID process identifier
- * @return array of dynaform file names
- */
- public function getProcessDynaformFileNames ($ProUID)
- {
- $dynaformFileNames = array ();
+ $totalCasesUpdated = count($aUpdatedApplications);
+ $loops = ((($totalCasesUpdated % $trunkSize) > 0 )? ($totalCasesUpdated / $trunkSize)+1: ($totalCasesUpdated / $trunkSize));
+ for ($i = 0; $i < $loops; $i++) {
+ //prepare trunk of appuids
+ $trunkUpdatedApplications = array_slice($aUpdatedApplications, $i * $trunkSize, $trunkSize);
- $c = new Criteria();
+ $this->updateApplicationSearchIndex ($trunkUpdatedApplications, true);
- $c->addSelectColumn( DynaformPeer::DYN_FILENAME );
-
- $c->add( DynaformPeer::PRO_UID, $ProUID );
-
- $rs = DynaformPeer::doSelectRS( $c );
- $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
- $rs->next();
- $row = $rs->getRow();
-
- while (is_array( $row )) {
- $dynaformFileNames[] = $row;
- $rs->next();
- $row = $rs->getRow();
- }
-
- return $dynaformFileNames;
+ /*foreach($trunkUpdatedApplications as $appUid){
+ $this->applicationChangedUpdateSolrQueue ($appUid, 0);
+ }*/
}
- /**
- * Store a flag indicating if the application was updated in database
- * table APP_SOLR_QUEUE
- *
- * @param string $AppUid applicatiom identifier
- * @param integer $updated 0:false, not updated, 1: updated, 2:deleted
- */
- public function applicationChangedUpdateSolrQueue ($AppUid, $updated)
- {
- $traceData = $this->getCurrentTraceInfo();
+ $totalCasesDeleted = count($aDeletedApplications);
+ $loops = ((($totalCasesDeleted % $trunkSize) > 0 )? ($totalCasesDeleted / $trunkSize)+1: ($totalCasesDeleted / $trunkSize));
+ for ($i = 0; $i < $loops; $i++) {
+ //prepare trunk of appuids
+ $trunkDeleteddApplications = array_slice($aDeletedApplications, $i * $trunkSize, $trunkSize);
- $oAppSolrQueue = new AppSolrQueue();
+ $this->deleteApplicationSearchIndex ($trunkDeleteddApplications, true);
- $oAppSolrQueue->createUpdate($AppUid, $traceData, $updated);
+ /*foreach($trunkDeleteddApplications as $appUid){
+ $this->applicationChangedUpdateSolrQueue ($appUid, 0);
+ }*/
+ }
+
+ /*
+ foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
+ // call the syncronization function
+ if($oAppSolrQueueEntity->appUpdated == 1){
+ $this->updateApplicationSearchIndex ($oAppSolrQueueEntity->appUid, false);
+ }
+ if($oAppSolrQueueEntity->appUpdated == 2){
+ $this->deleteApplicationSearchIndex ($oAppSolrQueueEntity->appUid, false);
+ }
+ $this->applicationChangedUpdateSolrQueue ($oAppSolrQueueEntity->appUid, 0);
+ }*/
+ }
+
+ /**
+ * Get the total number of application records in database
+ *
+ * @return integer application counter
+ */
+ public function getCountApplicationsPMOS2()
+ {
+ $c = new Criteria ();
+
+ $c->addSelectColumn (ApplicationPeer::APP_UID);
+
+ $count = ApplicationPeer::doCount ($c);
+
+ //Propel::close();
+
+ return $count;
+ }
+
+ /**
+ * Get the total number of application records in search index
+ *
+ * @return integer application counter
+ */
+ public function getCountApplicationsSearchIndex()
+ {
+ G::LoadClass ('searchIndex');
+
+ $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
+ // execute query
+ $count = $searchIndex->getNumberDocuments ($this->_solrInstance);
+
+ return $count;
+ }
+
+ /**
+ * Optimize the records in search index
+ *
+ * @return
+ */
+ public function optimizeSearchIndex()
+ {
+ G::LoadClass ('searchIndex');
+
+ $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
+ // execute query
+ $searchIndex->optimizeIndexChanges ($this->_solrInstance);
+
+ }
+
+ /**
+ * Get a paginated list of application uids from database.
+ *
+ * @param integer $skip
+ * the offset from where to return the application records
+ * @param integer $pagesize
+ * the size of the page
+ * @return array of application id's in the specified page.
+ */
+ public function getPagedApplicationUids($skip, $pagesize)
+ {
+
+ $c = new Criteria ();
+
+ $c->addSelectColumn (ApplicationPeer::APP_UID);
+ $c->setOffset ($skip);
+ $c->setLimit ($pagesize);
+
+ $rs = ApplicationPeer::doSelectRS ($c);
+ $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
+
+ $rs->next ();
+ $row = $rs->getRow ();
+ $appUIds = array ();
+ while (is_array ($row)) {
+ $appUIds [] = $row;
+ $rs->next ();
+ $row = $rs->getRow ();
}
- private function getCurrentTraceInfo()
- {
- $traceData = debug_backtrace();
- $resultTraceString = "";
+ //Propel::close();
- foreach ($traceData as $key => $value) {
- if ($value["function"] != "getCurrentTraceInfo" && $value["function"] != "require_once") {
- $resultTraceString .= $value["file"] . " (" . $value["line"] . ") " . $value["function"] . "\n";
- }
- }
+ return $appUIds;
+ }
+
+ /**
+ * Reindex all the application records in Solr server
+ * update applications in groups of 1000
+ */
+ public function reindexAllApplications($SkipRecords = 0, $indexTrunkSize = 1000)
+ {
+ $trunk = $indexTrunkSize;
- return $resultTraceString;
+ if(!$this->isSolrEnabled())
+ throw new Exception(date('Y-m-d H:i:s:u') . " Error connecting to solr server.");
+
+ // delete all documents to begin reindex
+ // deleteAllDocuments();
+ // commitChanges();
+ // print "Deleted all documents \n";
+ // search trunks of id's to regenerate index
+ $numRows = $this->getCountApplicationsPMOS2 ();
+ print "Total number of records: " . $numRows . "\n";
+ //
+ $initTimeAll = microtime (true);
+
+ for ($skip = $SkipRecords; $skip <= $numRows;) {
+ $aaAPPUIds = $this->getPagedApplicationUids ($skip, $trunk);
+
+ printf ("Indexing %d to %d \n", $skip, $skip + $trunk);
+ $initTimeDoc = microtime (true);
+ $this->updateApplicationSearchIndex ($aaAPPUIds, false);
+
+ $curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeDoc));
+ printf ("Indexing document time: %s \n", $curTimeDoc);
+ $skip += $trunk;
}
+
+ $curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeAll));
+ printf ("Total reindex time: %s \n", $curTimeDoc);
+ printf ("Reindex completed successfully!!.\n");
+ }
- /**
- * Update application records in Solr that are stored in APP_SOLR_QUEUE table
- */
- public function synchronizePendingApplications ()
- {
- if (!$this->isSolrEnabled()) {
- throw new Exception("Error connecting to solr server.");
- }
-
- // check table of pending updates
- $oAppSolrQueue = new AppSolrQueue();
-
- $aAppSolrQueue = $oAppSolrQueue->getListUpdatedApplications();
-
- foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
- // call the syncronization function
- if ($oAppSolrQueueEntity->appUpdated == 1) {
- $this->updateApplicationSearchIndex($oAppSolrQueueEntity->appUid, false);
- }
- if ($oAppSolrQueueEntity->appUpdated == 2) {
- $this->deleteApplicationSearchIndex($oAppSolrQueueEntity->appUid, false);
- }
- $this->applicationChangedUpdateSolrQueue( $oAppSolrQueueEntity->appUid, 0 );
- }
- }
-
- /**
- * Get the total number of application records in database
- *
- * @return integer application counter
- */
- public function getCountApplicationsPMOS2 ()
- {
- $c = new Criteria();
-
- $c->addSelectColumn( ApplicationPeer::APP_UID );
-
- $count = ApplicationPeer::doCount( $c );
-
- return $count;
- }
-
- /**
- * Get the total number of application records in search index
- *
- * @return integer application counter
- */
- public function getCountApplicationsSearchIndex ()
- {
- G::LoadClass( 'searchIndex' );
-
- $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
- // execute query
- $count = $searchIndex->getNumberDocuments( $this->_solrInstance );
-
- return $count;
- }
-
- /**
- * Optimize the records in search index
- *
- * @return
- *
- */
- public function optimizeSearchIndex ()
- {
- G::LoadClass( 'searchIndex' );
-
- $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
- // execute query
- $searchIndex->optimizeIndexChanges( $this->_solrInstance );
-
- }
-
- /**
- * Get a paginated list of application uids from database.
- *
- * @param integer $skip the offset from where to return the application records
- * @param integer $pagesize the size of the page
- * @return array of application id's in the specified page.
- */
- public function getPagedApplicationUids ($skip, $pagesize)
- {
-
- $c = new Criteria();
-
- $c->addSelectColumn( ApplicationPeer::APP_UID );
- $c->setOffset( $skip );
- $c->setLimit( $pagesize );
-
- $rs = ApplicationPeer::doSelectRS( $c );
- $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
-
- $rs->next();
- $row = $rs->getRow();
- $appUIds = array ();
- while (is_array( $row )) {
- $appUIds[] = $row;
- $rs->next();
- $row = $rs->getRow();
- }
- return $appUIds;
- }
-
- /**
- * Reindex all the application records in Solr server
- * update applications in groups of 1000
- */
- public function reindexAllApplications ($SkipRecords = 0, $indexTrunkSize = 1000)
- {
- if (!$this->isSolrEnabled()) {
- throw new Exception("Error connecting to solr server.");
- }
-
- $trunk = $indexTrunkSize;
-
- // delete all documents to begin reindex
- // deleteAllDocuments();
- // commitChanges();
- // print "Deleted all documents \n";
- // search trunks of id's to regenerate index
- $numRows = $this->getCountApplicationsPMOS2();
- print "Total number of records: " . $numRows . "\n";
- $initTimeAll = microtime( true );
-
- for ($skip = $SkipRecords; $skip <= $numRows; true) {
- $aaAPPUIds = $this->getPagedApplicationUids( $skip, $trunk );
-
- printf( "Indexing %d to %d \n", $skip, $skip + $trunk );
- $initTimeDoc = microtime( true );
- $this->updateApplicationSearchIndex($aaAPPUIds, false);
-
- $curTimeDoc = gmdate( 'H:i:s', (microtime( true ) - $initTimeDoc) );
- printf( "Indexing document time: %s \n", $curTimeDoc );
- $skip += $trunk;
- }
-
- $curTimeDoc = gmdate( 'H:i:s', (microtime( true ) - $initTimeAll) );
- printf( "Total reindex time: %s \n", $curTimeDoc );
- printf( "Reindex completed successfully!!.\n" );
- }
}
-
diff --git a/workflow/engine/classes/class.memcached.php b/workflow/engine/classes/class.memcached.php
index 49cfa3266..f0c20f2dc 100644
--- a/workflow/engine/classes/class.memcached.php
+++ b/workflow/engine/classes/class.memcached.php
@@ -153,7 +153,7 @@ class PMmemcached
public function delete($key)
{
- if (!$this->connected) {
+ if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -162,7 +162,7 @@ class PMmemcached
public function flush()
{
- if (!$this->connected) {
+ if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -171,7 +171,7 @@ class PMmemcached
public function getStats()
{
- if (!$this->connected) {
+ if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -180,13 +180,13 @@ class PMmemcached
public function printDetails()
{
- if (!$this->connected) {
+ if (! $this->connected || $this->class == 'filecache') {
return false;
}
$status = $this->mem->getStats();
- if (!is_array($status)) {
+ if (! is_array($status)) {
return false;
}
diff --git a/workflow/engine/classes/class.searchIndex.php b/workflow/engine/classes/class.searchIndex.php
index 3ea5497d0..5b00cee56 100644
--- a/workflow/engine/classes/class.searchIndex.php
+++ b/workflow/engine/classes/class.searchIndex.php
@@ -1,5 +1,6 @@
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;
- // }
- }
-
+ 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');
+
/**
- * 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 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);
}
-
+
/**
- * 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;
}
-
- /**
- * ***************************************************************
- */
- // 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)
- {
- G::LoadClass( 'solr' );
-
- $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)
- {
- G::LoadClass( 'solr' );
-
- $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)
- {
- G::LoadClass( 'solr' );
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
-
- // commit
- $solr->commitChanges( $workspace );
- }
-
- /**
- * Optimize index changes
- *
- * @param string $workspace
- */
- public function optimizeIndexChanges ($workspace)
- {
- G::LoadClass( 'solr' );
-
- $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];
- }
+ // 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;
}
- // 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;
+ }
}
-
+ // TODO:convert facet queries
+ // -----
/**
- * 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;
+ // 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)
+ {
+ G::LoadClass ('solr');
+
+ $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)
+ {
+ G::LoadClass ('solr');
+
+ $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)
+ {
+ G::LoadClass ('solr');
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
+
+ // commit
+ $solr->commitChanges ($workspace);
+ }
+
+ /**
+ * Optimize index changes
+ * @param string $workspace
+ */
+ public function optimizeIndexChanges($workspace)
+ {
+ G::LoadClass ('solr');
+
+ $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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/class.solr.php b/workflow/engine/classes/class.solr.php
index 3dbdfd32d..2bf840a5d 100644
--- a/workflow/engine/classes/class.solr.php
+++ b/workflow/engine/classes/class.solr.php
@@ -1,6 +1,6 @@
_solrIsEnabled = $solrIsEnabled;
+ $this->_solrHost = $solrHost;
+ }
+
+ /**
+ * Verify if the Solr service is available
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return bool
+ */
+ public function isEnabled($workspace)
+ {
+ $resultServerStatus = false;
- const SOLR_VERSION = '&version=2.2';
+ //if($this->_solrIsEnabled != true)
+ //return $resultServerStatus;
- private $_solrIsEnabled = false;
- private $_solrHost = "";
+ // verify solr server response
+ try{
+ $resultServerStatus = $this->ping($workspace);
+ }catch(Exception $ex){
+ $resultServerStatus = false;
+ }
+
+ return $resultServerStatus;
+ }
+
+ /**
+ * Returns the total number of indexed documents
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @param
+ * workspace: workspace name
+ * @return total
+ */
+ public function getNumberDocuments($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ // get configuration information in base to workspace parameter
+
+ // get total number of documents in registry
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=*:*";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
+
+ $handlerTotal = curl_init ($solrIntruct);
+ curl_setopt ($handlerTotal, CURLOPT_RETURNTRANSFER, true);
- public function __construct($solrIsEnabled = false, $solrHost = "")
- {
- // use the parameters to initialize class
- $this->_solrIsEnabled = $solrIsEnabled;
- $this->_solrHost = $solrHost;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Verify if the Solr service is available
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return bool
- */
- public function isEnabled($workspace)
- {
- $resultServerStatus = false;
+ $responseTotal = curl_exec ($handlerTotal);
+ curl_close ($handlerTotal);
+
+ // verify the result of solr
+ $responseSolrTotal = G::json_decode ($responseTotal);
+ if ($responseSolrTotal->responseHeader->status != 0) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ $numTotalDocs = $responseSolrTotal->response->numFound;
+ return $numTotalDocs;
+ }
+
+ /**
+ * Execute a query in base to Requested data
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function executeQuery($solrRequestData)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $workspace = $solrRequestData->workspace;
+
+ // format request
+ $query = empty ($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText;
+ $query = rawurlencode ($query);
+ $start = '&start=' . $solrRequestData->startAfter;
+ $rows = '&rows=' . $solrRequestData->pageSize;
+ $fieldList = '';
+ $cols = $solrRequestData->includeCols;
+ if (! empty ($cols)) {
+ $fieldList = "&fl=" . implode (",", $cols);
+ }
+ $sort = '';
+ if ($solrRequestData->numSortingCols > 0) {
+ $sort = '&sort=';
+ for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
+ $sort .= $solrRequestData->sortCols [$i] . "%20" . $solrRequestData->sortDir [$i] . ",";
+ }
+
+ $sort = substr_replace ($sort, "", - 1);
+ }
+ $resultFormat = empty ($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat;
+ $filters = '';
+ $aFilters = explode (',', $solrRequestData->filterText);
+ foreach ($aFilters as $value) {
+ $filters .= '&fq=' . urlencode ($value);
+ }
+
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=$query";
+ $solrIntruct .= "&echoParams=none";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= $start;
+ $solrIntruct .= $rows;
+ $solrIntruct .= $fieldList;
+ $solrIntruct .= $sort;
+ $solrIntruct .= $filters;
+ $solrIntruct .= $resultFormat;
+ // send query
+ // search the cases in base to datatable parameters
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- if ($this->_solrIsEnabled != true) {
- return $resultServerStatus;
- }
-
- //Verify solr server response
- try {
- $resultServerStatus = $this->ping($workspace);
- } catch (Exception $e) {
- $resultServerStatus = false;
- }
-
- return $resultServerStatus;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Returns the total number of indexed documents
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @param workspace: workspace name
- * @return total
- */
- public function getNumberDocuments($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- // get configuration information in base to workspace parameter
- // get total number of documents in registry
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=*:*";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ // decode
+ $responseSolr = G::json_decode ($response);
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+
+ return $responseSolr;
+ }
+
+ /**
+ * Insert or Update document index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function updateDocument($solrUpdateDocument)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $solrUpdateDocument->workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
- $handlerTotal = curl_init($solrIntruct);
- curl_setopt($handlerTotal, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $responseTotal = curl_exec($handlerTotal);
- curl_close($handlerTotal);
-
- // verify the result of solr
- $responseSolrTotal = G::json_decode($responseTotal);
- if ($responseSolrTotal->responseHeader->status != 0) {
- throw new Exception("Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- $numTotalDocs = $responseSolrTotal->response->numFound;
- return $numTotalDocs;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Execute a query in base to Requested data
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function executeQuery($solrRequestData)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $workspace = $solrRequestData->workspace;
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Commit the changes since the last commit
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function commitChanges($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
- // format request
- $query = empty($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText;
- $query = rawurlencode($query);
- $start = '&start=' . $solrRequestData->startAfter;
- $rows = '&rows=' . $solrRequestData->pageSize;
- $fieldList = '';
- $cols = $solrRequestData->includeCols;
- if (!empty($cols)) {
- $fieldList = "&fl=" . implode(",", $cols);
- }
- $sort = '';
- if ($solrRequestData->numSortingCols > 0) {
- $sort = '&sort=';
- for ($i = 0; $i < $solrRequestData->numSortingCols; $i++) {
- $sort .= $solrRequestData->sortCols[$i] . "%20" . $solrRequestData->sortDir[$i] . ",";
- }
-
- $sort = substr_replace($sort, "", - 1);
- }
- $resultFormat = empty($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat;
- $filters = '';
- $aFilters = explode(',', $solrRequestData->filterText);
- foreach ($aFilters as $value) {
- $filters .= '&fq=' . urlencode($value);
- }
-
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=$query";
- $solrIntruct .= "&echoParams=none";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= $start;
- $solrIntruct .= $rows;
- $solrIntruct .= $fieldList;
- $solrIntruct .= $sort;
- $solrIntruct .= $filters;
- $solrIntruct .= $resultFormat;
- // send query
- // search the cases in base to datatable parameters
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- // decode
- $responseSolr = G::json_decode($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception("Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
-
- return $responseSolr;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Insert or Update document index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function updateDocument($solrUpdateDocument)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $solrUpdateDocument->workspace;
- $solrIntruct .= "/update";
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Rollback the changes since the last commit
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function rollbackChanges($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml'
- )); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Commit the changes since the last commit
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function commitChanges($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Optimize Solr index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function optimizeChanges($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Rollback the changes since the last commit
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function rollbackChanges($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Return the list of the stored fields in Solr
+ *
+ * @param string $workspace
+ * Solr instance name
+ * @throws Exception
+ * @return void mixed of field names
+ */
+ public function getListIndexedStoredFields($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/admin/luke?numTerms=0&wt=json";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
-
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Optimize Solr index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function optimizeChanges($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+ // decode
+ $responseSolr = G::json_decode ($response);
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ return $responseSolr;
+ }
+
+ /**
+ * Ping the Solr Server to check his health
+ *
+ * @param string $workspace
+ * Solr instance name
+ * @throws Exception
+ * @return void mixed of field names
+ */
+ public function ping($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/admin/ping?wt=json";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ $response = curl_exec ($handler);
+ curl_close ($handler);
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
+ //there's no response
+ if(!$response)
+ return false;
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
+ // decode
+ $responseSolr = G::json_decode ($response);
+ if ($responseSolr->responseHeader->status != "OK") {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ return true;
+ }
- $response = curl_exec($handler);
- curl_close($handler);
+ /**
+ * Delete all documents from index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function deleteAllDocuments($workspace)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ // $registry = Zend_Registry::getInstance();
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, "*:*"); // data
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Return the list of the stored fields in Solr
- *
- * @param string $workspace Solr instance name
- * @throws Exception
- * @return void mixed of field names
- */
- public function getListIndexedStoredFields($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
+ $response = curl_exec ($handler);
+
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Delete specified documents from index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function deleteDocument($workspace, $idQuery)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+ // $registry = Zend_Registry::getInstance();
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
+
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
+ 'Content-type:application/xml'
+ )); // -H
+ curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
+ curl_setopt ($handler, CURLOPT_POSTFIELDS, "" . $idQuery . ""); // data
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/admin/luke?numTerms=0&wt=json";
-
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
- // decode
- $responseSolr = G::json_decode($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception("Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- return $responseSolr;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Ping the Solr Server to check his health
- *
- * @param string $workspace
- * Solr instance name
- * @throws Exception
- * @return void mixed of field names
- */
- public function ping($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
+ $response = curl_exec ($handler);
+
+ curl_close ($handler);
+
+ $swOk = strpos ($response, '0');
+ if (! $swOk) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ }
+ }
+
+ /**
+ * Execute a query in base to Request data
+ *
+ * @param Entity_FacetRequest $facetRequestEntity
+ * @return solr response: list of facets array
+ */
+ public function getFacetsList($facetRequest)
+ {
+ //if (! $this->_solrIsEnabled)
+ //return;
+
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $workspace = $facetRequest->workspace;
+
+ // format request
+ $query = empty ($facetRequest->searchText) ? '*:*' : $facetRequest->searchText;
+ $query = rawurlencode ($query);
+ $start = '&start=0';
+ $rows = '&rows=0';
+ $facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and
+ // only return facets
+ // with minimun one
+ // instance
+ foreach ($facetRequest->facetFields as $value) {
+ $facets .= '&facet.field=' . $value;
+ }
+ foreach ($facetRequest->facetQueries as $value) {
+ $facets .= '&facet.query=' . $value;
+ }
+ if (! empty ($facetRequest->facetDates)) {
+ foreach ($facetRequest->facetDates as $value) {
+ $facets .= '&facet.date=' . $value;
+ }
+ $facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
+ $facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
+ $facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
+ }
+ $filters = '';
+ foreach ($facetRequest->filters as $value) {
+ $filters .= '&fq=' . $value;
+ }
+ // echo "";
+
+ $resultFormat = '&wt=json';
+
+ $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=$query";
+ $solrIntruct .= "&echoParams=none";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= $start;
+ $solrIntruct .= $rows;
+ $solrIntruct .= $facets;
+ $solrIntruct .= $filters;
+ $solrIntruct .= $resultFormat;
+
+ // send query
+ // search the cases in base to datatable parameters
+ $handler = curl_init ($solrIntruct);
+ curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- $solrIntruct = "";
-
- //Get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/admin/ping?wt=json";
-
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
-
- if ($sysConf["proxy_host"] != "") {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf["proxy_host"] . (($sysConf["proxy_port"] != "") ? ":" . $sysConf["proxy_port"] : ""));
-
- if ($sysConf["proxy_port"] != "") {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf["proxy_port"]);
- }
-
- if ($sysConf["proxy_user"] != "") {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf["proxy_user"] . (($sysConf["proxy_pass"] != "") ? ":" . $sysConf["proxy_pass"] : ""));
- }
-
- curl_setopt($handler, CURLOPT_HTTPHEADER, array("Expect:"));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- //There's no response
- if (!$response) {
- return false;
- }
-
- //Decode
- $responseSolr = G::json_decode($response);
-
- if ($responseSolr->responseHeader->status != "OK") {
- throw new Exception("Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
- }
-
- return true;
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
+ }
+ curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
}
- /**
- * Delete all documents from index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function deleteAllDocuments($workspace)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- // $registry = Zend_Registry::getInstance();
-
-
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
-
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, "*:*"); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
-
- curl_close($handler);
-
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
-
- /**
- * Delete specified documents from index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function deleteDocument($workspace, $idQuery)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
- // $registry = Zend_Registry::getInstance();
-
-
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
-
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
- curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
- curl_setopt($handler, CURLOPT_POSTFIELDS, "" . $idQuery . ""); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
-
- curl_close($handler);
-
- $swOk = strpos($response, '0');
- if (!$swOk) {
- throw new Exception("Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
-
- /**
- * Execute a query in base to Request data
- *
- * @param Entity_FacetRequest $facetRequestEntity
- * @return solr response: list of facets array
- */
- public function getFacetsList($facetRequest)
- {
- if (!$this->_solrIsEnabled) {
- return;
- }
-
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $workspace = $facetRequest->workspace;
-
- // format request
- $query = empty($facetRequest->searchText) ? '*:*' : $facetRequest->searchText;
- $query = rawurlencode($query);
- $start = '&start=0';
- $rows = '&rows=0';
- $facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and
- // only return facets
- // with minimun one
- // instance
- foreach ($facetRequest->facetFields as $value) {
- $facets .= '&facet.field=' . $value;
- }
- foreach ($facetRequest->facetQueries as $value) {
- $facets .= '&facet.query=' . $value;
- }
- if (!empty($facetRequest->facetDates)) {
- foreach ($facetRequest->facetDates as $value) {
- $facets .= '&facet.date=' . $value;
- }
- $facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
- $facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
- $facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
- }
- $filters = '';
- foreach ($facetRequest->filters as $value) {
- $filters .= '&fq=' . $value;
- }
- // echo "";
-
-
- $resultFormat = '&wt=json';
-
- $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=$query";
- $solrIntruct .= "&echoParams=none";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= $start;
- $solrIntruct .= $rows;
- $solrIntruct .= $facets;
- $solrIntruct .= $filters;
- $solrIntruct .= $resultFormat;
-
- // send query
- // search the cases in base to datatable parameters
- $handler = curl_init($solrIntruct);
- curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec($handler);
- curl_close($handler);
-
- // decode
- $responseSolr = G::json_decode($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
-
- return $responseSolr;
+ $response = curl_exec ($handler);
+ curl_close ($handler);
+
+ // decode
+ $responseSolr = G::json_decode ($response);
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception (date('Y-m-d H:i:s:u') . " Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
}
+
+ return $responseSolr;
+ }
}
-
diff --git a/workflow/engine/classes/entities/AppSolrQueue.php b/workflow/engine/classes/entities/AppSolrQueue.php
index 6c3ef1290..8df7933fa 100644
--- a/workflow/engine/classes/entities/AppSolrQueue.php
+++ b/workflow/engine/classes/entities/AppSolrQueue.php
@@ -1,43 +1,43 @@
initializeObject ($data);
+
+ $requiredFields = array (
+ "appUid",
+ "appChangeDate",
+ "appChangeTrace",
+ "appUpdated"
+ );
+
+ $obj->validateRequiredFields ($requiredFields);
+
+ return $obj;
+ }
- 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",
- "appChangeDate",
- "appChangeTrace",
- "appUpdated"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
}
-
diff --git a/workflow/engine/classes/entities/Base.php b/workflow/engine/classes/entities/Base.php
index b8134c007..5aa927469 100644
--- a/workflow/engine/classes/entities/Base.php
+++ b/workflow/engine/classes/entities/Base.php
@@ -2,154 +2,156 @@
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;
- }
+
+ /**
+ * 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 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 = call_user_func (array (
+ $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;
}
}
-
- protected function validateRequiredFields ($requiredFields = array())
- {
- foreach ($requiredFields as $k => $field) {
- if ($this->{$field} === null) {
- throw (new Exception( "Field $field is required in " . get_class( $this ) ));
- die();
- }
- }
+
+ 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 = call_user_func (array (
+ $className,
+ 'GetAliases'
+ ));
+ // $aliases = $className::GetAliases ();
+ foreach ($this as $field => $value)
+ if (isset ($aliases [$field]))
+ $this->{$field} = $aAliasData [$aliases [$field]];
}
-
- /**
- *
- *
- *
- *
- * 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 = call_user_func( array ($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;
+ }
+
+ /**
+ *
+ *
+ *
+ * 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 = call_user_func (array (
+ $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);
+ }
- /**
- *
- *
- *
- *
- * 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 = call_user_func( array ($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 = call_user_func( array ($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 );
- }
-}
-
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/FacetGroup.php b/workflow/engine/classes/entities/FacetGroup.php
index 5e48822ab..4e3302d8d 100644
--- a/workflow/engine/classes/entities/FacetGroup.php
+++ b/workflow/engine/classes/entities/FacetGroup.php
@@ -1,49 +1,51 @@
initializeObject( $data );
-
- $requiredFields = array ("facetGroupName","facetItems"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/FacetInterfaceRequest.php b/workflow/engine/classes/entities/FacetInterfaceRequest.php
index d23b773b8..2b074a2a5 100644
--- a/workflow/engine/classes/entities/FacetInterfaceRequest.php
+++ b/workflow/engine/classes/entities/FacetInterfaceRequest.php
@@ -1,40 +1,40 @@
initializeObject( $data );
-
- $requiredFields = array ("searchText","selectedFacetsString"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
diff --git a/workflow/engine/classes/entities/FacetInterfaceResult.php b/workflow/engine/classes/entities/FacetInterfaceResult.php
index 39ecdfa1b..600581321 100644
--- a/workflow/engine/classes/entities/FacetInterfaceResult.php
+++ b/workflow/engine/classes/entities/FacetInterfaceResult.php
@@ -1,37 +1,39 @@
initializeObject( $data );
-
- $requiredFields = array ("aFacetGroup","aSelectedFacetGroupItem","sFilterText"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ // 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/FacetItem.php b/workflow/engine/classes/entities/FacetItem.php
index 070ba3420..f710af459 100644
--- a/workflow/engine/classes/entities/FacetItem.php
+++ b/workflow/engine/classes/entities/FacetItem.php
@@ -1,48 +1,47 @@
initializeObject( $data );
-
- $requiredFields = array ("facetName","facetCount"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/FacetRequest.php b/workflow/engine/classes/entities/FacetRequest.php
index 5c0fbeeb1..cfd82ed40 100644
--- a/workflow/engine/classes/entities/FacetRequest.php
+++ b/workflow/engine/classes/entities/FacetRequest.php
@@ -1,45 +1,43 @@
initializeObject ($data);
+
+ $requiredFields = array (
+ "workspace"
+ );
+
+ $obj->validateRequiredFields ($requiredFields);
+
+ return $obj;
+ }
- 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()
- {
- }
-
- public static function createEmpty()
- {
- $obj = new Entity_FacetRequest ();
- return $obj;
- }
-
- public static function createForRequest($data)
- {
- $obj = new Entity_FacetRequest ();
-
- $obj->initializeObject($data);
-
- $requiredFields = array(
- "workspace"
- );
-
- $obj->validateRequiredFields($requiredFields);
-
- return $obj;
- }
-}
-
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/FacetResult.php b/workflow/engine/classes/entities/FacetResult.php
index 8fd97da4a..c115a6220 100644
--- a/workflow/engine/classes/entities/FacetResult.php
+++ b/workflow/engine/classes/entities/FacetResult.php
@@ -1,34 +1,37 @@
initializeObject( $data );
-
- $requiredFields = array ("aFacetGroups","aSelectedFacetGroups","sFilterText"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/SelectedFacetGroupItem.php b/workflow/engine/classes/entities/SelectedFacetGroupItem.php
index 2fbf7109d..364ca2d74 100644
--- a/workflow/engine/classes/entities/SelectedFacetGroupItem.php
+++ b/workflow/engine/classes/entities/SelectedFacetGroupItem.php
@@ -1,40 +1,40 @@
initializeObject( $data );
-
- $requiredFields = array ("selectedFacetGroupName","selectedFacetItemName"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/SolrQueryResult.php b/workflow/engine/classes/entities/SolrQueryResult.php
index 98e00abd1..7be7246b5 100644
--- a/workflow/engine/classes/entities/SolrQueryResult.php
+++ b/workflow/engine/classes/entities/SolrQueryResult.php
@@ -1,38 +1,40 @@
initializeObject( $data );
-
- $requiredFields = array ('sEcho','iTotalRecords','iTotalDisplayRecords','aaData'
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/SolrRequestData.php b/workflow/engine/classes/entities/SolrRequestData.php
index 4bd43f4be..931afbea4 100644
--- a/workflow/engine/classes/entities/SolrRequestData.php
+++ b/workflow/engine/classes/entities/SolrRequestData.php
@@ -1,48 +1,46 @@
initializeObject ($data);
+
+ $requiredFields = array (
+ 'workspace'
+ );
+
+ $obj->validateRequiredFields ($requiredFields);
+
+ return $obj;
+ }
- 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()
- {
- }
-
- public static function createEmpty()
- {
- $obj = new Entity_SolrRequestData ();
- return $obj;
- }
-
- public static function createForRequestPagination($data)
- {
- $obj = new Entity_SolrRequestData ();
-
- $obj->initializeObject($data);
-
- $requiredFields = array(
- 'workspace'
- );
-
- $obj->validateRequiredFields($requiredFields);
-
- return $obj;
- }
-}
-
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/entities/SolrUpdateDocument.php b/workflow/engine/classes/entities/SolrUpdateDocument.php
index 713ce9dc3..6ce732516 100644
--- a/workflow/engine/classes/entities/SolrUpdateDocument.php
+++ b/workflow/engine/classes/entities/SolrUpdateDocument.php
@@ -1,33 +1,35 @@
initializeObject( $data );
-
- $requiredFields = array ("workspace","document"
- );
-
- $obj->validateRequiredFields( $requiredFields );
-
- return $obj;
- }
-}
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/classes/model/AppSolrQueue.php b/workflow/engine/classes/model/AppSolrQueue.php
index fbe3fffa4..680481646 100644
--- a/workflow/engine/classes/model/AppSolrQueue.php
+++ b/workflow/engine/classes/model/AppSolrQueue.php
@@ -81,22 +81,30 @@ class AppSolrQueue extends BaseAppSolrQueue
* Returns the list of updated applications
* array of Entity_AppSolrQueue
*/
- public function getListUpdatedApplications ()
+ public function getListUpdatedApplications($updated = true, $deleted = true)
{
$updatedApplications = array ();
try {
$c = new Criteria();
-
+
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
-
- //"WHERE
- $c->add( AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL );
-
- $rs = AppSolrQueuePeer::doSelectRS( $c );
- $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ //"WHERE
+ if($updated == true && $deleted == true){
+ $c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);
+ }
+ if($updated == true && $deleted == false){
+ $c->add(AppSolrQueuePeer::APP_UPDATED, 1, Criteria::EQUAL);
+ }
+ if($updated == false && $deleted == true){
+ $c->add(AppSolrQueuePeer::APP_UPDATED, 2, Criteria::EQUAL);
+ }
+
+ $rs = AppSolrQueuePeer::doSelectRS($c);
+ $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
//echo $c->toString();
$rs->next();
$row = $rs->getRow();
@@ -111,11 +119,11 @@ class AppSolrQueue extends BaseAppSolrQueue
$rs->next();
$row = $rs->getRow();
}
+
return $updatedApplications;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
-}
-
+} // AppSolrQueue
diff --git a/workflow/engine/methods/cases/casesMenuLoader.php b/workflow/engine/methods/cases/casesMenuLoader.php
index bb206131f..4bf88641e 100755
--- a/workflow/engine/methods/cases/casesMenuLoader.php
+++ b/workflow/engine/methods/cases/casesMenuLoader.php
@@ -181,10 +181,8 @@ function getAllCounters ()
G::LoadClass( 'AppSolr' );
$ApplicationSolrIndex = new AppSolr( $solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance'] );
- if ($ApplicationSolrIndex->isSolrEnabled()) {
+ if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
$solrEnabled = true;
- } else {
- $solrEnabled = false;
}
}
diff --git a/workflow/engine/methods/cases/proxyCasesList.php b/workflow/engine/methods/cases/proxyCasesList.php
index e8985ed61..d78f4a33d 100755
--- a/workflow/engine/methods/cases/proxyCasesList.php
+++ b/workflow/engine/methods/cases/proxyCasesList.php
@@ -62,7 +62,7 @@ try {
$solrConf["solr_instance"]
);
- if ($ApplicationSolrIndex->isSolrEnabled()) {
+ if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
//Check if there are missing records to reindex and reindex them
$ApplicationSolrIndex->synchronizePendingApplications();
$solrEnabled = true;