Bug fix for location findEntityReferenceById. getName was not returning the FQN.

This commit is contained in:
Alberto Miorin 2021-11-16 00:11:23 +01:00
parent 345ad9d413
commit 5403b5522f
2 changed files with 6 additions and 11 deletions

View File

@ -102,7 +102,7 @@ public class TableRepository extends EntityRepository<Table> {
table.setSampleData(fields.contains("sampleData") ? getSampleData(table) : null);
table.setViewDefinition(fields.contains("viewDefinition") ? table.getViewDefinition() : null);
table.setTableProfile(fields.contains("tableProfile") ? getTableProfile(table) : null);
table.setLocation(fields.contains("location") ? getLocation(table): null);
table.setLocation(fields.contains("location") ? getLocation(table.getId()): null);
table.setTableQueries(fields.contains("tableQueries") ? getQueries(table): null);
return table;
}
@ -374,13 +374,11 @@ public class TableRepository extends EntityRepository<Table> {
return dao.databaseDAO().findEntityReferenceById(UUID.fromString(result.get(0)));
}
private EntityReference getLocation(Table table) throws IOException {
// Find database for the table
String id = table.getId().toString();
List<String> result = dao.relationshipDAO().findTo(id, Relationship.HAS.ordinal(), Entity.LOCATION);
private EntityReference getLocation(UUID tableId) throws IOException {
// Find the location of the table
List<String> result = dao.relationshipDAO().findTo(tableId.toString(), Relationship.HAS.ordinal(), Entity.LOCATION);
if (result.size() == 1) {
Location location = dao.locationDAO().findEntityById(UUID.fromString(result.get(0)));
return new EntityReference().withName(location.getName()).withId(location.getId()).withType("location");
return dao.locationDAO().findEntityReferenceById(UUID.fromString(result.get(0)));
} else {
return null;
}

View File

@ -222,14 +222,11 @@ public final class TestUtils {
assertNotNull(ref.getName());
assertNotNull(ref.getType());
// Ensure data entities use fully qualified name
if (List.of("table", "database", "metrics", "dashboard", "pipeline", "report", "topic", "chart")
if (List.of("table", "database", "metrics", "dashboard", "pipeline", "report", "topic", "chart", "location")
.contains(ref.getType())) {
// FullyQualifiedName has "." as separator
assertTrue(ref.getName().contains("."), "entity name is not fully qualified - " + ref.getName());
}
if (List.of("location").contains(ref.getName())) {
ref.getName().contains(":/"); // FullyQualifiedName has ":/" as separator
}
}
public static void validateEntityReference(List<EntityReference> list) {