|
47 | 47 | import org.ohdsi.webapi.service.dto.ConceptSetDTO;
|
48 | 48 | import org.ohdsi.webapi.service.dto.ConceptSetAnnotationDTO;
|
49 | 49 | import org.ohdsi.webapi.service.dto.AnnotationDTO;
|
| 50 | +import org.ohdsi.webapi.service.dto.CopyAnnotationsRequest; |
50 | 51 | import org.ohdsi.webapi.shiro.Entities.UserEntity;
|
51 | 52 | import org.ohdsi.webapi.shiro.Entities.UserRepository;
|
52 | 53 | import org.ohdsi.webapi.shiro.management.Security;
|
@@ -916,6 +917,32 @@ public boolean saveConceptSetAnnotation(@PathParam("id") final int id, ConceptSe
|
916 | 917 | return true;
|
917 | 918 | }
|
918 | 919 |
|
| 920 | + private ConceptSetAnnotation copyAnnotation(ConceptSetAnnotation sourceConceptSetAnnotation, int targetConceptSetId){ |
| 921 | + ConceptSetAnnotation targetConceptSetAnnotation = new ConceptSetAnnotation(); |
| 922 | + targetConceptSetAnnotation.setConceptSetId(targetConceptSetId); |
| 923 | + targetConceptSetAnnotation.setConceptSetVersion(sourceConceptSetAnnotation.getConceptSetVersion()); |
| 924 | + targetConceptSetAnnotation.setAnnotationDetails(sourceConceptSetAnnotation.getAnnotationDetails()); |
| 925 | + targetConceptSetAnnotation.setConceptId(sourceConceptSetAnnotation.getConceptId()); |
| 926 | + targetConceptSetAnnotation.setVocabularyVersion(sourceConceptSetAnnotation.getVocabularyVersion()); |
| 927 | + targetConceptSetAnnotation.setCreatedBy(sourceConceptSetAnnotation.getCreatedBy()); |
| 928 | + targetConceptSetAnnotation.setCreatedDate(sourceConceptSetAnnotation.getCreatedDate()); |
| 929 | + targetConceptSetAnnotation.setModifiedBy(sourceConceptSetAnnotation.getModifiedBy()); |
| 930 | + targetConceptSetAnnotation.setModifiedDate(sourceConceptSetAnnotation.getModifiedDate()); |
| 931 | + return targetConceptSetAnnotation; |
| 932 | + } |
| 933 | + |
| 934 | + @POST |
| 935 | + @Path("/copy-annotations") |
| 936 | + @Produces(MediaType.APPLICATION_JSON) |
| 937 | + @Transactional |
| 938 | + public void copyAnnotations(CopyAnnotationsRequest copyAnnotationsRequest ) { |
| 939 | + List<ConceptSetAnnotation> sourceAnnotations = getConceptSetAnnotationRepository().findByConceptSetId(copyAnnotationsRequest.getSourceConceptSetId()); |
| 940 | + List<ConceptSetAnnotation> copiedAnnotations= sourceAnnotations.stream() |
| 941 | + .map(sourceAnnotation -> copyAnnotation(sourceAnnotation, copyAnnotationsRequest.getTargetConceptSetId())) |
| 942 | + .collect(Collectors.toList()); |
| 943 | + getConceptSetAnnotationRepository().save(copiedAnnotations); |
| 944 | + } |
| 945 | + |
919 | 946 | @GET
|
920 | 947 | @Path("/{id}/annotation")
|
921 | 948 | @Produces(MediaType.APPLICATION_JSON)
|
|
0 commit comments