From a2da6590de0e268e4590759463d6dcaae97dca2a Mon Sep 17 00:00:00 2001 From: tmushayahama Date: Wed, 13 Jan 2021 20:21:45 -0800 Subject: [PATCH] fix after replace and replace all logistics https://github.com/geneontology/noctua-annotation-review/issues/30 --- .../models/annoton/annoton-node.ts | 3 ++ src/@noctua.form/models/annoton/cam.ts | 8 ++--- src/@noctua.form/services/cam.service.ts | 6 ---- src/@noctua.form/services/cams.service.ts | 4 +-- src/@noctua.form/services/graph.service.ts | 36 ++----------------- .../services/noctua-search.service.ts | 5 ++- .../cam/cam-table/cam-table.component.html | 7 ++-- .../cam/cam-table/cam-table.component.ts | 3 -- .../noctua-search/noctua-search.component.ts | 7 ---- 9 files changed, 17 insertions(+), 62 deletions(-) diff --git a/src/@noctua.form/models/annoton/annoton-node.ts b/src/@noctua.form/models/annoton/annoton-node.ts index 46a71454..bf9cd3d6 100644 --- a/src/@noctua.form/models/annoton/annoton-node.ts +++ b/src/@noctua.form/models/annoton/annoton-node.ts @@ -95,6 +95,9 @@ export class AnnotonNode implements AnnotonNodeDisplay { private _id: string; + //For Save + pendingChangeEntity: Entity; + constructor(annotonNode?: Partial) { if (annotonNode) { this.overrideValues(annotonNode); diff --git a/src/@noctua.form/models/annoton/cam.ts b/src/@noctua.form/models/annoton/cam.ts index 5214f11c..21cd9c7b 100644 --- a/src/@noctua.form/models/annoton/cam.ts +++ b/src/@noctua.form/models/annoton/cam.ts @@ -282,7 +282,7 @@ export class Cam { } } - replace(findEntities: Entity[], replaceWith: Entity) { + addPendingChanges(findEntities: Entity[], replaceWith: Entity) { const self = this; each(self._annotons, (annoton: Annoton) => { @@ -290,10 +290,8 @@ export class Cam { // node.term.highlight = false; each(findEntities, (entity: Entity) => { if (node.term.uuid === entity.uuid) { - node.term.termHistory.push(new Entity(node.term.id, node.term.label)); - node.term.modified = true; - node.term.id = replaceWith.id; - node.term.label = replaceWith.label; + node.pendingChangeEntity = new Entity(replaceWith.id, replaceWith.label); + node.pendingChangeEntity.uuid = node.term.uuid; } }); }); diff --git a/src/@noctua.form/services/cam.service.ts b/src/@noctua.form/services/cam.service.ts index b9f51694..305c5d02 100644 --- a/src/@noctua.form/services/cam.service.ts +++ b/src/@noctua.form/services/cam.service.ts @@ -161,12 +161,6 @@ export class CamService { return result; } - diffModel(cam: Cam) { - const self = this; - - return self._noctuaGraphService.diffModel(cam); - } - resetModel(cam: Cam) { const self = this; diff --git a/src/@noctua.form/services/cams.service.ts b/src/@noctua.form/services/cams.service.ts index 1a34c4da..864f518f 100644 --- a/src/@noctua.form/services/cams.service.ts +++ b/src/@noctua.form/services/cams.service.ts @@ -128,7 +128,7 @@ export class CamsService { return this.httpClient .get(url) .pipe( - map(res => this.populateStoredModel(cam, res)), + map(res => self.populateStoredModel(cam, res)), finalize(() => { }) ); @@ -183,7 +183,7 @@ export class CamsService { each(groupedEntities, (values: Entity[], key) => { const cam: Cam = find(this.cams, { id: key }); if (cam) { - cam.replace(entities, replaceWithTerm); + cam.addPendingChanges(entities, replaceWithTerm); cams.push(cam) } }); diff --git a/src/@noctua.form/services/graph.service.ts b/src/@noctua.form/services/graph.service.ts index 80f2d73c..64b2e0d7 100644 --- a/src/@noctua.form/services/graph.service.ts +++ b/src/@noctua.form/services/graph.service.ts @@ -536,16 +536,6 @@ export class NoctuaGraphService { return connectorAnnotons; } - graphToAnnotonDFSError(annoton, annotonNode) { - const self = this; - const edge = annoton.getEdges(annotonNode.id); - - each(edge.nodes, function (node) { - node.object.status = 2; - self.graphToAnnotonDFSError(annoton, node.object); - }); - } - evidenceUseGroups(reqs, evidence: Evidence) { const self = this; const assignedBy = evidence.assignedBy; @@ -575,16 +565,6 @@ export class NoctuaGraphService { return cam.manager.request_with(reqs); } - diffModel(cam: Cam) { - const self = this; - const reqs = new minerva_requests.request_set(self.noctuaUserService.baristaToken, cam.id); - const req = new minerva_requests.request('model', 'diff'); - req.model(cam.id); - reqs.add(req, 'query'); - - return cam.artManager.request_with(reqs); - } - storeModel(cam: Cam) { const self = this; const reqs = new minerva_requests.request_set(self.noctuaUserService.baristaToken, cam.id); @@ -597,16 +577,6 @@ export class NoctuaGraphService { return cam.manager.request_with(reqs); } - storedModel(cam: Cam) { - const self = this; - const reqs = new minerva_requests.request_set(self.noctuaUserService.baristaToken, cam.id); - const req = new minerva_requests.request('model', 'get-stored-model'); - req.model(cam.id); - reqs.add(req, 'query'); - - return cam.artManager.request_with(reqs); - } - saveCamAnnotations(cam: Cam, annotations) { const self = this; @@ -935,7 +905,7 @@ export class NoctuaGraphService { } bulkEditIndividual(reqs, cam: Cam, node: AnnotonNode) { - if (node.hasValue() && node.term.modified) { + if (node.hasValue() && node.pendingChangeEntity) { reqs.remove_type_from_individual( node.classExpression, node.uuid, @@ -943,8 +913,8 @@ export class NoctuaGraphService { ); reqs.add_type_to_individual( - class_expression.cls(node.getTerm().id), - node.uuid, + class_expression.cls(node.pendingChangeEntity.id), + node.pendingChangeEntity.uuid, cam.id, ); } diff --git a/src/@noctua.search/services/noctua-search.service.ts b/src/@noctua.search/services/noctua-search.service.ts index f48f33b7..b45a3caa 100644 --- a/src/@noctua.search/services/noctua-search.service.ts +++ b/src/@noctua.search/services/noctua-search.service.ts @@ -23,6 +23,7 @@ import { CamPage } from './../models/cam-page'; import { SearchHistory } from './../models/search-history'; import { NoctuaDataService } from '@noctua.common/services/noctua-data.service'; import { NoctuaSearchMenuService } from './search-menu.service'; +import { MiddlePanel } from '../models/menu-panels'; declare const require: any; @@ -102,7 +103,9 @@ export class NoctuaSearchService { this.onCamsPageChanged.next(this.camPage); }); - this.noctuaSearchMenuService.resetResults(); + if (this.noctuaSearchMenuService.selectedMiddlePanel === MiddlePanel.cams) { + this.noctuaSearchMenuService.resetResults(); + } }); } diff --git a/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.html b/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.html index aa6cff71..4d752504 100644 --- a/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.html +++ b/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.html @@ -14,15 +14,12 @@ - diff --git a/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.ts b/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.ts index 259012f0..dbb1aafe 100644 --- a/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.ts +++ b/src/app/main/apps/noctua-form/cam/cam-table/cam-table.component.ts @@ -150,9 +150,6 @@ export class CamTableComponent implements OnInit, OnDestroy { } } - diffModel(cam: Cam) { - this.camService.diffModel(cam); - } resetModel(cam: Cam) { this.camService.resetModel(cam); diff --git a/src/app/main/apps/noctua-search/noctua-search.component.ts b/src/app/main/apps/noctua-search/noctua-search.component.ts index e59eee58..5ef544d1 100644 --- a/src/app/main/apps/noctua-search/noctua-search.component.ts +++ b/src/app/main/apps/noctua-search/noctua-search.component.ts @@ -144,16 +144,9 @@ export class NoctuaSearchComponent implements OnInit, AfterViewInit, OnDestroy { } loadCam(modelId) { - const self = this; - this.cam = this.camService.getCam(modelId); } - edit() { - // this.loadModel(this.selectCam) - // this.openRightDrawer(RightPanel.camForm); - } - openLeftDrawer(panel) { this.noctuaSearchMenuService.selectLeftPanel(panel); this.noctuaSearchMenuService.openLeftDrawer();