Skip to content

Commit

Permalink
Fix open-metadata#14089: reduce code duplications, use qliksense data…
Browse files Browse the repository at this point in the history
… models for sheets & data models
  • Loading branch information
harshsoni2024 committed Mar 28, 2024
1 parent b2c2565 commit 0907fd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
GET_SHEET_LAYOUT,
OPEN_DOC_REQ,
)
from metadata.ingestion.source.dashboard.qlikcloud.models import (
QlikAppDetails,
QlikAppList,
from metadata.ingestion.source.dashboard.qlikcloud.models import QlikApp, QlikAppList
from metadata.ingestion.source.dashboard.qliksense.models import (
QlikDataModelResult,
QlikSheet,
QlikSheetResult,
Expand Down Expand Up @@ -128,7 +127,7 @@ def get_dashboards_list(self) -> List[QlikAppList]:
logger.warning("Failed to fetch the app list")
return []

def get_dashboard_details(self, dashboard_id: str) -> Optional[QlikAppDetails]:
def get_dashboard_details(self, dashboard_id: str) -> Optional[QlikApp]:
"""
Get App Details
"""
Expand All @@ -137,15 +136,15 @@ def get_dashboard_details(self, dashboard_id: str) -> Optional[QlikAppDetails]:
try:
resp_dashboard = self.client.get(f"/v1/apps/{dashboard_id}")
if resp_dashboard:
return QlikAppDetails(**resp_dashboard.get("attributes"))
return QlikApp(**resp_dashboard.get("attributes"))
except Exception:
logger.debug(traceback.format_exc())
logger.warning(f"Failed to fetch the dashboard with id: {dashboard_id}")
return None

def get_dashboard_models(self) -> List[QlikTable]:
"""
Get dahsboard chart list
Get dahsboard data models
"""
try:
self._websocket_send_request(APP_LOADMODEL_REQ)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@
from metadata.ingestion.api.steps import InvalidSourceException
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.ingestion.source.dashboard.dashboard_service import DashboardServiceSource
from metadata.ingestion.source.dashboard.qlikcloud.models import (
QlikApp,
QlikAppDetails,
QlikAppList,
QlikTable,
)
from metadata.ingestion.source.dashboard.qlikcloud.models import QlikApp, QlikAppList
from metadata.ingestion.source.dashboard.qliksense.models import QlikTable
from metadata.utils import fqn
from metadata.utils.filters import filter_by_chart, filter_by_datamodel
from metadata.utils.helpers import clean_uri, replace_special_with
Expand Down Expand Up @@ -108,10 +104,10 @@ def get_dashboard_details(self, dashboard: QlikApp) -> dict:
"""
Get app Details
"""
return self.client.get_dashboard_details(dashboard.resourceId)
return self.client.get_dashboard_details(dashboard.app_id)

def yield_dashboard(
self, dashboard_details: QlikAppDetails
self, dashboard_details: QlikApp
) -> Iterable[Either[CreateDashboardRequest]]:
"""
Method to Get Dashboard Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,22 @@
"""
QlikCloud Models
"""
from typing import List, Optional, Union
from typing import List, Optional

from pydantic import BaseModel
from pydantic import BaseModel, Field


# App
# App Models
class QlikApp(BaseModel):
"""
QlikCloud App model
"""
"""QlikCloud App model"""

description: Optional[str]
name: str
id: str
resourceId: str


class QlikAppList(BaseModel):
apps: Optional[List[QlikApp]]


class QlikAppDetails(BaseModel):
"""
Qlik App details model
"""

description: Optional[str]

name: Optional[str]
id: str
collection_id: Optional[str]


# Sheet
class QlikSheetInfo(BaseModel):
qId: str


class QlikSheetMeta(BaseModel):
title: Optional[str]
description: Optional[str]


class QlikSheet(BaseModel):
qInfo: QlikSheetInfo
qMeta: Optional[QlikSheetMeta] = QlikSheetMeta()


class QlikSheetItems(BaseModel):
qItems: Optional[List[QlikSheet]] = []

app_id: Optional[str] = Field(alias="resourceId", default=None)

class QlikSheetAppObject(BaseModel):
qAppObjectList: Optional[QlikSheetItems] = QlikSheetItems()


class QlikSheetLayout(BaseModel):
qLayout: Optional[QlikSheetAppObject] = QlikSheetAppObject()


class QlikSheetResult(BaseModel):
result: Optional[QlikSheetLayout] = QlikSheetLayout()


# datamodel models
class QlikFields(BaseModel):
name: Optional[str]
id: Optional[str]


class QlikTableConnectionProp(BaseModel):
tableQualifiers: Optional[List[str]] = []


class QlikTable(BaseModel):
tableName: Optional[str]
id: Optional[str]
connectionInfo: Optional[QlikTableConnectionProp] = QlikTableConnectionProp()
fields: Optional[List[QlikFields]] = []


class QlikTablesList(BaseModel):
tables: Optional[List[QlikTable]] = []


class QlikDataModelValue(BaseModel):
value: Optional[QlikTablesList]


class QlikDataModelLayout(BaseModel):
qLayout: Optional[Union[QlikTablesList, List[QlikDataModelValue]]] = []

class QlikAppList(BaseModel):
"""QlikCloud Apps List"""

class QlikDataModelResult(BaseModel):
result: Optional[QlikDataModelLayout] = QlikDataModelLayout()
apps: Optional[List[QlikApp]]

0 comments on commit 0907fd9

Please sign in to comment.