-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: Ensure SampleIndexConfiguration always exists. Add migration…
…. #TASK-6765
- Loading branch information
Showing
33 changed files
with
258 additions
and
88 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
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
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
53 changes: 53 additions & 0 deletions
53
...encga/app/migrations/v3/v3_4_0/storage/EnsureSampleIndexConfigurationIsAlwaysDefined.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,53 @@ | ||
package org.opencb.opencga.app.migrations.v3.v3_4_0.storage; | ||
|
||
import org.opencb.opencga.app.migrations.StorageMigrationTool; | ||
import org.opencb.opencga.catalog.migration.Migration; | ||
import org.opencb.opencga.core.config.storage.SampleIndexConfiguration; | ||
import org.opencb.opencga.storage.core.metadata.models.StudyMetadata; | ||
import org.opencb.opencga.storage.core.variant.VariantStorageEngine; | ||
|
||
import java.time.Instant; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@Migration(id = "ensure_sample_index_configuration_is_defined", | ||
description = "Ensure that the SampleIndexConfiguration object is correctly defined. #TASK-6765", version = "3.4.0", | ||
language = Migration.MigrationLanguage.JAVA, | ||
domain = Migration.MigrationDomain.STORAGE, | ||
patch = 1, | ||
date = 20240910) | ||
public class EnsureSampleIndexConfigurationIsAlwaysDefined extends StorageMigrationTool { | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
|
||
for (String variantStorageProject : getVariantStorageProjects()) { | ||
VariantStorageEngine engine = getVariantStorageEngineByProject(variantStorageProject); | ||
if (engine.getMetadataManager().exists()) { | ||
for (Integer studyId : engine.getMetadataManager().getStudyIds()) { | ||
StudyMetadata studyMetadata = engine.getMetadataManager().getStudyMetadata(studyId); | ||
List<StudyMetadata.SampleIndexConfigurationVersioned> configurations = studyMetadata.getSampleIndexConfigurations(); | ||
if (configurations == null || configurations.isEmpty()) { | ||
configurations = new ArrayList<>(1); | ||
logger.info("Creating default SampleIndexConfiguration for study '" + studyMetadata.getName() + "' (" + studyId + ")"); | ||
configurations.add(new StudyMetadata.SampleIndexConfigurationVersioned( | ||
preFileDataConfiguration(), | ||
StudyMetadata.DEFAULT_SAMPLE_INDEX_VERSION, | ||
Date.from(Instant.now()), StudyMetadata.SampleIndexConfigurationVersioned.Status.ACTIVE)); | ||
studyMetadata.setSampleIndexConfigurations(configurations); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
public static SampleIndexConfiguration preFileDataConfiguration() { | ||
// If missing, it was assuming cellbase v5 | ||
SampleIndexConfiguration sampleIndexConfiguration = SampleIndexConfiguration.defaultConfiguration(false); | ||
sampleIndexConfiguration.getFileDataConfiguration().setIncludeOriginalCall(false); | ||
sampleIndexConfiguration.getFileDataConfiguration().setIncludeSecondaryAlternates(false); | ||
return sampleIndexConfiguration; | ||
} | ||
} |
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
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
Oops, something went wrong.