Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending Concept Set Items with Annotations #2403

Merged
merged 19 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e6c3857
ATL-17: Updating branch with latest release
hernaldourbina Mar 26, 2024
633eb78
ATL-17: Add feature about the metadata in concept set
May 3, 2024
757929a
Fixing migration scripts and Concept Set Service to save and update m…
alex-odysseus Jun 4, 2024
83579dd
[ATL-17] Refactored the annotations feature. Renamed metadata to anno…
oleg-odysseus Jun 28, 2024
7e9359c
[ATL-17] Fixed issue with clashing endpoints for conceptset delete op…
oleg-odysseus Jul 16, 2024
25f44ae
Correcting newly adjusted DELETE endpoint notation
alex-odysseus Jul 17, 2024
948fde3
Fixing the previous commit as the endpoint is DELETE /conceptset/anno…
alex-odysseus Jul 17, 2024
0fff858
Fixing the notation as the endpoint is DELETE /conceptset/annotation/…
alex-odysseus Jul 17, 2024
7adb69b
[ATL-58] Added concept set version to annotations
oleg-odysseus Jul 26, 2024
f40a666
[ATL-58] Implemented copying of annotations along with ConceptSet
oleg-odysseus Jul 30, 2024
2b9c35a
[ATL-58] Fixed permissions issues for annotations feature, transforme…
oleg-odysseus Aug 6, 2024
485b41a
Fix for annotation search data shown as JSON instead of human readabl…
oleg-odysseus Aug 22, 2024
937c72e
Added 'Copied From' list of concept set ids for concept set annotations
oleg-odysseus Sep 12, 2024
6a88e5d
Added i18n records for Origin Concept Sets ('Copied From' feature in …
oleg-odysseus Sep 18, 2024
deed559
A combined migration script has been assembled
alex-odysseus Nov 6, 2024
1f6476c
Changed owner/permissions check for annotations delete to consider ow…
oleg-odysseus Nov 9, 2024
4ee6b48
Added migration script to re-create annotation-related permissions. A…
oleg-odysseus Nov 9, 2024
57491c3
Changed SearchDataTransformer in accordance with the community discus…
oleg-odysseus Nov 9, 2024
4c3a304
Permissions update, concept_set_version column type change to integer
alex-odysseus Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/org/ohdsi/webapi/conceptset/ConceptSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.OneToOne;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.webapi.model.CommonEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package org.ohdsi.webapi.conceptset.annotation;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.webapi.model.CommonEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

@Entity(name = "ConceptSetAnnotation")
@Table(name = "concept_set_annotation")
public class ConceptSetAnnotation implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;

@Id
@GenericGenerator(
name = "concept_set_annotation_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "concept_set_annotation_sequence"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "concept_set_annotation_generator")
@Column(name = "concept_set_annotation_id")
private Integer id;

@Column(name = "concept_set_id", nullable = false)
private Integer conceptSetId;

@Column(name = "concept_id")
private Integer conceptId;

@Column(name = "annotation_details")
private String annotationDetails;

@Column(name = "vocabulary_version")
private String vocabularyVersion;

@Column(name = "concept_set_version")
private Integer conceptSetVersion;

@Column(name = "copied_from_concept_set_ids")
private String copiedFromConceptSetIds;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getConceptSetId() {
return conceptSetId;
}

public void setConceptSetId(Integer conceptSetId) {
this.conceptSetId = conceptSetId;
}

public Integer getConceptId() {
return conceptId;
}

public void setConceptId(Integer conceptId) {
this.conceptId = conceptId;
}

public String getAnnotationDetails() {
return annotationDetails;
}

public void setAnnotationDetails(String annotationDetails) {
this.annotationDetails = annotationDetails;
}

public String getVocabularyVersion() {
return vocabularyVersion;
}

public void setVocabularyVersion(String vocabularyVersion) {
this.vocabularyVersion = vocabularyVersion;
}

public Integer getConceptSetVersion() {
return conceptSetVersion;
}

public void setConceptSetVersion(Integer conceptSetVersion) {
this.conceptSetVersion = conceptSetVersion;
}

public String getCopiedFromConceptSetIds() {
return copiedFromConceptSetIds;
}

public void setCopiedFromConceptSetIds(String copiedFromConceptSetIds) {
this.copiedFromConceptSetIds = copiedFromConceptSetIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.ohdsi.webapi.conceptset.annotation;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface ConceptSetAnnotationRepository extends JpaRepository<ConceptSetAnnotation, Integer> {

@Query("DELETE FROM ConceptSetAnnotation cc WHERE cc.conceptSetId = :conceptSetId and cc.conceptId in :conceptId")
void deleteAnnotationByConceptSetIdAndInConceptId(int conceptSetId, List<Integer> conceptId);

void deleteAnnotationByConceptSetIdAndConceptId(int conceptSetId, int conceptId);

List<ConceptSetAnnotation> findByConceptSetId(int conceptSetId);
ConceptSetAnnotation findById(int id);
void deleteById(int id);
Optional<ConceptSetAnnotation> findConceptSetAnnotationByConceptIdAndConceptId(int conceptSetId, int conceptId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ public class ConceptSetPermissionSchema extends EntityPermissionSchema {
private static Map<String, String> writePermissions = new HashMap<String, String>() {{
put("conceptset:%s:put", "Update Concept Set with ID = %s");
put("conceptset:%s:items:put", "Update Items of Concept Set with ID = %s");
put("conceptset:*:annotation:put", "Create Concept Set Annotation");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be * permissions. What happens is that when you delete the entity, it finds the write permission schema and deletes it, thus deleting the wildcard permission' from all users, and then preventing access to the endpiont for all users.

However, this is what happens when you extend the 'CommonEntity' which you didn't do in this case, however, ou are using a permissionSchema as if it was a common entity, so there may be a little confusion here.

But, in any case, we shouldn't see * permissions in any writePermission schema because these permission schemas are targeting a specific entity ID.

put("conceptset:%s:annotation:*:delete", "Delete Annotations of Concept Set with ID = %s");
put("conceptset:*:annotation:*:delete", "Delete Annotations of any Concept Set");
put("conceptset:%s:delete", "Delete Concept Set with ID = %s");
}};

private static Map<String, String> readPermissions = new HashMap<String, String>() {{
put("conceptset:%s:get", "view conceptset definition with id %s");
put("conceptset:%s:expression:get", "Resolve concept set %s expression");
put("conceptset:%s:annotation:get", "Resolve concept set annotations");
put("conceptset:*:annotation:get", "Resolve concept set annotations");
put("conceptset:%s:version:*:expression:get", "Get expression for concept set %s items for default source");
}};

public ConceptSetPermissionSchema() {

super(EntityType.CONCEPT_SET, readPermissions, writePermissions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public enum EntityType {
COHORT_SAMPLE(CohortSample.class),
TAG(Tag.class),
REUSABLE(Reusable.class);

private final Class<? extends CommonEntity> entityClass;

EntityType(Class<? extends CommonEntity> entityClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.ohdsi.webapi.conceptset.ConceptSetComparison;
import org.ohdsi.webapi.conceptset.ConceptSetItemRepository;
import org.ohdsi.webapi.conceptset.ConceptSetRepository;
import org.ohdsi.webapi.conceptset.annotation.ConceptSetAnnotationRepository;
import org.ohdsi.webapi.exception.BadRequestAtlasException;
import org.ohdsi.webapi.ircalc.IncidenceRateAnalysis;
import org.ohdsi.webapi.model.CommonEntity;
Expand Down Expand Up @@ -106,6 +107,9 @@ public abstract class AbstractDaoService extends AbstractAdminService {
@Autowired
private ConceptSetItemRepository conceptSetItemRepository;

@Autowired
private ConceptSetAnnotationRepository conceptSetAnnotationRepository;

@Autowired
protected Security security;

Expand All @@ -120,6 +124,9 @@ public abstract class AbstractDaoService extends AbstractAdminService {
public ConceptSetItemRepository getConceptSetItemRepository() {
return conceptSetItemRepository;
}
public ConceptSetAnnotationRepository getConceptSetAnnotationRepository() {
return conceptSetAnnotationRepository;
}

@Autowired
private ConceptSetRepository conceptSetRepository;
Expand Down
Loading
Loading