Skip to content

Commit 937c72e

Browse files
oleg-odysseusalex-odysseus
authored andcommitted
Added 'Copied From' list of concept set ids for concept set annotations
1 parent 485b41a commit 937c72e

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/main/java/org/ohdsi/webapi/conceptset/annotation/ConceptSetAnnotation.java

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public class ConceptSetAnnotation extends CommonEntity<Integer> implements Seria
4747
@Column(name = "concept_set_version")
4848
private String conceptSetVersion;
4949

50+
@Column(name = "copied_from_concept_set_ids")
51+
private String copiedFromConceptSetIds;
52+
5053
public Integer getId() {
5154
return id;
5255
}
@@ -94,4 +97,12 @@ public String getConceptSetVersion() {
9497
public void setConceptSetVersion(String conceptSetVersion) {
9598
this.conceptSetVersion = conceptSetVersion;
9699
}
100+
101+
public String getCopiedFromConceptSetIds() {
102+
return copiedFromConceptSetIds;
103+
}
104+
105+
public void setCopiedFromConceptSetIds(String copiedFromConceptSetIds) {
106+
this.copiedFromConceptSetIds = copiedFromConceptSetIds;
107+
}
97108
}

src/main/java/org/ohdsi/webapi/service/ConceptSetService.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.fasterxml.jackson.databind.ObjectMapper;
3131

3232
import org.apache.commons.collections4.CollectionUtils;
33+
import org.apache.commons.lang3.StringUtils;
3334
import org.apache.shiro.authz.UnauthorizedException;
3435
import org.ohdsi.circe.vocabulary.ConceptSetExpression;
3536
import org.ohdsi.vocabulary.Concept;
@@ -929,7 +930,7 @@ private void removeAnnotations(int id, SaveConceptSetAnnotationsRequest request)
929930
}
930931
}
931932
}
932-
private ConceptSetAnnotation copyAnnotation(ConceptSetAnnotation sourceConceptSetAnnotation, int targetConceptSetId){
933+
private ConceptSetAnnotation copyAnnotation(ConceptSetAnnotation sourceConceptSetAnnotation, int sourceConceptSetId, int targetConceptSetId){
933934
ConceptSetAnnotation targetConceptSetAnnotation = new ConceptSetAnnotation();
934935
targetConceptSetAnnotation.setConceptSetId(targetConceptSetId);
935936
targetConceptSetAnnotation.setConceptSetVersion(sourceConceptSetAnnotation.getConceptSetVersion());
@@ -940,17 +941,25 @@ private ConceptSetAnnotation copyAnnotation(ConceptSetAnnotation sourceConceptSe
940941
targetConceptSetAnnotation.setCreatedDate(sourceConceptSetAnnotation.getCreatedDate());
941942
targetConceptSetAnnotation.setModifiedBy(sourceConceptSetAnnotation.getModifiedBy());
942943
targetConceptSetAnnotation.setModifiedDate(sourceConceptSetAnnotation.getModifiedDate());
944+
targetConceptSetAnnotation.setCopiedFromConceptSetIds(appendCopiedFromConceptSetId(sourceConceptSetAnnotation.getCopiedFromConceptSetIds(), sourceConceptSetId));
943945
return targetConceptSetAnnotation;
944946
}
945947

948+
private String appendCopiedFromConceptSetId(String copiedFromConceptSetIds, int sourceConceptSetId) {
949+
if(StringUtils.isEmpty(copiedFromConceptSetIds)){
950+
return Integer.toString(sourceConceptSetId);
951+
}
952+
return copiedFromConceptSetIds.concat(",").concat(Integer.toString(sourceConceptSetId));
953+
}
954+
946955
@POST
947956
@Path("/copy-annotations")
948957
@Produces(MediaType.APPLICATION_JSON)
949958
@Transactional
950959
public void copyAnnotations(CopyAnnotationsRequest copyAnnotationsRequest ) {
951960
List<ConceptSetAnnotation> sourceAnnotations = getConceptSetAnnotationRepository().findByConceptSetId(copyAnnotationsRequest.getSourceConceptSetId());
952961
List<ConceptSetAnnotation> copiedAnnotations= sourceAnnotations.stream()
953-
.map(sourceAnnotation -> copyAnnotation(sourceAnnotation, copyAnnotationsRequest.getTargetConceptSetId()))
962+
.map(sourceAnnotation -> copyAnnotation(sourceAnnotation, copyAnnotationsRequest.getSourceConceptSetId(), copyAnnotationsRequest.getTargetConceptSetId()))
954963
.collect(Collectors.toList());
955964
getConceptSetAnnotationRepository().save(copiedAnnotations);
956965
}
@@ -985,6 +994,7 @@ private AnnotationDTO convertAnnotationEntityToDTO(ConceptSetAnnotation conceptS
985994

986995
annotationDTO.setVocabularyVersion(conceptSetAnnotation.getVocabularyVersion());
987996
annotationDTO.setConceptSetVersion(conceptSetAnnotation.getConceptSetVersion());
997+
annotationDTO.setCopiedFromConceptSetIds(conceptSetAnnotation.getCopiedFromConceptSetIds());
988998
annotationDTO.setCreatedBy(conceptSetAnnotation.getCreatedBy() != null ? conceptSetAnnotation.getCreatedBy().getName() : null);
989999
annotationDTO.setCreatedDate(conceptSetAnnotation.getCreatedDate() != null ? conceptSetAnnotation.getCreatedDate().toString() : null);
9901000

src/main/java/org/ohdsi/webapi/service/dto/AnnotationDTO.java

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class AnnotationDTO {
1111
private String vocabularyVersion;
1212
private String conceptSetVersion;
1313
private String searchData;
14+
private String copiedFromConceptSetIds;
1415
private Integer conceptId;
1516

1617
public String getCreatedBy() {
@@ -68,4 +69,12 @@ public Integer getConceptId() {
6869
public void setConceptId(Integer conceptId) {
6970
this.conceptId = conceptId;
7071
}
72+
73+
public String getCopiedFromConceptSetIds() {
74+
return copiedFromConceptSetIds;
75+
}
76+
77+
public void setCopiedFromConceptSetIds(String copiedFromConceptSetIds) {
78+
this.copiedFromConceptSetIds = copiedFromConceptSetIds;
79+
}
7180
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE ${ohdsiSchema}.concept_set_annotation ADD copied_from_concept_set_ids VARCHAR;

0 commit comments

Comments
 (0)