-
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.
core: add new CVDB index status in Clinical Analysis, #TASK-5610
- Loading branch information
Showing
7 changed files
with
246 additions
and
11 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
.../java/org/opencb/opencga/app/migrations/v4/v4_0_0/catalog/ClinicalCvdbIndexMigration.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,47 @@ | ||
package org.opencb.opencga.app.migrations.v4.v4_0_0.catalog; | ||
|
||
import com.mongodb.client.model.Filters; | ||
import com.mongodb.client.model.Updates; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import org.opencb.opencga.catalog.db.api.ClinicalAnalysisDBAdaptor; | ||
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory; | ||
import org.opencb.opencga.catalog.migration.Migration; | ||
import org.opencb.opencga.catalog.migration.MigrationTool; | ||
import org.opencb.opencga.core.models.clinical.ClinicalStatusValue; | ||
import org.opencb.opencga.core.models.clinical.CvdbIndexStatus; | ||
|
||
import java.util.Arrays; | ||
|
||
@Migration(id = "add_cvdb_index_to_clinical_analysis", | ||
description = "Add CVDB index status to Clinical Analysis #TASK-5610", version = "4.0.0", | ||
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20241118) | ||
public class ClinicalCvdbIndexMigration extends MigrationTool { | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
Bson closedCaseQuery = Filters.and( | ||
Filters.exists(ClinicalAnalysisDBAdaptor.QueryParams.INTERNAL_CVDB_INDEX.key(), false), | ||
Filters.eq("status.type", ClinicalStatusValue.ClinicalStatusType.CLOSED) | ||
); | ||
Bson openCaseQuery = Filters.and( | ||
Filters.exists(ClinicalAnalysisDBAdaptor.QueryParams.INTERNAL_CVDB_INDEX.key(), false), | ||
Filters.ne("status.type", ClinicalStatusValue.ClinicalStatusType.CLOSED) | ||
); | ||
CvdbIndexStatus pendingCvdbIndexStatus = new CvdbIndexStatus(CvdbIndexStatus.PENDING); | ||
Document pendingCvdbIndexDoc = convertToDocument(pendingCvdbIndexStatus); | ||
Bson updateClosedCase = Updates.set(ClinicalAnalysisDBAdaptor.QueryParams.INTERNAL_CVDB_INDEX.key(), pendingCvdbIndexDoc); | ||
|
||
CvdbIndexStatus noneCvdbIndexStatus = new CvdbIndexStatus(CvdbIndexStatus.NONE); | ||
Document noneCvdbIndexDoc = convertToDocument(noneCvdbIndexStatus); | ||
Bson updateOpenCase = Updates.set(ClinicalAnalysisDBAdaptor.QueryParams.INTERNAL_CVDB_INDEX.key(), noneCvdbIndexDoc); | ||
|
||
for (String collection : Arrays.asList(OrganizationMongoDBAdaptorFactory.CLINICAL_ANALYSIS_COLLECTION, | ||
OrganizationMongoDBAdaptorFactory.CLINICAL_ANALYSIS_ARCHIVE_COLLECTION, | ||
OrganizationMongoDBAdaptorFactory.DELETED_CLINICAL_ANALYSIS_COLLECTION)) { | ||
getMongoCollection(collection).updateMany(closedCaseQuery, updateClosedCase); | ||
getMongoCollection(collection).updateMany(openCaseQuery, updateOpenCase); | ||
} | ||
} | ||
|
||
} |
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
56 changes: 56 additions & 0 deletions
56
opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/CvdbIndexStatus.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,56 @@ | ||
package org.opencb.opencga.core.models.clinical; | ||
|
||
import org.opencb.opencga.core.models.common.OperationIndexStatus; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CvdbIndexStatus extends OperationIndexStatus { | ||
|
||
public static final String ERROR = "ERROR"; | ||
public static final String PENDING_REMOVE = "PENDING_REMOVE"; | ||
public static final String PENDING_OVERWRITE = "PENDING_OVERWRITE"; | ||
|
||
public static final List<String> STATUS_LIST = Arrays.asList(NONE, PENDING, PENDING_REMOVE, PENDING_OVERWRITE, READY, ERROR); | ||
|
||
public CvdbIndexStatus(String status, String message) { | ||
if (isValid(status)) { | ||
init(status, message); | ||
} else { | ||
throw new IllegalArgumentException("Unknown status " + status); | ||
} | ||
} | ||
|
||
public CvdbIndexStatus(String status) { | ||
this(status, ""); | ||
} | ||
|
||
public CvdbIndexStatus() { | ||
this(NONE, ""); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return super.getId(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return super.getName(); | ||
} | ||
|
||
public static CvdbIndexStatus init() { | ||
return new CvdbIndexStatus(); | ||
} | ||
|
||
public static boolean isValid(String status) { | ||
return status != null | ||
&& (status.equals(NONE) | ||
|| status.equals(PENDING) | ||
|| status.equals(PENDING_REMOVE) | ||
|| status.equals(PENDING_OVERWRITE) | ||
|| status.equals(READY) | ||
|| status.equals(ERROR)); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
opencga-core/src/main/java/org/opencb/opencga/core/models/common/OperationIndexStatus.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,48 @@ | ||
package org.opencb.opencga.core.models.common; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class OperationIndexStatus extends IndexStatus { | ||
|
||
public static final String PENDING = "PENDING"; | ||
|
||
public static final List<String> STATUS_LIST = Arrays.asList(READY, PENDING, NONE); | ||
|
||
public OperationIndexStatus(String status, String message) { | ||
if (isValid(status)) { | ||
init(status, message); | ||
} else { | ||
throw new IllegalArgumentException("Unknown status " + status); | ||
} | ||
} | ||
|
||
public OperationIndexStatus(String status) { | ||
this(status, ""); | ||
} | ||
|
||
public OperationIndexStatus() { | ||
this(NONE, ""); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return super.getId(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return super.getName(); | ||
} | ||
|
||
public static OperationIndexStatus init() { | ||
return new OperationIndexStatus(); | ||
} | ||
|
||
public static boolean isValid(String status) { | ||
return status != null | ||
&& (status.equals(READY) | ||
|| status.equals(PENDING) | ||
|| status.equals(NONE)); | ||
} | ||
} |