forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datahub-project:master' into master
- Loading branch information
Showing
100 changed files
with
48,898 additions
and
2,898 deletions.
There are no files selected for viewing
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
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
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
14 changes: 14 additions & 0 deletions
14
entity-registry/src/main/java/com/linkedin/metadata/models/UrnValidationFieldSpec.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,14 @@ | ||
package com.linkedin.metadata.models; | ||
|
||
import com.linkedin.data.schema.DataSchema; | ||
import com.linkedin.data.schema.PathSpec; | ||
import com.linkedin.metadata.models.annotation.UrnValidationAnnotation; | ||
import javax.annotation.Nonnull; | ||
import lombok.Value; | ||
|
||
@Value | ||
public class UrnValidationFieldSpec { | ||
@Nonnull PathSpec path; | ||
@Nonnull UrnValidationAnnotation urnValidationAnnotation; | ||
@Nonnull DataSchema pegasusSchema; | ||
} |
57 changes: 57 additions & 0 deletions
57
...-registry/src/main/java/com/linkedin/metadata/models/UrnValidationFieldSpecExtractor.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,57 @@ | ||
package com.linkedin.metadata.models; | ||
|
||
import com.linkedin.data.schema.DataSchema; | ||
import com.linkedin.data.schema.DataSchemaTraverse; | ||
import com.linkedin.data.schema.PathSpec; | ||
import com.linkedin.data.schema.annotation.SchemaVisitor; | ||
import com.linkedin.data.schema.annotation.SchemaVisitorTraversalResult; | ||
import com.linkedin.data.schema.annotation.TraverserContext; | ||
import com.linkedin.metadata.models.annotation.UrnValidationAnnotation; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class UrnValidationFieldSpecExtractor implements SchemaVisitor { | ||
private final List<UrnValidationFieldSpec> urnValidationFieldSpecs = new ArrayList<>(); | ||
|
||
@Override | ||
public void callbackOnContext(TraverserContext context, DataSchemaTraverse.Order order) { | ||
if (context.getEnclosingField() == null) { | ||
return; | ||
} | ||
|
||
if (DataSchemaTraverse.Order.PRE_ORDER.equals(order)) { | ||
final DataSchema currentSchema = context.getCurrentSchema().getDereferencedDataSchema(); | ||
final PathSpec path = new PathSpec(context.getSchemaPathSpec()); | ||
|
||
// Check for @UrnValidation annotation in primary properties | ||
final Object urnValidationAnnotationObj = | ||
context.getEnclosingField().getProperties().get(UrnValidationAnnotation.ANNOTATION_NAME); | ||
|
||
// Check if it's either explicitly annotated with @UrnValidation | ||
if (urnValidationAnnotationObj != null) { | ||
addUrnValidationFieldSpec(currentSchema, path, urnValidationAnnotationObj); | ||
} | ||
} | ||
} | ||
|
||
private void addUrnValidationFieldSpec( | ||
DataSchema currentSchema, PathSpec path, Object annotationObj) { | ||
UrnValidationAnnotation annotation = | ||
UrnValidationAnnotation.fromPegasusAnnotationObject( | ||
annotationObj, FieldSpecUtils.getSchemaFieldName(path), path.toString()); | ||
|
||
urnValidationFieldSpecs.add(new UrnValidationFieldSpec(path, annotation, currentSchema)); | ||
} | ||
|
||
@Override | ||
public VisitorContext getInitialVisitorContext() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public SchemaVisitorTraversalResult getSchemaVisitorTraversalResult() { | ||
return new SchemaVisitorTraversalResult(); | ||
} | ||
} |
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.