-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2474 from opencb/TASK-5964
TASK-5964 - Clinical Improvements
- Loading branch information
Showing
49 changed files
with
1,663 additions
and
656 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
35 changes: 35 additions & 0 deletions
35
...ain/java/org/opencb/opencga/app/migrations/v3/v3_2_0/TASK_5964/AddInterpretationName.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,35 @@ | ||
package org.opencb.opencga.app.migrations.v3.v3_2_0.TASK_5964; | ||
|
||
import com.mongodb.client.model.Filters; | ||
import com.mongodb.client.model.Projections; | ||
import com.mongodb.client.model.UpdateOneModel; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory; | ||
import org.opencb.opencga.catalog.migration.Migration; | ||
import org.opencb.opencga.catalog.migration.MigrationTool; | ||
|
||
import java.util.Arrays; | ||
|
||
@Migration(id = "add_interpretation_name", description = "Add Interpretation name #TASK-5964", version = "3.2.0", | ||
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20240610) | ||
public class AddInterpretationName extends MigrationTool { | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
// Add new Interpretation name field | ||
Bson nameDoesNotExistQuery = Filters.exists("name", false); | ||
Bson projection = Projections.include("id"); | ||
for (String collection : Arrays.asList(OrganizationMongoDBAdaptorFactory.INTERPRETATION_COLLECTION, | ||
OrganizationMongoDBAdaptorFactory.INTERPRETATION_ARCHIVE_COLLECTION, | ||
OrganizationMongoDBAdaptorFactory.DELETED_INTERPRETATION_COLLECTION)) { | ||
migrateCollection(collection, nameDoesNotExistQuery, projection, | ||
(document, bulk) -> { | ||
Document updateDocument = new Document() | ||
.append("name", document.get("id")); | ||
bulk.add(new UpdateOneModel<>(Filters.eq("_id", document.get("_id")), new Document("$set", updateDocument))); | ||
}); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.