Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLT-1759 | Refactor to use AtlasTypeRegistry to check for Duplicate Business Metadata Names #3319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ public AtlasVertex preCreate(AtlasBusinessMetadataDef businessMetadataDef) throw
throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, businessMetadataDef.getName());
}

//validate uniqueness of display name for BM
if (type.getTypeCategory() == TypeCategory.BUSINESS_METADATA) {
ret = typeDefStore.findTypeVertexByDisplayName(
businessMetadataDef.getDisplayName(), DataTypes.TypeCategory.BUSINESS_METADATA);
if (ret != null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_WITH_DISPLAY_NAME_ALREADY_EXISTS, businessMetadataDef.getDisplayName());
}
}

ret = typeDefStore.createTypeVertex(businessMetadataDef);

updateVertexPreCreate(businessMetadataDef, (AtlasBusinessMetadataType) type, ret);
Expand All @@ -107,10 +98,9 @@ public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
AtlasBusinessMetadataDef businessMetadataDef = (AtlasBusinessMetadataDef) typeDef;

//validate uniqueness of display name for BM
AtlasVertex ret = typeDefStore.findTypeVertexByDisplayName(
businessMetadataDef.getDisplayName(), DataTypes.TypeCategory.BUSINESS_METADATA);
if (ret != null && (
businessMetadataDef.getGuid() == null || !businessMetadataDef.getGuid().equals(ret.getProperty(Constants.GUID_PROPERTY_KEY, String.class)))) {
AtlasBusinessMetadataType ret = typeRegistry.getBusinessMetadataTypeByDisplayName(businessMetadataDef.getDisplayName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to cover this with an unit test??
If we don't have any existing tests, we can add one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anbarasantr Yes. Right now we don't cover this via Unit test. But should be able to do. Will add

if ((ret != null && ret.getBusinessMetadataDef().getGuid() != null) && (
businessMetadataDef.getGuid() == null || !businessMetadataDef.getGuid().equals(ret.getBusinessMetadataDef().getGuid()))) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_WITH_DISPLAY_NAME_ALREADY_EXISTS, businessMetadataDef.getDisplayName());
}

Expand Down
Loading