Commit d6c6d0ee authored by Dainis Abols's avatar Dainis Abols
Browse files

Added Names SOLR search

2.6.7
parent 154fe430
......@@ -6,7 +6,7 @@ use Lu\LuApi\Helpers\ReturnPretty;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class class LuisStudyTypes
* Class LuisStudyTypes
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
......
<?php
namespace Lu\LuApi\DataSources;
use Lu\LuApi\Helpers\ReturnPretty;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class SolrNames
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 06.10..2020
*/
class SolrNames
{
/**
* Extension configuration
*
* @array
*/
private $conf = [];
/**
* Filter request
*
* @var array
*/
private $filters = [];
/**
* Types request
*
* @var array
*/
private $types = [];
/**
* Solr cores
*
* @var string
*/
private $solrCore = '';
/**
* Set parent IDs
*
* @var array
*/
private $parentIDs = [];
/**
* SolrRegulations constructor.
*
* Gathers and sets connection data from environmental values. Prepares and opens connection.
*/
public function __construct()
{
// Read config file
$this->conf = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('lu_api');
// Set Solr Core
if ($this->conf) {
$this->solrCore = $this->conf['solrDatabase']['names'];
}
}
/**
* Sets filters
*
* @param array $filters
*/
public function setFilters(array $filters)
{
$this->filters = $filters;
}
/**
* Set limit
*
* @param int $limit
*/
public function setLimit($limit)
{
$this->limit = $limit;
}
/**
* Set parent IDs
*
* @param int $parentIDs
*/
public function setParentIDs($parentIDs)
{
$this->parentIDs = $parentIDs;
}
/**
* Set offset
*
* @param int $offset
*/
public function setOffset($offset)
{
$this->offset = $offset;
}
/**
* Sets types
*
* @param array $types
*/
public function setTypes(array $types)
{
$this->types = $types;
}
/**
* Sets weather to use or not use facets
*
* @param bool $facet
*/
public function useFacets(bool $facet)
{
$this->facet = $facet;
}
/**
* Fetch data from provided endpoint
*
* Return [Programme Object, Catalogue Object]
*
* @param bool $fullReponse
*
* @return string
*/
public function fetch($fullReponse = false)
{
// Build solr request
$SolrLibrary = new SolrLibrary();
// Execute request
$SolrLibrary->select(['*'])
->from($this->solrCore)
->where('*', '*')
->limit($SolrLibrary::MAXINT);
// Build request with filters and types
if (!empty($this->filters)) {
$SolrLibrary->whereStr("(".implode(" OR ", $this->filters).")");
}
// Set limit
$SolrLibrary->limit($this->limit);
$SolrLibrary->offset($this->offset);
// Fetch results
$result = $SolrLibrary->execute($fullReponse);
$data = !empty($result['data']) ? $result['data'] : [];
// Return back to the request
return ReturnPretty::json($data, 200);
}
}
......@@ -6,7 +6,7 @@ use Lu\LuApi\Helpers\ReturnPretty;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class LuisProgrammes
* Class SolrSearch
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
......
......@@ -136,4 +136,20 @@ class SolrSynchronize
// Return back to the request
return ReturnPretty::json($this->sync(), 200);
}
}
\ No newline at end of file
/**
* Sync names database
*
* @return string
*/
public function syncNames($command = 'full-import')
{
// Pre-set variables
$this->setPath('names/dataimport');
$this->setParam('command', $command);
// Return back to the request
return ReturnPretty::json($this->sync(), 200);
}
}
{
"name": "luitd/lu-api",
"version": "2.6.4",
"version": "2.6.7",
"description": "REST API Integration for TYPO3",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -40,6 +40,9 @@ solrDatabase.contactsList = lucontacts
# cat=SOLR/set; type=string; label=Contacts list DB
solrDatabase.purchasesList = lupurchases
# cat=SOLR/set; type=string; label=Names list DB
solrDatabase.names= names
# cat=SOLR/set; type=string; label=Regulations (Normative Acts) list DB
solrDatabase.regulations = db
......
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'LU API',
'description' => 'REST API Integration for TYPO3',
'category' => 'plugin',
'version' => '2.6.4',
'version' => '2.6.7',
'dependencies' => 'typo3',
'state' => 'stable',
'clearCacheOnLoad' => true,
......
......@@ -4,7 +4,7 @@
## Version
2.6.4
2.6.7
## Dependencies
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment