diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OrganizationsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OrganizationsCommandExecutor.java index 1294b1397e7..caefda1d320 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OrganizationsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OrganizationsCommandExecutor.java @@ -19,6 +19,7 @@ import org.opencb.opencga.core.config.Optimizations; import org.opencb.opencga.core.models.notes.Note; import org.opencb.opencga.core.models.notes.NoteCreateParams; +import org.opencb.opencga.core.models.notes.NoteType; import org.opencb.opencga.core.models.notes.NoteUpdateParams; import org.opencb.opencga.core.models.organizations.Organization; import org.opencb.opencga.core.models.organizations.OrganizationConfiguration; @@ -164,6 +165,7 @@ private RestResponse createNotes() throws Exception { } else { ObjectMap beanParams = new ObjectMap(); putNestedIfNotEmpty(beanParams, "id", commandOptions.id, true); + putNestedIfNotNull(beanParams, "type", commandOptions.type, true); putNestedIfNotNull(beanParams, "tags", commandOptions.tags, true); putNestedIfNotNull(beanParams, "visibility", commandOptions.visibility, true); putNestedIfNotNull(beanParams, "valueType", commandOptions.valueType, true); @@ -186,6 +188,7 @@ private RestResponse searchNotes() throws Exception { queryParams.putIfNotEmpty("creationDate", commandOptions.creationDate); queryParams.putIfNotEmpty("modificationDate", commandOptions.modificationDate); queryParams.putIfNotEmpty("id", commandOptions.id); + queryParams.putIfNotEmpty("type", commandOptions.type); queryParams.putIfNotEmpty("scope", commandOptions.scope); queryParams.putIfNotEmpty("visibility", commandOptions.visibility); queryParams.putIfNotEmpty("uuid", commandOptions.uuid); @@ -230,6 +233,7 @@ private RestResponse updateNotes() throws Exception { .readValue(new java.io.File(commandOptions.jsonFile), NoteUpdateParams.class); } else { ObjectMap beanParams = new ObjectMap(); + putNestedIfNotNull(beanParams, "type", commandOptions.type, true); putNestedIfNotNull(beanParams, "tags", commandOptions.tags, true); putNestedIfNotNull(beanParams, "visibility", commandOptions.visibility, true); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java index 0c18639ed52..009be9f6b7a 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java @@ -33,6 +33,7 @@ import org.opencb.opencga.core.models.job.Job; import org.opencb.opencga.core.models.notes.Note; import org.opencb.opencga.core.models.notes.NoteCreateParams; +import org.opencb.opencga.core.models.notes.NoteType; import org.opencb.opencga.core.models.notes.NoteUpdateParams; import org.opencb.opencga.core.models.study.CustomGroup; import org.opencb.opencga.core.models.study.Group; @@ -398,6 +399,7 @@ private RestResponse createNotes() throws Exception { } else { ObjectMap beanParams = new ObjectMap(); putNestedIfNotEmpty(beanParams, "id", commandOptions.id, true); + putNestedIfNotNull(beanParams, "type", commandOptions.type, true); putNestedIfNotNull(beanParams, "tags", commandOptions.tags, true); putNestedIfNotNull(beanParams, "visibility", commandOptions.visibility, true); putNestedIfNotNull(beanParams, "valueType", commandOptions.valueType, true); @@ -420,6 +422,7 @@ private RestResponse searchNotes() throws Exception { queryParams.putIfNotEmpty("creationDate", commandOptions.creationDate); queryParams.putIfNotEmpty("modificationDate", commandOptions.modificationDate); queryParams.putIfNotEmpty("id", commandOptions.id); + queryParams.putIfNotEmpty("type", commandOptions.type); queryParams.putIfNotEmpty("uuid", commandOptions.uuid); queryParams.putIfNotEmpty("userId", commandOptions.userId); queryParams.putIfNotEmpty("tags", commandOptions.tags); @@ -463,6 +466,7 @@ private RestResponse updateNotes() throws Exception { .readValue(new java.io.File(commandOptions.jsonFile), NoteUpdateParams.class); } else { ObjectMap beanParams = new ObjectMap(); + putNestedIfNotNull(beanParams, "type", commandOptions.type, true); putNestedIfNotNull(beanParams, "tags", commandOptions.tags, true); putNestedIfNotNull(beanParams, "visibility", commandOptions.visibility, true); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/OrganizationsCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/OrganizationsCommandOptions.java index 0f9f2a18c49..6fc4e04c9c7 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/OrganizationsCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/OrganizationsCommandOptions.java @@ -127,6 +127,9 @@ public class CreateNotesCommandOptions { @Parameter(names = {"--id"}, description = "The body web service id parameter", required = false, arity = 1) public String id; + @Parameter(names = {"--type"}, description = "Enum param allowed values: VARIANT, GENE, TRANSCRIPT, PROTEIN, JOB, FILE, SAMPLE, INDIVIDUAL, FAMILY, COHORT, DISEASE_PANEL, CLINICAL_ANALYSIS, WORKFLOW, ORGANIZATION, OTHER, UNKNOWN", required = false, arity = 1) + public String type; + @Parameter(names = {"--tags"}, description = "The body web service tags parameter", required = false, arity = 1) public String tags; @@ -159,6 +162,9 @@ public class SearchNotesCommandOptions { @Parameter(names = {"--id"}, description = "Note unique identifier.", required = false, arity = 1) public String id; + @Parameter(names = {"--type"}, description = "Note type.", required = false, arity = 1) + public String type; + @Parameter(names = {"--scope"}, description = "Scope of the Note.", required = false, arity = 1) public String scope; @@ -220,6 +226,9 @@ public class UpdateNotesCommandOptions { @Parameter(names = {"--include-result"}, description = "Flag indicating to include the created or updated document result in the response", required = false, help = true, arity = 0) public boolean includeResult = false; + @Parameter(names = {"--type"}, description = "Enum param allowed values: VARIANT, GENE, TRANSCRIPT, PROTEIN, JOB, FILE, SAMPLE, INDIVIDUAL, FAMILY, COHORT, DISEASE_PANEL, CLINICAL_ANALYSIS, WORKFLOW, ORGANIZATION, OTHER, UNKNOWN", required = false, arity = 1) + public String type; + @Parameter(names = {"--tags"}, description = "The body web service tags parameter", required = false, arity = 1) public String tags; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/StudiesCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/StudiesCommandOptions.java index d75022de0b9..f317c8e4122 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/StudiesCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/StudiesCommandOptions.java @@ -412,6 +412,9 @@ public class CreateNotesCommandOptions { @Parameter(names = {"--id"}, description = "The body web service id parameter", required = false, arity = 1) public String id; + @Parameter(names = {"--type"}, description = "Enum param allowed values: VARIANT, GENE, TRANSCRIPT, PROTEIN, JOB, FILE, SAMPLE, INDIVIDUAL, FAMILY, COHORT, DISEASE_PANEL, CLINICAL_ANALYSIS, WORKFLOW, ORGANIZATION, OTHER, UNKNOWN", required = false, arity = 1) + public String type; + @Parameter(names = {"--tags"}, description = "The body web service tags parameter", required = false, arity = 1) public String tags; @@ -447,6 +450,9 @@ public class SearchNotesCommandOptions { @Parameter(names = {"--id"}, description = "Note unique identifier.", required = false, arity = 1) public String id; + @Parameter(names = {"--type"}, description = "Note type.", required = false, arity = 1) + public String type; + @Parameter(names = {"--uuid"}, description = "Unique 32-character identifier assigned automatically by OpenCGA.", required = false, arity = 1) public String uuid; @@ -511,6 +517,9 @@ public class UpdateNotesCommandOptions { @Parameter(names = {"--include-result"}, description = "Flag indicating to include the created or updated document result in the response", required = false, help = true, arity = 0) public boolean includeResult = false; + @Parameter(names = {"--type"}, description = "Enum param allowed values: VARIANT, GENE, TRANSCRIPT, PROTEIN, JOB, FILE, SAMPLE, INDIVIDUAL, FAMILY, COHORT, DISEASE_PANEL, CLINICAL_ANALYSIS, WORKFLOW, ORGANIZATION, OTHER, UNKNOWN", required = false, arity = 1) + public String type; + @Parameter(names = {"--tags"}, description = "The body web service tags parameter", required = false, arity = 1) public String tags; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v4/v4_0_0/catalog/AddNewNoteTypeMigration.java b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v4/v4_0_0/catalog/AddNewNoteTypeMigration.java new file mode 100644 index 00000000000..b18c1350268 --- /dev/null +++ b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v4/v4_0_0/catalog/AddNewNoteTypeMigration.java @@ -0,0 +1,43 @@ +package org.opencb.opencga.app.migrations.v4.v4_0_0.catalog; + +import com.mongodb.client.MongoCollection; +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.mongodb.OrganizationMongoDBAdaptorFactory; +import org.opencb.opencga.catalog.migration.Migration; +import org.opencb.opencga.catalog.migration.MigrationTool; +import org.opencb.opencga.core.api.ParamConstants; +import org.opencb.opencga.core.models.notes.NoteType; + +import java.util.Arrays; + +@Migration(id = "addNewNoteType__task_7046", + description = "Add new Note type #7046", version = "4.0.0", + language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20241030) +public class AddNewNoteTypeMigration extends MigrationTool { + + @Override + protected void run() throws Exception { + NoteType type = NoteType.UNKNOWN; + if (ParamConstants.ADMIN_ORGANIZATION.equals(organizationId)) { + type = NoteType.ORGANIZATION; + } + MongoCollection collection = getMongoCollection(OrganizationMongoDBAdaptorFactory.NOTE_COLLECTION); + Bson query = Filters.exists("type", false); + Bson update = Updates.set("type", type); + logger.info("Setting all notes from organization '{}' to type '{}'", organizationId, type); + collection.updateMany(query, update); + + // Drop old index + Document oldIndex = new Document() + .append("id", 1) + .append("studyUid", 1) + .append("version", 1); + dropIndex(Arrays.asList(OrganizationMongoDBAdaptorFactory.NOTE_COLLECTION, OrganizationMongoDBAdaptorFactory.NOTE_ARCHIVE_COLLECTION), + oldIndex); + // Generate new indexes + catalogManager.installIndexes(organizationId, token); + } +} diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/NoteDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/NoteDBAdaptor.java index eeecd6d55df..51dcaef3e5a 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/NoteDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/NoteDBAdaptor.java @@ -32,6 +32,7 @@ enum QueryParams implements QueryParam { UUID("uuid", STRING, ""), SCOPE("scope", STRING, ""), STUDY("study", STRING, ""), + TYPE("type", STRING, ""), TAGS("tags", TEXT_ARRAY, ""), USER_ID("userId", STRING, ""), VISIBILITY("visibility", STRING, ""), diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MongoDBAdaptorFactory.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MongoDBAdaptorFactory.java index 75ffb1106ee..62e490f37b9 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MongoDBAdaptorFactory.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MongoDBAdaptorFactory.java @@ -38,6 +38,7 @@ import org.opencb.opencga.core.config.Configuration; import org.opencb.opencga.core.models.notes.Note; import org.opencb.opencga.core.models.notes.NoteCreateParams; +import org.opencb.opencga.core.models.notes.NoteType; import org.opencb.opencga.core.models.organizations.Organization; import org.opencb.opencga.core.models.organizations.OrganizationSummary; import org.opencb.opencga.core.response.OpenCGAResult; @@ -278,7 +279,7 @@ public OpenCGAResult createOrganization(Organization organization, OrganizationSummary organizationSummary = new OrganizationSummary(organization.getId(), organizationDBAdaptorFactory.getMongoDataStore().getDatabaseName(), OrganizationTag.ACTIVE.name(), null); - NoteCreateParams noteCreateParams = new NoteCreateParams(ORGANIZATION_PREFIX + organization.getId(), + NoteCreateParams noteCreateParams = new NoteCreateParams(ORGANIZATION_PREFIX + organization.getId(), NoteType.ORGANIZATION, Collections.singletonList(OrganizationTag.ACTIVE.name()), Note.Visibility.PRIVATE, Note.Type.OBJECT, null); try { String orgSummaryString = JacksonUtils.getDefaultObjectMapper().writeValueAsString(organizationSummary); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/NoteMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/NoteMongoDBAdaptor.java index 0b953919713..ea138e29ac4 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/NoteMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/NoteMongoDBAdaptor.java @@ -208,7 +208,7 @@ private UpdateDocument parseAndValidateUpdateParams(Document note, ObjectMap par // document.getSet().put(PRIVATE_MODIFICATION_DATE, date); // } - final String[] acceptedStringParams = {QueryParams.USER_ID.key(), QueryParams.VISIBILITY.key()}; + final String[] acceptedStringParams = {QueryParams.USER_ID.key(), QueryParams.VISIBILITY.key(), QueryParams.TYPE.key()}; filterStringParams(parameters, document.getSet(), acceptedStringParams); Object value = parameters.get(QueryParams.VALUE.key()); @@ -399,6 +399,7 @@ private Bson parseQuery(Query query) throws CatalogDBException { break; case ID: case UUID: + case TYPE: case SCOPE: case USER_ID: case TAGS: diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/NoteManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/NoteManager.java index f32c8422dec..33f0fa0bdee 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/NoteManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/NoteManager.java @@ -24,6 +24,7 @@ import org.opencb.opencga.core.models.common.Enums; import org.opencb.opencga.core.models.notes.Note; import org.opencb.opencga.core.models.notes.NoteCreateParams; +import org.opencb.opencga.core.models.notes.NoteType; import org.opencb.opencga.core.models.notes.NoteUpdateParams; import org.opencb.opencga.core.models.study.Study; import org.opencb.opencga.core.response.OpenCGAResult; @@ -396,6 +397,7 @@ public static void validateNewNote(Note note, String userId) throws CatalogParam ParamUtils.checkObj(note.getValueType(), NoteDBAdaptor.QueryParams.VALUE_TYPE.key()); ParamUtils.checkObj(note.getValue(), NoteDBAdaptor.QueryParams.VALUE.key()); + note.setType(ParamUtils.defaultObject(note.getType(), NoteType.UNKNOWN)); note.setTags(CollectionUtils.isNotEmpty(note.getTags()) ? note.getTags() : Collections.emptyList()); note.setUserId(userId); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/migration/MigrationManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/migration/MigrationManager.java index 7b1f979c863..fae8ea4f2f3 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/migration/MigrationManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/migration/MigrationManager.java @@ -213,6 +213,9 @@ public void runMigration(String organizationId, String version, Collection migration : runnableMigrations) { run(organizationId, migration, appHomePath, params, token); } + + // 5. Execute install indexes just in case there are new indexes + catalogManager.installIndexes(organizationId, token); } public List> getPendingMigrations(String organizationId, String version, String token) diff --git a/opencga-catalog/src/main/resources/catalog-indexes.txt b/opencga-catalog/src/main/resources/catalog-indexes.txt index abf49089714..09ce5ac283e 100644 --- a/opencga-catalog/src/main/resources/catalog-indexes.txt +++ b/opencga-catalog/src/main/resources/catalog-indexes.txt @@ -1,7 +1,8 @@ -{"collections": ["note", "note_archive"], "fields": {"id": 1, "studyUid": 1, "version": 1}, "options": {"unique": true}} +{"collections": ["note", "note_archive"], "fields": {"id": 1, "studyUid": 1, "type": 1, "version": 1}, "options": {"unique": true}} {"collections": ["note", "note_archive"], "fields": {"uid": 1, "version": 1}, "options": {"unique": true}} {"collections": ["note", "note_archive"], "fields": {"uuid": 1, "version": 1}, "options": {"unique": true}} {"collections": ["note", "note_archive"], "fields": {"scope": 1, "studyUid": 1}, "options": {}} +{"collections": ["note", "note_archive"], "fields": {"type": 1, "studyUid": 1}, "options": {}} {"collections": ["note", "note_archive"], "fields": {"studyUid": 1}, "options": {}} {"collections": ["note", "note_archive"], "fields": {"visibility": 1, "studyUid": 1}, "options": {}} {"collections": ["note", "note_archive"], "fields": {"userId": 1, "studyUid": 1}, "options": {}} diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/NoteManagerTest.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/NoteManagerTest.java index 9d1afcadb2b..843bb95c037 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/NoteManagerTest.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/NoteManagerTest.java @@ -12,6 +12,7 @@ import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.models.notes.Note; import org.opencb.opencga.core.models.notes.NoteCreateParams; +import org.opencb.opencga.core.models.notes.NoteType; import org.opencb.opencga.core.models.notes.NoteUpdateParams; import org.opencb.opencga.core.models.organizations.Organization; import org.opencb.opencga.core.models.study.Study; @@ -37,11 +38,14 @@ public void createOrganizationNoteTest() throws CatalogException { Note note = catalogManager.getNotesManager().createOrganizationNote(noteCreateParams, INCLUDE_RESULT, ownerToken).first(); assertEquals(noteCreateParams.getId(), note.getId()); assertEquals(orgOwnerUserId, note.getUserId()); + assertEquals(NoteType.UNKNOWN, note.getType()); noteCreateParams.setId("note2"); + noteCreateParams.setType(NoteType.FAMILY); note = catalogManager.getNotesManager().createOrganizationNote(noteCreateParams, INCLUDE_RESULT, orgAdminToken1).first(); assertEquals(noteCreateParams.getId(), note.getId()); assertEquals(orgAdminUserId1, note.getUserId()); + assertEquals(NoteType.FAMILY, note.getType()); thrown.expect(CatalogAuthorizationException.class); thrown.expectMessage("denied"); @@ -59,10 +63,12 @@ public void updateOrganizationNoteTest() throws CatalogException { assertEquals(1, note.getVersion()); NoteUpdateParams noteUpdateParams = new NoteUpdateParams() - .setTags(Arrays.asList("tag1", "tag2")); + .setTags(Arrays.asList("tag1", "tag2")) + .setType(NoteType.GENE); note = catalogManager.getNotesManager().updateOrganizationNote(note.getId(), noteUpdateParams, INCLUDE_RESULT, ownerToken).first(); assertEquals(2, note.getVersion()); assertEquals(orgOwnerUserId, note.getUserId()); + assertEquals(NoteType.GENE, note.getType()); assertEquals(2, note.getTags().size()); assertArrayEquals(noteUpdateParams.getTags().toArray(), note.getTags().toArray()); diff --git a/opencga-client/src/main/R/R/Organization-methods.R b/opencga-client/src/main/R/R/Organization-methods.R index 14e44864ed9..70e53aa5144 100644 --- a/opencga-client/src/main/R/R/Organization-methods.R +++ b/opencga-client/src/main/R/R/Organization-methods.R @@ -21,7 +21,7 @@ #' | -- | :-- | --: | #' | create | /{apiVersion}/organizations/create | include, exclude, includeResult, body[*] | #' | createNotes | /{apiVersion}/organizations/notes/create | include, exclude, includeResult, body[*] | -#' | searchNotes | /{apiVersion}/organizations/notes/search | include, exclude, creationDate, modificationDate, id, scope, visibility, uuid, userId, tags, version | +#' | searchNotes | /{apiVersion}/organizations/notes/search | include, exclude, creationDate, modificationDate, id, type, scope, visibility, uuid, userId, tags, version | #' | deleteNotes | /{apiVersion}/organizations/notes/{id}/delete | id[*], includeResult | #' | updateNotes | /{apiVersion}/organizations/notes/{id}/update | include, exclude, id[*], tagsAction, includeResult, body[*] | #' | userUpdateStatus | /{apiVersion}/organizations/user/{user}/status/update | include, exclude, user[*], organization, includeResult, body[*] | @@ -64,6 +64,7 @@ setMethod("organizationClient", "OpencgaR", function(OpencgaR, id, organization, #' @param creationDate Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. #' @param modificationDate Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. #' @param id Note unique identifier. + #' @param type Note type. #' @param scope Scope of the Note. #' @param visibility Visibility of the Note. #' @param uuid Unique 32-character identifier assigned automatically by OpenCGA. diff --git a/opencga-client/src/main/R/R/Study-methods.R b/opencga-client/src/main/R/R/Study-methods.R index 510511f8633..6bef965d132 100644 --- a/opencga-client/src/main/R/R/Study-methods.R +++ b/opencga-client/src/main/R/R/Study-methods.R @@ -29,7 +29,7 @@ #' | updateGroups | /{apiVersion}/studies/{study}/groups/update | study[*], action, body[*] | #' | updateGroupsUsers | /{apiVersion}/studies/{study}/groups/{group}/users/update | study[*], group[*], action, body[*] | #' | createNotes | /{apiVersion}/studies/{study}/notes/create | include, exclude, study[*], includeResult, body[*] | -#' | searchNotes | /{apiVersion}/studies/{study}/notes/search | include, exclude, study[*], creationDate, modificationDate, id, uuid, userId, tags, visibility, version | +#' | searchNotes | /{apiVersion}/studies/{study}/notes/search | include, exclude, study[*], creationDate, modificationDate, id, type, uuid, userId, tags, visibility, version | #' | deleteNotes | /{apiVersion}/studies/{study}/notes/{id}/delete | study[*], id[*], includeResult | #' | updateNotes | /{apiVersion}/studies/{study}/notes/{id}/update | include, exclude, study[*], id[*], tagsAction, includeResult, body[*] | #' | permissionRules | /{apiVersion}/studies/{study}/permissionRules | study[*], entity[*] | @@ -169,6 +169,7 @@ setMethod("studyClient", "OpencgaR", function(OpencgaR, group, id, members, stud #' @param creationDate Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. #' @param modificationDate Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. #' @param id Note unique identifier. + #' @param type Note type. #' @param uuid Unique 32-character identifier assigned automatically by OpenCGA. #' @param userId User that wrote that Note. #' @param tags Note tags. diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/OrganizationClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/OrganizationClient.java index b5d5a3b7fa1..f8fe3d8d7a4 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/OrganizationClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/OrganizationClient.java @@ -93,6 +93,7 @@ public RestResponse createNotes(NoteCreateParams data, ObjectMap params) t * creationDate: Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * modificationDate: Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * id: Note unique identifier. + * type: Note type. * scope: Scope of the Note. * visibility: Visibility of the Note. * uuid: Unique 32-character identifier assigned automatically by OpenCGA. diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java index b1a8bce6959..a073df38553 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java @@ -252,6 +252,7 @@ public RestResponse createNotes(String study, NoteCreateParams data, Objec * creationDate: Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * modificationDate: Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * id: Note unique identifier. + * type: Note type. * uuid: Unique 32-character identifier assigned automatically by OpenCGA. * userId: User that wrote that Note. * tags: Note tags. diff --git a/opencga-client/src/main/javascript/Organization.js b/opencga-client/src/main/javascript/Organization.js index 09b79429246..59723bae9f7 100644 --- a/opencga-client/src/main/javascript/Organization.js +++ b/opencga-client/src/main/javascript/Organization.js @@ -67,6 +67,7 @@ export default class Organization extends OpenCGAParentClass { * @param {String} [params.creationDate] - Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * @param {String} [params.modificationDate] - Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * @param {String} [params.id] - Note unique identifier. + * @param {String} [params.type] - Note type. * @param {String} [params.scope] - Scope of the Note. * @param {String} [params.visibility] - Visibility of the Note. * @param {String} [params.uuid] - Unique 32-character identifier assigned automatically by OpenCGA. diff --git a/opencga-client/src/main/javascript/Study.js b/opencga-client/src/main/javascript/Study.js index 0d5afff54e5..a4139fa1813 100644 --- a/opencga-client/src/main/javascript/Study.js +++ b/opencga-client/src/main/javascript/Study.js @@ -188,6 +188,7 @@ export default class Study extends OpenCGAParentClass { * @param {String} [params.creationDate] - Creation date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * @param {String} [params.modificationDate] - Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. * @param {String} [params.id] - Note unique identifier. + * @param {String} [params.type] - Note type. * @param {String} [params.uuid] - Unique 32-character identifier assigned automatically by OpenCGA. * @param {String} [params.userId] - User that wrote that Note. * @param {String} [params.tags] - Note tags. diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/organization_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/organization_client.py index 0d7dc0ff159..ff7a5423da9 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/organization_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/organization_client.py @@ -66,6 +66,7 @@ def search_notes(self, **options): :param str modification_date: Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. :param str id: Note unique identifier. + :param str type: Note type. :param str scope: Scope of the Note. :param str visibility: Visibility of the Note. :param str uuid: Unique 32-character identifier assigned automatically diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py index 1a0644bed87..2ab53b7c02a 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py @@ -229,6 +229,7 @@ def search_notes(self, study, **options): :param str modification_date: Modification date. Format: yyyyMMddHHmmss. Examples: >2018, 2017-2018, <201805. :param str id: Note unique identifier. + :param str type: Note type. :param str uuid: Unique 32-character identifier assigned automatically by OpenCGA. :param str user_id: User that wrote that Note. diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java b/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java index 23b8cee110a..d23e55a5d16 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java @@ -54,6 +54,7 @@ public class FieldConstants { public static final String NOTES_ID_DESCRIPTION = "Note unique identifier."; public static final String NOTES_SCOPE_DESCRIPTION = "Scope of the Note."; public static final String NOTES_STUDY_DESCRIPTION = "Study FQN if the Note scope is STUDY."; + public static final String NOTES_TYPE_DESCRIPTION = "Note type."; public static final String NOTES_TAGS_DESCRIPTION = "Note tags."; public static final String NOTES_USER_ID_DESCRIPTION = "User that wrote that Note."; public static final String NOTES_VISIBILITY_DESCRIPTION = "Visibility of the Note."; @@ -62,6 +63,7 @@ public class FieldConstants { public static final String NOTES_ID_PARAM = "id"; public static final String NOTES_SCOPE_PARAM = "scope"; + public static final String NOTES_TYPE_PARAM = "type"; public static final String NOTES_STUDY_PARAM = "study"; public static final String NOTES_TAGS_PARAM = "tags"; public static final String NOTES_USER_ID_PARAM = "userId"; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/Note.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/Note.java index ac12c5a474e..789fdd79a3f 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/Note.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/Note.java @@ -26,6 +26,9 @@ public class Note extends PrivateStudyUid { @DataField(id = "study", indexed = true, immutable = true, description = FieldConstants.NOTES_STUDY_DESCRIPTION) private String study; + @DataField(id = "type", indexed = true, description = FieldConstants.NOTES_TYPE_DESCRIPTION) + private NoteType type; + @DataField(id = "tags", indexed = true, description = FieldConstants.NOTES_TAGS_DESCRIPTION) private List tags; @@ -73,12 +76,13 @@ public enum Type { public Note() { } - public Note(String id, String uuid, Scope scope, String study, List tags, String userId, Visibility visibility, int version, - String creationDate, String modificationDate, Type valueType, Object value) { + public Note(String id, String uuid, Scope scope, String study, NoteType type, List tags, String userId, Visibility visibility, + int version, String creationDate, String modificationDate, Type valueType, Object value) { this.id = id; this.uuid = uuid; this.scope = scope; this.study = study; + this.type = type; this.tags = tags; this.userId = userId; this.visibility = visibility; @@ -91,11 +95,12 @@ public Note(String id, String uuid, Scope scope, String study, List tags @Override public String toString() { - final StringBuilder sb = new StringBuilder("Notes{"); + final StringBuilder sb = new StringBuilder("Note{"); sb.append("id='").append(id).append('\''); sb.append(", uuid='").append(uuid).append('\''); sb.append(", scope=").append(scope); sb.append(", study='").append(study).append('\''); + sb.append(", type=").append(type); sb.append(", tags=").append(tags); sb.append(", userId='").append(userId).append('\''); sb.append(", visibility=").append(visibility); @@ -144,6 +149,15 @@ public Note setStudy(String study) { return this; } + public NoteType getType() { + return type; + } + + public Note setType(NoteType type) { + this.type = type; + return this; + } + public List getTags() { return tags; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteCreateParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteCreateParams.java index dfc277ccce9..3924ce431cc 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteCreateParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteCreateParams.java @@ -8,6 +8,7 @@ public class NoteCreateParams { private String id; + private NoteType type; private List tags; private Note.Visibility visibility; private Note.Type valueType; @@ -16,8 +17,9 @@ public class NoteCreateParams { public NoteCreateParams() { } - public NoteCreateParams(String id, List tags, Note.Visibility visibility, Note.Type valueType, Object value) { + public NoteCreateParams(String id, NoteType type, List tags, Note.Visibility visibility, Note.Type valueType, Object value) { this.id = id; + this.type = type; this.tags = tags; this.visibility = visibility; this.valueType = valueType; @@ -26,8 +28,9 @@ public NoteCreateParams(String id, List tags, Note.Visibility visibility @Override public String toString() { - final StringBuilder sb = new StringBuilder("NotesCreateParams{"); + final StringBuilder sb = new StringBuilder("NoteCreateParams{"); sb.append("id='").append(id).append('\''); + sb.append(", type=").append(type); sb.append(", tags=").append(tags); sb.append(", visibility=").append(visibility); sb.append(", valueType=").append(valueType); @@ -37,8 +40,8 @@ public String toString() { } public Note toNote(Note.Scope scope, String userId) { - return new Note(id, null, scope, null, tags != null ? tags : Collections.emptyList(), userId, visibility, 1, TimeUtils.getTime(), - TimeUtils.getTime(), valueType, value != null ? value : Collections.emptyMap()); + return new Note(id, null, scope, null, type, tags != null ? tags : Collections.emptyList(), userId, visibility, 1, + TimeUtils.getTime(), TimeUtils.getTime(), valueType, value != null ? value : Collections.emptyMap()); } public String getId() { @@ -50,6 +53,15 @@ public NoteCreateParams setId(String id) { return this; } + public NoteType getType() { + return type; + } + + public NoteCreateParams setType(NoteType type) { + this.type = type; + return this; + } + public List getTags() { return tags; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteType.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteType.java new file mode 100644 index 00000000000..a3acf18c6ab --- /dev/null +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteType.java @@ -0,0 +1,20 @@ +package org.opencb.opencga.core.models.notes; + +public enum NoteType { + VARIANT, + GENE, + TRANSCRIPT, + PROTEIN, + JOB, + FILE, + SAMPLE, + INDIVIDUAL, + FAMILY, + COHORT, + DISEASE_PANEL, + CLINICAL_ANALYSIS, + WORKFLOW, + ORGANIZATION, + OTHER, + UNKNOWN +} diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteUpdateParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteUpdateParams.java index ba8c792add0..128f4593c2c 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteUpdateParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/notes/NoteUpdateParams.java @@ -10,6 +10,7 @@ public class NoteUpdateParams { + private NoteType type; private List tags; private Note.Visibility visibility; private Object value; @@ -17,7 +18,8 @@ public class NoteUpdateParams { public NoteUpdateParams() { } - public NoteUpdateParams(List tags, Note.Visibility visibility, Object value) { + public NoteUpdateParams(NoteType type, List tags, Note.Visibility visibility, Object value) { + this.type = type; this.tags = tags; this.visibility = visibility; this.value = value; @@ -30,14 +32,24 @@ public ObjectMap getUpdateMap() throws JsonProcessingException { @Override public String toString() { - final StringBuilder sb = new StringBuilder("NotesUpdateParams{"); - sb.append("tags=").append(tags); + final StringBuilder sb = new StringBuilder("NoteUpdateParams{"); + sb.append("type=").append(type); + sb.append(", tags=").append(tags); sb.append(", visibility=").append(visibility); sb.append(", value=").append(value); sb.append('}'); return sb.toString(); } + public NoteType getType() { + return type; + } + + public NoteUpdateParams setType(NoteType type) { + this.type = type; + return this; + } + public List getTags() { return tags; } diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OrganizationWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OrganizationWSServer.java index 73079cf2704..16bbd794232 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OrganizationWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OrganizationWSServer.java @@ -161,6 +161,7 @@ public Response noteSearch( @ApiParam(value = ParamConstants.CREATION_DATE_DESCRIPTION) @QueryParam(ParamConstants.CREATION_DATE_PARAM) String creationDate, @ApiParam(value = ParamConstants.MODIFICATION_DATE_DESCRIPTION) @QueryParam(ParamConstants.MODIFICATION_DATE_PARAM) String modificationDate, @ApiParam(value = FieldConstants.NOTES_ID_DESCRIPTION) @QueryParam(FieldConstants.NOTES_ID_PARAM) String noteId, + @ApiParam(value = FieldConstants.NOTES_TYPE_DESCRIPTION) @QueryParam(FieldConstants.NOTES_TYPE_PARAM) String type, @ApiParam(value = FieldConstants.NOTES_SCOPE_DESCRIPTION) @QueryParam(FieldConstants.NOTES_SCOPE_PARAM) String scope, @ApiParam(value = FieldConstants.NOTES_VISIBILITY_DESCRIPTION) @QueryParam(FieldConstants.NOTES_VISIBILITY_PARAM) String visibility, @ApiParam(value = FieldConstants.GENERIC_UUID_DESCRIPTION) @QueryParam("uuid") String uuid, diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/StudyWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/StudyWSServer.java index 8492d30c490..ed3cc499fb7 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/StudyWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/StudyWSServer.java @@ -571,6 +571,7 @@ public Response noteSearch( @ApiParam(value = ParamConstants.CREATION_DATE_DESCRIPTION) @QueryParam(ParamConstants.CREATION_DATE_PARAM) String creationDate, @ApiParam(value = ParamConstants.MODIFICATION_DATE_DESCRIPTION) @QueryParam(ParamConstants.MODIFICATION_DATE_PARAM) String modificationDate, @ApiParam(value = FieldConstants.NOTES_ID_DESCRIPTION) @QueryParam(FieldConstants.NOTES_ID_PARAM) String noteId, + @ApiParam(value = FieldConstants.NOTES_TYPE_DESCRIPTION) @QueryParam(FieldConstants.NOTES_TYPE_PARAM) String type, @ApiParam(value = FieldConstants.GENERIC_UUID_DESCRIPTION) @QueryParam("uuid") String uuid, @ApiParam(value = FieldConstants.NOTES_USER_ID_DESCRIPTION) @QueryParam(FieldConstants.NOTES_USER_ID_PARAM) String userId, @ApiParam(value = FieldConstants.NOTES_TAGS_DESCRIPTION) @QueryParam(FieldConstants.NOTES_TAGS_PARAM) String tags,