-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: software and project maintainer can select organisation specifi…
…c categories
- Loading branch information
1 parent
9c1ee20
commit a6cbf7a
Showing
18 changed files
with
968 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
-- SPDX-FileCopyrightText: 2023 - 2024 Felix Mühlbauer (GFZ) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2023 - 2024 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences | ||
-- SPDX-FileCopyrightText: 2024 Christian Meeßen (GFZ) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
@@ -107,15 +108,6 @@ CREATE INDEX category_parent_idx ON category(parent); | |
CREATE INDEX category_community_idx ON category(community); | ||
|
||
|
||
CREATE TABLE category_for_software ( | ||
software_id UUID REFERENCES software (id), | ||
category_id UUID REFERENCES category (id), | ||
PRIMARY KEY (software_id, category_id) | ||
); | ||
|
||
CREATE INDEX category_for_software_category_id_idx ON category_for_software(category_id); | ||
|
||
|
||
-- sanitize categories | ||
|
||
CREATE FUNCTION sanitise_insert_category() | ||
|
@@ -228,6 +220,19 @@ $$ | |
$$; | ||
|
||
|
||
-- TABLE FOR software categories | ||
-- includes organisation, community and general categories | ||
-- Note! to filter specific categories of an community or organisation use join with community table | ||
|
||
CREATE TABLE category_for_software ( | ||
software_id UUID REFERENCES software (id), | ||
category_id UUID REFERENCES category (id), | ||
PRIMARY KEY (software_id, category_id) | ||
); | ||
|
||
CREATE INDEX category_for_software_category_id_idx ON category_for_software(category_id); | ||
|
||
-- RPC for software page to show all software categories | ||
CREATE FUNCTION category_paths_by_software_expanded(software_id UUID) | ||
RETURNS JSON | ||
LANGUAGE SQL STABLE AS | ||
|
@@ -242,3 +247,14 @@ $$ | |
ELSE '[]'::json | ||
END AS result | ||
$$; | ||
|
||
|
||
-- TABLE FOR project categories | ||
-- currently used only for organisation categories | ||
CREATE TABLE category_for_project ( | ||
project_id UUID REFERENCES project (id), | ||
category_id UUID REFERENCES category (id), | ||
PRIMARY KEY (project_id, category_id) | ||
); | ||
|
||
CREATE INDEX category_for_project_category_id_idx ON category_for_project(category_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-- SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
-- SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
-- | ||
|
@@ -11,3 +12,33 @@ DELETE FROM category_for_software | |
USING category | ||
WHERE category_for_software.category_id = category.id AND category_for_software.software_id = software_id AND category.community = community_id; | ||
$$; | ||
|
||
|
||
-- DELETE organisation categories for specific software | ||
CREATE FUNCTION delete_organisation_categories_from_software(software_id UUID, organisation_id UUID) | ||
RETURNS VOID | ||
LANGUAGE sql AS | ||
$$ | ||
DELETE FROM category_for_software | ||
USING | ||
category | ||
WHERE | ||
category_for_software.category_id = category.id AND | ||
category_for_software.software_id = software_id AND | ||
category.organisation = organisation_id; | ||
$$; | ||
|
||
|
||
-- DELETE organisation categories for specific project | ||
CREATE FUNCTION delete_organisation_categories_from_project(project_id UUID, organisation_id UUID) | ||
RETURNS VOID | ||
LANGUAGE sql AS | ||
$$ | ||
DELETE FROM category_for_project | ||
USING | ||
category | ||
WHERE | ||
category_for_project.category_id = category.id AND | ||
category_for_project.project_id = project_id AND | ||
category.organisation = organisation_id; | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {CategoryEntry} from '~/types/Category' | ||
import {TreeNode} from '~/types/TreeNode' | ||
|
||
type LoadCategoryProps={ | ||
community?: string | null, | ||
organisation?: string | null, | ||
allow_software?: boolean, | ||
allow_projects?: boolean | ||
} | ||
|
||
|
||
// DEFAULT mock return empty array of categories | ||
export async function loadCategoryRoots({community, organisation, allow_software, allow_projects}:LoadCategoryProps){ | ||
const result: TreeNode<CategoryEntry>[] = [] | ||
return result | ||
} | ||
|
||
// DEFAULT mock return empty array of categories | ||
export function categoryEntriesToRoots(categoriesArr: CategoryEntry[]): TreeNode<CategoryEntry>[] { | ||
const result: TreeNode<CategoryEntry>[] = [] | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.