mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-03 03:59:12 +00:00
move common code to classbase (#23700)
This commit is contained in:
parent
b7545e6305
commit
45c2ad9d4a
@ -23,50 +23,11 @@ import {
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { EntityType, TabSpecificField } from '../../../enums/entity.enum';
|
||||
import { TabSpecificField } from '../../../enums/entity.enum';
|
||||
import { Table } from '../../../generated/entity/data/table';
|
||||
import { Include } from '../../../generated/type/include';
|
||||
import { useApplicationStore } from '../../../hooks/useApplicationStore';
|
||||
import { getAlertsFromName } from '../../../rest/alertsAPI';
|
||||
import { getApiCollectionByFQN } from '../../../rest/apiCollectionsAPI';
|
||||
import { getApiEndPointByFQN } from '../../../rest/apiEndpointsAPI';
|
||||
import { getApplicationByName } from '../../../rest/applicationAPI';
|
||||
import { getMarketPlaceApplicationByFqn } from '../../../rest/applicationMarketPlaceAPI';
|
||||
import { getChartByFqn } from '../../../rest/chartsAPI';
|
||||
import { getContract } from '../../../rest/contractAPI';
|
||||
import { getDashboardByFqn } from '../../../rest/dashboardAPI';
|
||||
import {
|
||||
getDatabaseDetailsByFQN,
|
||||
getDatabaseSchemaDetailsByFQN,
|
||||
} from '../../../rest/databaseAPI';
|
||||
import { getDataModelByFqn } from '../../../rest/dataModelsAPI';
|
||||
import { getDataProductByName } from '../../../rest/dataProductAPI';
|
||||
import { getDomainByName } from '../../../rest/domainAPI';
|
||||
import {
|
||||
getGlossariesByName,
|
||||
getGlossaryTermByFQN,
|
||||
} from '../../../rest/glossaryAPI';
|
||||
import { getIngestionPipelineByFqn } from '../../../rest/ingestionPipelineAPI';
|
||||
import { getKPIByName } from '../../../rest/KpiAPI';
|
||||
import { getTypeByFQN } from '../../../rest/metadataTypeAPI';
|
||||
import { getMetricByFqn } from '../../../rest/metricsAPI';
|
||||
import { getMlModelByFQN } from '../../../rest/mlModelAPI';
|
||||
import { getPersonaByName } from '../../../rest/PersonaAPI';
|
||||
import { getPipelineByFqn } from '../../../rest/pipelineAPI';
|
||||
import { getQueryByFqn } from '../../../rest/queryAPI';
|
||||
import { getPolicyByName, getRoleByName } from '../../../rest/rolesAPIV1';
|
||||
import { getSearchIndexDetailsByFQN } from '../../../rest/SearchIndexAPI';
|
||||
import { getServiceByFQN } from '../../../rest/serviceAPI';
|
||||
import { getContainerByFQN } from '../../../rest/storageAPI';
|
||||
import { getStoredProceduresByFqn } from '../../../rest/storedProceduresAPI';
|
||||
import { getTableDetailsByFQN } from '../../../rest/tableAPI';
|
||||
import { getClassificationByName, getTagByFqn } from '../../../rest/tagAPI';
|
||||
import { getTeamByName } from '../../../rest/teamsAPI';
|
||||
import { getTestCaseByFqn, getTestSuiteByName } from '../../../rest/testAPI';
|
||||
import { getTopicByFqn } from '../../../rest/topicsAPI';
|
||||
import { getBotByName, getUserByName } from '../../../rest/userAPI';
|
||||
import entityUtilClassBase from '../../../utils/EntityUtilClassBase';
|
||||
import { getEntityName } from '../../../utils/EntityUtils';
|
||||
import { EntityUnion } from '../../Explore/ExplorePage.interface';
|
||||
import ExploreSearchCard from '../../ExploreV1/ExploreSearchCard/ExploreSearchCard';
|
||||
import { SearchedDataProps } from '../../SearchedData/SearchedData.interface';
|
||||
import Loader from '../Loader/Loader';
|
||||
@ -110,230 +71,12 @@ export const PopoverContent: React.FC<{
|
||||
const getData = useCallback(async () => {
|
||||
const fields = `${TabSpecificField.TAGS},${TabSpecificField.OWNERS}`;
|
||||
setLoading(true);
|
||||
let promise: Promise<EntityUnion> | null = null;
|
||||
|
||||
switch (entityType) {
|
||||
case EntityType.TABLE:
|
||||
promise = getTableDetailsByFQN(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.TEST_CASE:
|
||||
promise = getTestCaseByFqn(entityFQN, {
|
||||
fields: [TabSpecificField.OWNERS],
|
||||
});
|
||||
|
||||
break;
|
||||
case EntityType.TOPIC:
|
||||
promise = getTopicByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.DASHBOARD:
|
||||
promise = getDashboardByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.CHART:
|
||||
promise = getChartByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.PIPELINE:
|
||||
promise = getPipelineByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.MLMODEL:
|
||||
promise = getMlModelByFQN(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.DATABASE:
|
||||
promise = getDatabaseDetailsByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
break;
|
||||
case EntityType.DATABASE_SCHEMA:
|
||||
promise = getDatabaseSchemaDetailsByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
include: Include.All,
|
||||
});
|
||||
|
||||
break;
|
||||
case EntityType.GLOSSARY_TERM:
|
||||
promise = getGlossaryTermByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
break;
|
||||
case EntityType.GLOSSARY:
|
||||
promise = getGlossariesByName(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.CONTAINER:
|
||||
promise = getContainerByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
include: Include.All,
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.DASHBOARD_DATA_MODEL:
|
||||
promise = getDataModelByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.STORED_PROCEDURE:
|
||||
promise = getStoredProceduresByFqn(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.DOMAIN:
|
||||
promise = getDomainByName(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.DATA_PRODUCT:
|
||||
promise = getDataProductByName(entityFQN, {
|
||||
fields: [TabSpecificField.OWNERS, TabSpecificField.DOMAINS],
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.TAG:
|
||||
promise = getTagByFqn(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.API_COLLECTION:
|
||||
promise = getApiCollectionByFQN(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.API_ENDPOINT:
|
||||
promise = getApiEndPointByFQN(entityFQN, { fields });
|
||||
|
||||
break;
|
||||
case EntityType.METRIC:
|
||||
promise = getMetricByFqn(entityFQN, {
|
||||
fields: [
|
||||
TabSpecificField.OWNERS,
|
||||
TabSpecificField.TAGS,
|
||||
TabSpecificField.DOMAINS,
|
||||
],
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.BOT:
|
||||
promise = getBotByName(entityFQN, {
|
||||
fields: [EntityType.BOT],
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.EVENT_SUBSCRIPTION:
|
||||
promise = getAlertsFromName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.ROLE:
|
||||
promise = getRoleByName(entityFQN, '');
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.POLICY:
|
||||
promise = getPolicyByName(entityFQN, '');
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.CLASSIFICATION:
|
||||
promise = getClassificationByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.DATABASE_SERVICE:
|
||||
case EntityType.MESSAGING_SERVICE:
|
||||
case EntityType.DASHBOARD_SERVICE:
|
||||
case EntityType.PIPELINE_SERVICE:
|
||||
case EntityType.MLMODEL_SERVICE:
|
||||
case EntityType.STORAGE_SERVICE:
|
||||
case EntityType.SEARCH_SERVICE:
|
||||
case EntityType.API_SERVICE:
|
||||
case EntityType.SECURITY_SERVICE:
|
||||
case EntityType.METADATA_SERVICE:
|
||||
promise = getServiceByFQN(entityType, entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.TYPE:
|
||||
promise = getTypeByFQN(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.TEAM:
|
||||
promise = getTeamByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.USER:
|
||||
promise = getUserByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.TEST_SUITE:
|
||||
promise = getTestSuiteByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.KPI:
|
||||
promise = getKPIByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.SEARCH_INDEX:
|
||||
promise = getSearchIndexDetailsByFQN(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.APP_MARKET_PLACE_DEFINITION:
|
||||
promise = getMarketPlaceApplicationByFqn(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.APPLICATION:
|
||||
promise = getApplicationByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.PERSONA:
|
||||
promise = getPersonaByName(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.INGESTION_PIPELINE:
|
||||
promise = getIngestionPipelineByFqn(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.SERVICE:
|
||||
promise = getServiceByFQN(EntityType.SERVICE, entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.DATA_CONTRACT:
|
||||
promise = getContract(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
case EntityType.QUERY:
|
||||
promise = getQueryByFqn(entityFQN);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const promise = entityUtilClassBase.getEntityByFqn(
|
||||
entityType,
|
||||
entityFQN,
|
||||
fields
|
||||
);
|
||||
|
||||
if (promise) {
|
||||
try {
|
||||
|
||||
@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright 2024 Collate.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EntityType } from '../enums/entity.enum';
|
||||
import * as alertsAPI from '../rest/alertsAPI';
|
||||
import * as apiCollectionsAPI from '../rest/apiCollectionsAPI';
|
||||
import * as apiEndpointsAPI from '../rest/apiEndpointsAPI';
|
||||
import * as databaseAPI from '../rest/databaseAPI';
|
||||
import * as glossaryAPI from '../rest/glossaryAPI';
|
||||
import * as serviceAPI from '../rest/serviceAPI';
|
||||
import * as tableAPI from '../rest/tableAPI';
|
||||
import * as testAPI from '../rest/testAPI';
|
||||
import { getEntityByFqnUtil } from './EntityByFqnUtils';
|
||||
|
||||
jest.mock('../rest/tableAPI');
|
||||
jest.mock('../rest/databaseAPI');
|
||||
jest.mock('../rest/glossaryAPI');
|
||||
jest.mock('../rest/serviceAPI');
|
||||
jest.mock('../rest/alertsAPI');
|
||||
jest.mock('../rest/apiCollectionsAPI');
|
||||
jest.mock('../rest/apiEndpointsAPI');
|
||||
jest.mock('../rest/testAPI');
|
||||
|
||||
describe('EntityByFqnUtils', () => {
|
||||
const mockFqn = 'test.fqn';
|
||||
const mockFields = 'owners,tags';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('getEntityByFqnUtil', () => {
|
||||
it('should fetch TABLE entity correctly', async () => {
|
||||
const mockTableData = { id: '1', name: 'test-table' };
|
||||
(tableAPI.getTableDetailsByFQN as jest.Mock).mockResolvedValue(
|
||||
mockTableData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.TABLE,
|
||||
mockFqn,
|
||||
mockFields
|
||||
);
|
||||
|
||||
expect(tableAPI.getTableDetailsByFQN).toHaveBeenCalledWith(mockFqn, {
|
||||
fields: mockFields,
|
||||
});
|
||||
expect(result).toEqual(mockTableData);
|
||||
});
|
||||
|
||||
it('should fetch DATABASE entity with OWNERS field', async () => {
|
||||
const mockDatabaseData = { id: '1', name: 'test-db' };
|
||||
(databaseAPI.getDatabaseDetailsByFQN as jest.Mock).mockResolvedValue(
|
||||
mockDatabaseData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(EntityType.DATABASE, mockFqn);
|
||||
|
||||
expect(databaseAPI.getDatabaseDetailsByFQN).toHaveBeenCalledWith(
|
||||
mockFqn,
|
||||
{
|
||||
fields: 'owners',
|
||||
}
|
||||
);
|
||||
expect(result).toEqual(mockDatabaseData);
|
||||
});
|
||||
|
||||
it('should fetch DATABASE_SCHEMA entity with OWNERS field and Include.All', async () => {
|
||||
const mockSchemaData = { id: '1', name: 'test-schema' };
|
||||
(
|
||||
databaseAPI.getDatabaseSchemaDetailsByFQN as jest.Mock
|
||||
).mockResolvedValue(mockSchemaData);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.DATABASE_SCHEMA,
|
||||
mockFqn
|
||||
);
|
||||
|
||||
expect(databaseAPI.getDatabaseSchemaDetailsByFQN).toHaveBeenCalledWith(
|
||||
mockFqn,
|
||||
{
|
||||
fields: 'owners',
|
||||
include: 'all',
|
||||
}
|
||||
);
|
||||
expect(result).toEqual(mockSchemaData);
|
||||
});
|
||||
|
||||
it('should fetch GLOSSARY_TERM entity correctly', async () => {
|
||||
const mockGlossaryTermData = { id: '1', name: 'test-term' };
|
||||
(glossaryAPI.getGlossaryTermByFQN as jest.Mock).mockResolvedValue(
|
||||
mockGlossaryTermData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.GLOSSARY_TERM,
|
||||
mockFqn
|
||||
);
|
||||
|
||||
expect(glossaryAPI.getGlossaryTermByFQN).toHaveBeenCalledWith(mockFqn, {
|
||||
fields: 'owners',
|
||||
});
|
||||
expect(result).toEqual(mockGlossaryTermData);
|
||||
});
|
||||
|
||||
it('should fetch GLOSSARY entity correctly', async () => {
|
||||
const mockGlossaryData = { id: '1', name: 'test-glossary' };
|
||||
(glossaryAPI.getGlossariesByName as jest.Mock).mockResolvedValue(
|
||||
mockGlossaryData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(EntityType.GLOSSARY, mockFqn);
|
||||
|
||||
expect(glossaryAPI.getGlossariesByName).toHaveBeenCalledWith(mockFqn, {
|
||||
fields: 'owners',
|
||||
});
|
||||
expect(result).toEqual(mockGlossaryData);
|
||||
});
|
||||
|
||||
it('should fetch TEST_CASE entity with correct fields', async () => {
|
||||
const mockTestCaseData = { id: '1', name: 'test-case' };
|
||||
(testAPI.getTestCaseByFqn as jest.Mock).mockResolvedValue(
|
||||
mockTestCaseData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(EntityType.TEST_CASE, mockFqn);
|
||||
|
||||
expect(testAPI.getTestCaseByFqn).toHaveBeenCalledWith(mockFqn, {
|
||||
fields: ['owners'],
|
||||
});
|
||||
expect(result).toEqual(mockTestCaseData);
|
||||
});
|
||||
|
||||
it('should fetch DATABASE_SERVICE using getServiceByFQN', async () => {
|
||||
const mockServiceData = { id: '1', name: 'test-service' };
|
||||
(serviceAPI.getServiceByFQN as jest.Mock).mockResolvedValue(
|
||||
mockServiceData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.DATABASE_SERVICE,
|
||||
mockFqn
|
||||
);
|
||||
|
||||
expect(serviceAPI.getServiceByFQN).toHaveBeenCalledWith(
|
||||
EntityType.DATABASE_SERVICE,
|
||||
mockFqn
|
||||
);
|
||||
expect(result).toEqual(mockServiceData);
|
||||
});
|
||||
|
||||
it('should fetch MESSAGING_SERVICE using getServiceByFQN', async () => {
|
||||
const mockServiceData = { id: '1', name: 'test-messaging-service' };
|
||||
(serviceAPI.getServiceByFQN as jest.Mock).mockResolvedValue(
|
||||
mockServiceData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.MESSAGING_SERVICE,
|
||||
mockFqn
|
||||
);
|
||||
|
||||
expect(serviceAPI.getServiceByFQN).toHaveBeenCalledWith(
|
||||
EntityType.MESSAGING_SERVICE,
|
||||
mockFqn
|
||||
);
|
||||
expect(result).toEqual(mockServiceData);
|
||||
});
|
||||
|
||||
it('should fetch API_COLLECTION entity correctly', async () => {
|
||||
const mockAPICollectionData = { id: '1', name: 'test-collection' };
|
||||
(apiCollectionsAPI.getApiCollectionByFQN as jest.Mock).mockResolvedValue(
|
||||
mockAPICollectionData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.API_COLLECTION,
|
||||
mockFqn,
|
||||
mockFields
|
||||
);
|
||||
|
||||
expect(apiCollectionsAPI.getApiCollectionByFQN).toHaveBeenCalledWith(
|
||||
mockFqn,
|
||||
{
|
||||
fields: mockFields,
|
||||
}
|
||||
);
|
||||
expect(result).toEqual(mockAPICollectionData);
|
||||
});
|
||||
|
||||
it('should fetch API_ENDPOINT entity correctly', async () => {
|
||||
const mockAPIEndpointData = { id: '1', name: 'test-endpoint' };
|
||||
(apiEndpointsAPI.getApiEndPointByFQN as jest.Mock).mockResolvedValue(
|
||||
mockAPIEndpointData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.API_ENDPOINT,
|
||||
mockFqn,
|
||||
mockFields
|
||||
);
|
||||
|
||||
expect(apiEndpointsAPI.getApiEndPointByFQN).toHaveBeenCalledWith(
|
||||
mockFqn,
|
||||
{
|
||||
fields: mockFields,
|
||||
}
|
||||
);
|
||||
expect(result).toEqual(mockAPIEndpointData);
|
||||
});
|
||||
|
||||
it('should fetch EVENT_SUBSCRIPTION entity correctly', async () => {
|
||||
const mockEventSubData = { id: '1', name: 'test-event-sub' };
|
||||
(alertsAPI.getAlertsFromName as jest.Mock).mockResolvedValue(
|
||||
mockEventSubData
|
||||
);
|
||||
|
||||
const result = await getEntityByFqnUtil(
|
||||
EntityType.EVENT_SUBSCRIPTION,
|
||||
mockFqn
|
||||
);
|
||||
|
||||
expect(alertsAPI.getAlertsFromName).toHaveBeenCalledWith(mockFqn);
|
||||
expect(result).toEqual(mockEventSubData);
|
||||
});
|
||||
|
||||
it('should return null for unknown entity type', async () => {
|
||||
const result = await getEntityByFqnUtil('UNKNOWN_TYPE', mockFqn);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should handle all service types correctly', async () => {
|
||||
const serviceTypes = [
|
||||
EntityType.DATABASE_SERVICE,
|
||||
EntityType.MESSAGING_SERVICE,
|
||||
EntityType.DASHBOARD_SERVICE,
|
||||
EntityType.PIPELINE_SERVICE,
|
||||
EntityType.MLMODEL_SERVICE,
|
||||
EntityType.STORAGE_SERVICE,
|
||||
EntityType.SEARCH_SERVICE,
|
||||
EntityType.API_SERVICE,
|
||||
EntityType.SECURITY_SERVICE,
|
||||
EntityType.METADATA_SERVICE,
|
||||
EntityType.SERVICE,
|
||||
];
|
||||
|
||||
const mockServiceData = { id: '1', name: 'test-service' };
|
||||
(serviceAPI.getServiceByFQN as jest.Mock).mockResolvedValue(
|
||||
mockServiceData
|
||||
);
|
||||
|
||||
for (const serviceType of serviceTypes) {
|
||||
await getEntityByFqnUtil(serviceType, mockFqn);
|
||||
|
||||
expect(serviceAPI.getServiceByFQN).toHaveBeenCalledWith(
|
||||
serviceType,
|
||||
mockFqn
|
||||
);
|
||||
}
|
||||
|
||||
expect(serviceAPI.getServiceByFQN).toHaveBeenCalledTimes(
|
||||
serviceTypes.length
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright 2024 Collate.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EntityUnion } from '../components/Explore/ExplorePage.interface';
|
||||
import { EntityType, TabSpecificField } from '../enums/entity.enum';
|
||||
import { Include } from '../generated/type/include';
|
||||
import { getAlertsFromName } from '../rest/alertsAPI';
|
||||
import { getApiCollectionByFQN } from '../rest/apiCollectionsAPI';
|
||||
import { getApiEndPointByFQN } from '../rest/apiEndpointsAPI';
|
||||
import { getApplicationByName } from '../rest/applicationAPI';
|
||||
import { getMarketPlaceApplicationByFqn } from '../rest/applicationMarketPlaceAPI';
|
||||
import { getChartByFqn } from '../rest/chartsAPI';
|
||||
import { getContract } from '../rest/contractAPI';
|
||||
import { getDashboardByFqn } from '../rest/dashboardAPI';
|
||||
import {
|
||||
getDatabaseDetailsByFQN,
|
||||
getDatabaseSchemaDetailsByFQN,
|
||||
} from '../rest/databaseAPI';
|
||||
import { getDataModelByFqn } from '../rest/dataModelsAPI';
|
||||
import { getDataProductByName } from '../rest/dataProductAPI';
|
||||
import { getDomainByName } from '../rest/domainAPI';
|
||||
import { getGlossariesByName, getGlossaryTermByFQN } from '../rest/glossaryAPI';
|
||||
import { getIngestionPipelineByFqn } from '../rest/ingestionPipelineAPI';
|
||||
import { getKPIByName } from '../rest/KpiAPI';
|
||||
import { getTypeByFQN } from '../rest/metadataTypeAPI';
|
||||
import { getMetricByFqn } from '../rest/metricsAPI';
|
||||
import { getMlModelByFQN } from '../rest/mlModelAPI';
|
||||
import { getPersonaByName } from '../rest/PersonaAPI';
|
||||
import { getPipelineByFqn } from '../rest/pipelineAPI';
|
||||
import { getQueryByFqn } from '../rest/queryAPI';
|
||||
import { getPolicyByName, getRoleByName } from '../rest/rolesAPIV1';
|
||||
import { getSearchIndexDetailsByFQN } from '../rest/SearchIndexAPI';
|
||||
import { getServiceByFQN } from '../rest/serviceAPI';
|
||||
import { getContainerByFQN } from '../rest/storageAPI';
|
||||
import { getStoredProceduresByFqn } from '../rest/storedProceduresAPI';
|
||||
import { getTableDetailsByFQN } from '../rest/tableAPI';
|
||||
import { getClassificationByName, getTagByFqn } from '../rest/tagAPI';
|
||||
import { getTeamByName } from '../rest/teamsAPI';
|
||||
import { getTestCaseByFqn, getTestSuiteByName } from '../rest/testAPI';
|
||||
import { getTopicByFqn } from '../rest/topicsAPI';
|
||||
import { getBotByName, getUserByName } from '../rest/userAPI';
|
||||
|
||||
export const getEntityByFqnUtil = (
|
||||
entityType: string,
|
||||
entityFQN: string,
|
||||
fields?: string
|
||||
): Promise<EntityUnion> | null => {
|
||||
switch (entityType) {
|
||||
case EntityType.TABLE:
|
||||
return getTableDetailsByFQN(entityFQN, { fields });
|
||||
|
||||
case EntityType.TEST_CASE:
|
||||
return getTestCaseByFqn(entityFQN, {
|
||||
fields: [TabSpecificField.OWNERS],
|
||||
});
|
||||
|
||||
case EntityType.TOPIC:
|
||||
return getTopicByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.DASHBOARD:
|
||||
return getDashboardByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.CHART:
|
||||
return getChartByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.PIPELINE:
|
||||
return getPipelineByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.MLMODEL:
|
||||
return getMlModelByFQN(entityFQN, { fields });
|
||||
|
||||
case EntityType.DATABASE:
|
||||
return getDatabaseDetailsByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
case EntityType.DATABASE_SCHEMA:
|
||||
return getDatabaseSchemaDetailsByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
include: Include.All,
|
||||
});
|
||||
|
||||
case EntityType.GLOSSARY_TERM:
|
||||
return getGlossaryTermByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
case EntityType.GLOSSARY:
|
||||
return getGlossariesByName(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
case EntityType.CONTAINER:
|
||||
return getContainerByFQN(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
include: Include.All,
|
||||
});
|
||||
|
||||
case EntityType.DASHBOARD_DATA_MODEL:
|
||||
return getDataModelByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.STORED_PROCEDURE:
|
||||
return getStoredProceduresByFqn(entityFQN, { fields });
|
||||
|
||||
case EntityType.DOMAIN:
|
||||
return getDomainByName(entityFQN, {
|
||||
fields: TabSpecificField.OWNERS,
|
||||
});
|
||||
|
||||
case EntityType.DATA_PRODUCT:
|
||||
return getDataProductByName(entityFQN, {
|
||||
fields: [TabSpecificField.OWNERS, TabSpecificField.DOMAINS],
|
||||
});
|
||||
|
||||
case EntityType.TAG:
|
||||
return getTagByFqn(entityFQN);
|
||||
|
||||
case EntityType.API_COLLECTION:
|
||||
return getApiCollectionByFQN(entityFQN, { fields });
|
||||
|
||||
case EntityType.API_ENDPOINT:
|
||||
return getApiEndPointByFQN(entityFQN, { fields });
|
||||
|
||||
case EntityType.METRIC:
|
||||
return getMetricByFqn(entityFQN, {
|
||||
fields: [
|
||||
TabSpecificField.OWNERS,
|
||||
TabSpecificField.TAGS,
|
||||
TabSpecificField.DOMAINS,
|
||||
],
|
||||
});
|
||||
|
||||
case EntityType.BOT:
|
||||
return getBotByName(entityFQN, {
|
||||
fields: [EntityType.BOT],
|
||||
});
|
||||
|
||||
case EntityType.EVENT_SUBSCRIPTION:
|
||||
return getAlertsFromName(entityFQN);
|
||||
|
||||
case EntityType.ROLE:
|
||||
return getRoleByName(entityFQN, '');
|
||||
|
||||
case EntityType.POLICY:
|
||||
return getPolicyByName(entityFQN, '');
|
||||
|
||||
case EntityType.CLASSIFICATION:
|
||||
return getClassificationByName(entityFQN);
|
||||
|
||||
case EntityType.DATABASE_SERVICE:
|
||||
case EntityType.MESSAGING_SERVICE:
|
||||
case EntityType.DASHBOARD_SERVICE:
|
||||
case EntityType.PIPELINE_SERVICE:
|
||||
case EntityType.MLMODEL_SERVICE:
|
||||
case EntityType.STORAGE_SERVICE:
|
||||
case EntityType.SEARCH_SERVICE:
|
||||
case EntityType.API_SERVICE:
|
||||
case EntityType.SECURITY_SERVICE:
|
||||
case EntityType.METADATA_SERVICE:
|
||||
return getServiceByFQN(entityType, entityFQN);
|
||||
|
||||
case EntityType.TYPE:
|
||||
return getTypeByFQN(entityFQN);
|
||||
|
||||
case EntityType.TEAM:
|
||||
return getTeamByName(entityFQN);
|
||||
|
||||
case EntityType.USER:
|
||||
return getUserByName(entityFQN);
|
||||
|
||||
case EntityType.TEST_SUITE:
|
||||
return getTestSuiteByName(entityFQN);
|
||||
|
||||
case EntityType.KPI:
|
||||
return getKPIByName(entityFQN);
|
||||
|
||||
case EntityType.SEARCH_INDEX:
|
||||
return getSearchIndexDetailsByFQN(entityFQN);
|
||||
|
||||
case EntityType.APP_MARKET_PLACE_DEFINITION:
|
||||
return getMarketPlaceApplicationByFqn(entityFQN);
|
||||
|
||||
case EntityType.APPLICATION:
|
||||
return getApplicationByName(entityFQN);
|
||||
|
||||
case EntityType.PERSONA:
|
||||
return getPersonaByName(entityFQN);
|
||||
|
||||
case EntityType.INGESTION_PIPELINE:
|
||||
return getIngestionPipelineByFqn(entityFQN);
|
||||
|
||||
case EntityType.SERVICE:
|
||||
return getServiceByFQN(EntityType.SERVICE, entityFQN);
|
||||
|
||||
case EntityType.DATA_CONTRACT:
|
||||
return getContract(entityFQN);
|
||||
|
||||
case EntityType.QUERY:
|
||||
return getQueryByFqn(entityFQN);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@ -47,16 +47,10 @@ import StoredProcedurePage from '../pages/StoredProcedure/StoredProcedurePage';
|
||||
import TableDetailsPageV1 from '../pages/TableDetailsPageV1/TableDetailsPageV1';
|
||||
import TopicDetailsPage from '../pages/TopicDetails/TopicDetailsPage.component';
|
||||
import WorksheetDetailsPage from '../pages/WorksheetDetailsPage/WorksheetDetailsPage';
|
||||
import {
|
||||
getDatabaseDetailsByFQN,
|
||||
getDatabaseSchemaDetailsByFQN,
|
||||
} from '../rest/databaseAPI';
|
||||
import { getGlossariesByName } from '../rest/glossaryAPI';
|
||||
import { getServiceByFQN } from '../rest/serviceAPI';
|
||||
import { getTableDetailsByFQN } from '../rest/tableAPI';
|
||||
import { ExtraDatabaseDropdownOptions } from './Database/Database.util';
|
||||
import { ExtraDatabaseSchemaDropdownOptions } from './DatabaseSchemaDetailsUtils';
|
||||
import { ExtraDatabaseServiceDropdownOptions } from './DatabaseServiceUtils';
|
||||
import { getEntityByFqnUtil } from './EntityByFqnUtils';
|
||||
import { EntityTypeName } from './EntityUtils';
|
||||
import {
|
||||
FormattedAPIServiceType,
|
||||
@ -372,20 +366,8 @@ class EntityUtilClassBase {
|
||||
}
|
||||
}
|
||||
|
||||
public getEntityByFqn(entityType: string, fqn: string, fields?: string[]) {
|
||||
switch (entityType) {
|
||||
case EntityType.DATABASE_SERVICE:
|
||||
return getServiceByFQN('databaseServices', fqn, { fields });
|
||||
case EntityType.DATABASE:
|
||||
return getDatabaseDetailsByFQN(fqn, { fields });
|
||||
case EntityType.DATABASE_SCHEMA:
|
||||
return getDatabaseSchemaDetailsByFQN(fqn, { fields });
|
||||
|
||||
case EntityType.GLOSSARY_TERM:
|
||||
return getGlossariesByName(fqn, { fields });
|
||||
default:
|
||||
return getTableDetailsByFQN(fqn, { fields });
|
||||
}
|
||||
public getEntityByFqn(entityType: string, fqn: string, fields?: string) {
|
||||
return getEntityByFqnUtil(entityType, fqn, fields);
|
||||
}
|
||||
|
||||
public getEntityDetailComponent(entityType: string): FC | null {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user