[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:
Pere Miquel Brull 2021-10-24 19:26:28 +02:00 committed by GitHub
parent 3fe8ae99a9
commit 1291bf6ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 13 additions and 18 deletions

View File

@ -123,8 +123,8 @@ public class ChartRepository extends EntityRepository<Chart> {
@Override
public Chart setFields(Chart chart, Fields fields) throws IOException {
chart.setService(getService(chart));
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.setTags(fields.contains("tags") ? getTags(chart.getFullyQualifiedName()) : null);
return chart;

View File

@ -97,8 +97,8 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
@Override
public Dashboard setFields(Dashboard dashboard, Fields fields) throws IOException {
dashboard.setDisplayName(dashboard.getDisplayName());
dashboard.setService(getService(dashboard));
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.setCharts(fields.contains("charts") ? getCharts(dashboard) : null);
dashboard.setTags(fields.contains("tags") ? getTags(dashboard.getFullyQualifiedName()) : null);

View File

@ -119,9 +119,9 @@ public class DatabaseRepository extends EntityRepository<Database> {
}
public Database setFields(Database database, Fields fields) throws IOException {
database.setService(getService(database));
database.setOwner(fields.contains("owner") ? getOwner(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.getId()) : null);
return database;

View File

@ -92,11 +92,11 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
@Override
public Pipeline setFields(Pipeline pipeline, Fields fields) throws IOException {
pipeline.setDisplayName(pipeline.getDisplayName());
pipeline.setService(getService(pipeline));
pipeline.setPipelineUrl(pipeline.getPipelineUrl());
pipeline.setStartDate(pipeline.getStartDate());
pipeline.setConcurrency(pipeline.getConcurrency());
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.setTasks(fields.contains("tasks") ? getTasks(pipeline) : null);
pipeline.setTags(fields.contains("tags") ? getTags(pipeline.getFullyQualifiedName()) : null);

View File

@ -127,8 +127,8 @@ public class TaskRepository extends EntityRepository<Task> {
task.setTaskSQL(task.getTaskSQL());
task.setStartDate(task.getStartDate());
task.setEndDate(task.getEndDate());
task.setService(getService(task));
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.setDownstreamTasks(fields.contains("downstreamTasks") ? task.getDownstreamTasks() : null);
return task;

View File

@ -126,8 +126,8 @@ public class TopicRepository extends EntityRepository<Topic> {
@Override
public Topic setFields(Topic topic, Fields fields) throws IOException {
topic.setService(getService(topic));
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.setTags(fields.contains("tags") ? getTags(topic.getFullyQualifiedName()) : null);
return topic;

View File

@ -40,8 +40,6 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
import org.openmetadata.catalog.util.RestUtil;
import org.openmetadata.catalog.util.RestUtil.PutResponse;
import org.openmetadata.catalog.util.ResultList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.json.JsonPatch;
import javax.validation.Valid;

View File

@ -40,8 +40,6 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
import org.openmetadata.catalog.util.RestUtil;
import org.openmetadata.catalog.util.RestUtil.PutResponse;
import org.openmetadata.catalog.util.ResultList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.json.JsonPatch;
import javax.validation.Valid;
@ -81,7 +79,6 @@ import java.util.UUID;
@Consumes(MediaType.APPLICATION_JSON)
@Collection(name = "tasks")
public class TaskResource {
private static final Logger LOG = LoggerFactory.getLogger(TaskResource.class);
private static final String TASK_COLLECTION_PATH = "v1/tasks/";
private final TaskRepository dao;
private final CatalogAuthorizer authorizer;

View File

@ -525,7 +525,7 @@ public class ChartResourceTest extends CatalogApplicationTest {
chart = byName ? getChartByName(chart.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getChart(chart.getId(), fields, adminAuthHeaders());
assertNotNull(chart.getOwner());
assertNull(chart.getService());
assertNotNull(chart.getService()); // We always return the service
// .../charts?fields=owner,service
fields = "owner,service";

View File

@ -543,7 +543,7 @@ public class DashboardResourceTest extends CatalogApplicationTest {
dashboard = byName ? getDashboardByName(dashboard.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getDashboard(dashboard.getId(), fields, adminAuthHeaders());
assertNotNull(dashboard.getOwner());
assertNull(dashboard.getService());
assertNotNull(dashboard.getService()); // We always return the service
assertNull(dashboard.getCharts());
// .../Dashboards?fields=owner,service

View File

@ -505,7 +505,7 @@ public class DatabaseResourceTest extends CatalogApplicationTest {
database = byName ? getDatabaseByName(database.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getDatabase(database.getId(), fields, adminAuthHeaders());
assertNotNull(database.getOwner());
assertNull(database.getService());
assertNotNull(database.getService()); // We always return the service
assertNull(database.getTables());
// .../databases?fields=owner,service

View File

@ -575,7 +575,7 @@ public class PipelineResourceTest extends CatalogApplicationTest {
pipeline = byName ? getPipelineByName(pipeline.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getPipeline(pipeline.getId(), fields, adminAuthHeaders());
assertNotNull(pipeline.getOwner());
assertNull(pipeline.getService());
assertNotNull(pipeline.getService()); // We always return the service
assertNull(pipeline.getTasks());
// .../Pipelines?fields=owner,service

View File

@ -520,7 +520,7 @@ public class TaskResourceTest extends CatalogApplicationTest {
task = byName ? getTaskByName(task.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getTask(task.getId(), fields, adminAuthHeaders());
assertNotNull(task.getOwner());
assertNull(task.getService());
assertNotNull(task.getService()); // We always return the service
// .../tasks?fields=owner,service
fields = "owner,service";

View File

@ -540,7 +540,7 @@ public class TopicResourceTest extends CatalogApplicationTest {
topic = byName ? getTopicByName(topic.getFullyQualifiedName(), fields, adminAuthHeaders()) :
getTopic(topic.getId(), fields, adminAuthHeaders());
assertNotNull(topic.getOwner());
assertNull(topic.getService());
assertNotNull(topic.getService()); // We always return the service
// .../topics?fields=owner,service
fields = "owner,service";

View File

@ -17,4 +17,4 @@
mvn -DskipTests clean package
cd docker/local-metadata/
docker-compose up
docker-compose up --build