mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 11:12:12 -05:00
Compare commits
1 Commits
run-develo
...
fix/tenant
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c07dcbb9ca |
@@ -24,6 +24,8 @@ public interface DashboardRepositoryInterface {
|
||||
|
||||
List<Dashboard> findAll(String tenantId);
|
||||
|
||||
List<Dashboard> findAllWithNoAcl(String tenantId);
|
||||
|
||||
default Dashboard save(Dashboard dashboard, String source) {
|
||||
return this.save(null, dashboard, source);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ public interface FlowRepositoryInterface {
|
||||
|
||||
List<FlowWithSource> findAllWithSource(String tenantId);
|
||||
|
||||
List<FlowWithSource> findAllWithSourceWithNoAcl(String tenantId);
|
||||
|
||||
List<Flow> findAllForAllTenants();
|
||||
|
||||
List<FlowWithSource> findAllWithSourceForAllTenants();
|
||||
|
||||
@@ -12,6 +12,8 @@ public interface TemplateRepositoryInterface {
|
||||
|
||||
List<Template> findAll(String tenantId);
|
||||
|
||||
List<Template> findAllWithNoAcl(String tenantId);
|
||||
|
||||
List<Template> findAllForAllTenants();
|
||||
|
||||
ArrayListTotal<Template> find(
|
||||
|
||||
@@ -107,6 +107,25 @@ public abstract class AbstractJdbcDashboardRepository extends AbstractJdbcReposi
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dashboard> findAllWithNoAcl(String tenantId) {
|
||||
return this.jdbcRepository
|
||||
.getDslContextWrapper()
|
||||
.transactionResult(configuration -> {
|
||||
DSLContext context = DSL.using(configuration);
|
||||
|
||||
SelectConditionStep<Record1<Object>> select = context
|
||||
.select(
|
||||
field("value")
|
||||
)
|
||||
.hint(context.configuration().dialect().supports(SQLDialect.MYSQL) ? "SQL_CALC_FOUND_ROWS" : null)
|
||||
.from(jdbcRepository.getTable())
|
||||
.where(this.defaultFilterWithNoACL(tenantId));
|
||||
|
||||
return this.jdbcRepository.fetch(select);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dashboard save(Dashboard previousDashboard, Dashboard dashboard, String source) throws ConstraintViolationException {
|
||||
dashboard = dashboard.toBuilder().sourceCode(source).build();
|
||||
|
||||
@@ -360,6 +360,29 @@ public abstract class AbstractJdbcFlowRepository extends AbstractJdbcRepository
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FlowWithSource> findAllWithSourceWithNoAcl(String tenantId) {
|
||||
return this.jdbcRepository
|
||||
.getDslContextWrapper()
|
||||
.transactionResult(configuration -> {
|
||||
var select = DSL
|
||||
.using(configuration)
|
||||
.select(
|
||||
field("value"),
|
||||
field("source_code"),
|
||||
field("namespace"),
|
||||
field("tenant_id")
|
||||
)
|
||||
.from(fromLastRevision(true))
|
||||
.where(this.noAclDefaultFilter(tenantId));
|
||||
|
||||
return select.fetch().map(record -> FlowWithSource.of(
|
||||
(Flow)jdbcRepository.map(record),
|
||||
record.get(SOURCE_FIELD)
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FlowWithSource> findAllWithSourceForAllTenants() {
|
||||
return this.jdbcRepository
|
||||
|
||||
@@ -64,6 +64,21 @@ public abstract class AbstractJdbcTemplateRepository extends AbstractJdbcReposit
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Template> findAllWithNoAcl(String tenantId) {
|
||||
return this.jdbcRepository
|
||||
.getDslContextWrapper()
|
||||
.transactionResult(configuration -> {
|
||||
SelectConditionStep<Record1<Object>> select = DSL
|
||||
.using(configuration)
|
||||
.select(field("value"))
|
||||
.from(this.jdbcRepository.getTable())
|
||||
.where(this.defaultFilterWithNoACL(tenantId));
|
||||
|
||||
return this.jdbcRepository.fetch(select);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Template> findAllForAllTenants() {
|
||||
return this.jdbcRepository
|
||||
|
||||
Reference in New Issue
Block a user