Skip to content

Commit

Permalink
catalog: add new type field in Note data model, #TASK-7046
Browse files Browse the repository at this point in the history
  • Loading branch information
pfurio committed Oct 7, 2024
1 parent 3b7a8df commit 0f94256
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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, ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ public void runMigration(String organizationId, String version, Collection<Migra
for (Class<? extends MigrationTool> 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<Class<? extends MigrationTool>> getPendingMigrations(String organizationId, String version, String token)
Expand Down
1 change: 1 addition & 0 deletions opencga-catalog/src/main/resources/catalog-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{"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": {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> tags;

Expand Down Expand Up @@ -73,12 +76,13 @@ public enum Type {
public Note() {
}

public Note(String id, String uuid, Scope scope, String study, List<String> 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<String> 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;
Expand All @@ -91,11 +95,12 @@ public Note(String id, String uuid, Scope scope, String study, List<String> 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);
Expand Down Expand Up @@ -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<String> getTags() {
return tags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class NoteCreateParams {

private String id;
private NoteType type;
private List<String> tags;
private Note.Visibility visibility;
private Note.Type valueType;
Expand All @@ -16,8 +17,9 @@ public class NoteCreateParams {
public NoteCreateParams() {
}

public NoteCreateParams(String id, List<String> tags, Note.Visibility visibility, Note.Type valueType, Object value) {
public NoteCreateParams(String id, NoteType type, List<String> tags, Note.Visibility visibility, Note.Type valueType, Object value) {
this.id = id;
this.type = type;
this.tags = tags;
this.visibility = visibility;
this.valueType = valueType;
Expand All @@ -26,8 +28,9 @@ public NoteCreateParams(String id, List<String> 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);
Expand All @@ -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() {
Expand All @@ -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<String> getTags() {
return tags;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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,
OTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

public class NoteUpdateParams {

private NoteType type;
private List<String> tags;
private Note.Visibility visibility;
private Object value;

public NoteUpdateParams() {
}

public NoteUpdateParams(List<String> tags, Note.Visibility visibility, Object value) {
public NoteUpdateParams(NoteType type, List<String> tags, Note.Visibility visibility, Object value) {
this.type = type;
this.tags = tags;
this.visibility = visibility;
this.value = value;
Expand All @@ -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<String> getTags() {
return tags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,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,
Expand Down

0 comments on commit 0f94256

Please sign in to comment.