2
2
3
3
import static com .linkedin .metadata .Constants .*;
4
4
5
+ import com .linkedin .common .DataPlatformInstance ;
5
6
import com .linkedin .common .urn .Urn ;
6
7
import com .linkedin .data .DataMap ;
7
8
import com .linkedin .data .template .GetMode ;
8
9
import com .linkedin .datahub .graphql .generated .AuditStamp ;
10
+ import com .linkedin .datahub .graphql .generated .DataPlatform ;
9
11
import com .linkedin .datahub .graphql .generated .Dataset ;
10
12
import com .linkedin .datahub .graphql .generated .EntityType ;
11
13
import com .linkedin .datahub .graphql .generated .QueryEntity ;
12
14
import com .linkedin .datahub .graphql .generated .QueryLanguage ;
13
15
import com .linkedin .datahub .graphql .generated .QuerySource ;
14
16
import com .linkedin .datahub .graphql .generated .QueryStatement ;
15
17
import com .linkedin .datahub .graphql .generated .QuerySubject ;
18
+ import com .linkedin .datahub .graphql .types .common .mappers .UrnToEntityMapper ;
16
19
import com .linkedin .datahub .graphql .types .common .mappers .util .MappingHelper ;
17
20
import com .linkedin .datahub .graphql .types .mappers .ModelMapper ;
18
21
import com .linkedin .entity .EntityResponse ;
22
25
import java .util .List ;
23
26
import java .util .stream .Collectors ;
24
27
import javax .annotation .Nonnull ;
28
+ import lombok .extern .slf4j .Slf4j ;
25
29
30
+ @ Slf4j
26
31
public class QueryMapper implements ModelMapper <EntityResponse , QueryEntity > {
27
32
28
33
public static final QueryMapper INSTANCE = new QueryMapper ();
@@ -41,9 +46,20 @@ public QueryEntity apply(@Nonnull final EntityResponse entityResponse) {
41
46
MappingHelper <QueryEntity > mappingHelper = new MappingHelper <>(aspectMap , result );
42
47
mappingHelper .mapToResult (QUERY_PROPERTIES_ASPECT_NAME , this ::mapQueryProperties );
43
48
mappingHelper .mapToResult (QUERY_SUBJECTS_ASPECT_NAME , this ::mapQuerySubjects );
49
+ mappingHelper .mapToResult (DATA_PLATFORM_INSTANCE_ASPECT_NAME , this ::mapPlatform );
44
50
return mappingHelper .getResult ();
45
51
}
46
52
53
+ private void mapPlatform (@ Nonnull QueryEntity query , @ Nonnull DataMap dataMap ) {
54
+ DataPlatformInstance aspect = new DataPlatformInstance (dataMap );
55
+ if (aspect .hasPlatform ()) {
56
+ final DataPlatform platform = new DataPlatform ();
57
+ platform .setUrn (aspect .getPlatform ().toString ());
58
+ platform .setType (EntityType .DATA_PLATFORM );
59
+ query .setPlatform (platform );
60
+ }
61
+ }
62
+
47
63
private void mapQueryProperties (@ Nonnull QueryEntity query , @ Nonnull DataMap dataMap ) {
48
64
QueryProperties queryProperties = new QueryProperties (dataMap );
49
65
com .linkedin .datahub .graphql .generated .QueryProperties res =
@@ -57,6 +73,9 @@ private void mapQueryProperties(@Nonnull QueryEntity query, @Nonnull DataMap dat
57
73
QueryLanguage .valueOf (queryProperties .getStatement ().getLanguage ().toString ())));
58
74
res .setName (queryProperties .getName (GetMode .NULL ));
59
75
res .setDescription (queryProperties .getDescription (GetMode .NULL ));
76
+ if (queryProperties .hasOrigin () && queryProperties .getOrigin () != null ) {
77
+ res .setOrigin (UrnToEntityMapper .map (queryProperties .getOrigin ()));
78
+ }
60
79
61
80
AuditStamp created = new AuditStamp ();
62
81
created .setTime (queryProperties .getCreated ().getTime ());
0 commit comments