Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't modify deleted values (DEV-3894) #114

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion dsp_permissions_scripts/oap/oap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@

logger = get_logger(__name__)

IGNORE_KEYS = [
"@id",
"@type",
"@context",
"rdfs:label",
"knora-api:DeletedValue",
"knora-api:lastModificationDate",
"knora-api:creationDate",
"knora-api:arkUrl",
"knora-api:versionArkUrl",
"knora-api:attachedToProject",
"knora-api:attachedToUser",
"knora-api:userHasPermission",
"knora-api:hasPermissions",
]


def _get_all_oaps_of_resclass(
resclass_localname: str, project_iri: str, dsp_client: DspClient, oap_config: OapRetrieveConfig
Expand Down Expand Up @@ -108,12 +124,14 @@ def _get_oap_of_one_resource(r: dict[str, Any], oap_config: OapRetrieveConfig) -
def _get_value_oaps(resource: dict[str, Any], restrict_to_props: list[str] | None = None) -> list[ValueOap]:
res = []
for k, v in resource.items():
if k in {"@id", "@type", "@context", "rdfs:label", "knora-api:DeletedValue"}:
if k in IGNORE_KEYS:
continue
if restrict_to_props is not None and k not in restrict_to_props:
continue
values = v if isinstance(v, list) else [v]
for val in values:
if not isinstance(val, dict) or val.get("knora-api:isDeleted"):
continue
match val:
case {
"@id": id_,
Expand Down