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

Fmd 348 metadata spec #356

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion deployments/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- name: AZURE_REDIRECT_URI
value: "$AZURE_REDIRECT_URI"
- name: AZURE_AUTHORITY
value: "$AZURE_AUTHORITY"
value: "$AZURE_AUTHORITY"
- name: SECRET_KEY
valueFrom:
secretKeyRef:
Expand Down
2 changes: 1 addition & 1 deletion home/forms/domain_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import NamedTuple
import os
from typing import NamedTuple


class Domain(NamedTuple):
Expand Down
13 changes: 8 additions & 5 deletions home/forms/search.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from copy import deepcopy
from urllib.parse import urlencode

from data_platform_catalogue.search_types import ResultType
from django import forms

from .domain_model import Domain, DomainModel
from data_platform_catalogue.search_types import ResultType


def get_domain_choices() -> list[Domain]:
Expand Down Expand Up @@ -35,10 +35,13 @@ def get_where_to_access_choices():


def get_entity_types():
return sorted([
(entity.name, entity.name.replace("_", " ").lower().title())
for entity in ResultType if entity.name != "GLOSSARY_TERM"
])
return sorted(
[
(entity.name, entity.name.replace("_", " ").lower().title())
for entity in ResultType
if entity.name != "GLOSSARY_TERM"
]
)


class SelectWithOptionAttribute(forms.Select):
Expand Down
44 changes: 44 additions & 0 deletions home/service/metadata_specification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from data_platform_catalogue.entities import (
AccessInformation,
Chart,
Column,
ColumnRef,
CustomEntityProperties,
Database,
DataSummary,
DomainRef,
Entity,
EntityRef,
Governance,
OwnerRef,
Table,
TagRef,
UsageRestrictions,
)


class MetadataSpecificationService:
def __init__(self):
self.context = self._get_context()

def _get_context(self):
return {
"h1_value": "Metadata Specification",
"entities": {
"Table": Table.model_json_schema(),
"Database": Database.model_json_schema(),
"Chart": Chart.model_json_schema(),
"CustomEntityProperties": CustomEntityProperties.model_json_schema(),
"UsageRestrictions": UsageRestrictions.model_json_schema(),
"AccessInformation": AccessInformation.model_json_schema(),
"EntityRef": EntityRef.model_json_schema(),
"Governance": Governance.model_json_schema(),
"OwnerRef": OwnerRef.model_json_schema(),
"DomainRef": DomainRef.model_json_schema(),
"Column": Column.model_json_schema(),
"ColumnRef": ColumnRef.model_json_schema(),
"TagRef": TagRef.model_json_schema(),
"DataSummary": DataSummary.model_json_schema(),
"Entity": Entity.model_json_schema(),
},
}
18 changes: 18 additions & 0 deletions home/templatetags/format_metadata_field_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django import template

register = template.Library()


@register.filter
def format_metadata_field_type(value: dict) -> str:
if value.get("title"):
title = value["title"]
if value.get("type"):
type_string = value["type"]
if value.get("anyOf"):
type_string = " or ".join(item["type"] for item in value["anyOf"])
output = f"{title} ({type_string})"
if value.get("allOf"):
linked_entity = value["allOf"][0]["$ref"].split("/")[2]
output = f"{linked_entity} (object)"
return output
2 changes: 1 addition & 1 deletion home/templatetags/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _align_snippet(snippet, max_chars):
Align a snippet to a few words before start_mark_idx
"""
start_mark_idx = snippet.find("<mark>")
end_mark_idx = snippet[start_mark_idx + 1 :].find("</mark>")
end_mark_idx = snippet[start_mark_idx + 1:].find("</mark>")

# If the mark is at the beginning of the first remaining paragraph,
# no further alignment is required.
Expand Down
11 changes: 10 additions & 1 deletion home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
path("", views.home_view, name="home"),
path("search", views.search_view, name="search"),
path("glossary", views.glossary_view, name="glossary"),
path("details/<str:result_type>/<str:urn>", views.details_view, name="details"),
path(
"metadata_specification",
views.metadata_specification_view,
name="metadata_specification",
),
path(
"details/<str:result_type>/<str:urn>",
views.details_view,
name="details",
),
path("pagination/<str:page>", views.search_view, name="pagination"),
]
8 changes: 8 additions & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DatasetDetailsService,
)
from home.service.glossary import GlossaryService
from home.service.metadata_specification import MetadataSpecificationService
from home.service.search import SearchService


Expand Down Expand Up @@ -83,3 +84,10 @@ def search_view(request, page: str = "1"):
def glossary_view(request):
glossary_service = GlossaryService()
return render(request, "glossary.html", glossary_service.context)


def metadata_specification_view(request):
metadata_specification = MetadataSpecificationService()
return render(
request, "metadata_specification.html", metadata_specification.context
)
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def get_table_details(self, urn) -> Table:
else:
relations = {}
return Table(
urn=None,
urn=urn,
display_name=display_name,
name=name,
fully_qualified_name=qualified_name,
Expand Down
Loading
Loading