mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-12 17:26:43 +00:00
[Issue-892] - GET operations return service (#916)
* Force image build in local docker * Use service as default field query param for entities with required service * Return service in List * Naming convention * Update Repository setFields to include service * Revert resource changes * Revert resource changes * Update tests to check we always return the service, even if not specified * Return service for database
This commit is contained in:
parent
3fe8ae99a9
commit
1291bf6ec0
@ -123,8 +123,8 @@ public class ChartRepository extends EntityRepository<Chart> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chart setFields(Chart chart, Fields fields) throws IOException {
|
public Chart setFields(Chart chart, Fields fields) throws IOException {
|
||||||
|
chart.setService(getService(chart));
|
||||||
chart.setOwner(fields.contains("owner") ? getOwner(chart) : null);
|
chart.setOwner(fields.contains("owner") ? getOwner(chart) : null);
|
||||||
chart.setService(fields.contains("service") ? getService(chart) : null);
|
|
||||||
chart.setFollowers(fields.contains("followers") ? getFollowers(chart) : null);
|
chart.setFollowers(fields.contains("followers") ? getFollowers(chart) : null);
|
||||||
chart.setTags(fields.contains("tags") ? getTags(chart.getFullyQualifiedName()) : null);
|
chart.setTags(fields.contains("tags") ? getTags(chart.getFullyQualifiedName()) : null);
|
||||||
return chart;
|
return chart;
|
||||||
|
@ -97,8 +97,8 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
|
|||||||
@Override
|
@Override
|
||||||
public Dashboard setFields(Dashboard dashboard, Fields fields) throws IOException {
|
public Dashboard setFields(Dashboard dashboard, Fields fields) throws IOException {
|
||||||
dashboard.setDisplayName(dashboard.getDisplayName());
|
dashboard.setDisplayName(dashboard.getDisplayName());
|
||||||
|
dashboard.setService(getService(dashboard));
|
||||||
dashboard.setOwner(fields.contains("owner") ? getOwner(dashboard) : null);
|
dashboard.setOwner(fields.contains("owner") ? getOwner(dashboard) : null);
|
||||||
dashboard.setService(fields.contains("service") ? getService(dashboard) : null);
|
|
||||||
dashboard.setFollowers(fields.contains("followers") ? getFollowers(dashboard) : null);
|
dashboard.setFollowers(fields.contains("followers") ? getFollowers(dashboard) : null);
|
||||||
dashboard.setCharts(fields.contains("charts") ? getCharts(dashboard) : null);
|
dashboard.setCharts(fields.contains("charts") ? getCharts(dashboard) : null);
|
||||||
dashboard.setTags(fields.contains("tags") ? getTags(dashboard.getFullyQualifiedName()) : null);
|
dashboard.setTags(fields.contains("tags") ? getTags(dashboard.getFullyQualifiedName()) : null);
|
||||||
|
@ -119,9 +119,9 @@ public class DatabaseRepository extends EntityRepository<Database> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Database setFields(Database database, Fields fields) throws IOException {
|
public Database setFields(Database database, Fields fields) throws IOException {
|
||||||
|
database.setService(getService(database));
|
||||||
database.setOwner(fields.contains("owner") ? getOwner(database) : null);
|
database.setOwner(fields.contains("owner") ? getOwner(database) : null);
|
||||||
database.setTables(fields.contains("tables") ? getTables(database) : null);
|
database.setTables(fields.contains("tables") ? getTables(database) : null);
|
||||||
database.setService(fields.contains("service") ? getService(database) : null);
|
|
||||||
database.setUsageSummary(fields.contains("usageSummary") ? EntityUtil.getLatestUsage(dao.usageDAO(),
|
database.setUsageSummary(fields.contains("usageSummary") ? EntityUtil.getLatestUsage(dao.usageDAO(),
|
||||||
database.getId()) : null);
|
database.getId()) : null);
|
||||||
return database;
|
return database;
|
||||||
|
@ -92,11 +92,11 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
|||||||
@Override
|
@Override
|
||||||
public Pipeline setFields(Pipeline pipeline, Fields fields) throws IOException {
|
public Pipeline setFields(Pipeline pipeline, Fields fields) throws IOException {
|
||||||
pipeline.setDisplayName(pipeline.getDisplayName());
|
pipeline.setDisplayName(pipeline.getDisplayName());
|
||||||
|
pipeline.setService(getService(pipeline));
|
||||||
pipeline.setPipelineUrl(pipeline.getPipelineUrl());
|
pipeline.setPipelineUrl(pipeline.getPipelineUrl());
|
||||||
pipeline.setStartDate(pipeline.getStartDate());
|
pipeline.setStartDate(pipeline.getStartDate());
|
||||||
pipeline.setConcurrency(pipeline.getConcurrency());
|
pipeline.setConcurrency(pipeline.getConcurrency());
|
||||||
pipeline.setOwner(fields.contains("owner") ? getOwner(pipeline) : null);
|
pipeline.setOwner(fields.contains("owner") ? getOwner(pipeline) : null);
|
||||||
pipeline.setService(fields.contains("service") ? getService(pipeline) : null);
|
|
||||||
pipeline.setFollowers(fields.contains("followers") ? getFollowers(pipeline) : null);
|
pipeline.setFollowers(fields.contains("followers") ? getFollowers(pipeline) : null);
|
||||||
pipeline.setTasks(fields.contains("tasks") ? getTasks(pipeline) : null);
|
pipeline.setTasks(fields.contains("tasks") ? getTasks(pipeline) : null);
|
||||||
pipeline.setTags(fields.contains("tags") ? getTags(pipeline.getFullyQualifiedName()) : null);
|
pipeline.setTags(fields.contains("tags") ? getTags(pipeline.getFullyQualifiedName()) : null);
|
||||||
|
@ -127,8 +127,8 @@ public class TaskRepository extends EntityRepository<Task> {
|
|||||||
task.setTaskSQL(task.getTaskSQL());
|
task.setTaskSQL(task.getTaskSQL());
|
||||||
task.setStartDate(task.getStartDate());
|
task.setStartDate(task.getStartDate());
|
||||||
task.setEndDate(task.getEndDate());
|
task.setEndDate(task.getEndDate());
|
||||||
|
task.setService(getService(task));
|
||||||
task.setOwner(fields.contains("owner") ? getOwner(task) : null);
|
task.setOwner(fields.contains("owner") ? getOwner(task) : null);
|
||||||
task.setService(fields.contains("service") ? getService(task) : null);
|
|
||||||
task.setTags(fields.contains("tags") ? getTags(task.getFullyQualifiedName()) : null);
|
task.setTags(fields.contains("tags") ? getTags(task.getFullyQualifiedName()) : null);
|
||||||
task.setDownstreamTasks(fields.contains("downstreamTasks") ? task.getDownstreamTasks() : null);
|
task.setDownstreamTasks(fields.contains("downstreamTasks") ? task.getDownstreamTasks() : null);
|
||||||
return task;
|
return task;
|
||||||
|
@ -126,8 +126,8 @@ public class TopicRepository extends EntityRepository<Topic> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Topic setFields(Topic topic, Fields fields) throws IOException {
|
public Topic setFields(Topic topic, Fields fields) throws IOException {
|
||||||
|
topic.setService(getService(topic));
|
||||||
topic.setOwner(fields.contains("owner") ? getOwner(topic) : null);
|
topic.setOwner(fields.contains("owner") ? getOwner(topic) : null);
|
||||||
topic.setService(fields.contains("service") ? getService(topic) : null);
|
|
||||||
topic.setFollowers(fields.contains("followers") ? getFollowers(topic) : null);
|
topic.setFollowers(fields.contains("followers") ? getFollowers(topic) : null);
|
||||||
topic.setTags(fields.contains("tags") ? getTags(topic.getFullyQualifiedName()) : null);
|
topic.setTags(fields.contains("tags") ? getTags(topic.getFullyQualifiedName()) : null);
|
||||||
return topic;
|
return topic;
|
||||||
|
@ -40,8 +40,6 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
||||||
import org.openmetadata.catalog.util.ResultList;
|
import org.openmetadata.catalog.util.ResultList;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -40,8 +40,6 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
||||||
import org.openmetadata.catalog.util.ResultList;
|
import org.openmetadata.catalog.util.ResultList;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -81,7 +79,6 @@ import java.util.UUID;
|
|||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Collection(name = "tasks")
|
@Collection(name = "tasks")
|
||||||
public class TaskResource {
|
public class TaskResource {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TaskResource.class);
|
|
||||||
private static final String TASK_COLLECTION_PATH = "v1/tasks/";
|
private static final String TASK_COLLECTION_PATH = "v1/tasks/";
|
||||||
private final TaskRepository dao;
|
private final TaskRepository dao;
|
||||||
private final CatalogAuthorizer authorizer;
|
private final CatalogAuthorizer authorizer;
|
||||||
|
@ -525,7 +525,7 @@ public class ChartResourceTest extends CatalogApplicationTest {
|
|||||||
chart = byName ? getChartByName(chart.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
chart = byName ? getChartByName(chart.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getChart(chart.getId(), fields, adminAuthHeaders());
|
getChart(chart.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(chart.getOwner());
|
assertNotNull(chart.getOwner());
|
||||||
assertNull(chart.getService());
|
assertNotNull(chart.getService()); // We always return the service
|
||||||
|
|
||||||
// .../charts?fields=owner,service
|
// .../charts?fields=owner,service
|
||||||
fields = "owner,service";
|
fields = "owner,service";
|
||||||
|
@ -543,7 +543,7 @@ public class DashboardResourceTest extends CatalogApplicationTest {
|
|||||||
dashboard = byName ? getDashboardByName(dashboard.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
dashboard = byName ? getDashboardByName(dashboard.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getDashboard(dashboard.getId(), fields, adminAuthHeaders());
|
getDashboard(dashboard.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(dashboard.getOwner());
|
assertNotNull(dashboard.getOwner());
|
||||||
assertNull(dashboard.getService());
|
assertNotNull(dashboard.getService()); // We always return the service
|
||||||
assertNull(dashboard.getCharts());
|
assertNull(dashboard.getCharts());
|
||||||
|
|
||||||
// .../Dashboards?fields=owner,service
|
// .../Dashboards?fields=owner,service
|
||||||
|
@ -505,7 +505,7 @@ public class DatabaseResourceTest extends CatalogApplicationTest {
|
|||||||
database = byName ? getDatabaseByName(database.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
database = byName ? getDatabaseByName(database.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getDatabase(database.getId(), fields, adminAuthHeaders());
|
getDatabase(database.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(database.getOwner());
|
assertNotNull(database.getOwner());
|
||||||
assertNull(database.getService());
|
assertNotNull(database.getService()); // We always return the service
|
||||||
assertNull(database.getTables());
|
assertNull(database.getTables());
|
||||||
|
|
||||||
// .../databases?fields=owner,service
|
// .../databases?fields=owner,service
|
||||||
|
@ -575,7 +575,7 @@ public class PipelineResourceTest extends CatalogApplicationTest {
|
|||||||
pipeline = byName ? getPipelineByName(pipeline.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
pipeline = byName ? getPipelineByName(pipeline.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getPipeline(pipeline.getId(), fields, adminAuthHeaders());
|
getPipeline(pipeline.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(pipeline.getOwner());
|
assertNotNull(pipeline.getOwner());
|
||||||
assertNull(pipeline.getService());
|
assertNotNull(pipeline.getService()); // We always return the service
|
||||||
assertNull(pipeline.getTasks());
|
assertNull(pipeline.getTasks());
|
||||||
|
|
||||||
// .../Pipelines?fields=owner,service
|
// .../Pipelines?fields=owner,service
|
||||||
|
@ -520,7 +520,7 @@ public class TaskResourceTest extends CatalogApplicationTest {
|
|||||||
task = byName ? getTaskByName(task.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
task = byName ? getTaskByName(task.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getTask(task.getId(), fields, adminAuthHeaders());
|
getTask(task.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(task.getOwner());
|
assertNotNull(task.getOwner());
|
||||||
assertNull(task.getService());
|
assertNotNull(task.getService()); // We always return the service
|
||||||
|
|
||||||
// .../tasks?fields=owner,service
|
// .../tasks?fields=owner,service
|
||||||
fields = "owner,service";
|
fields = "owner,service";
|
||||||
|
@ -540,7 +540,7 @@ public class TopicResourceTest extends CatalogApplicationTest {
|
|||||||
topic = byName ? getTopicByName(topic.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
topic = byName ? getTopicByName(topic.getFullyQualifiedName(), fields, adminAuthHeaders()) :
|
||||||
getTopic(topic.getId(), fields, adminAuthHeaders());
|
getTopic(topic.getId(), fields, adminAuthHeaders());
|
||||||
assertNotNull(topic.getOwner());
|
assertNotNull(topic.getOwner());
|
||||||
assertNull(topic.getService());
|
assertNotNull(topic.getService()); // We always return the service
|
||||||
|
|
||||||
// .../topics?fields=owner,service
|
// .../topics?fields=owner,service
|
||||||
fields = "owner,service";
|
fields = "owner,service";
|
||||||
|
@ -17,4 +17,4 @@
|
|||||||
|
|
||||||
mvn -DskipTests clean package
|
mvn -DskipTests clean package
|
||||||
cd docker/local-metadata/
|
cd docker/local-metadata/
|
||||||
docker-compose up
|
docker-compose up --build
|
Loading…
x
Reference in New Issue
Block a user