-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from MI-FraunhoferIWM/enh/sparql-update
Enh/sparql update
- Loading branch information
Showing
5 changed files
with
142 additions
and
49 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
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
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,44 @@ | ||
"""DSMS Subgraph interface""" | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from dsms.knowledge.sparql_interface.utils import ( | ||
_create_subgraph, | ||
_delete_subgraph, | ||
_get_subgraph, | ||
_update_subgraph, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from rdflib import Graph | ||
|
||
from dsms import DSMS | ||
|
||
|
||
class Subgraph: | ||
"""Subgraph interface for DSMS""" | ||
|
||
def __init__(self, dsms): | ||
"""Initalize the Sparql interface""" | ||
self._dsms: "DSMS" = dsms | ||
|
||
def update(self, graph: "Graph", repository: str = "knowledge") -> None: | ||
"""Update a subgraph in the DSMS""" | ||
_update_subgraph(graph, self._dsms.config.encoding, repository) | ||
|
||
def create(self, graph: "Graph", repository: str = "knowledge") -> None: | ||
"""Create a subgraph in the DSMS""" | ||
_create_subgraph(graph, self._dsms.config.encoding, repository) | ||
|
||
def delete(self, identifier: str, repository: str = "knowledge") -> None: | ||
"""Delete a subgraph in the DSMS""" | ||
_delete_subgraph(identifier, repository) | ||
|
||
def get( | ||
self, | ||
identifier: str, | ||
repository: str = "knowledge", | ||
is_kitem_id: bool = False, | ||
) -> "Graph": | ||
"""Get a subgraph from the DSMS""" | ||
return _get_subgraph(identifier, repository, is_kitem_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