-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acb76cd
commit c6fd3bc
Showing
12 changed files
with
424 additions
and
58 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...main/java/com/linkedin/datahub/graphql/types/common/mappers/DataTransformLogicMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.linkedin.datahub.graphql.types.common.mappers; | ||
|
||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.DataTransform; | ||
import com.linkedin.datahub.graphql.generated.DataTransformLogic; | ||
import com.linkedin.datahub.graphql.generated.QueryLanguage; | ||
import com.linkedin.datahub.graphql.generated.QueryStatement; | ||
import com.linkedin.datahub.graphql.types.mappers.ModelMapper; | ||
import java.util.stream.Collectors; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class DataTransformLogicMapper | ||
implements ModelMapper< | ||
com.linkedin.common.DataTransformLogic, | ||
com.linkedin.datahub.graphql.generated.DataTransformLogic> { | ||
|
||
public static final DataTransformLogicMapper INSTANCE = new DataTransformLogicMapper(); | ||
|
||
public static DataTransformLogic map( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.DataTransformLogic input) { | ||
return INSTANCE.apply(context, input); | ||
} | ||
|
||
@Override | ||
public DataTransformLogic apply( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.DataTransformLogic input) { | ||
|
||
final DataTransformLogic result = new DataTransformLogic(); | ||
|
||
// Map transforms array using DataTransformMapper | ||
result.setTransforms( | ||
input.getTransforms().stream() | ||
.map(transform -> DataTransformMapper.map(context, transform)) | ||
.collect(Collectors.toList())); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
class DataTransformMapper | ||
implements ModelMapper< | ||
com.linkedin.common.DataTransform, com.linkedin.datahub.graphql.generated.DataTransform> { | ||
|
||
public static final DataTransformMapper INSTANCE = new DataTransformMapper(); | ||
|
||
public static DataTransform map( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.DataTransform input) { | ||
return INSTANCE.apply(context, input); | ||
} | ||
|
||
@Override | ||
public DataTransform apply( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.DataTransform input) { | ||
|
||
final DataTransform result = new DataTransform(); | ||
|
||
// Map query statement if present | ||
if (input.hasQueryStatement()) { | ||
QueryStatement statement = | ||
new QueryStatement( | ||
input.getQueryStatement().getValue(), | ||
QueryLanguage.valueOf(input.getQueryStatement().getLanguage().toString())); | ||
result.setQueryStatement(statement); | ||
} | ||
|
||
return result; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...rc/main/java/com/linkedin/datahub/graphql/types/common/mappers/QueryPropertiesMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.linkedin.datahub.graphql.types.common.mappers; | ||
|
||
import com.linkedin.data.template.GetMode; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.*; | ||
import com.linkedin.datahub.graphql.types.mappers.ModelMapper; | ||
import com.linkedin.query.QueryProperties; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class QueryPropertiesMapper | ||
implements ModelMapper< | ||
QueryProperties, com.linkedin.datahub.graphql.generated.QueryProperties> { | ||
|
||
public static final QueryPropertiesMapper INSTANCE = new QueryPropertiesMapper(); | ||
|
||
public static com.linkedin.datahub.graphql.generated.QueryProperties map( | ||
@Nullable final QueryContext context, @Nonnull final QueryProperties input) { | ||
return INSTANCE.apply(context, input); | ||
} | ||
|
||
@Override | ||
public com.linkedin.datahub.graphql.generated.QueryProperties apply( | ||
@Nullable final QueryContext context, @Nonnull final QueryProperties input) { | ||
|
||
final com.linkedin.datahub.graphql.generated.QueryProperties result = | ||
new com.linkedin.datahub.graphql.generated.QueryProperties(); | ||
|
||
// Map Query Source | ||
result.setSource(QuerySource.valueOf(input.getSource().toString())); | ||
|
||
// Map Query Statement | ||
result.setStatement( | ||
new QueryStatement( | ||
input.getStatement().getValue(), | ||
QueryLanguage.valueOf(input.getStatement().getLanguage().toString()))); | ||
|
||
// Map optional fields | ||
result.setName(input.getName(GetMode.NULL)); | ||
result.setDescription(input.getDescription(GetMode.NULL)); | ||
|
||
// Map origin if present | ||
if (input.hasOrigin() && input.getOrigin() != null) { | ||
result.setOrigin(UrnToEntityMapper.map(context, input.getOrigin())); | ||
} | ||
|
||
// Map created audit stamp | ||
AuditStamp created = new AuditStamp(); | ||
created.setTime(input.getCreated().getTime()); | ||
created.setActor(input.getCreated().getActor(GetMode.NULL).toString()); | ||
result.setCreated(created); | ||
|
||
// Map last modified audit stamp | ||
AuditStamp lastModified = new AuditStamp(); | ||
lastModified.setTime(input.getLastModified().getTime()); | ||
lastModified.setActor(input.getLastModified().getActor(GetMode.NULL).toString()); | ||
result.setLastModified(lastModified); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.