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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion 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 All @@ -36,7 +37,7 @@
*
* @author fdefalco
*/
@Entity(name = "ConceptSet")
@Entity(name="ConceptSet")
@Table(name="concept_set")
public class ConceptSet extends CommonEntityExt<Integer> implements Serializable {

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 extends CommonEntity<Integer> 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 String 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 String getConceptSetVersion() {
return conceptSetVersion;
}

public void setConceptSetVersion(String 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
@@ -0,0 +1,25 @@
package org.ohdsi.webapi.security.model;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class ConceptSetAnnotationPermissionSchema extends EntityPermissionSchema {

private static Map<String, String> writePermissions = new HashMap<String, String>() {
{
put("conceptset:annotation:%s:delete", "Delete Concept Set Annotation with ID %s");
}
};

private static Map<String, String> readPermissions = new HashMap<String, String>() {
{
}
};
Comment on lines +11 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is odd to me:

Shouldn't the writePermissions contain all permissions related to creating annotations and the read have the ones related to reading annotations?


public ConceptSetAnnotationPermissionSchema() {
super(EntityType.CONCEPT_SET_ANNOTATION, readPermissions, writePermissions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortsample.CohortSample;
import org.ohdsi.webapi.conceptset.ConceptSet;
import org.ohdsi.webapi.conceptset.annotation.ConceptSetAnnotation;
import org.ohdsi.webapi.estimation.Estimation;
import org.ohdsi.webapi.feanalysis.domain.FeAnalysisEntity;
import org.ohdsi.webapi.ircalc.IncidenceRateAnalysis;
Expand All @@ -26,7 +27,8 @@ public enum EntityType {
PREDICTION(PredictionAnalysis.class),
COHORT_SAMPLE(CohortSample.class),
TAG(Tag.class),
REUSABLE(Reusable.class);
REUSABLE(Reusable.class),
CONCEPT_SET_ANNOTATION(ConceptSetAnnotation.class);

private final 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