Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
48cf4a53
Commit
48cf4a53
authored
3 years ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Add distributions last_modified and created values when graph is created from...
parent
9f0f6303
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!17
Stage System soll in Zukunft Master Branch erhalten
,
!4
Add distributions last_modified and created values when graph is created from...
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/profiles/odsh_dcat_de_profile.py
+63
-35
63 additions, 35 deletions
ckanext/odsh/profiles/odsh_dcat_de_profile.py
with
63 additions
and
35 deletions
ckanext/odsh/profiles/odsh_dcat_de_profile.py
+
63
−
35
View file @
48cf4a53
...
@@ -57,7 +57,6 @@ class ODSHDCATdeProfile(DCATdeProfile):
...
@@ -57,7 +57,6 @@ class ODSHDCATdeProfile(DCATdeProfile):
def
_mark_for_adding_to_ckan_collection
(
self
,
dataset_dict
,
dataset_ref
):
def
_mark_for_adding_to_ckan_collection
(
self
,
dataset_dict
,
dataset_ref
):
dataset_dict
.
update
({
'
add_to_collection
'
:
True
})
dataset_dict
.
update
({
'
add_to_collection
'
:
True
})
# to RDF
# to RDF
def
graph_from_dataset
(
self
,
dataset_dict
,
dataset_ref
):
def
graph_from_dataset
(
self
,
dataset_dict
,
dataset_ref
):
...
@@ -72,6 +71,7 @@ class ODSHDCATdeProfile(DCATdeProfile):
...
@@ -72,6 +71,7 @@ class ODSHDCATdeProfile(DCATdeProfile):
self
.
_add_contributor_id
(
dataset_dict
,
dataset_ref
)
self
.
_add_contributor_id
(
dataset_dict
,
dataset_ref
)
self
.
_add_license_attribution_by_text
(
dataset_dict
,
dataset_ref
)
self
.
_add_license_attribution_by_text
(
dataset_dict
,
dataset_ref
)
self
.
_add_type
(
dataset_dict
,
dataset_ref
)
self
.
_add_type
(
dataset_dict
,
dataset_ref
)
self
.
_add_modified_and_issued
(
dataset_dict
,
dataset_ref
)
if
self
.
_is_dataset_collection
(
dataset_dict
):
if
self
.
_is_dataset_collection
(
dataset_dict
):
self
.
_remove_predefined_collection_members
()
self
.
_remove_predefined_collection_members
()
self
.
_add_collection_members
(
dataset_dict
,
dataset_ref
)
self
.
_add_collection_members
(
dataset_dict
,
dataset_ref
)
...
@@ -87,14 +87,39 @@ class ODSHDCATdeProfile(DCATdeProfile):
...
@@ -87,14 +87,39 @@ class ODSHDCATdeProfile(DCATdeProfile):
)
)
def
_add_license_attribution_by_text
(
self
,
dataset_dict
,
dataset_ref
):
def
_add_license_attribution_by_text
(
self
,
dataset_dict
,
dataset_ref
):
licenseAttributionByText
=
self
.
_get_dataset_value
(
dataset_dict
,
'
licenseAttributionByText
'
)
licenseAttributionByText
=
self
.
_get_dataset_value
(
dataset_dict
,
'
licenseAttributionByText
'
)
if
licenseAttributionByText
:
if
licenseAttributionByText
:
self
.
g
.
set
(
self
.
g
.
set
(
(
dataset_ref
,
DCATDE
.
licenseAttributionByText
,
rdflib
.
Literal
(
licenseAttributionByText
))
(
dataset_ref
,
DCATDE
.
licenseAttributionByText
,
rdflib
.
Literal
(
licenseAttributionByText
))
)
for
distribution
in
self
.
g
.
objects
(
dataset_ref
,
DCAT
.
distribution
):
self
.
g
.
set
(
(
distribution
,
DCATDE
.
licenseAttributionByText
,
rdflib
.
Literal
(
licenseAttributionByText
))
)
)
def
_add_modified_and_issued
(
self
,
dataset_dict
,
dataset_ref
):
'''
Adds distributions last_modified and created values to
dcat:modified and dcat:issued.
'''
for
distribution
in
self
.
g
.
objects
(
dataset_ref
,
DCAT
.
distribution
):
for
distribution
in
self
.
g
.
objects
(
dataset_ref
,
DCAT
.
distribution
):
for
resource_dict
in
dataset_dict
.
get
(
'
resources
'
,
[]):
# Match distribution in graph and distribution in ckan-dict
if
unicode
(
distribution
)
==
resource_uri
(
resource_dict
):
last_modified
=
resource_dict
.
get
(
'
last_modified
'
,
None
)
if
last_modified
:
self
.
g
.
set
(
(
distribution
,
DCT
.
modified
,
rdflib
.
Literal
(
last_modified
,
datatype
=
"
http://www.w3.org/2001/XMLSchema#dateTime
"
))
)
created
=
resource_dict
.
get
(
'
created
'
,
None
)
if
created
:
self
.
g
.
set
(
self
.
g
.
set
(
(
distribution
,
DCATDE
.
licenseAttributionByText
,
rdflib
.
Literal
(
licenseAttributionByText
))
(
distribution
,
DCT
.
issued
,
rdflib
.
Literal
(
created
,
datatype
=
"
http://www.w3.org/2001/XMLSchema#dateTime
"
))
)
)
def
_add_type
(
self
,
dataset_dict
,
dataset_ref
):
def
_add_type
(
self
,
dataset_dict
,
dataset_ref
):
...
@@ -121,7 +146,8 @@ class ODSHDCATdeProfile(DCATdeProfile):
...
@@ -121,7 +146,8 @@ class ODSHDCATdeProfile(DCATdeProfile):
self
.
g
.
remove
((
s
,
p
,
o
))
self
.
g
.
remove
((
s
,
p
,
o
))
def
_add_collection_members
(
self
,
dataset_dict
,
dataset_ref
):
def
_add_collection_members
(
self
,
dataset_dict
,
dataset_ref
):
dataset_refs_belonging_to_collection
=
self
.
_get_dataset_refs_belonging_to_collection
(
dataset_dict
)
dataset_refs_belonging_to_collection
=
self
.
_get_dataset_refs_belonging_to_collection
(
dataset_dict
)
for
ref
in
dataset_refs_belonging_to_collection
:
for
ref
in
dataset_refs_belonging_to_collection
:
self
.
g
.
add
(
self
.
g
.
add
(
(
dataset_ref
,
DCT
.
hasVersion
,
rdflib
.
URIRef
(
ref
))
(
dataset_ref
,
DCT
.
hasVersion
,
rdflib
.
URIRef
(
ref
))
...
@@ -134,8 +160,10 @@ class ODSHDCATdeProfile(DCATdeProfile):
...
@@ -134,8 +160,10 @@ class ODSHDCATdeProfile(DCATdeProfile):
def
_get_dataset_refs_belonging_to_collection
(
self
,
dataset_dict
):
def
_get_dataset_refs_belonging_to_collection
(
self
,
dataset_dict
):
dataset_names
=
helpers_collection
.
get_dataset_names
(
dataset_dict
)
dataset_names
=
helpers_collection
.
get_dataset_names
(
dataset_dict
)
dataset_dicts
=
[
model
.
Package
.
get
(
name
).
as_dict
()
for
name
in
dataset_names
]
dataset_dicts
=
[
model
.
Package
.
get
(
dataset_ids
=
[
dataset_dict
.
get
(
'
id
'
)
for
dataset_dict
in
dataset_dicts
]
name
).
as_dict
()
for
name
in
dataset_names
]
dataset_ids
=
[
dataset_dict
.
get
(
'
id
'
)
for
dataset_dict
in
dataset_dicts
]
dataset_refs
=
[
self
.
_construct_refs
(
id
)
for
id
in
dataset_ids
]
dataset_refs
=
[
self
.
_construct_refs
(
id
)
for
id
in
dataset_ids
]
return
dataset_refs
return
dataset_refs
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment