mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-12 10:31:14 +00:00
Cleaned up all DAO3 classes and moved common implementation to EntityDAO3
This commit is contained in:
parent
c600fc3f66
commit
aaa30c92f7
@ -36,7 +36,6 @@ import java.util.stream.Collectors;
|
|||||||
public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {
|
public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(ConstraintViolationException exception) {
|
public Response toResponse(ConstraintViolationException exception) {
|
||||||
System.out.println(exception.getMessage());
|
|
||||||
Set<ConstraintViolation<?>> constraintViolations = exception.getConstraintViolations();
|
Set<ConstraintViolation<?>> constraintViolations = exception.getConstraintViolations();
|
||||||
List<String> errorMessages = constraintViolations.stream()
|
List<String> errorMessages = constraintViolations.stream()
|
||||||
.map(constraintViolation -> {
|
.map(constraintViolation -> {
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Define;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
import org.openmetadata.catalog.entity.data.Chart;
|
import org.openmetadata.catalog.entity.data.Chart;
|
||||||
import org.openmetadata.catalog.entity.data.Table;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ChartDAO3 extends EntityDAO<Chart>{
|
public interface ChartDAO3 extends EntityDAO<Chart>{
|
||||||
@Override
|
@Override
|
||||||
@ -17,40 +10,5 @@ public interface ChartDAO3 extends EntityDAO<Chart>{
|
|||||||
default Class<Chart> getEntityClass() { return Chart.class; }
|
default Class<Chart> getEntityClass() { return Chart.class; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE fullyQualifiedName = :name")
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
String findByName(@Define("table") String table, @Bind("name") String name);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT count(*) FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL)")
|
|
||||||
int listCount(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix);
|
|
||||||
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +// Filter by
|
|
||||||
// service name
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by chart fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " + // Pagination ordering by chart fullyQualifiedName
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +
|
|
||||||
"fullyQualifiedName > :after " +
|
|
||||||
"ORDER BY fullyQualifiedName " +
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM <table> WHERE id = :id)")
|
|
||||||
boolean exists(@Define("table") String table, @Bind("id") String id);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
|
||||||
int delete(@Define("table") String table, @Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -250,8 +250,7 @@ public class ChartRepositoryHelper implements EntityRepository<Chart>{
|
|||||||
private EntityReference getService(EntityReference service) throws IOException {
|
private EntityReference getService(EntityReference service) throws IOException {
|
||||||
String id = service.getId().toString();
|
String id = service.getId().toString();
|
||||||
if (service.getType().equalsIgnoreCase(Entity.DASHBOARD_SERVICE)) {
|
if (service.getType().equalsIgnoreCase(Entity.DASHBOARD_SERVICE)) {
|
||||||
DashboardService serviceInstance = EntityUtil.validate(id, repo3.dashboardServiceDAO().findById(id),
|
DashboardService serviceInstance = repo3.dashboardServiceDAO().findEntityById(id);
|
||||||
DashboardService.class);
|
|
||||||
service.setDescription(serviceInstance.getDescription());
|
service.setDescription(serviceInstance.getDescription());
|
||||||
service.setName(serviceInstance.getName());
|
service.setName(serviceInstance.getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,26 +2,20 @@ package org.openmetadata.catalog.jdbi3;
|
|||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Bind;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.services.DashboardService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface DashboardServiceDAO3 {
|
public interface DashboardServiceDAO3 extends EntityDAO<DashboardService> {
|
||||||
@SqlUpdate("INSERT INTO dashboard_service_entity (json) VALUES (:json)")
|
@Override
|
||||||
void insert(@Bind("json") String json);
|
default String getTableName() { return "dashboard_service_entity"; }
|
||||||
|
|
||||||
@SqlUpdate("UPDATE dashboard_service_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default String getNameColumn() { return "name"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM dashboard_service_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("id") String id);
|
default Class<DashboardService> getEntityClass() { return DashboardService.class; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM dashboard_service_entity WHERE name = :name")
|
|
||||||
String findByName(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM dashboard_service_entity WHERE (name = :name OR :name is NULL)")
|
@SqlQuery("SELECT json FROM dashboard_service_entity WHERE (name = :name OR :name is NULL)")
|
||||||
List<String> list(@Bind("name") String name);
|
List<String> list(@Bind("name") String name);
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM dashboard_service_entity WHERE id = :id")
|
|
||||||
int delete(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Define;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
import org.openmetadata.catalog.entity.data.Database;
|
import org.openmetadata.catalog.entity.data.Database;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface DatabaseDAO3 extends EntityDAO<Database> {
|
public interface DatabaseDAO3 extends EntityDAO<Database> {
|
||||||
@Override
|
@Override
|
||||||
default String getTableName() { return "database_entity"; }
|
default String getTableName() { return "database_entity"; }
|
||||||
@ -18,36 +12,5 @@ public interface DatabaseDAO3 extends EntityDAO<Database> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE fullyQualifiedName = :name")
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
String findByName(@Define("table") String table, @Bind("name") String name);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT count(*) FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL)")
|
|
||||||
int listCount(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix);
|
|
||||||
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +// Filter by service name
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by database fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " + // Pagination ordering by database fullyQualifiedName
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Define("table") String table, @Bind("fqnPrefix") String parentFQN, @Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +
|
|
||||||
"fullyQualifiedName > :after " +
|
|
||||||
"ORDER BY fullyQualifiedName " +
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Define("table") String table, @Bind("fqnPrefix") String parentFQN, @Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM <table> WHERE id = :id)")
|
|
||||||
boolean exists(@Define("table") String table, @Bind("id") String id);
|
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
|
||||||
int delete(@Define("table") String table, @Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -4,48 +4,21 @@ package org.openmetadata.catalog.jdbi3;
|
|||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Bind;
|
||||||
import org.jdbi.v3.sqlobject.customizer.Define;
|
import org.jdbi.v3.sqlobject.customizer.Define;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
import org.openmetadata.catalog.entity.data.Table;
|
|
||||||
import org.openmetadata.catalog.entity.services.DatabaseService;
|
import org.openmetadata.catalog.entity.services.DatabaseService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface DatabaseServiceDAO3 extends EntityDAO<DatabaseService> {
|
public interface DatabaseServiceDAO3 extends EntityDAO<DatabaseService> {
|
||||||
@Override
|
@Override
|
||||||
default String getTableName() { return "dbService_entity"; }
|
default String getTableName() { return "dbService_Entity"; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default Class<DatabaseService> getEntityClass() { return DatabaseService.class; }
|
default Class<DatabaseService> getEntityClass() { return DatabaseService.class; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE name = :name")
|
default String getNameColumn() { return "name"; }
|
||||||
String findByName(@Define("table") String table, @Bind("name") String name);
|
|
||||||
|
|
||||||
// TODO clean this up
|
// TODO clean this up
|
||||||
@SqlQuery("SELECT json FROM dbService_Entity WHERE (name = :name OR :name is NULL)")
|
@SqlQuery("SELECT json FROM dbService_Entity WHERE (name = :name OR :name is NULL)")
|
||||||
List<String> list(@Define("table") String table, @Bind("name") String name);
|
List<String> list(@Define("table") String table, @Bind("name") String name);
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<String> listAfter(String table, String parentFQN, int limit, String after) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<String> listBefore(String table, String parentFQN, int limit, String before) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int listCount(String table, String databaseFQN) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean exists(String table, String id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
|
||||||
int delete(@Define("table") String table, @Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,16 @@ import java.util.List;
|
|||||||
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
|
||||||
|
|
||||||
public interface EntityDAO<T> {
|
public interface EntityDAO<T> {
|
||||||
// TODO javadoc
|
/**
|
||||||
|
* Methods that need to be overridden by interfaces extending this
|
||||||
|
*/
|
||||||
String getTableName();
|
String getTableName();
|
||||||
Class<T> getEntityClass();
|
Class<T> getEntityClass();
|
||||||
|
String getNameColumn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common queries for all entities implemented here. Do not override.
|
||||||
|
*/
|
||||||
@SqlUpdate("INSERT INTO <table> (json) VALUES (:json)")
|
@SqlUpdate("INSERT INTO <table> (json) VALUES (:json)")
|
||||||
void insert(@Define("table") String table, @Bind("json") String json);
|
void insert(@Define("table") String table, @Bind("json") String json);
|
||||||
|
|
||||||
@ -43,13 +49,50 @@ public interface EntityDAO<T> {
|
|||||||
@SqlQuery("SELECT json FROM <table> WHERE id = :id")
|
@SqlQuery("SELECT json FROM <table> WHERE id = :id")
|
||||||
String findById(@Define("table") String table, @Bind("id") String id);
|
String findById(@Define("table") String table, @Bind("id") String id);
|
||||||
|
|
||||||
String findByName(String table, String name);
|
@SqlQuery("SELECT json FROM <table> WHERE <nameColumn> = :name")
|
||||||
int listCount(String table, String databaseFQN); // TODO check this
|
String findByName(@Define("table") String table, @Define("nameColumn") String nameColumn,
|
||||||
List<String> listBefore(String table, String parentFQN, int limit, String before);
|
@Bind("name") String name);
|
||||||
List<String> listAfter(String table, String parentFQN, int limit, String after);
|
|
||||||
boolean exists(String table, String id);
|
|
||||||
int delete(String table, String id);
|
|
||||||
|
|
||||||
|
@SqlQuery("SELECT count(*) FROM <table> WHERE " +
|
||||||
|
"(<nameColumn> LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL)")
|
||||||
|
int listCount(@Define("table") String table, @Define("nameColumn") String nameColumn,
|
||||||
|
@Bind("fqnPrefix") String fqnPrefix);
|
||||||
|
|
||||||
|
@SqlQuery(
|
||||||
|
"SELECT json FROM (" +
|
||||||
|
"SELECT <nameColumn>, json FROM <table> WHERE " +
|
||||||
|
"(<nameColumn> LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +// Filter by
|
||||||
|
// service name
|
||||||
|
"<nameColumn> < :before " + // Pagination by chart fullyQualifiedName
|
||||||
|
"ORDER BY <nameColumn> DESC " + // Pagination ordering by chart fullyQualifiedName
|
||||||
|
"LIMIT :limit" +
|
||||||
|
") last_rows_subquery ORDER BY <nameColumn>")
|
||||||
|
List<String> listBefore(@Define("table") String table,
|
||||||
|
@Define("nameColumn") String nameColumn,
|
||||||
|
@Bind("fqnPrefix") String fqnPrefix,
|
||||||
|
@Bind("limit") int limit,
|
||||||
|
@Bind("before") String before);
|
||||||
|
|
||||||
|
@SqlQuery("SELECT json FROM <table> WHERE " +
|
||||||
|
"(<nameColumn> LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +
|
||||||
|
"<nameColumn> > :after " +
|
||||||
|
"ORDER BY <nameColumn> " +
|
||||||
|
"LIMIT :limit")
|
||||||
|
List<String> listAfter(@Define("table") String table,
|
||||||
|
@Define("nameColumn") String nameColumn,
|
||||||
|
@Bind("fqnPrefix") String fqnPrefix,
|
||||||
|
@Bind("limit") int limit,
|
||||||
|
@Bind("after") String after);
|
||||||
|
|
||||||
|
@SqlQuery("SELECT EXISTS (SELECT * FROM <table> WHERE id = :id)")
|
||||||
|
boolean exists(@Define("table") String table, @Bind("id") String id);
|
||||||
|
|
||||||
|
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
||||||
|
int delete(@Define("table") String table, @Bind("id") String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default methods that interfaces with implementation. Don't override
|
||||||
|
*/
|
||||||
default void insert(String json) {
|
default void insert(String json) {
|
||||||
insert(getTableName(), json);
|
insert(getTableName(), json);
|
||||||
}
|
}
|
||||||
@ -73,7 +116,7 @@ public interface EntityDAO<T> {
|
|||||||
|
|
||||||
default T findEntityByName(String fqn) throws IOException {
|
default T findEntityByName(String fqn) throws IOException {
|
||||||
Class<T> clz = getEntityClass();
|
Class<T> clz = getEntityClass();
|
||||||
String json = findByName(getTableName(), fqn);
|
String json = findByName(getTableName(), getNameColumn(), fqn);
|
||||||
T entity = null;
|
T entity = null;
|
||||||
if (json != null) {
|
if (json != null) {
|
||||||
entity = JsonUtils.readValue(json, clz);
|
entity = JsonUtils.readValue(json, clz);
|
||||||
@ -89,19 +132,19 @@ public interface EntityDAO<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default String findJsonByFqn(String fqn) throws IOException {
|
default String findJsonByFqn(String fqn) throws IOException {
|
||||||
return findByName(getTableName(), fqn);
|
return findByName(getTableName(), getNameColumn(), fqn);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int listCount(String databaseFQN) {
|
default int listCount(String databaseFQN) {
|
||||||
return listCount(getTableName(), databaseFQN);
|
return listCount(getTableName(), getNameColumn(), databaseFQN);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<String> listBefore(String parentFQN, int limit, String before) {
|
default List<String> listBefore(String parentFQN, int limit, String before) {
|
||||||
return listBefore(getTableName(), parentFQN, limit, before);
|
return listBefore(getTableName(), getNameColumn(), parentFQN, limit, before);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<String> listAfter(String databaseFQN, int limit, String after) {
|
default List<String> listAfter(String databaseFQN, int limit, String after) {
|
||||||
return listAfter(getTableName(), databaseFQN, limit, after);
|
return listAfter(getTableName(), getNameColumn(), databaseFQN, limit, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean exists(String id) {
|
default boolean exists(String id) {
|
||||||
|
@ -1,27 +1,22 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Bind;
|
||||||
|
import org.jdbi.v3.sqlobject.customizer.Define;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.services.MessagingService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MessagingServiceDAO3 {
|
public interface MessagingServiceDAO3 extends EntityDAO<MessagingService> {
|
||||||
@SqlUpdate("INSERT INTO messaging_service_entity (json) VALUES (:json)")
|
@Override
|
||||||
void insert(@Bind("json") String json);
|
default String getTableName() { return "messaging_service_entity"; }
|
||||||
|
|
||||||
@SqlUpdate("UPDATE messaging_service_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default Class<MessagingService> getEntityClass() { return MessagingService.class; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM messaging_service_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("id") String id);
|
default String getNameColumn() { return "name"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM messaging_service_entity WHERE name = :name")
|
|
||||||
String findByName(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM messaging_service_entity WHERE (name = :name OR :name is NULL)")
|
@SqlQuery("SELECT json FROM messaging_service_entity WHERE (name = :name OR :name is NULL)")
|
||||||
List<String> list(@Bind("name") String name);
|
List<String> list(@Define("table") String table, @Bind("name") String name);
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM messaging_service_entity WHERE id = :id")
|
|
||||||
int delete(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,21 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Define;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.data.Model;
|
||||||
|
|
||||||
import java.util.List;
|
public interface ModelDAO3 extends EntityDAO<Model>{
|
||||||
|
@Override
|
||||||
|
default String getTableName() { return "model_entity"; }
|
||||||
|
|
||||||
public interface ModelDAO3 {
|
@Override
|
||||||
@SqlUpdate("INSERT INTO model_entity(json) VALUES (:json)")
|
default Class<Model> getEntityClass() { return Model.class; }
|
||||||
void insert(@Bind("json") String json);
|
|
||||||
|
|
||||||
@SqlUpdate("UPDATE model_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM model_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("id") String id);
|
@SqlQuery("SELECT count(*) FROM <table>")
|
||||||
|
int listCount(@Define("table") String table);
|
||||||
@SqlQuery("SELECT json FROM model_entity WHERE fullyQualifiedName = :name")
|
|
||||||
String findByFQN(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT count(*) FROM model_entity")
|
|
||||||
int listCount();
|
|
||||||
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM model_entity WHERE " +
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by model fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " +
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM model_entity WHERE " +
|
|
||||||
"fullyQualifiedName > :after " +
|
|
||||||
"ORDER BY fullyQualifiedName " +
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM model_entity WHERE id = :id")
|
|
||||||
int delete(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,14 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.openmetadata.catalog.entity.data.Pipeline;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
|
|
||||||
import java.util.List;
|
public interface PipelineDAO3 extends EntityDAO<Pipeline> {
|
||||||
|
@Override
|
||||||
|
default String getTableName() { return "pipeline_entity"; }
|
||||||
|
|
||||||
public interface PipelineDAO3 {
|
@Override
|
||||||
@SqlUpdate("INSERT INTO pipeline_entity(json) VALUES (:json)")
|
default Class<Pipeline> getEntityClass() { return Pipeline.class; }
|
||||||
void insert(@Bind("json") String json);
|
|
||||||
|
|
||||||
@SqlUpdate("UPDATE pipeline_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_entity WHERE id = :id")
|
|
||||||
String findById(@Bind("id") String id);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_entity WHERE fullyQualifiedName = :name")
|
|
||||||
String findByFQN(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT count(*) FROM pipeline_entity WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL)")
|
|
||||||
int listCount(@Bind("fqnPrefix") String fqnPrefix);
|
|
||||||
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM pipeline_entity WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +// Filter by
|
|
||||||
// service name
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by pipeline fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " + // Pagination ordering by fullyQualifiedName
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_entity WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +
|
|
||||||
"fullyQualifiedName > :after " +
|
|
||||||
"ORDER BY fullyQualifiedName " +
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM pipeline_entity WHERE id = :id")
|
|
||||||
int delete(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -2,26 +2,20 @@ package org.openmetadata.catalog.jdbi3;
|
|||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Bind;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.services.PipelineService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface PipelineServiceDAO3 {
|
public interface PipelineServiceDAO3 extends EntityDAO<PipelineService> {
|
||||||
@SqlUpdate("INSERT INTO pipeline_service_entity (json) VALUES (:json)")
|
@Override
|
||||||
void insert(@Bind("json") String json);
|
default String getTableName() { return "pipeline_service_entity"; }
|
||||||
|
|
||||||
@SqlUpdate("UPDATE pipeline_service_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default Class<PipelineService> getEntityClass() { return PipelineService.class; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_service_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("id") String id);
|
default String getNameColumn() { return "name"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_service_entity WHERE name = :name")
|
|
||||||
String findByName(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM pipeline_service_entity WHERE (name = :name OR :name is NULL)")
|
@SqlQuery("SELECT json FROM pipeline_service_entity WHERE (name = :name OR :name is NULL)")
|
||||||
List<String> list(@Bind("name") String name);
|
List<String> list(@Bind("name") String name);
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM pipeline_service_entity WHERE id = :id")
|
|
||||||
int delete(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,20 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.data.Report;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ReportDAO3 {
|
public interface ReportDAO3 extends EntityDAO<Report> {
|
||||||
@SqlUpdate("INSERT INTO report_entity(json) VALUES (:json)")
|
@Override
|
||||||
void insert(@Bind("json") String json);
|
default String getTableName() { return "report_entity"; }
|
||||||
|
|
||||||
@SqlUpdate("UPDATE report_entity SET json = :json where id = :id")
|
@Override
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
default Class<Report> getEntityClass() { return Report.class; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM report_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("name") String id);
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM report_entity WHERE fullyQualifiedName = :name")
|
|
||||||
String findByFQN(@Bind("name") String name);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM report_entity")
|
@SqlQuery("SELECT json FROM report_entity")
|
||||||
List<String> list();
|
List<String> list();
|
||||||
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM report_entity where id = :id)")
|
|
||||||
boolean exists(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Define;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
import org.openmetadata.catalog.entity.data.Table;
|
import org.openmetadata.catalog.entity.data.Table;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface TableDAO3 extends EntityDAO<Table> {
|
public interface TableDAO3 extends EntityDAO<Table> {
|
||||||
@Override
|
@Override
|
||||||
default String getTableName() {
|
default String getTableName() {
|
||||||
@ -19,40 +13,5 @@ public interface TableDAO3 extends EntityDAO<Table> {
|
|||||||
default Class<Table> getEntityClass() { return Table.class; }
|
default Class<Table> getEntityClass() { return Table.class; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE fullyQualifiedName = :tableFQN")
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
String findByName(@Define("table") String table, @Bind("tableFQN") String tableFQN);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT count(*) FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:databaseFQN, '.%') OR :databaseFQN IS NULL)")
|
|
||||||
int listCount(@Define("table") String table, @Bind("databaseFQN") String databaseFQN);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:databaseFQN, '.%') OR :databaseFQN IS NULL) AND " +
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by table fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " + // Pagination ordering by table fullyQualifiedName
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Define("table") String table, @Bind("databaseFQN") String parentFQN, @Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:databaseFQN, '.%') OR :databaseFQN IS NULL) AND "+//Filter by databaseName
|
|
||||||
"fullyQualifiedName > :after " + // Pagination by table fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName " + // Pagination ordering by table fullyQualifiedName
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Define("table") String table, @Bind("databaseFQN") String parentFQN, @Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM <table> WHERE id = :id)")
|
|
||||||
boolean exists(@Define("table") String table, @Bind("id") String id);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
|
||||||
int delete(@Define("table") String table, @Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,21 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Define;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.teams.Team;
|
||||||
|
|
||||||
import java.util.List;
|
public interface TeamDAO3 extends EntityDAO<Team> {
|
||||||
|
@Override
|
||||||
|
default String getTableName() { return "team_entity"; }
|
||||||
|
|
||||||
public interface TeamDAO3 {
|
@Override
|
||||||
@SqlUpdate("INSERT INTO team_entity (json) VALUES (:json)")
|
default Class<Team> getEntityClass() { return Team.class; }
|
||||||
void insert(@Bind("json") String json);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM team_entity where id = :teamId")
|
@Override
|
||||||
String findById(@Bind("teamId") String teamId);
|
default String getNameColumn() { return "name"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM team_entity where name = :name")
|
@Override
|
||||||
String findByName(@Bind("name") String name);
|
@SqlQuery("SELECT count(*) FROM <table>")
|
||||||
|
int listCount(@Define("table") String table);
|
||||||
@SqlQuery("SELECT count(*) FROM team_entity")
|
|
||||||
int listCount();
|
|
||||||
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT name, json FROM team_entity WHERE " +
|
|
||||||
"name < :before " + // Pagination by team name
|
|
||||||
"ORDER BY name DESC " + // Pagination ordering by team name
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY name")
|
|
||||||
List<String> listBefore(@Bind("limit") int limit, @Bind("before") String before);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM team_entity WHERE " +
|
|
||||||
"name > :after " + // Pagination by team name
|
|
||||||
"ORDER BY name " + // Pagination ordering by team name
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Bind("limit") int limit, @Bind("after") String after);
|
|
||||||
|
|
||||||
@SqlUpdate("DELETE FROM team_entity WHERE id = :teamId")
|
|
||||||
int delete(@Bind("teamId") String teamId);
|
|
||||||
|
|
||||||
@SqlUpdate("UPDATE team_entity SET json = :json WHERE id = :id")
|
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Define;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
|
||||||
import org.openmetadata.catalog.entity.data.Table;
|
|
||||||
import org.openmetadata.catalog.entity.data.Topic;
|
import org.openmetadata.catalog.entity.data.Topic;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface TopicDAO3 extends EntityDAO<Topic> {
|
public interface TopicDAO3 extends EntityDAO<Topic> {
|
||||||
@Override
|
@Override
|
||||||
default String getTableName() { return "topic_entity"; }
|
default String getTableName() { return "topic_entity"; }
|
||||||
@ -18,42 +11,5 @@ public interface TopicDAO3 extends EntityDAO<Topic> {
|
|||||||
default Class<Topic> getEntityClass() { return Topic.class; }
|
default Class<Topic> getEntityClass() { return Topic.class; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE fullyQualifiedName = :name")
|
default String getNameColumn() { return "fullyQualifiedName"; }
|
||||||
String findByName(@Define("table") String table, @Bind("name") String name);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT count(*) FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL)")
|
|
||||||
// Filter by service name
|
|
||||||
int listCount(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery(
|
|
||||||
"SELECT json FROM (" +
|
|
||||||
"SELECT fullyQualifiedName, json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +// Filter by
|
|
||||||
// service name
|
|
||||||
"fullyQualifiedName < :before " + // Pagination by topic fullyQualifiedName
|
|
||||||
"ORDER BY fullyQualifiedName DESC " + // Pagination ordering by topic fullyQualifiedName
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY fullyQualifiedName")
|
|
||||||
List<String> listBefore(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("before") String before);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT json FROM <table> WHERE " +
|
|
||||||
"(fullyQualifiedName LIKE CONCAT(:fqnPrefix, '.%') OR :fqnPrefix IS NULL) AND " +
|
|
||||||
"fullyQualifiedName > :after " +
|
|
||||||
"ORDER BY fullyQualifiedName " +
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Define("table") String table, @Bind("fqnPrefix") String fqnPrefix, @Bind("limit") int limit,
|
|
||||||
@Bind("after") String after);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM <table> WHERE id = :id)")
|
|
||||||
boolean exists(@Define("table") String table, @Bind("id") String id);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SqlUpdate("DELETE FROM <table> WHERE id = :id")
|
|
||||||
int delete(@Define("table") String table, @Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -256,8 +256,7 @@ public class TopicRepositoryHelper implements EntityRepository<Topic> {
|
|||||||
private EntityReference getService(EntityReference service) throws IOException {
|
private EntityReference getService(EntityReference service) throws IOException {
|
||||||
String id = service.getId().toString();
|
String id = service.getId().toString();
|
||||||
if (service.getType().equalsIgnoreCase(Entity.MESSAGING_SERVICE)) {
|
if (service.getType().equalsIgnoreCase(Entity.MESSAGING_SERVICE)) {
|
||||||
MessagingService serviceInstance = EntityUtil.validate(id, repo3.messageServiceDAO().findById(id),
|
MessagingService serviceInstance = repo3.messageServiceDAO().findEntityById(id);
|
||||||
MessagingService.class);
|
|
||||||
service.setDescription(serviceInstance.getDescription());
|
service.setDescription(serviceInstance.getDescription());
|
||||||
service.setName(serviceInstance.getName());
|
service.setName(serviceInstance.getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,48 +1,29 @@
|
|||||||
package org.openmetadata.catalog.jdbi3;
|
package org.openmetadata.catalog.jdbi3;
|
||||||
|
|
||||||
import org.jdbi.v3.sqlobject.customizer.Bind;
|
import org.jdbi.v3.sqlobject.customizer.Bind;
|
||||||
|
import org.jdbi.v3.sqlobject.customizer.Define;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
import org.jdbi.v3.sqlobject.statement.SqlQuery;
|
||||||
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
|
import org.openmetadata.catalog.entity.teams.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface UserDAO3 {
|
public interface UserDAO3 extends EntityDAO<User> {
|
||||||
@SqlUpdate("INSERT INTO user_entity (json) VALUES (:json)")
|
@Override
|
||||||
void insert(@Bind("json") String json);
|
default String getTableName() { return "user_entity"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity WHERE id = :id")
|
@Override
|
||||||
String findById(@Bind("id") String id);
|
default Class<User> getEntityClass() { return User.class; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity WHERE name = :name")
|
@Override
|
||||||
String findByName(@Bind("name") String name);
|
default String getNameColumn() { return "name"; }
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity WHERE email = :email")
|
|
||||||
String findByEmail(@Bind("email") String email);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity")
|
@SqlQuery("SELECT json FROM user_entity")
|
||||||
List<String> list();
|
List<String> list();
|
||||||
|
|
||||||
@SqlQuery("SELECT count(*) FROM user_entity")
|
@SqlQuery("SELECT json FROM user_entity WHERE email = :email")
|
||||||
int listCount();
|
String findByEmail(@Bind("email") String email);
|
||||||
|
|
||||||
@SqlQuery(
|
@Override
|
||||||
"SELECT json FROM (" +
|
@SqlQuery("SELECT count(*) FROM <table>")
|
||||||
"SELECT name, json FROM user_entity WHERE " +
|
int listCount(@Define("table") String table);
|
||||||
"name < :before " + // Pagination by user name
|
|
||||||
"ORDER BY name DESC " + // Pagination ordering by user name
|
|
||||||
"LIMIT :limit" +
|
|
||||||
") last_rows_subquery ORDER BY name")
|
|
||||||
List<String> listBefore(@Bind("limit") int limit, @Bind("before") String before);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT json FROM user_entity WHERE " +
|
|
||||||
"name > :after " + // Pagination by user name
|
|
||||||
"ORDER BY name " + // Pagination ordering by user name
|
|
||||||
"LIMIT :limit")
|
|
||||||
List<String> listAfter(@Bind("limit") int limit, @Bind("after") String after);
|
|
||||||
|
|
||||||
@SqlUpdate("UPDATE user_entity SET json = :json WHERE id = :id")
|
|
||||||
void update(@Bind("id") String id, @Bind("json") String json);
|
|
||||||
|
|
||||||
@SqlQuery("SELECT EXISTS (SELECT * FROM user_entity where id = :id)")
|
|
||||||
boolean exists(@Bind("id") String id);
|
|
||||||
}
|
}
|
||||||
|
@ -268,13 +268,13 @@ public final class EntityUtil {
|
|||||||
}
|
}
|
||||||
String id = owner.getId().toString();
|
String id = owner.getId().toString();
|
||||||
if (owner.getType().equalsIgnoreCase("user")) {
|
if (owner.getType().equalsIgnoreCase("user")) {
|
||||||
User ownerInstance = EntityUtil.validate(id, userDAO3.findById(id), User.class);
|
User ownerInstance = userDAO3.findEntityById(id);
|
||||||
owner.setName(ownerInstance.getName());
|
owner.setName(ownerInstance.getName());
|
||||||
if (Optional.ofNullable(ownerInstance.getDeactivated()).orElse(false)) {
|
if (Optional.ofNullable(ownerInstance.getDeactivated()).orElse(false)) {
|
||||||
throw new IllegalArgumentException(CatalogExceptionMessage.deactivatedUser(id));
|
throw new IllegalArgumentException(CatalogExceptionMessage.deactivatedUser(id));
|
||||||
}
|
}
|
||||||
} else if (owner.getType().equalsIgnoreCase("team")) {
|
} else if (owner.getType().equalsIgnoreCase("team")) {
|
||||||
Team ownerInstance = EntityUtil.validate(id, teamDAO.findById(id), Team.class);
|
Team ownerInstance = teamDAO.findEntityById(id);
|
||||||
owner.setDescription(ownerInstance.getDescription());
|
owner.setDescription(ownerInstance.getDescription());
|
||||||
owner.setName(ownerInstance.getName());
|
owner.setName(ownerInstance.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -933,7 +933,7 @@ public final class EntityUtil {
|
|||||||
String followedEntityId,
|
String followedEntityId,
|
||||||
String followedEntityType, String followerId, String followerEntity)
|
String followedEntityType, String followerId, String followerEntity)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
User user = EntityUtil.validate(followerId, userDAO3.findById(followerId), User.class);
|
User user = userDAO3.findEntityById(followerId);
|
||||||
if (Optional.ofNullable(user.getDeactivated()).orElse(false)) {
|
if (Optional.ofNullable(user.getDeactivated()).orElse(false)) {
|
||||||
throw new IllegalArgumentException(CatalogExceptionMessage.deactivatedUser(followerId));
|
throw new IllegalArgumentException(CatalogExceptionMessage.deactivatedUser(followerId));
|
||||||
}
|
}
|
||||||
@ -969,7 +969,7 @@ public final class EntityUtil {
|
|||||||
Entity.USER);
|
Entity.USER);
|
||||||
List<EntityReference> followers = new ArrayList<>();
|
List<EntityReference> followers = new ArrayList<>();
|
||||||
for (String followerId : followerIds) {
|
for (String followerId : followerIds) {
|
||||||
User user = EntityUtil.validate(followerId, userDAO3.findById(followerId), User.class);
|
User user = userDAO3.findEntityById(followerId);
|
||||||
followers.add(new EntityReference().withName(user.getName()).withId(user.getId()).withType("user"));
|
followers.add(new EntityReference().withName(user.getName()).withId(user.getId()).withType("user"));
|
||||||
}
|
}
|
||||||
return followers;
|
return followers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user