Skip to content

Commit

Permalink
Introduce existsClusters
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Nuyanzin <[email protected]>
  • Loading branch information
snuyanzin authored Oct 13, 2023
1 parent afe900e commit fd39190
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ List<SchemaRequest> getAllSchemaRequests(

List<KwClusters> getAllClusters(KafkaClustersType typeOfCluster, int tenantId);

boolean existsClusters(KafkaClustersType typeOfCluster, int tenantId);

KwClusters getClusterDetails(int id, int tenantId);

// Analytics - charts - dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,11 @@ public List<KwClusters> getAllClusters(KafkaClustersType typeOfCluster, int tena
return jdbcSelectHelper.getAllClusters(typeOfCluster, tenantId);
}

@Override
public boolean existsClusters(KafkaClustersType typeOfCluster, int tenantId) {
return jdbcSelectHelper.existsClusters(typeOfCluster, tenantId);
}

@Override
public KwClusters getClusterDetails(int id, int tenantId) {
return jdbcSelectHelper.getClusterDetails(id, tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,10 @@ public List<KwClusters> getAllClusters(KafkaClustersType typeOfCluster, int tena
}
}

public boolean existsClusters(KafkaClustersType typeOfCluster, int tenantId) {
return kwClusterRepo.existsByClusterTypeAndTenantId(typeOfCluster.value, tenantId);
}

public KwClusters getClusterDetails(int id, int tenantId) {
KwClusterID kwClusterID = new KwClusterID();
kwClusterID.setClusterId(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
public interface KwClusterRepo extends CrudRepository<KwClusters, KwClusterID> {
List<KwClusters> findAllByClusterTypeAndTenantId(String type, int tenantId);

boolean existsByClusterTypeAndTenantId(String type, int tenantId);

@Query(
value = "select max(clusterid) from kwclusters where tenantid = :tenantId",
nativeQuery = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,7 @@ public void handleQuickStartData(
HandleDbRequestsJdbc handleDbRequests, String encryptorSecretKey, String infraTeam) {
if (quickStartEnabled) {
// verify if quick start data already exists tbd
List<KwClusters> kwClusters =
handleDbRequests.getAllClusters(KafkaClustersType.KAFKA, KwConstants.DEFAULT_TENANT_ID);
if (!kwClusters.isEmpty()) {
if (handleDbRequests.existsClusters(KafkaClustersType.KAFKA, KwConstants.DEFAULT_TENANT_ID)) {
return;
}

Expand Down Expand Up @@ -536,7 +534,7 @@ public void handleQuickStartData(
handleDbRequests.addNewCluster(kwClusterSchemaRegistry);

// Add kafka environment
kwClusters =
var kwClusters =
handleDbRequests.getAllClusters(KafkaClustersType.KAFKA, KwConstants.DEFAULT_TENANT_ID);
Env envKafka = new Env();
envKafka.setClusterId(kwClusters.get(0).getClusterId());
Expand Down

0 comments on commit fd39190

Please sign in to comment.