mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
DMS Search
This commit is contained in:
+101
-34
@@ -3,10 +3,6 @@
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
// TODO(chris): permissions
|
||||
// TODO(chris): foto
|
||||
|
||||
|
||||
$config['person'] = [
|
||||
'primarykey' => 'person_id',
|
||||
'table' => 'public.tbl_person',
|
||||
@@ -70,7 +66,7 @@ $config['person'] = [
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"b.uid",
|
||||
"b.uid", // TODO(chris): multiple?
|
||||
"p.person_id",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
|
||||
@@ -678,7 +674,7 @@ $config['room'] = [
|
||||
|
||||
$config['cms'] = [
|
||||
'primarykey' => 'contentsprache_id',
|
||||
'table' => 'cms',
|
||||
'table' => 'campus.tbl_contentsprache',
|
||||
'prepare' => "
|
||||
cms_auth (content_id) AS (
|
||||
SELECT content_id
|
||||
@@ -711,47 +707,23 @@ $config['cms'] = [
|
||||
SELECT content_id
|
||||
FROM cms_active
|
||||
WHERE template_kurzbz IN ('contentmittitel', 'contentohnetitel', 'contentmittitel_filterwidget')
|
||||
),
|
||||
cms (contentsprache_id) AS (
|
||||
SELECT contentsprache_id
|
||||
FROM campus.tbl_contentsprache
|
||||
WHERE content_id IN (
|
||||
SELECT content_id
|
||||
FROM cms_active_redirect_linked
|
||||
UNION
|
||||
SELECT content_id
|
||||
FROM cms_active_others
|
||||
)
|
||||
AND version = campus.get_highest_content_version(content_id)
|
||||
)
|
||||
",
|
||||
'searchfields' => [
|
||||
'content' => [
|
||||
'alias' => ['inhalt'],
|
||||
'comparison' => "vector",
|
||||
'field' => "(setweight(to_tsvector('simple', COALESCE(titel, '')), 'A') || setweight(to_tsvector('simple', COALESCE(content, '')::text), 'B'))",
|
||||
'join' => [
|
||||
'table' => "campus.tbl_contentsprache",
|
||||
'using' => "contentsprache_id"
|
||||
]
|
||||
'field' => "(setweight(to_tsvector('simple', COALESCE(titel, '')), 'A') || setweight(to_tsvector('simple', COALESCE(content, '')::text), 'B'))"
|
||||
],
|
||||
'content_id' => [
|
||||
'alias' => ['id'],
|
||||
'comparison' => "equal-int",
|
||||
'field' => "content_id",
|
||||
'join' => [
|
||||
'table' => "campus.tbl_contentsprache",
|
||||
'using' => "contentsprache_id"
|
||||
]
|
||||
'field' => "content_id"
|
||||
],
|
||||
'lang' => [
|
||||
'alias' => ['language', 'sprache'],
|
||||
'comparison' => "equals",
|
||||
'field' => "sprache",
|
||||
'join' => [
|
||||
'table' => "campus.tbl_contentsprache",
|
||||
'using' => "contentsprache_id"
|
||||
]
|
||||
'field' => "sprache"
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
@@ -767,5 +739,100 @@ $config['cms'] = [
|
||||
JOIN campus.tbl_contentsprache contentsprache
|
||||
USING (contentsprache_id)
|
||||
JOIN campus.tbl_content content
|
||||
USING (content_id)"
|
||||
USING (content_id)
|
||||
WHERE content_id IN (
|
||||
SELECT content_id
|
||||
FROM cms_active_redirect_linked
|
||||
UNION
|
||||
SELECT content_id
|
||||
FROM cms_active_others
|
||||
)
|
||||
AND version = campus.get_highest_content_version(content_id)"
|
||||
];
|
||||
|
||||
$config['dms'] = [
|
||||
// TODO(chris): IMPLEMENT
|
||||
// TODO(chris): TEST
|
||||
// TODO(chris): project?
|
||||
'primarykey' => 'dms_id, version',
|
||||
'table' => 'campus.tbl_dms_version',
|
||||
'searchfields' => [
|
||||
'keywords' => [
|
||||
'alias' => ['keyword', 'keywords', 'schlagwort', 'schlagworte'],
|
||||
'comparison' => "vector",
|
||||
'field' => "(to_tsvector('simple', COALESCE(schlagworte, '')))"
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"v.dms_id",
|
||||
"v.version",
|
||||
"v.filename",
|
||||
"v.mimetype",
|
||||
"v.name",
|
||||
"v.beschreibung AS description",
|
||||
"v.schlagworte AS keywords"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN campus.tbl_dms_version v
|
||||
USING (dms_id, version)
|
||||
WHERE cis_suche = TRUE
|
||||
AND version=(SELECT MAX(version) FROM campus.tbl_dms_version WHERE dms_id=v.dms_id)
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
fue.tbl_projekt_dokument p
|
||||
WHERE p.dms_id = v.dms_id
|
||||
) AND (
|
||||
NOT EXISTS (
|
||||
WITH RECURSIVE categories (kategorie_kurzbz) AS (
|
||||
SELECT
|
||||
kategorie_kurzbz
|
||||
FROM
|
||||
campus.tbl_dms c
|
||||
WHERE c.dms_id = v.dms_id
|
||||
UNION ALL
|
||||
SELECT
|
||||
cat.parent_kategorie_kurzbz AS kategorie_kurzbz
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie cat USING (kategorie_kurzbz)
|
||||
)
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie_gruppe USING (kategorie_kurzbz)
|
||||
UNION
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie USING (kategorie_kurzbz)
|
||||
WHERE
|
||||
berechtigung_kurzbz IS NOT NULL
|
||||
) OR EXISTS (
|
||||
WITH RECURSIVE categories (kategorie_kurzbz) AS (
|
||||
SELECT
|
||||
kategorie_kurzbz
|
||||
FROM
|
||||
campus.tbl_dms c
|
||||
WHERE c.dms_id = v.dms_id
|
||||
UNION ALL
|
||||
SELECT
|
||||
cat.parent_kategorie_kurzbz AS kategorie_kurzbz
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie cat USING (kategorie_kurzbz)
|
||||
)
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie_gruppe USING (kategorie_kurzbz)
|
||||
JOIN public.tbl_benutzergruppe USING(gruppe_kurzbz)
|
||||
WHERE
|
||||
uid = (TABLE auth)
|
||||
)
|
||||
)"
|
||||
];
|
||||
|
||||
@@ -5,6 +5,7 @@ import ResultEmployee from "./result/employee.js";
|
||||
import ResultOrganisationunit from "./result/organisationunit.js";
|
||||
import ResultRoom from "./result/room.js";
|
||||
import ResultCms from "./result/cms.js";
|
||||
import ResultDms from "./result/dms.js";
|
||||
import ResultMergedperson from "./result/mergedperson.js";
|
||||
import ResultMergedstudent from "./result/mergedstudent.js";
|
||||
|
||||
@@ -19,6 +20,7 @@ export default {
|
||||
ResultOrganisationunit,
|
||||
ResultRoom,
|
||||
ResultCms,
|
||||
ResultDms,
|
||||
ResultMergedperson,
|
||||
ResultMergedstudent
|
||||
},
|
||||
@@ -263,6 +265,7 @@ export default {
|
||||
<result-organisationunit v-else-if="res.type === 'organisationunit'" :res="res" :actions="searchoptions.actions.organisationunit" @actionexecuted="hideresult"></result-organisationunit>
|
||||
<result-room v-else-if="res.type === 'room'" :res="res" :actions="searchoptions.actions.room" @actionexecuted="hideresult"></result-room>
|
||||
<result-cms v-else-if="res.type === 'cms'" :res="res" :actions="searchoptions.actions.cms" @actionexecuted="hideresult"></result-cms>
|
||||
<result-dms v-else-if="res.type === 'dms'" :res="res" :actions="searchoptions.actions.dms" @actionexecuted="hideresult"></result-dms>
|
||||
<result-mergedperson v-else-if="res.type === 'mergedperson'" :res="res" :actions="searchoptions.actions.mergedperson" @actionexecuted="hideresult"></result-mergedperson>
|
||||
<result-mergedstudent v-else-if="res.type === 'mergedstudent'" :res="res" :actions="searchoptions.actions.mergedstudent" @actionexecuted="hideresult"></result-mergedstudent>
|
||||
<div v-else>Unbekannter Ergebnistyp: '{{ res.type }}'.</div>
|
||||
|
||||
@@ -184,3 +184,18 @@ FROM pg_indexes WHERE indexname = 'idx_tbl_contentsprache_fts_titel_content_vect
|
||||
else
|
||||
echo 'campus.tbl_contentsprache: added index "idx_tbl_contentsprache_fts_titel_content_vector"<br>';
|
||||
}
|
||||
// Add index for schlagworte to campus.tbl_dms_version
|
||||
if (!$db->db_num_rows(@$db->db_query("SELECT 1
|
||||
FROM pg_indexes WHERE indexname = 'idx_tbl_dms_version_fts_schlagworte_vector' LIMIT 1;")))
|
||||
{
|
||||
$qry = "
|
||||
CREATE INDEX idx_tbl_dms_version_fts_schlagworte_vector
|
||||
ON campus.tbl_dms_version
|
||||
USING GIN ((to_tsvector('simple', COALESCE(schlagworte, ''))));
|
||||
";
|
||||
|
||||
if (!$db->db_query($qry))
|
||||
echo '<strong>campus.tbl_dms_version ' . $db->db_last_error() . '</strong><br>';
|
||||
else
|
||||
echo 'campus.tbl_contentsprache: added index "idx_tbl_dms_version_fts_schlagworte_vector"<br>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user