mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-11-03 20:19:31 +00:00 
			
		
		
		
	Fix #98 Need fullyQualifiedName field for data assets
This commit is contained in:
		
							parent
							
								
									1b140b37d5
								
							
						
					
					
						commit
						2f4275c88b
					
				@ -218,19 +218,19 @@ public final class EntityUtil {
 | 
				
			|||||||
    String id = ref.getId().toString();
 | 
					    String id = ref.getId().toString();
 | 
				
			||||||
    if (entity.equalsIgnoreCase(Entity.TABLE)) {
 | 
					    if (entity.equalsIgnoreCase(Entity.TABLE)) {
 | 
				
			||||||
      Table instance = EntityUtil.validate(id, tableDAO.findById(id), Table.class);
 | 
					      Table instance = EntityUtil.validate(id, tableDAO.findById(id), Table.class);
 | 
				
			||||||
      return ref.withDescription(instance.getDescription()).withName(instance.getName());
 | 
					      return ref.withDescription(instance.getDescription()).withName(instance.getFullyQualifiedName());
 | 
				
			||||||
    } else if (entity.equalsIgnoreCase(Entity.DATABASE)) {
 | 
					    } else if (entity.equalsIgnoreCase(Entity.DATABASE)) {
 | 
				
			||||||
      Database instance = EntityUtil.validate(id, databaseDAO.findById(id), Database.class);
 | 
					      Database instance = EntityUtil.validate(id, databaseDAO.findById(id), Database.class);
 | 
				
			||||||
      return ref.withDescription(instance.getDescription()).withName(instance.getName());
 | 
					      return ref.withDescription(instance.getDescription()).withName(instance.getFullyQualifiedName());
 | 
				
			||||||
    } else if (entity.equalsIgnoreCase(Entity.METRICS)) {
 | 
					    } else if (entity.equalsIgnoreCase(Entity.METRICS)) {
 | 
				
			||||||
      Metrics instance = EntityUtil.validate(id, metricsDAO.findById(id), Metrics.class);
 | 
					      Metrics instance = EntityUtil.validate(id, metricsDAO.findById(id), Metrics.class);
 | 
				
			||||||
      return ref.withDescription(instance.getDescription()).withName(instance.getName());
 | 
					      return ref.withDescription(instance.getDescription()).withName(instance.getFullyQualifiedName());
 | 
				
			||||||
    } else if (entity.equalsIgnoreCase(Entity.DATABASE_SERVICE)) {
 | 
					    } else if (entity.equalsIgnoreCase(Entity.DATABASE_SERVICE)) {
 | 
				
			||||||
      Dashboard instance = EntityUtil.validate(id, dashboardDAO.findById(id), Dashboard.class);
 | 
					      Dashboard instance = EntityUtil.validate(id, dashboardDAO.findById(id), Dashboard.class);
 | 
				
			||||||
      return ref.withDescription(instance.getDescription()).withName(instance.getName());
 | 
					      return ref.withDescription(instance.getDescription()).withName(instance.getFullyQualifiedName());
 | 
				
			||||||
    } else if (entity.equalsIgnoreCase(Entity.REPORT)) {
 | 
					    } else if (entity.equalsIgnoreCase(Entity.REPORT)) {
 | 
				
			||||||
      Report instance = EntityUtil.validate(id, reportDAO.findById(id), Report.class);
 | 
					      Report instance = EntityUtil.validate(id, reportDAO.findById(id), Report.class);
 | 
				
			||||||
      return ref.withDescription(instance.getDescription()).withName(instance.getName());
 | 
					      return ref.withDescription(instance.getDescription()).withName(instance.getFullyQualifiedName());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityTypeNotFound(entity));
 | 
					    throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityTypeNotFound(entity));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@
 | 
				
			|||||||
      "type": "string"
 | 
					      "type": "string"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "name": {
 | 
					    "name": {
 | 
				
			||||||
      "description": "Name of the entity instance.",
 | 
					      "description": "Name of the entity instance. For entities such as tables, database where name is not unique, fullyQualifiedName is returned in this field.",
 | 
				
			||||||
      "type": "string"
 | 
					      "type": "string"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "description": {
 | 
					    "description": {
 | 
				
			||||||
 | 
				
			|||||||
@ -63,6 +63,7 @@ import static org.openmetadata.catalog.util.TestUtils.adminAuthHeaders;
 | 
				
			|||||||
import static org.openmetadata.catalog.util.TestUtils.assertEntityPagination;
 | 
					import static org.openmetadata.catalog.util.TestUtils.assertEntityPagination;
 | 
				
			||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
 | 
					import static org.openmetadata.catalog.util.TestUtils.assertResponse;
 | 
				
			||||||
import static org.openmetadata.catalog.util.TestUtils.authHeaders;
 | 
					import static org.openmetadata.catalog.util.TestUtils.authHeaders;
 | 
				
			||||||
 | 
					import static org.openmetadata.catalog.util.TestUtils.validateEntityReference;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TeamResourceTest extends CatalogApplicationTest {
 | 
					public class TeamResourceTest extends CatalogApplicationTest {
 | 
				
			||||||
  private static final Logger LOG = LoggerFactory.getLogger(TeamResourceTest.class);
 | 
					  private static final Logger LOG = LoggerFactory.getLogger(TeamResourceTest.class);
 | 
				
			||||||
@ -497,19 +498,22 @@ public class TeamResourceTest extends CatalogApplicationTest {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /** Validate returned fields GET .../teams/{id}?fields="..." or GET .../teams/name/{name}?fields="..." */
 | 
					  /** Validate returned fields GET .../teams/{id}?fields="..." or GET .../teams/name/{name}?fields="..." */
 | 
				
			||||||
  private void validateGetWithDifferentFields(Team team, boolean byName, Map<String, String> authHeaders)
 | 
					  private void validateGetWithDifferentFields(Team expectedTeam, boolean byName, Map<String, String> authHeaders)
 | 
				
			||||||
          throws HttpResponseException {
 | 
					          throws HttpResponseException {
 | 
				
			||||||
    // .../teams?fields=profile
 | 
					    // .../teams?fields=profile
 | 
				
			||||||
    String fields = "profile";
 | 
					    String fields = "profile";
 | 
				
			||||||
    team = byName ? getTeamByName(team.getName(), fields, authHeaders) : getTeam(team.getId(), fields, authHeaders);
 | 
					    Team getTeam = byName ? getTeamByName(expectedTeam.getName(), fields, authHeaders) : getTeam(expectedTeam.getId(), fields,
 | 
				
			||||||
    assertNotNull(team.getProfile());
 | 
					            authHeaders);
 | 
				
			||||||
    assertNull(team.getUsers());
 | 
					    validateTeam(getTeam, expectedTeam.getDescription(), expectedTeam.getDisplayName(),
 | 
				
			||||||
 | 
					            expectedTeam.getProfile(), null);
 | 
				
			||||||
 | 
					    assertNull(getTeam.getOwns());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // .../teams?fields=profile,users
 | 
					    // .../teams?fields=users,owns
 | 
				
			||||||
    fields = "profile,users";
 | 
					    fields = "users,owns";
 | 
				
			||||||
    team = byName ? getTeamByName(team.getName(), fields, authHeaders) : getTeam(team.getId(), fields, authHeaders);
 | 
					    getTeam = byName ? getTeamByName(expectedTeam.getName(), fields, authHeaders) : getTeam(expectedTeam.getId(), fields, authHeaders);
 | 
				
			||||||
    assertNotNull(team.getProfile());
 | 
					    assertNotNull(expectedTeam.getProfile());
 | 
				
			||||||
    assertNotNull(team.getUsers());
 | 
					    validateEntityReference(expectedTeam.getUsers());
 | 
				
			||||||
 | 
					    validateEntityReference(expectedTeam.getOwns());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private Team patchTeam(UUID teamId, String originalJson, Team updated, Map<String, String> authHeaders)
 | 
					  private Team patchTeam(UUID teamId, String originalJson, Team updated, Map<String, String> authHeaders)
 | 
				
			||||||
 | 
				
			|||||||
@ -168,6 +168,10 @@ public final class TestUtils {
 | 
				
			|||||||
    assertNotNull(ref.getHref());
 | 
					    assertNotNull(ref.getHref());
 | 
				
			||||||
    assertNotNull(ref.getName());
 | 
					    assertNotNull(ref.getName());
 | 
				
			||||||
    assertNotNull(ref.getType());
 | 
					    assertNotNull(ref.getType());
 | 
				
			||||||
 | 
					    // Ensure data entities use fully qualified name
 | 
				
			||||||
 | 
					    if (List.of("table", "database", "metrics", "dashboard", "pipeline", "report").contains(ref.getName())) {
 | 
				
			||||||
 | 
					      ref.getName().contains("."); // FullyQualifiedName has "." as separator
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static void validateEntityReference(List<EntityReference> list) {
 | 
					  public static void validateEntityReference(List<EntityReference> list) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user