Additional default methods to prevent repository classes having to override the methods

This commit is contained in:
sureshms 2021-10-24 08:29:03 -07:00
parent 363262a699
commit b584382c65
18 changed files with 10 additions and 193 deletions

View File

@ -47,11 +47,6 @@ public class BotsRepository extends EntityRepository<Bots>{
return bots; return bots;
} }
@Override
public String getFullyQualifiedName(Bots entity) {
return entity.getName();
}
@Override @Override
public Bots setFields(Bots entity, Fields fields) throws IOException, ParseException { public Bots setFields(Bots entity, Fields fields) throws IOException, ParseException {
return entity; return entity;
@ -60,11 +55,6 @@ public class BotsRepository extends EntityRepository<Bots>{
@Override @Override
public void restorePatchAttributes(Bots original, Bots update) throws IOException, ParseException { } public void restorePatchAttributes(Bots original, Bots update) throws IOException, ParseException { }
@Override
public ResultList<Bots> getResultList(List<Bots> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new BotsList(entities);
}
@Override @Override
public EntityInterface<Bots> getEntityInterface(Bots entity) { public EntityInterface<Bots> getEntityInterface(Bots entity) {
return new BotsEntityInterface(entity); return new BotsEntityInterface(entity);

View File

@ -121,11 +121,6 @@ public class ChartRepository extends EntityRepository<Chart> {
chart.setOwner(owner); chart.setOwner(owner);
} }
@Override
public String getFullyQualifiedName(Chart entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Chart setFields(Chart chart, Fields fields) throws IOException { public Chart setFields(Chart chart, Fields fields) throws IOException {
chart.setOwner(fields.contains("owner") ? getOwner(chart) : null); chart.setOwner(fields.contains("owner") ? getOwner(chart) : null);
@ -142,12 +137,6 @@ public class ChartRepository extends EntityRepository<Chart> {
.withService(original.getService()).withId(original.getId()); .withService(original.getService()).withId(original.getId());
} }
@Override
public ResultList<Chart> getResultList(List<Chart> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new ResultList<>(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Chart> getEntityInterface(Chart entity) { public EntityInterface<Chart> getEntityInterface(Chart entity) {
return new ChartEntityInterface(entity); return new ChartEntityInterface(entity);

View File

@ -59,17 +59,6 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
return (dashboard.getService().getName() + "." + dashboard.getName()); return (dashboard.getService().getName() + "." + dashboard.getName());
} }
@Override
public String getFullyQualifiedName(Dashboard entity) {
return entity.getFullyQualifiedName();
}
@Override
public ResultList<Dashboard> getResultList(List<Dashboard> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new DashboardList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Dashboard> getEntityInterface(Dashboard entity) { public EntityInterface<Dashboard> getEntityInterface(Dashboard entity) {
return new DashboardEntityInterface(entity); return new DashboardEntityInterface(entity);

View File

@ -70,11 +70,6 @@ public class DashboardServiceRepository extends EntityRepository<DashboardServic
dao.relationshipDAO().deleteAll(id.toString()); dao.relationshipDAO().deleteAll(id.toString());
} }
@Override
public String getFullyQualifiedName(DashboardService entity) {
return entity.getName();
}
@Override @Override
public DashboardService setFields(DashboardService entity, Fields fields) throws IOException, ParseException { public DashboardService setFields(DashboardService entity, Fields fields) throws IOException, ParseException {
return entity; return entity;
@ -85,13 +80,6 @@ public class DashboardServiceRepository extends EntityRepository<DashboardServic
ParseException { ParseException {
} }
@Override
public ResultList<DashboardService> getResultList(List<DashboardService> entities, String beforeCursor,
String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new DashboardServiceList(entities);
}
@Override @Override
public EntityInterface<DashboardService> getEntityInterface(DashboardService entity) { public EntityInterface<DashboardService> getEntityInterface(DashboardService entity) {
return new DashboardServiceEntityInterface(entity); return new DashboardServiceEntityInterface(entity);

View File

@ -118,11 +118,6 @@ public class DatabaseRepository extends EntityRepository<Database> {
return tables; return tables;
} }
@Override
public String getFullyQualifiedName(Database entity) {
return entity.getFullyQualifiedName();
}
public Database setFields(Database database, Fields fields) throws IOException { public Database setFields(Database database, Fields fields) throws IOException {
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);
@ -139,12 +134,6 @@ public class DatabaseRepository extends EntityRepository<Database> {
.withService(original.getService()).withId(original.getId()); .withService(original.getService()).withId(original.getId());
} }
@Override
public ResultList<Database> getResultList(List<Database> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new DatabaseList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Database> getEntityInterface(Database entity) { public EntityInterface<Database> getEntityInterface(Database entity) {
return new DatabaseEntityInterface(entity); return new DatabaseEntityInterface(entity);

View File

@ -68,11 +68,6 @@ public class DatabaseServiceRepository extends EntityRepository<DatabaseService>
dao.relationshipDAO().deleteAll(id.toString()); dao.relationshipDAO().deleteAll(id.toString());
} }
@Override
public String getFullyQualifiedName(DatabaseService entity) {
return entity.getName();
}
@Override @Override
public DatabaseService setFields(DatabaseService entity, Fields fields) throws IOException, ParseException { public DatabaseService setFields(DatabaseService entity, Fields fields) throws IOException, ParseException {
return entity; return entity;
@ -84,13 +79,6 @@ public class DatabaseServiceRepository extends EntityRepository<DatabaseService>
} }
@Override
public ResultList<DatabaseService> getResultList(List<DatabaseService> entities, String beforeCursor,
String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new DatabaseServiceList(entities);
}
@Override @Override
public EntityInterface<DatabaseService> getEntityInterface(DatabaseService entity) { public EntityInterface<DatabaseService> getEntityInterface(DatabaseService entity) {
return new DatabaseServiceEntityInterface(entity); return new DatabaseServiceEntityInterface(entity);

View File

@ -39,14 +39,10 @@ public abstract class EntityRepository<T> {
/** /**
* Entity related operations that should be implemented or overridden by entities * Entity related operations that should be implemented or overridden by entities
*/ */
public abstract String getFullyQualifiedName(T entity);
public abstract ResultList<T> getResultList(List<T> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException;
public abstract EntityInterface<T> getEntityInterface(T entity); public abstract EntityInterface<T> getEntityInterface(T entity);
public abstract T setFields(T entity, Fields fields) throws IOException, ParseException; public abstract T setFields(T entity, Fields fields) throws IOException, ParseException;
public abstract void restorePatchAttributes(T original, T updated) throws IOException, ParseException; public abstract void restorePatchAttributes(T original, T updated) throws IOException, ParseException;
public abstract void validate(T entity) throws IOException; public abstract void validate(T entity) throws IOException;
public abstract void store(T entity, boolean update) throws IOException; public abstract void store(T entity, boolean update) throws IOException;
public abstract void storeRelationships(T entity) throws IOException; public abstract void storeRelationships(T entity) throws IOException;
@ -156,6 +152,15 @@ public abstract class EntityRepository<T> {
return updated; return updated;
} }
public final String getFullyQualifiedName(T entity) {
return getEntityInterface(entity).getFullyQualifiedName();
}
public final ResultList<T> getResultList(List<T> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new ResultList<>(entities, beforeCursor, afterCursor, total);
}
private T createInternal(T entity) throws IOException { private T createInternal(T entity) throws IOException {
store(entity, false); store(entity, false);
storeRelationships(entity); storeRelationships(entity);

View File

@ -70,11 +70,6 @@ public class MessagingServiceRepository extends EntityRepository<MessagingServic
dao.relationshipDAO().deleteAll(id.toString()); dao.relationshipDAO().deleteAll(id.toString());
} }
@Override
public String getFullyQualifiedName(MessagingService entity) {
return entity.getName();
}
@Override @Override
public MessagingService setFields(MessagingService entity, Fields fields) throws IOException, ParseException { public MessagingService setFields(MessagingService entity, Fields fields) throws IOException, ParseException {
return entity; return entity;
@ -86,13 +81,6 @@ public class MessagingServiceRepository extends EntityRepository<MessagingServic
} }
@Override
public ResultList<MessagingService> getResultList(List<MessagingService> entities, String beforeCursor,
String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new MessagingServiceList(entities);
}
@Override @Override
public EntityInterface<MessagingService> getEntityInterface(MessagingService entity) { public EntityInterface<MessagingService> getEntityInterface(MessagingService entity) {
return new MessagingServiceEntityInterface(entity); return new MessagingServiceEntityInterface(entity);

View File

@ -49,11 +49,6 @@ public class MetricsRepository extends EntityRepository<Metrics> {
return (metrics.getService().getName() + "." + metrics.getName()); return (metrics.getService().getName() + "." + metrics.getName());
} }
@Override
public String getFullyQualifiedName(Metrics entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Metrics setFields(Metrics metrics, Fields fields) throws IOException { public Metrics setFields(Metrics metrics, Fields fields) throws IOException {
metrics.setOwner(fields.contains("owner") ? getOwner(metrics) : null); metrics.setOwner(fields.contains("owner") ? getOwner(metrics) : null);
@ -67,12 +62,6 @@ public class MetricsRepository extends EntityRepository<Metrics> {
public void restorePatchAttributes(Metrics original, Metrics updated) throws IOException, ParseException { public void restorePatchAttributes(Metrics original, Metrics updated) throws IOException, ParseException {
} }
@Override
public ResultList<Metrics> getResultList(List<Metrics> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new MetricsList(entities);
}
@Override @Override
public EntityInterface<Metrics> getEntityInterface(Metrics entity) { public EntityInterface<Metrics> getEntityInterface(Metrics entity) {
return new MetricsEntityInterface(entity); return new MetricsEntityInterface(entity);

View File

@ -91,11 +91,6 @@ public class ModelRepository extends EntityRepository<Model> {
return EntityUtil.populateOwner(dao.userDAO(), dao.teamDAO(), model.getOwner()); return EntityUtil.populateOwner(dao.userDAO(), dao.teamDAO(), model.getOwner());
} }
@Override
public String getFullyQualifiedName(Model entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Model setFields(Model model, Fields fields) throws IOException { public Model setFields(Model model, Fields fields) throws IOException {
model.setDisplayName(model.getDisplayName()); model.setDisplayName(model.getDisplayName());
@ -113,12 +108,6 @@ public class ModelRepository extends EntityRepository<Model> {
} }
@Override
public ResultList<Model> getResultList(List<Model> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new ModelList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Model> getEntityInterface(Model entity) { public EntityInterface<Model> getEntityInterface(Model entity) {
return new ModelEntityInterface(entity); return new ModelEntityInterface(entity);

View File

@ -89,11 +89,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
return EntityUtil.populateOwner(dao.userDAO(), dao.teamDAO(), pipeline.getOwner()); return EntityUtil.populateOwner(dao.userDAO(), dao.teamDAO(), pipeline.getOwner());
} }
@Override
public String getFullyQualifiedName(Pipeline entity) {
return entity.getFullyQualifiedName();
}
@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());
@ -115,12 +110,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
.withService(original.getService()).withId(original.getId()); .withService(original.getService()).withId(original.getId());
} }
@Override
public ResultList<Pipeline> getResultList(List<Pipeline> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new PipelineList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Pipeline> getEntityInterface(Pipeline entity) { public EntityInterface<Pipeline> getEntityInterface(Pipeline entity) {
return new PipelineEntityInterface(entity); return new PipelineEntityInterface(entity);

View File

@ -71,11 +71,6 @@ public class PipelineServiceRepository extends EntityRepository<PipelineService>
dao.relationshipDAO().deleteAll(id.toString()); dao.relationshipDAO().deleteAll(id.toString());
} }
@Override
public String getFullyQualifiedName(PipelineService entity) {
return entity.getName();
}
@Override @Override
public PipelineService setFields(PipelineService entity, Fields fields) throws IOException, ParseException { public PipelineService setFields(PipelineService entity, Fields fields) throws IOException, ParseException {
return entity; return entity;
@ -87,13 +82,6 @@ public class PipelineServiceRepository extends EntityRepository<PipelineService>
} }
@Override
public ResultList<PipelineService> getResultList(List<PipelineService> entities, String beforeCursor,
String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new PipelineServiceList(entities);
}
@Override @Override
public EntityInterface<PipelineService> getEntityInterface(PipelineService entity) { public EntityInterface<PipelineService> getEntityInterface(PipelineService entity) {
return new PipelineServiceEntityInterface(entity); return new PipelineServiceEntityInterface(entity);

View File

@ -44,11 +44,6 @@ public class ReportRepository extends EntityRepository<Report> {
this.dao = dao; this.dao = dao;
} }
@Override
public String getFullyQualifiedName(Report entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Report setFields(Report report, Fields fields) throws IOException { public Report setFields(Report report, Fields fields) throws IOException {
report.setOwner(fields.contains("owner") ? getOwner(report) : null); report.setOwner(fields.contains("owner") ? getOwner(report) : null);
@ -63,12 +58,6 @@ public class ReportRepository extends EntityRepository<Report> {
} }
@Override
public ResultList<Report> getResultList(List<Report> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new ReportList(entities);
}
@Override @Override
public EntityInterface<Report> getEntityInterface(Report entity) { public EntityInterface<Report> getEntityInterface(Report entity) {
return new ReportEntityInterface(entity); return new ReportEntityInterface(entity);

View File

@ -81,11 +81,6 @@ public class TableRepository extends EntityRepository<Table> {
this.dao = dao; this.dao = dao;
} }
@Override
public String getFullyQualifiedName(Table entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Table setFields(Table table, Fields fields) throws IOException, ParseException { public Table setFields(Table table, Fields fields) throws IOException, ParseException {
table.setColumns(fields.contains("columns") ? table.getColumns() : null); table.setColumns(fields.contains("columns") ? table.getColumns() : null);
@ -111,12 +106,6 @@ public class TableRepository extends EntityRepository<Table> {
.withDatabase(original.getDatabase()).withId(original.getId()); .withDatabase(original.getDatabase()).withId(original.getId());
} }
@Override
public ResultList<Table> getResultList(List<Table> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new TableList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Table> getEntityInterface(Table entity) { public EntityInterface<Table> getEntityInterface(Table entity) {
return new TableEntityInterface(entity); return new TableEntityInterface(entity);

View File

@ -121,11 +121,6 @@ public class TaskRepository extends EntityRepository<Task> {
task.setOwner(owner); task.setOwner(owner);
} }
@Override
public String getFullyQualifiedName(Task entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Task setFields(Task task, Fields fields) throws IOException { public Task setFields(Task task, Fields fields) throws IOException {
task.setTaskUrl(task.getTaskUrl()); task.setTaskUrl(task.getTaskUrl());
@ -144,12 +139,6 @@ public class TaskRepository extends EntityRepository<Task> {
} }
@Override
public ResultList<Task> getResultList(List<Task> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new TaskList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Task> getEntityInterface(Task entity) { public EntityInterface<Task> getEntityInterface(Task entity) {
return new TaskEntityInterface(entity); return new TaskEntityInterface(entity);

View File

@ -86,11 +86,6 @@ public class TeamRepository extends EntityRepository<Team> {
} }
} }
@Override
public String getFullyQualifiedName(Team entity) {
return entity.getName();
}
@Override @Override
public Team setFields(Team team, Fields fields) throws IOException { public Team setFields(Team team, Fields fields) throws IOException {
if (!fields.contains("profile")) { if (!fields.contains("profile")) {
@ -107,12 +102,6 @@ public class TeamRepository extends EntityRepository<Team> {
updated.withName(original.getName()).withId(original.getId()); updated.withName(original.getName()).withId(original.getId());
} }
@Override
public ResultList<Team> getResultList(List<Team> entities, String beforeCursor, String afterCursor, int total)
throws GeneralSecurityException, UnsupportedEncodingException {
return new TeamList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Team> getEntityInterface(Team entity) { public EntityInterface<Team> getEntityInterface(Team entity) {
return new TeamEntityInterface(entity); return new TeamEntityInterface(entity);

View File

@ -124,11 +124,6 @@ public class TopicRepository extends EntityRepository<Topic> {
topic.setOwner(owner); topic.setOwner(owner);
} }
@Override
public String getFullyQualifiedName(Topic entity) {
return entity.getFullyQualifiedName();
}
@Override @Override
public Topic setFields(Topic topic, Fields fields) throws IOException { public Topic setFields(Topic topic, Fields fields) throws IOException {
topic.setOwner(fields.contains("owner") ? getOwner(topic) : null); topic.setOwner(fields.contains("owner") ? getOwner(topic) : null);
@ -143,11 +138,6 @@ public class TopicRepository extends EntityRepository<Topic> {
} }
@Override
public ResultList<Topic> getResultList(List<Topic> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new TopicList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<Topic> getEntityInterface(Topic entity) { public EntityInterface<Topic> getEntityInterface(Topic entity) {
return new TopicEntityInterface(entity); return new TopicEntityInterface(entity);

View File

@ -60,17 +60,12 @@ public class UserRepository extends EntityRepository<User> {
this.dao = dao; this.dao = dao;
} }
@Override
public ResultList<User> getResultList(List<User> entities, String beforeCursor, String afterCursor,
int total) throws GeneralSecurityException, UnsupportedEncodingException {
return new UserList(entities, beforeCursor, afterCursor, total);
}
@Override @Override
public EntityInterface<User> getEntityInterface(User entity) { public EntityInterface<User> getEntityInterface(User entity) {
return new UserEntityInterface(entity); return new UserEntityInterface(entity);
} }
@Override @Override
public void validate(User entity) throws IOException { public void validate(User entity) throws IOException {
@ -122,11 +117,6 @@ public class UserRepository extends EntityRepository<User> {
dao.relationshipDAO().deleteFrom(id.toString(), FOLLOWS.ordinal()); dao.relationshipDAO().deleteFrom(id.toString(), FOLLOWS.ordinal());
} }
@Override
public String getFullyQualifiedName(User entity) {
return entity.getName();
}
@Override @Override
public User setFields(User user, Fields fields) throws IOException { public User setFields(User user, Fields fields) throws IOException {
user.setProfile(fields.contains("profile") ? user.getProfile() : null); user.setProfile(fields.contains("profile") ? user.getProfile() : null);