mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 10:49:00 +00:00 
			
		
		
		
	Fixing lint and referntial delete
This commit is contained in:
		
							parent
							
								
									e6d27d92ea
								
							
						
					
					
						commit
						62cc9131f0
					
				| @ -1300,7 +1300,8 @@ public class GmsGraphQLEngine { | ||||
|                   "createApplication", | ||||
|                   new CreateApplicationResolver(this.applicationService, this.entityService)) | ||||
|               .dataFetcher( | ||||
|                   "deleteApplication", new DeleteApplicationResolver(this.applicationService)) | ||||
|                   "deleteApplication", | ||||
|                   new DeleteApplicationResolver(this.entityClient, this.applicationService)) | ||||
|               .dataFetcher( | ||||
|                   "batchSetApplication", new BatchSetApplicationResolver(this.applicationService)) | ||||
|               .dataFetcher( | ||||
|  | ||||
| @ -11,6 +11,7 @@ import com.linkedin.datahub.graphql.QueryContext; | ||||
| import com.linkedin.datahub.graphql.authorization.AuthorizationUtils; | ||||
| import com.linkedin.datahub.graphql.concurrency.GraphQLConcurrencyUtils; | ||||
| import com.linkedin.datahub.graphql.exception.AuthorizationException; | ||||
| import com.linkedin.entity.client.EntityClient; | ||||
| import com.linkedin.metadata.authorization.PoliciesConfig; | ||||
| import com.linkedin.metadata.service.ApplicationService; | ||||
| import graphql.schema.DataFetcher; | ||||
| @ -23,6 +24,7 @@ import lombok.extern.slf4j.Slf4j; | ||||
| @RequiredArgsConstructor | ||||
| public class DeleteApplicationResolver implements DataFetcher<CompletableFuture<Boolean>> { | ||||
| 
 | ||||
|   private final EntityClient entityClient; | ||||
|   private final ApplicationService applicationService; | ||||
| 
 | ||||
|   private static final ConjunctivePrivilegeGroup ALL_PRIVILEGES_GROUP = | ||||
| @ -52,6 +54,19 @@ public class DeleteApplicationResolver implements DataFetcher<CompletableFuture< | ||||
| 
 | ||||
|           try { | ||||
|             applicationService.deleteApplication(context.getOperationContext(), applicationUrn); | ||||
|             CompletableFuture.runAsync( | ||||
|                 () -> { | ||||
|                   try { | ||||
|                     this.entityClient.deleteEntityReferences( | ||||
|                         context.getOperationContext(), applicationUrn); | ||||
|                   } catch (Exception e) { | ||||
|                     log.error( | ||||
|                         String.format( | ||||
|                             "Caught exception while attempting to clear all entity references for Application with urn %s", | ||||
|                             applicationUrn), | ||||
|                         e); | ||||
|                   } | ||||
|                 }); | ||||
|             return true; | ||||
|           } catch (Exception e) { | ||||
|             throw new RuntimeException("Failed to delete Application", e); | ||||
|  | ||||
| @ -8,6 +8,7 @@ import static org.testng.Assert.*; | ||||
| import com.linkedin.common.urn.Urn; | ||||
| import com.linkedin.common.urn.UrnUtils; | ||||
| import com.linkedin.datahub.graphql.QueryContext; | ||||
| import com.linkedin.entity.client.EntityClient; | ||||
| import com.linkedin.metadata.service.ApplicationService; | ||||
| import graphql.schema.DataFetchingEnvironment; | ||||
| import java.util.concurrent.CompletionException; | ||||
| @ -25,11 +26,13 @@ public class DeleteApplicationResolverTest { | ||||
|   private DeleteApplicationResolver resolver; | ||||
|   private QueryContext mockContext; | ||||
|   private DataFetchingEnvironment mockEnv; | ||||
|   private EntityClient mockEntityClient; | ||||
| 
 | ||||
|   @BeforeMethod | ||||
|   public void setupTest() { | ||||
|     mockApplicationService = Mockito.mock(ApplicationService.class); | ||||
|     resolver = new DeleteApplicationResolver(mockApplicationService); | ||||
|     mockEntityClient = Mockito.mock(EntityClient.class); | ||||
|     resolver = new DeleteApplicationResolver(mockEntityClient, mockApplicationService); | ||||
|     mockContext = getMockAllowContext(TEST_ACTOR_URN.toString()); | ||||
|     mockEnv = Mockito.mock(DataFetchingEnvironment.class); | ||||
|     Mockito.when(mockEnv.getContext()).thenReturn(mockContext); | ||||
|  | ||||
| @ -35,6 +35,12 @@ import { Application, EntityType, SearchResult } from '@types'; | ||||
| 
 | ||||
| const headerDropdownItems = new Set([EntityMenuItems.SHARE, EntityMenuItems.DELETE, EntityMenuItems.EDIT]); | ||||
| 
 | ||||
| type ApplicationWithChildren = Application & { | ||||
|     children?: { | ||||
|         total: number; | ||||
|     } | null; | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Definition of the DataHub Application entity. | ||||
|  */ | ||||
| @ -181,8 +187,7 @@ export class ApplicationEntity implements Entity<Application> { | ||||
|                 globalTags={data.tags} | ||||
|                 glossaryTerms={data.glossaryTerms} | ||||
|                 domain={data.domain?.domain} | ||||
|                 // @ts-ignore
 | ||||
|                 entityCount={data?.children?.total || undefined} | ||||
|                 entityCount={(data as ApplicationWithChildren)?.children?.total || undefined} | ||||
|                 externalUrl={data.properties?.externalUrl} | ||||
|                 headerDropdownItems={headerDropdownItems} | ||||
|                 previewType={previewType} | ||||
| @ -204,8 +209,7 @@ export class ApplicationEntity implements Entity<Application> { | ||||
|                 globalTags={data.tags} | ||||
|                 glossaryTerms={data.glossaryTerms} | ||||
|                 domain={data.domain?.domain} | ||||
|                 // @ts-ignore
 | ||||
|                 entityCount={data?.children?.total || undefined} | ||||
|                 entityCount={(data as ApplicationWithChildren)?.children?.total || undefined} | ||||
|                 externalUrl={data.properties?.externalUrl} | ||||
|                 degree={(result as any).degree} | ||||
|                 paths={(result as any).paths} | ||||
| @ -221,8 +225,7 @@ export class ApplicationEntity implements Entity<Application> { | ||||
|     getOverridePropertiesFromEntity = (data: Application) => { | ||||
|         const name = data?.properties?.name; | ||||
|         const externalUrl = data?.properties?.externalUrl; | ||||
|         // @ts-ignore
 | ||||
|         const entityCount = data?.children?.total || undefined; | ||||
|         const entityCount = (data as ApplicationWithChildren)?.children?.total || undefined; | ||||
|         const parentDomains = { | ||||
|             domains: (data?.domain && [data?.domain?.domain]) || [], | ||||
|             count: (data?.domain && 1) || 0, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Gabe Lyons
						Gabe Lyons