Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature_docker_k8s
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/starter.yaml
  • Loading branch information
BernhardKoschicek committed Oct 11, 2023
2 parents 2c019c5 + 32aed2c commit 3eb09d4
Show file tree
Hide file tree
Showing 254 changed files with 19,817 additions and 12,443 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ disable=C0111, broad-except, cyclic-import, duplicate-code
good-names=f,i,j,k,ex,Run,_,e,js,bc,id,rv,ip,to # default is i,j,k,ex,Run,_
ignore=openatlas.wsgi
min-public-methods=0
--disable=W cidoc_rtfs_parser

[FORMAT]
max-line-length=79
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ Please refer to our [contributing guidelines](CONTRIBUTING.md)
([bernhard.koschicek-krombholz@oeaw.ac.at](mailto:bernhard.koschicek-krombholz@oeaw.ac.at))
- **Nina Richards** - Bioarchaeological Expertise
([nina.richards@oeaw.ac.at](mailto:nina.richards@oeaw.ac.at))
- **Andreas Olschnögger** - Frontend Development
- **Moritz Großfurtner** - Frontend Development
([moritz.großfurtner@oeaw.ac.at](mailto:moritz.großfurtner@oeaw.ac.at)
- **Olivia Reichl** - Frontend Development
([Olivia.Reichl@oeaw.ac.at](mailto:Olivia.Reichl@oeaw.ac.at)
- **Jan Belik** - Logo Design and Design Consulting
([buero@janbelik.com](mailto:buero@janbelik.com))

Expand Down
3 changes: 3 additions & 0 deletions config/database_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Used for automatic database upgrades and database version checks
DATABASE_VERSIONS = [
'7.16.0',
'7.15.0',
'7.14.0',
'7.13.0',
'7.11.0',
'7.10.0',
Expand Down
24 changes: 16 additions & 8 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

from config.database_versions import DATABASE_VERSIONS

VERSION = '7.14.0'
VERSION = '7.16.1'
DATABASE_VERSION = DATABASE_VERSIONS[0]
DEMO_MODE = False # If activated some options are disabled, login is prefilled

LANGUAGES = {'ca': 'Català', 'de': 'Deutsch', 'en': 'English', 'es': 'Español'}
LANGUAGES = {
'ca': 'Català',
'de': 'Deutsch',
'en': 'English',
'es': 'Español',
'fr': 'Français'}
DEBUG = False

DATABASE_NAME = 'openatlas'
Expand Down Expand Up @@ -70,6 +75,8 @@
'geojson-v2': 'application/json'}
API_FORMATS = RDF_FORMATS | JSON_FORMATS

API_PROXY = ''

LOGICAL_OPERATOR: list[str] = ['and', 'or']
STR_CATEGORIES: list[str] = [
"entityName", "entityDescription", "entityAliases", "entityCidocClass",
Expand All @@ -79,17 +86,18 @@
"entityID", "typeID", "typeIDWithSubs", "relationToID"]
SET_CATEGORIES: list[str] = ["valueTypeID"]
VALID_CATEGORIES: list[str] = [
*STR_CATEGORIES, *INT_CATEGORIES, *SET_CATEGORIES]
*STR_CATEGORIES,
*INT_CATEGORIES,
*SET_CATEGORIES]
COMPARE_OPERATORS: list[str] = [
'equal', 'notEqual', 'greaterThan', 'lesserThan', 'greaterThanEqual',
'lesserThanEqual', 'like']

# Used to connect to ACDH-CH ARCHE systems
ARCHE = {
'id': None,
'collection_ids': None,
'base_url': None,
'thumbnail_url': 'https://arche-thumbnails.acdh.oeaw.ac.at/'}
ARCHE = {'id': None, 'url': None}

# Used to connect to password protected Vocabs systems
VOCABS_PASS = ''

# Table options
TABLE_ROWS = {10: '10', 25: '25', 50: '50', 100: '100'}
Expand Down
3,986 changes: 1,996 additions & 1,990 deletions install/2_data_model.sql

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions install/3_data_web.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ INSERT INTO web.user (username, password, active, email, group_id) VALUES (
(SELECT id FROM web.group WHERE name = 'admin'));

INSERT INTO web.settings (name, value) VALUES
('database_version', '7.13.0'),
('database_version', '7.16.0'),
('api_public', ''),
('default_language', 'en'),
('table_rows', '25'),
Expand Down Expand Up @@ -45,4 +45,7 @@ INSERT INTO web.settings (name, value) VALUES
('profile_image_width', '200'),
('random_password_length', '16'),
('reset_confirm_hours', '24'),
('site_name', 'OpenAtlas');
('site_name', 'OpenAtlas'),
('vocabs_base_url', 'https://vocabs.acdh.oeaw.ac.at/'),
('vocabs_endpoint', 'rest/v1/'),
('vocabs_user', '');
9,851 changes: 4,934 additions & 4,917 deletions install/crm/CIDOC_CRM_v7.1.1.rdfs → install/crm/CIDOC_CRM_v7.1.2.rdf

Large diffs are not rendered by default.

93 changes: 46 additions & 47 deletions install/crm/cidoc_rtfs_parser.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# pylint: disable=C,R
#
# This script is for developing purposes and not needed to install OpenAtlas.
#
# CIDOC CRM is used as basis for the underlying data model of OpenAtlas.
# Currently we are using CIDOC CRM 7.7.1 (October 2021) from
# http://www.cidoc-crm.org/versions-of-the-cidoc-crm
# Currently, we are using CIDOC CRM 7.1.2 (June 2022):
# https://cidoc-crm.org/rdfs/7.1.2/CIDOC_CRM_v7.1.2.rdf
#
# The script parses the rdfs file and imports it to a PostgreSQL database.
# Installation of needed package: # apt-get install python3-rdflib
# Installation of needed package:
# apt-get install python3-rdflib
#
# Create a database named cidoc
# $ createdb cidoc -O openatlas
# $ psql cidoc -c "CREATE EXTENSION postgis; CREATE EXTENSION unaccent;"
# $ cd install
# $ cat 1_structure.sql 2_data_model.sql | psql -d cidoc -f -
#
# Execute the script in install/crm:
# $ python3 cidoc_rtfs_parser.py
#
# Table data can than be extracted to be joined in an upgrade SQL with e.g.
# pg_dump --column-inserts --data-only --rows-per-insert=1000 --table=model.cidoc_class cidoc > class.sql
#
# Following has to be added manually to the upgrade SQL
# UPDATE model.property_i18n set text_inverse = 'ist erster Ort von' WHERE property_code = 'OA8' AND language_code = 'de';
# UPDATE model.property_i18n set text_inverse = 'is first appearance of' WHERE property_code = 'OA8' AND language_code = 'en';
# UPDATE model.property_i18n set text_inverse = 'ist letzter Ort von' WHERE property_code = 'OA9' AND language_code = 'de';
# UPDATE model.property_i18n set text_inverse = 'is last appearance of' WHERE property_code = 'OA9' AND language_code = 'en';
#
# Once run table data can be extracted with e.g.
# pg_dump --column-inserts --data-only --rows-per-insert=1000
# --table=model.cidoc_class cidoc > class.sql

import time
from typing import Dict, List, Optional
Expand All @@ -18,12 +36,12 @@
from rdflib import URIRef
from rdflib.graph import Graph

FILENAME = 'CIDOC_CRM_v7.1.1.rdfs'
FILENAME = 'CIDOC_CRM_v7.1.2.rdf'
CRM_URL = 'http://www.cidoc-crm.org/cidoc-crm/'

EXCLUDE_PROPERTIES = [
'P3', 'P57', 'P79', 'P80', 'P81', 'P81a', 'P81b', 'P82', 'P82a', 'P82b',
'P90', 'P90a', 'P90b', 'P171', 'P172', 'P190', 'P168']
'P90', 'P90a', 'P90b', 'P168', 'P169', 'P170', 'P171', 'P172', 'P190']

DATABASE_NAME = 'cidoc'
DATABASE_USER = 'openatlas'
Expand All @@ -42,7 +60,6 @@ def connect() -> psycopg2.connect:


class Item:

domain_code: str
range_code: str

Expand Down Expand Up @@ -161,28 +178,30 @@ def import_cidoc() -> None:
'de': 'hat Beziehung zu'}
properties['OA8'] = Item(
'OA8',
' begins in',
'begins in',
"OA8 is used to link the beginning of a persistent item's (E77) life "
"span (or time of usage) with a certain place. E.g to document the "
"birthplace of a person. E77 Persistent Item linked with a E53 Place: "
"E77 (Persistent Item) - P92i (was brought into existence by) - E63 "
"(Beginning of Existence) - P7 (took place at) - E53 (Place) Example: "
"[Albert Einstein (E21)] was brought into existence by [Birth of "
"Albert Einstein (E12)] took place at [Ulm (E53)]")
properties['OA8'].name_inverse = 'is first appearance of'
properties['OA8'].domain_code = 'E77'
properties['OA8'].range_code = 'E53'
properties['OA8'].label = {'en': 'begins in', 'de': 'beginnt in'}

properties['OA9'] = Item(
'OA9',
' begins in',
'ends in',
"OA9 is used to link the end of a persistent item's (E77) life span "
"(or time of usage) with a certain place. E.g to document a person's "
"place of death. E77 Persistent Item linked with a E53 Place: E77 "
"(Persistent Item) - P93i (was taken out of existence by) - E64 "
"(End of Existence) - P7 (took place at) - E53 (Place) Example: "
"[Albert Einstein (E21)] was taken out of by [Death of Albert "
"Einstein (E12)] took place at [Princeton (E53)]")
properties['OA9'].name_inverse = 'is last appearance of'
properties['OA9'].domain_code = 'E77'
properties['OA9'].range_code = 'E53'
properties['OA9'].label = {'en': 'ends in', 'de': 'endet in'}
Expand All @@ -192,31 +211,6 @@ def import_cidoc() -> None:
cursor.execute("""
BEGIN;
UPDATE model.entity SET (cidoc_class_code, openatlas_class_name) =
('E41', 'appellation') WHERE cidoc_class_code = 'E82';
UPDATE model.link SET property_code = 'P1'
WHERE property_code = 'P131';
DELETE FROM model.openatlas_class WHERE cidoc_class_code = 'E82';
ALTER TABLE model.cidoc_class DROP COLUMN IF EXISTS created,
DROP COLUMN IF EXISTS modified;
ALTER TABLE model.cidoc_class_inheritance
DROP COLUMN IF EXISTS created, DROP COLUMN IF EXISTS modified;
ALTER TABLE model.cidoc_class_i18n DROP COLUMN IF EXISTS created,
DROP COLUMN IF EXISTS modified;
ALTER TABLE model.property DROP COLUMN IF EXISTS created,
DROP COLUMN IF EXISTS modified;
ALTER TABLE model.property_inheritance DROP COLUMN IF EXISTS created,
DROP COLUMN IF EXISTS modified;
ALTER TABLE model.property_i18n DROP COLUMN IF EXISTS created,
DROP COLUMN IF EXISTS modified;
DROP TRIGGER IF EXISTS update_modified ON model.cidoc_class;
DROP TRIGGER IF EXISTS update_modified
ON model.cidoc_class_inheritance;
DROP TRIGGER IF EXISTS update_modified ON model.cidoc_class_i18n;
DROP TRIGGER IF EXISTS update_modified ON model.property;
DROP TRIGGER IF EXISTS update_modified ON model.property_inheritance;
DROP TRIGGER IF EXISTS update_modified ON model.property_i18n;
ALTER TABLE model.entity
DROP CONSTRAINT IF EXISTS entity_class_code_fkey;
ALTER TABLE model.entity
Expand Down Expand Up @@ -246,9 +240,12 @@ def import_cidoc() -> None:
reference_system_openatlas_class_openatlas_class_name_fkey;
TRUNCATE
model.cidoc_class_inheritance, model.cidoc_class_i18n,
model.cidoc_class, model.property_inheritance,
model.property_i18n, model.property;
model.cidoc_class_inheritance,
model.cidoc_class_i18n,
model.cidoc_class,
model.property_inheritance,
model.property_i18n,
model.property;
ALTER SEQUENCE model.cidoc_class_id_seq RESTART;
ALTER SEQUENCE model.cidoc_class_inheritance_id_seq RESTART;
Expand All @@ -259,6 +256,7 @@ def import_cidoc() -> None:

# Classes
for code, class_ in classes.items():
print(code)
sql = """
INSERT INTO model.cidoc_class (code, name, comment)
VALUES (%(code)s, %(name)s, %(comment)s);"""
Expand All @@ -268,13 +266,14 @@ def import_cidoc() -> None:
'comment': class_.comment})
for code, class_ in classes.items():
for sub_code_of in class_.sub_class_of:
sql = """
INSERT INTO model.cidoc_class_inheritance
(super_code, sub_code)
VALUES (%(super_code)s, %(sub_code)s);"""
cursor.execute(sql, {
'super_code': sub_code_of,
'sub_code': class_.code})
if sub_code_of != class_.code: # Prevent circular relations
sql = """
INSERT INTO model.cidoc_class_inheritance
(super_code, sub_code)
VALUES (%(super_code)s, %(sub_code)s);"""
cursor.execute(sql, {
'super_code': sub_code_of,
'sub_code': class_.code})
for language, label in class_.label.items():
sql = """
INSERT INTO model.cidoc_class_i18n
Expand Down Expand Up @@ -398,7 +397,7 @@ def import_cidoc() -> None:
ON UPDATE CASCADE ON DELETE CASCADE;
""")
cursor.execute("COMMIT")
print('Execution time: ' + str(int(time.time() - start)) + ' seconds')
print(f'Execution time: {int(time.time() - start)} seconds')


import_cidoc()
Loading

0 comments on commit 3eb09d4

Please sign in to comment.