diff --git a/build.gradle b/build.gradle index 9737999..e062c90 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { } group = 'org.monarchinitiative.poet' -version = '1.0.6' +version = '1.0.8' sourceCompatibility = '11' configurations { diff --git a/src/main/java/org/monarchinitiative/poet/model/entities/AnnotationSource.java b/src/main/java/org/monarchinitiative/poet/model/entities/AnnotationSource.java index 317e44f..d67e516 100644 --- a/src/main/java/org/monarchinitiative/poet/model/entities/AnnotationSource.java +++ b/src/main/java/org/monarchinitiative/poet/model/entities/AnnotationSource.java @@ -8,6 +8,10 @@ import java.util.Objects; @Entity +@Table( + uniqueConstraints= + @UniqueConstraint(columnNames={"publication_id", "disease_id"}) +) public class AnnotationSource { @Id diff --git a/src/main/java/org/monarchinitiative/poet/model/entities/TreatmentAnnotation.java b/src/main/java/org/monarchinitiative/poet/model/entities/TreatmentAnnotation.java index 04f86be..70bddb1 100644 --- a/src/main/java/org/monarchinitiative/poet/model/entities/TreatmentAnnotation.java +++ b/src/main/java/org/monarchinitiative/poet/model/entities/TreatmentAnnotation.java @@ -134,4 +134,11 @@ public String getExtensionId() { public String getExtensionLabel() { return extensionLabel; } + + public String getExportPhenotypeId() { + if (hpoId.equals("HP:0000118")){ + return super.getAnnotationSource().getDisease().getExportDiseaseId(); + } + return hpoId; + } } diff --git a/src/main/java/org/monarchinitiative/poet/service/ExportService.java b/src/main/java/org/monarchinitiative/poet/service/ExportService.java index 6d50090..b15c3f3 100644 --- a/src/main/java/org/monarchinitiative/poet/service/ExportService.java +++ b/src/main/java/org/monarchinitiative/poet/service/ExportService.java @@ -93,9 +93,10 @@ public void exportMAXOAnnotations(PrintWriter writer, CSVFormat format, boolean annotationService.getLastUpdatedForAnnotation(annotation); annotationService.getCreatedDateForAnnotation(annotation); + String hpoId = annotation.getHpoId(); csvPrinter.printRecord(annotation.getAnnotationSource().getDisease().getExportDiseaseId(), annotation.getAnnotationSource().getDisease().getDiseaseName(), reference, - annotation.getMaxoId(), annotation.getMaxoName(), annotation.getHpoId(), annotation.getRelation(), + annotation.getMaxoId(), annotation.getMaxoName(), annotation.getExportPhenotypeId(), annotation.getRelation(), annotation.getEvidence(), annotation.getExtensionId(), annotation.getExtensionLabel(), annotation.getComment(), "", annotation.getOwner().getExportName(), annotation.getExportLastUpdatedDate(), annotation.getCreatedDate() ); diff --git a/src/main/poet/package-lock.json b/src/main/poet/package-lock.json index 0a24107..9766a9a 100644 --- a/src/main/poet/package-lock.json +++ b/src/main/poet/package-lock.json @@ -1,12 +1,12 @@ { "name": "poet", - "version": "1.0.6", + "version": "1.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "poet", - "version": "1.0.6", + "version": "1.0.8", "dependencies": { "@angular/animations": "^14.2.12", "@angular/cdk": "^14.2.7", diff --git a/src/main/poet/package.json b/src/main/poet/package.json index 5ffe435..5b706d3 100644 --- a/src/main/poet/package.json +++ b/src/main/poet/package.json @@ -1,6 +1,6 @@ { "name": "poet", - "version": "1.0.6", + "version": "1.0.8", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.html b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.html index 0987d29..a0c660b 100644 --- a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.html +++ b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.html @@ -1,15 +1,9 @@ -

Source Selection

+ - - add_box -
- Add New Publication for {{selectedDisease.diseaseName}} -
-
diff --git a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.scss b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.scss index 76f5283..f8bc218 100644 --- a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.scss +++ b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.scss @@ -61,3 +61,7 @@ margin: 0 auto; text-align: center; } + +.new-btn { + margin-left: 1rem; +} diff --git a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.ts b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.ts index 48ce812..b5c9221 100644 --- a/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.ts +++ b/src/main/poet/src/app/portal/portal-curate/dialog-source/dialog-source.component.ts @@ -3,7 +3,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; import { UntypedFormControl, FormGroupDirective, NgForm, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { CurationService } from '../../../shared/services/curation/curation.service'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs/operators'; import { PubmedService } from '../../../shared/services/external/pubmed.service'; import { StateService } from '../../../shared/services/state/state.service'; import { Publication } from '../../../shared/models/models'; @@ -105,17 +105,28 @@ export class DialogSourceComponent implements OnInit { firstAuthor: this.selectedPublication.sortfirstauthor } }; - this.curationService.savePublication(source).subscribe(() => { - this.annotatedPublications$ = this.curationService.getDiseasePublications(this.selectedDisease.diseaseId); - this.newPublication = false; - this.selectedPublication = source.publication; - this.closeDialog(); - }, error => { - const message = this.getErrorMessage(error); - this._snackBar.open(message, 'Close', { - duration: 5000, - }); - }); + + this.annotatedPublications$.pipe( + map(items => + items.filter(item => item.publicationId == source.publication.publicationId) + )).subscribe((existing) => { + if(existing && existing.length > 0){ + this.newPublication = false; + this.selectPublication(existing[0]); + } else { + this.curationService.savePublication(source).subscribe(() => { + this.annotatedPublications$ = this.curationService.getDiseasePublications(this.selectedDisease.diseaseId); + this.newPublication = false; + this.selectedPublication = source.publication; + this.closeDialog(); + }, error => { + const message = this.getErrorMessage(error); + this._snackBar.open(message, 'Close', { + duration: 5000, + }); + }); + } + }) } getErrorMessage(error: any) {