-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Roll out link generation across catprez / vocprez / spaceprez
- Loading branch information
1 parent
bd93347
commit 934b174
Showing
44 changed files
with
402 additions
and
1,004 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
from prez.models.catprez_item import CatalogItem | ||
from prez.models.catprez_listings import CatalogMembers | ||
from prez.models.vocprez_item import VocabItem | ||
from prez.models.vocprez_listings import VocabMembers | ||
from prez.models.spaceprez_item import SpatialItem | ||
from prez.models.spaceprez_listings import SpatialMembers | ||
from prez.models.search_method import SearchMethod |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
from typing import Optional, FrozenSet | ||
|
||
from pydantic import BaseModel, root_validator | ||
from rdflib import URIRef, Literal, XSD | ||
|
||
from prez.cache import endpoints_graph_cache | ||
from prez.reference_data.prez_ns import ONT | ||
|
||
|
||
class ListingModel(BaseModel): | ||
uri: Optional[ | ||
URIRef | ||
] = None # this is the URI of the focus object (if listing by membership) | ||
endpoint_uri: Optional[URIRef] = None | ||
selected_class: Optional[FrozenSet[URIRef]] = None | ||
profile: Optional[URIRef] = None | ||
top_level_listing: Optional[bool] = False | ||
|
||
def __hash__(self): | ||
return hash(self.uri) | ||
|
||
@root_validator | ||
def populate(cls, values): | ||
endpoint_uri_str = values.get("endpoint_uri") | ||
if endpoint_uri_str: | ||
endpoint_uri = URIRef(endpoint_uri_str) | ||
values["classes"] = frozenset( | ||
[ | ||
klass | ||
for klass in endpoints_graph_cache.objects( | ||
endpoint_uri, ONT.deliversClasses, None | ||
) | ||
] | ||
) | ||
values["base_class"] = endpoints_graph_cache.value( | ||
endpoint_uri, ONT.baseClass | ||
) | ||
tll_text = endpoints_graph_cache.value(endpoint_uri, ONT.isTopLevelEndpoint) | ||
if tll_text == Literal("true", datatype=XSD.boolean): | ||
values["top_level_listing"] = True | ||
else: | ||
values["top_level_listing"] = False | ||
return values |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.