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

[pull] master from apache:master #129

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
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 @@ -404,7 +404,7 @@ private void checkBusinessMetadataRef(String typeName) throws AtlasBaseException
String vertexPropertyName = AtlasStructType.AtlasAttribute.generateVertexPropertyName(businessMetadataDef, attributeDef, qualifiedName);
Set<String> applicableTypes = AtlasJson.fromJson(attributeDef.getOption(AtlasBusinessMetadataDef.ATTR_OPTION_APPLICABLE_ENTITY_TYPES), Set.class);

if (isBusinessAttributePresent(vertexPropertyName, applicableTypes)) {
if (CollectionUtils.isNotEmpty(applicableTypes) && isBusinessAttributePresent(vertexPropertyName, applicableTypes)) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ public void deleteBusinessMetadataDefs() throws AtlasBaseException {
}
}

@Test
public void deleteBusinessMetadataDefWithNoAssignedTypes() throws AtlasBaseException {
createBusinessMetadataTypesWithoutAssignedTypes(businessMetadataName);
for (AtlasBusinessMetadataDef atlasBusinessMetaDataDef : typesDefs.getBusinessMetadataDefs()) {
if (atlasBusinessMetaDataDef.getName().equals(businessMetadataName)) {
typesDefs = new AtlasTypesDef(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
Collections.emptyList());
typesDefs.setBusinessMetadataDefs(Arrays.asList(atlasBusinessMetaDataDef));
typeDefStore.deleteTypesDef(typesDefs);
}
}

for (AtlasBusinessMetadataDef businessMetadataDef : typeRegistry.getAllBusinessMetadataDefs()) {
Assert.assertNotEquals(businessMetadataDef.getName(), businessMetadataName);
}
}

@Test
public void updateBusinessMetadataDefs() throws AtlasBaseException {
createBusinessMetadataTypes(businessMetadataName);
Expand Down Expand Up @@ -413,6 +430,23 @@ private AtlasBusinessMetadataDef createBusinessMetadataDef(String businessMetada
return businessMetadataDef1;
}

private void createBusinessMetadataTypesWithoutAssignedTypes(String businessMetadataName) throws AtlasBaseException {
List<AtlasBusinessMetadataDef> businessMetadataDefs = new ArrayList(typesDefs.getBusinessMetadataDefs());
businessMetadataDefs.add(createBusinessMetadataDefWithoutAssignedTypes(businessMetadataName));
typesDefs.setBusinessMetadataDefs(businessMetadataDefs);
AtlasTypesDef createdTypesDef = typeDefStore.createTypesDef(typesDefs);

Assert.assertEquals(createdTypesDef.getBusinessMetadataDefs(), businessMetadataDefs, "Data integrity issue while persisting");
}

private AtlasBusinessMetadataDef createBusinessMetadataDefWithoutAssignedTypes(String businessMetadataName) {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef(businessMetadataName, "test_no_attributes", null);
addBusinessAttribute(businessMetadataDef1, "test_businessMetadata_attribute1", Collections.emptySet(), "int",
AtlasStructDef.AtlasAttributeDef.Cardinality.SINGLE);
TestUtilsV2.populateSystemAttributes(businessMetadataDef1);
return businessMetadataDef1;
}

private AtlasBusinessMetadataDef createBusinessMetadataDef2(String businessMetadataName) {
AtlasBusinessMetadataDef businessMetadataDef1 = new AtlasBusinessMetadataDef(businessMetadataName, "test_description", null);
addBusinessAttribute(businessMetadataDef1, "test_businessMetadata_attribute1", Collections.emptySet(), "int",
Expand Down
Loading