Skip to content

Commit c17ce38

Browse files
committed
feature Sinar#45 further softcode the ownership schema
1 parent d089664 commit c17ce38

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/popit_relationship/sync.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@
99
from loguru import logger
1010
from toolz.dicttoolz import get_in, valfilter
1111

12-
from popit_relationship.common import coro, graph_init, graph_prune, graph_save
12+
from popit_relationship.common import (
13+
coro,
14+
graph_init,
15+
graph_prune,
16+
graph_save,
17+
schema_generate_uri,
18+
)
19+
from popit_relationship.schema.sinar import Ownership, Sinar
1320

1421
TYPE_PERSON = "https://www.w3.org/ns/person#Person"
1522
TYPE_POST = "http://www.w3.org/ns/org#Post"
1623
TYPE_ORGANIZATION = "http://www.w3.org/ns/org#Organization"
1724
TYPE_MEMBERSHIP = "http://www.w3.org/ns/org#Membership"
1825
TYPE_RELATIONSHIP = "http://purl.org/vocab/relationship/Relationship"
1926

20-
SINAR_NS_MOCK = "https://sinarproject.org/ns/ownership#"
21-
2227

2328
@click.group()
2429
def sync():
@@ -35,7 +40,7 @@ async def all_sync(_ctx):
3540
await tree_import(TYPE_POST, "Post", post_build_node)
3641
await tree_import(TYPE_MEMBERSHIP, "Membership", membership_build_node)
3742
await tree_import(
38-
f"{SINAR_NS_MOCK}ownershipOrControlStatement",
43+
schema_generate_uri(Sinar.OWNERSHIP, Ownership.OWNERSHIP_OR_CONTROL_STATEMENT),
3944
"Ownership Control Statement",
4045
ownership_build_node,
4146
)
@@ -103,7 +108,7 @@ def membership_build_node(membership):
103108
@coro
104109
async def ownership():
105110
await tree_import(
106-
f"{SINAR_NS_MOCK}ownershipOrControlStatement",
111+
schema_generate_uri(Sinar.OWNERSHIP, Ownership.OWNERSHIP_OR_CONTROL_STATEMENT),
107112
"Ownership Control Statement",
108113
ownership_build_node,
109114
)
@@ -117,7 +122,9 @@ def ownership_build_node(ownership):
117122
{
118123
"subject": get_in(["interestedParty", "@id"], ownership, None),
119124
"predicate": {
120-
"key": f"{SINAR_NS_MOCK}ownershipOrControlStatement",
125+
"key": schema_generate_uri(
126+
Sinar.OWNERSHIP, Ownership.OWNERSHIP_OR_CONTROL_STATEMENT
127+
),
121128
"attributes": predicate_attribute_filter_empty(
122129
{
123130
"interest_level": get_in(

0 commit comments

Comments
 (0)