-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TSPS-405 Add quota units to pipeline quotas (#205)
- Loading branch information
1 parent
cb2c82d
commit 0a482f0
Showing
12 changed files
with
117 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
service/src/main/java/bio/terra/pipelines/common/utils/QuotaUnitsEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package bio.terra.pipelines.common.utils; | ||
|
||
public enum QuotaUnitsEnum { | ||
SAMPLES("samples"); | ||
|
||
private final String value; | ||
|
||
QuotaUnitsEnum(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
service/src/main/java/bio/terra/pipelines/db/entities/converters/QuotaUnitsConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package bio.terra.pipelines.db.entities.converters; | ||
|
||
import bio.terra.pipelines.common.utils.QuotaUnitsEnum; | ||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
// inspired by https://www.baeldung.com/jpa-persisting-enums-in-jpa | ||
@Converter(autoApply = true) | ||
public class QuotaUnitsConverter implements AttributeConverter<QuotaUnitsEnum, String> { | ||
@Override | ||
public String convertToDatabaseColumn(QuotaUnitsEnum quotaUnitsEnum) { | ||
return quotaUnitsEnum.getValue(); | ||
} | ||
|
||
@Override | ||
public QuotaUnitsEnum convertToEntityAttribute(String quotaUnitsString) { | ||
return QuotaUnitsEnum.valueOf(quotaUnitsString.toUpperCase()); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
service/src/main/java/bio/terra/pipelines/db/repositories/PipelineQuotasRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package bio.terra.pipelines.db.repositories; | ||
|
||
import bio.terra.pipelines.common.utils.PipelinesEnum; | ||
import bio.terra.pipelines.common.utils.QuotaUnitsEnum; | ||
import bio.terra.pipelines.db.entities.PipelineQuota; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface PipelineQuotasRepository extends CrudRepository<PipelineQuota, Long> { | ||
PipelineQuota findByPipelineName(PipelinesEnum pipelineName); | ||
|
||
@Query("SELECT p.quotaUnits FROM PipelineQuota p WHERE p.pipelineName = ?1") | ||
QuotaUnitsEnum findQuotaUnitsByPipelineName(PipelinesEnum pipelineName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
service/src/main/resources/db/changesets/20250225_add_quota_units.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# add quota_units field to pipeline_quotas table and set value for array_imputation pipeline | ||
|
||
databaseChangeLog: | ||
- changeSet: | ||
id: add and populate quota_units column in pipeline_quotas table | ||
author: mma | ||
changes: | ||
# add quota_units column to pipeline_quotas table | ||
- addColumn: | ||
tableName: pipeline_quotas | ||
columns: | ||
- column: | ||
name: quota_units | ||
type: text | ||
constraints: | ||
nullable: true | ||
# update quota_units value for array_imputation pipeline | ||
- update: | ||
tableName: pipeline_quotas | ||
columns: | ||
- column: | ||
name: quota_units | ||
value: 'samples' | ||
where: pipeline_name='array_imputation' | ||
# make quota_units non-nullable | ||
- addNotNullConstraint: | ||
tableName: pipeline_quotas | ||
columnName: quota_units |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters